babylon.module.d.ts 5.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  686. static readonly GEQUAL: number;
  687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = nearest */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * 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. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar not used as infinity is used as far clip
  4496. * @param result defines the target matrix
  4497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4498. */
  4499. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4500. /**
  4501. * Creates a right-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a right-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a right-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a right-handed perspective projection into a given matrix
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Stores a perspective projection for WebVR info a given matrix
  4531. * @param fov defines the field of view
  4532. * @param znear defines the near clip plane
  4533. * @param zfar defines the far clip plane
  4534. * @param result defines the target matrix
  4535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4536. */
  4537. static PerspectiveFovWebVRToRef(fov: {
  4538. upDegrees: number;
  4539. downDegrees: number;
  4540. leftDegrees: number;
  4541. rightDegrees: number;
  4542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4543. /**
  4544. * Computes a complete transformation matrix
  4545. * @param viewport defines the viewport to use
  4546. * @param world defines the world matrix
  4547. * @param view defines the view matrix
  4548. * @param projection defines the projection matrix
  4549. * @param zmin defines the near clip plane
  4550. * @param zmax defines the far clip plane
  4551. * @returns the transformation matrix
  4552. */
  4553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4554. /**
  4555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4556. * @param matrix defines the matrix to use
  4557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4558. */
  4559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4560. /**
  4561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4562. * @param matrix defines the matrix to use
  4563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4564. */
  4565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4566. /**
  4567. * Compute the transpose of a given matrix
  4568. * @param matrix defines the matrix to transpose
  4569. * @returns the new matrix
  4570. */
  4571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4572. /**
  4573. * Compute the transpose of a matrix and store it in a target matrix
  4574. * @param matrix defines the matrix to transpose
  4575. * @param result defines the target matrix
  4576. */
  4577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4578. /**
  4579. * Computes a reflection matrix from a plane
  4580. * @param plane defines the reflection plane
  4581. * @returns a new matrix
  4582. */
  4583. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4584. /**
  4585. * Computes a reflection matrix from a plane
  4586. * @param plane defines the reflection plane
  4587. * @param result defines the target matrix
  4588. */
  4589. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4590. /**
  4591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4592. * @param xaxis defines the value of the 1st axis
  4593. * @param yaxis defines the value of the 2nd axis
  4594. * @param zaxis defines the value of the 3rd axis
  4595. * @param result defines the target matrix
  4596. */
  4597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4598. /**
  4599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4600. * @param quat defines the quaternion to use
  4601. * @param result defines the target matrix
  4602. */
  4603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4604. }
  4605. /**
  4606. * @hidden
  4607. */
  4608. export class TmpVectors {
  4609. static Vector2: Vector2[];
  4610. static Vector3: Vector3[];
  4611. static Vector4: Vector4[];
  4612. static Quaternion: Quaternion[];
  4613. static Matrix: Matrix[];
  4614. }
  4615. }
  4616. declare module "babylonjs/Maths/math.path" {
  4617. import { DeepImmutable, Nullable } from "babylonjs/types";
  4618. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4619. /**
  4620. * Defines potential orientation for back face culling
  4621. */
  4622. export enum Orientation {
  4623. /**
  4624. * Clockwise
  4625. */
  4626. CW = 0,
  4627. /** Counter clockwise */
  4628. CCW = 1
  4629. }
  4630. /** Class used to represent a Bezier curve */
  4631. export class BezierCurve {
  4632. /**
  4633. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4634. * @param t defines the time
  4635. * @param x1 defines the left coordinate on X axis
  4636. * @param y1 defines the left coordinate on Y axis
  4637. * @param x2 defines the right coordinate on X axis
  4638. * @param y2 defines the right coordinate on Y axis
  4639. * @returns the interpolated value
  4640. */
  4641. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4642. }
  4643. /**
  4644. * Defines angle representation
  4645. */
  4646. export class Angle {
  4647. private _radians;
  4648. /**
  4649. * Creates an Angle object of "radians" radians (float).
  4650. * @param radians the angle in radians
  4651. */
  4652. constructor(radians: number);
  4653. /**
  4654. * Get value in degrees
  4655. * @returns the Angle value in degrees (float)
  4656. */
  4657. degrees(): number;
  4658. /**
  4659. * Get value in radians
  4660. * @returns the Angle value in radians (float)
  4661. */
  4662. radians(): number;
  4663. /**
  4664. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4665. * @param a defines first vector
  4666. * @param b defines second vector
  4667. * @returns a new Angle
  4668. */
  4669. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4670. /**
  4671. * Gets a new Angle object from the given float in radians
  4672. * @param radians defines the angle value in radians
  4673. * @returns a new Angle
  4674. */
  4675. static FromRadians(radians: number): Angle;
  4676. /**
  4677. * Gets a new Angle object from the given float in degrees
  4678. * @param degrees defines the angle value in degrees
  4679. * @returns a new Angle
  4680. */
  4681. static FromDegrees(degrees: number): Angle;
  4682. }
  4683. /**
  4684. * This represents an arc in a 2d space.
  4685. */
  4686. export class Arc2 {
  4687. /** Defines the start point of the arc */
  4688. startPoint: Vector2;
  4689. /** Defines the mid point of the arc */
  4690. midPoint: Vector2;
  4691. /** Defines the end point of the arc */
  4692. endPoint: Vector2;
  4693. /**
  4694. * Defines the center point of the arc.
  4695. */
  4696. centerPoint: Vector2;
  4697. /**
  4698. * Defines the radius of the arc.
  4699. */
  4700. radius: number;
  4701. /**
  4702. * Defines the angle of the arc (from mid point to end point).
  4703. */
  4704. angle: Angle;
  4705. /**
  4706. * Defines the start angle of the arc (from start point to middle point).
  4707. */
  4708. startAngle: Angle;
  4709. /**
  4710. * Defines the orientation of the arc (clock wise/counter clock wise).
  4711. */
  4712. orientation: Orientation;
  4713. /**
  4714. * Creates an Arc object from the three given points : start, middle and end.
  4715. * @param startPoint Defines the start point of the arc
  4716. * @param midPoint Defines the midlle point of the arc
  4717. * @param endPoint Defines the end point of the arc
  4718. */
  4719. constructor(
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2,
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2,
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2);
  4726. }
  4727. /**
  4728. * Represents a 2D path made up of multiple 2D points
  4729. */
  4730. export class Path2 {
  4731. private _points;
  4732. private _length;
  4733. /**
  4734. * If the path start and end point are the same
  4735. */
  4736. closed: boolean;
  4737. /**
  4738. * Creates a Path2 object from the starting 2D coordinates x and y.
  4739. * @param x the starting points x value
  4740. * @param y the starting points y value
  4741. */
  4742. constructor(x: number, y: number);
  4743. /**
  4744. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4745. * @param x the added points x value
  4746. * @param y the added points y value
  4747. * @returns the updated Path2.
  4748. */
  4749. addLineTo(x: number, y: number): Path2;
  4750. /**
  4751. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4752. * @param midX middle point x value
  4753. * @param midY middle point y value
  4754. * @param endX end point x value
  4755. * @param endY end point y value
  4756. * @param numberOfSegments (default: 36)
  4757. * @returns the updated Path2.
  4758. */
  4759. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4760. /**
  4761. * Closes the Path2.
  4762. * @returns the Path2.
  4763. */
  4764. close(): Path2;
  4765. /**
  4766. * Gets the sum of the distance between each sequential point in the path
  4767. * @returns the Path2 total length (float).
  4768. */
  4769. length(): number;
  4770. /**
  4771. * Gets the points which construct the path
  4772. * @returns the Path2 internal array of points.
  4773. */
  4774. getPoints(): Vector2[];
  4775. /**
  4776. * Retreives the point at the distance aways from the starting point
  4777. * @param normalizedLengthPosition the length along the path to retreive the point from
  4778. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4779. */
  4780. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4781. /**
  4782. * Creates a new path starting from an x and y position
  4783. * @param x starting x value
  4784. * @param y starting y value
  4785. * @returns a new Path2 starting at the coordinates (x, y).
  4786. */
  4787. static StartingAt(x: number, y: number): Path2;
  4788. }
  4789. /**
  4790. * Represents a 3D path made up of multiple 3D points
  4791. */
  4792. export class Path3D {
  4793. /**
  4794. * an array of Vector3, the curve axis of the Path3D
  4795. */
  4796. path: Vector3[];
  4797. private _curve;
  4798. private _distances;
  4799. private _tangents;
  4800. private _normals;
  4801. private _binormals;
  4802. private _raw;
  4803. private _alignTangentsWithPath;
  4804. private readonly _pointAtData;
  4805. /**
  4806. * new Path3D(path, normal, raw)
  4807. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4808. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4809. * @param path an array of Vector3, the curve axis of the Path3D
  4810. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4811. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4812. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4813. */
  4814. constructor(
  4815. /**
  4816. * an array of Vector3, the curve axis of the Path3D
  4817. */
  4818. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4819. /**
  4820. * Returns the Path3D array of successive Vector3 designing its curve.
  4821. * @returns the Path3D array of successive Vector3 designing its curve.
  4822. */
  4823. getCurve(): Vector3[];
  4824. /**
  4825. * Returns the Path3D array of successive Vector3 designing its curve.
  4826. * @returns the Path3D array of successive Vector3 designing its curve.
  4827. */
  4828. getPoints(): Vector3[];
  4829. /**
  4830. * @returns the computed length (float) of the path.
  4831. */
  4832. length(): number;
  4833. /**
  4834. * Returns an array populated with tangent vectors on each Path3D curve point.
  4835. * @returns an array populated with tangent vectors on each Path3D curve point.
  4836. */
  4837. getTangents(): Vector3[];
  4838. /**
  4839. * Returns an array populated with normal vectors on each Path3D curve point.
  4840. * @returns an array populated with normal vectors on each Path3D curve point.
  4841. */
  4842. getNormals(): Vector3[];
  4843. /**
  4844. * Returns an array populated with binormal vectors on each Path3D curve point.
  4845. * @returns an array populated with binormal vectors on each Path3D curve point.
  4846. */
  4847. getBinormals(): Vector3[];
  4848. /**
  4849. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4851. */
  4852. getDistances(): number[];
  4853. /**
  4854. * Returns an interpolated point along this path
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @returns a new Vector3 as the point
  4857. */
  4858. getPointAt(position: number): Vector3;
  4859. /**
  4860. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4861. * @param position the position of the point along this path, from 0.0 to 1.0
  4862. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4863. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4864. */
  4865. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4866. /**
  4867. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4868. * @param position the position of the point along this path, from 0.0 to 1.0
  4869. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4870. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4871. */
  4872. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4873. /**
  4874. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4877. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4878. */
  4879. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4880. /**
  4881. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4884. */
  4885. getDistanceAt(position: number): number;
  4886. /**
  4887. * Returns the array index of the previous point of an interpolated point along this path
  4888. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4889. * @returns the array index
  4890. */
  4891. getPreviousPointIndexAt(position: number): number;
  4892. /**
  4893. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4894. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4895. * @returns the sub position
  4896. */
  4897. getSubPositionAt(position: number): number;
  4898. /**
  4899. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4900. * @param target the vector of which to get the closest position to
  4901. * @returns the position of the closest virtual point on this path to the target vector
  4902. */
  4903. getClosestPositionTo(target: Vector3): number;
  4904. /**
  4905. * Returns a sub path (slice) of this path
  4906. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4907. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4908. * @returns a sub path (slice) of this path
  4909. */
  4910. slice(start?: number, end?: number): Path3D;
  4911. /**
  4912. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4913. * @param path path which all values are copied into the curves points
  4914. * @param firstNormal which should be projected onto the curve
  4915. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4916. * @returns the same object updated.
  4917. */
  4918. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4919. private _compute;
  4920. private _getFirstNonNullVector;
  4921. private _getLastNonNullVector;
  4922. private _normalVector;
  4923. /**
  4924. * Updates the point at data for an interpolated point along this curve
  4925. * @param position the position of the point along this curve, from 0.0 to 1.0
  4926. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4927. * @returns the (updated) point at data
  4928. */
  4929. private _updatePointAtData;
  4930. /**
  4931. * Updates the point at data from the specified parameters
  4932. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4933. * @param point the interpolated point
  4934. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4935. */
  4936. private _setPointAtData;
  4937. /**
  4938. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4939. */
  4940. private _updateInterpolationMatrix;
  4941. }
  4942. /**
  4943. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4944. * A Curve3 is designed from a series of successive Vector3.
  4945. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4946. */
  4947. export class Curve3 {
  4948. private _points;
  4949. private _length;
  4950. /**
  4951. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4952. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4953. * @param v1 (Vector3) the control point
  4954. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4961. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4962. * @param v1 (Vector3) the first control point
  4963. * @param v2 (Vector3) the second control point
  4964. * @param v3 (Vector3) the end point of the Cubic Bezier
  4965. * @param nbPoints (integer) the wanted number of points in the curve
  4966. * @returns the created Curve3
  4967. */
  4968. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4969. /**
  4970. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4971. * @param p1 (Vector3) the origin point of the Hermite Spline
  4972. * @param t1 (Vector3) the tangent vector at the origin point
  4973. * @param p2 (Vector3) the end point of the Hermite Spline
  4974. * @param t2 (Vector3) the tangent vector at the end point
  4975. * @param nbPoints (integer) the wanted number of points in the curve
  4976. * @returns the created Curve3
  4977. */
  4978. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4979. /**
  4980. * Returns a Curve3 object along a CatmullRom Spline curve :
  4981. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4982. * @param nbPoints (integer) the wanted number of points between each curve control points
  4983. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4984. * @returns the created Curve3
  4985. */
  4986. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4987. /**
  4988. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4989. * A Curve3 is designed from a series of successive Vector3.
  4990. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4991. * @param points points which make up the curve
  4992. */
  4993. constructor(points: Vector3[]);
  4994. /**
  4995. * @returns the Curve3 stored array of successive Vector3
  4996. */
  4997. getPoints(): Vector3[];
  4998. /**
  4999. * @returns the computed length (float) of the curve.
  5000. */
  5001. length(): number;
  5002. /**
  5003. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5004. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5005. * curveA and curveB keep unchanged.
  5006. * @param curve the curve to continue from this curve
  5007. * @returns the newly constructed curve
  5008. */
  5009. continue(curve: DeepImmutable<Curve3>): Curve3;
  5010. private _computeLength;
  5011. }
  5012. }
  5013. declare module "babylonjs/Animations/easing" {
  5014. /**
  5015. * This represents the main contract an easing function should follow.
  5016. * Easing functions are used throughout the animation system.
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export interface IEasingFunction {
  5020. /**
  5021. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5022. * of the easing function.
  5023. * The link below provides some of the most common examples of easing functions.
  5024. * @see https://easings.net/
  5025. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5026. * @returns the corresponding value on the curve defined by the easing function
  5027. */
  5028. ease(gradient: number): number;
  5029. }
  5030. /**
  5031. * Base class used for every default easing function.
  5032. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5033. */
  5034. export class EasingFunction implements IEasingFunction {
  5035. /**
  5036. * Interpolation follows the mathematical formula associated with the easing function.
  5037. */
  5038. static readonly EASINGMODE_EASEIN: number;
  5039. /**
  5040. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5041. */
  5042. static readonly EASINGMODE_EASEOUT: number;
  5043. /**
  5044. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5045. */
  5046. static readonly EASINGMODE_EASEINOUT: number;
  5047. private _easingMode;
  5048. /**
  5049. * Sets the easing mode of the current function.
  5050. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5051. */
  5052. setEasingMode(easingMode: number): void;
  5053. /**
  5054. * Gets the current easing mode.
  5055. * @returns the easing mode
  5056. */
  5057. getEasingMode(): number;
  5058. /**
  5059. * @hidden
  5060. */
  5061. easeInCore(gradient: number): number;
  5062. /**
  5063. * Given an input gradient between 0 and 1, this returns the corresponding value
  5064. * of the easing function.
  5065. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5066. * @returns the corresponding value on the curve defined by the easing function
  5067. */
  5068. ease(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a circle shape (see link below).
  5072. * @see https://easings.net/#easeInCirc
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class CircleEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a ease back shape (see link below).
  5081. * @see https://easings.net/#easeInBack
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class BackEase extends EasingFunction implements IEasingFunction {
  5085. /** Defines the amplitude of the function */
  5086. amplitude: number;
  5087. /**
  5088. * Instantiates a back ease easing
  5089. * @see https://easings.net/#easeInBack
  5090. * @param amplitude Defines the amplitude of the function
  5091. */
  5092. constructor(
  5093. /** Defines the amplitude of the function */
  5094. amplitude?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. /**
  5099. * Easing function with a bouncing shape (see link below).
  5100. * @see https://easings.net/#easeInBounce
  5101. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5102. */
  5103. export class BounceEase extends EasingFunction implements IEasingFunction {
  5104. /** Defines the number of bounces */
  5105. bounces: number;
  5106. /** Defines the amplitude of the bounce */
  5107. bounciness: number;
  5108. /**
  5109. * Instantiates a bounce easing
  5110. * @see https://easings.net/#easeInBounce
  5111. * @param bounces Defines the number of bounces
  5112. * @param bounciness Defines the amplitude of the bounce
  5113. */
  5114. constructor(
  5115. /** Defines the number of bounces */
  5116. bounces?: number,
  5117. /** Defines the amplitude of the bounce */
  5118. bounciness?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. /**
  5123. * Easing function with a power of 3 shape (see link below).
  5124. * @see https://easings.net/#easeInCubic
  5125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5126. */
  5127. export class CubicEase extends EasingFunction implements IEasingFunction {
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with an elastic shape (see link below).
  5133. * @see https://easings.net/#easeInElastic
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of oscillations*/
  5138. oscillations: number;
  5139. /** Defines the amplitude of the oscillations*/
  5140. springiness: number;
  5141. /**
  5142. * Instantiates an elastic easing function
  5143. * @see https://easings.net/#easeInElastic
  5144. * @param oscillations Defines the number of oscillations
  5145. * @param springiness Defines the amplitude of the oscillations
  5146. */
  5147. constructor(
  5148. /** Defines the number of oscillations*/
  5149. oscillations?: number,
  5150. /** Defines the amplitude of the oscillations*/
  5151. springiness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with an exponential shape (see link below).
  5157. * @see https://easings.net/#easeInExpo
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5161. /** Defines the exponent of the function */
  5162. exponent: number;
  5163. /**
  5164. * Instantiates an exponential easing function
  5165. * @see https://easings.net/#easeInExpo
  5166. * @param exponent Defines the exponent of the function
  5167. */
  5168. constructor(
  5169. /** Defines the exponent of the function */
  5170. exponent?: number);
  5171. /** @hidden */
  5172. easeInCore(gradient: number): number;
  5173. }
  5174. /**
  5175. * Easing function with a power shape (see link below).
  5176. * @see https://easings.net/#easeInQuad
  5177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5178. */
  5179. export class PowerEase extends EasingFunction implements IEasingFunction {
  5180. /** Defines the power of the function */
  5181. power: number;
  5182. /**
  5183. * Instantiates an power base easing function
  5184. * @see https://easings.net/#easeInQuad
  5185. * @param power Defines the power of the function
  5186. */
  5187. constructor(
  5188. /** Defines the power of the function */
  5189. power?: number);
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with a power of 2 shape (see link below).
  5195. * @see https://easings.net/#easeInQuad
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5199. /** @hidden */
  5200. easeInCore(gradient: number): number;
  5201. }
  5202. /**
  5203. * Easing function with a power of 4 shape (see link below).
  5204. * @see https://easings.net/#easeInQuart
  5205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. /**
  5212. * Easing function with a power of 5 shape (see link below).
  5213. * @see https://easings.net/#easeInQuint
  5214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5215. */
  5216. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a sin shape (see link below).
  5222. * @see https://easings.net/#easeInSine
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class SineEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a bezier shape (see link below).
  5231. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5235. /** Defines the x component of the start tangent in the bezier curve */
  5236. x1: number;
  5237. /** Defines the y component of the start tangent in the bezier curve */
  5238. y1: number;
  5239. /** Defines the x component of the end tangent in the bezier curve */
  5240. x2: number;
  5241. /** Defines the y component of the end tangent in the bezier curve */
  5242. y2: number;
  5243. /**
  5244. * Instantiates a bezier function
  5245. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5246. * @param x1 Defines the x component of the start tangent in the bezier curve
  5247. * @param y1 Defines the y component of the start tangent in the bezier curve
  5248. * @param x2 Defines the x component of the end tangent in the bezier curve
  5249. * @param y2 Defines the y component of the end tangent in the bezier curve
  5250. */
  5251. constructor(
  5252. /** Defines the x component of the start tangent in the bezier curve */
  5253. x1?: number,
  5254. /** Defines the y component of the start tangent in the bezier curve */
  5255. y1?: number,
  5256. /** Defines the x component of the end tangent in the bezier curve */
  5257. x2?: number,
  5258. /** Defines the y component of the end tangent in the bezier curve */
  5259. y2?: number);
  5260. /** @hidden */
  5261. easeInCore(gradient: number): number;
  5262. }
  5263. }
  5264. declare module "babylonjs/Maths/math.color" {
  5265. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5266. /**
  5267. * Class used to hold a RBG color
  5268. */
  5269. export class Color3 {
  5270. /**
  5271. * Defines the red component (between 0 and 1, default is 0)
  5272. */
  5273. r: number;
  5274. /**
  5275. * Defines the green component (between 0 and 1, default is 0)
  5276. */
  5277. g: number;
  5278. /**
  5279. * Defines the blue component (between 0 and 1, default is 0)
  5280. */
  5281. b: number;
  5282. /**
  5283. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5284. * @param r defines the red component (between 0 and 1, default is 0)
  5285. * @param g defines the green component (between 0 and 1, default is 0)
  5286. * @param b defines the blue component (between 0 and 1, default is 0)
  5287. */
  5288. constructor(
  5289. /**
  5290. * Defines the red component (between 0 and 1, default is 0)
  5291. */
  5292. r?: number,
  5293. /**
  5294. * Defines the green component (between 0 and 1, default is 0)
  5295. */
  5296. g?: number,
  5297. /**
  5298. * Defines the blue component (between 0 and 1, default is 0)
  5299. */
  5300. b?: number);
  5301. /**
  5302. * Creates a string with the Color3 current values
  5303. * @returns the string representation of the Color3 object
  5304. */
  5305. toString(): string;
  5306. /**
  5307. * Returns the string "Color3"
  5308. * @returns "Color3"
  5309. */
  5310. getClassName(): string;
  5311. /**
  5312. * Compute the Color3 hash code
  5313. * @returns an unique number that can be used to hash Color3 objects
  5314. */
  5315. getHashCode(): number;
  5316. /**
  5317. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5318. * @param array defines the array where to store the r,g,b components
  5319. * @param index defines an optional index in the target array to define where to start storing values
  5320. * @returns the current Color3 object
  5321. */
  5322. toArray(array: FloatArray, index?: number): Color3;
  5323. /**
  5324. * Returns a new Color4 object from the current Color3 and the given alpha
  5325. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5326. * @returns a new Color4 object
  5327. */
  5328. toColor4(alpha?: number): Color4;
  5329. /**
  5330. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5331. * @returns the new array
  5332. */
  5333. asArray(): number[];
  5334. /**
  5335. * Returns the luminance value
  5336. * @returns a float value
  5337. */
  5338. toLuminance(): number;
  5339. /**
  5340. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5341. * @param otherColor defines the second operand
  5342. * @returns the new Color3 object
  5343. */
  5344. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5345. /**
  5346. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5347. * @param otherColor defines the second operand
  5348. * @param result defines the Color3 object where to store the result
  5349. * @returns the current Color3
  5350. */
  5351. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5352. /**
  5353. * Determines equality between Color3 objects
  5354. * @param otherColor defines the second operand
  5355. * @returns true if the rgb values are equal to the given ones
  5356. */
  5357. equals(otherColor: DeepImmutable<Color3>): boolean;
  5358. /**
  5359. * Determines equality between the current Color3 object and a set of r,b,g values
  5360. * @param r defines the red component to check
  5361. * @param g defines the green component to check
  5362. * @param b defines the blue component to check
  5363. * @returns true if the rgb values are equal to the given ones
  5364. */
  5365. equalsFloats(r: number, g: number, b: number): boolean;
  5366. /**
  5367. * Multiplies in place each rgb value by scale
  5368. * @param scale defines the scaling factor
  5369. * @returns the updated Color3
  5370. */
  5371. scale(scale: number): Color3;
  5372. /**
  5373. * Multiplies the rgb values by scale and stores the result into "result"
  5374. * @param scale defines the scaling factor
  5375. * @param result defines the Color3 object where to store the result
  5376. * @returns the unmodified current Color3
  5377. */
  5378. scaleToRef(scale: number, result: Color3): Color3;
  5379. /**
  5380. * Scale the current Color3 values by a factor and add the result to a given Color3
  5381. * @param scale defines the scale factor
  5382. * @param result defines color to store the result into
  5383. * @returns the unmodified current Color3
  5384. */
  5385. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5386. /**
  5387. * Clamps the rgb values by the min and max values and stores the result into "result"
  5388. * @param min defines minimum clamping value (default is 0)
  5389. * @param max defines maximum clamping value (default is 1)
  5390. * @param result defines color to store the result into
  5391. * @returns the original Color3
  5392. */
  5393. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5394. /**
  5395. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5396. * @param otherColor defines the second operand
  5397. * @returns the new Color3
  5398. */
  5399. add(otherColor: DeepImmutable<Color3>): Color3;
  5400. /**
  5401. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5402. * @param otherColor defines the second operand
  5403. * @param result defines Color3 object to store the result into
  5404. * @returns the unmodified current Color3
  5405. */
  5406. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5407. /**
  5408. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5409. * @param otherColor defines the second operand
  5410. * @returns the new Color3
  5411. */
  5412. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5413. /**
  5414. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5415. * @param otherColor defines the second operand
  5416. * @param result defines Color3 object to store the result into
  5417. * @returns the unmodified current Color3
  5418. */
  5419. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5420. /**
  5421. * Copy the current object
  5422. * @returns a new Color3 copied the current one
  5423. */
  5424. clone(): Color3;
  5425. /**
  5426. * Copies the rgb values from the source in the current Color3
  5427. * @param source defines the source Color3 object
  5428. * @returns the updated Color3 object
  5429. */
  5430. copyFrom(source: DeepImmutable<Color3>): Color3;
  5431. /**
  5432. * Updates the Color3 rgb values from the given floats
  5433. * @param r defines the red component to read from
  5434. * @param g defines the green component to read from
  5435. * @param b defines the blue component to read from
  5436. * @returns the current Color3 object
  5437. */
  5438. copyFromFloats(r: number, g: number, b: number): Color3;
  5439. /**
  5440. * Updates the Color3 rgb values from the given floats
  5441. * @param r defines the red component to read from
  5442. * @param g defines the green component to read from
  5443. * @param b defines the blue component to read from
  5444. * @returns the current Color3 object
  5445. */
  5446. set(r: number, g: number, b: number): Color3;
  5447. /**
  5448. * Compute the Color3 hexadecimal code as a string
  5449. * @returns a string containing the hexadecimal representation of the Color3 object
  5450. */
  5451. toHexString(): string;
  5452. /**
  5453. * Computes a new Color3 converted from the current one to linear space
  5454. * @returns a new Color3 object
  5455. */
  5456. toLinearSpace(): Color3;
  5457. /**
  5458. * Converts current color in rgb space to HSV values
  5459. * @returns a new color3 representing the HSV values
  5460. */
  5461. toHSV(): Color3;
  5462. /**
  5463. * Converts current color in rgb space to HSV values
  5464. * @param result defines the Color3 where to store the HSV values
  5465. */
  5466. toHSVToRef(result: Color3): void;
  5467. /**
  5468. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5469. * @param convertedColor defines the Color3 object where to store the linear space version
  5470. * @returns the unmodified Color3
  5471. */
  5472. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5473. /**
  5474. * Computes a new Color3 converted from the current one to gamma space
  5475. * @returns a new Color3 object
  5476. */
  5477. toGammaSpace(): Color3;
  5478. /**
  5479. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5480. * @param convertedColor defines the Color3 object where to store the gamma space version
  5481. * @returns the unmodified Color3
  5482. */
  5483. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5484. private static _BlackReadOnly;
  5485. /**
  5486. * Convert Hue, saturation and value to a Color3 (RGB)
  5487. * @param hue defines the hue
  5488. * @param saturation defines the saturation
  5489. * @param value defines the value
  5490. * @param result defines the Color3 where to store the RGB values
  5491. */
  5492. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5493. /**
  5494. * Creates a new Color3 from the string containing valid hexadecimal values
  5495. * @param hex defines a string containing valid hexadecimal values
  5496. * @returns a new Color3 object
  5497. */
  5498. static FromHexString(hex: string): Color3;
  5499. /**
  5500. * Creates a new Color3 from the starting index of the given array
  5501. * @param array defines the source array
  5502. * @param offset defines an offset in the source array
  5503. * @returns a new Color3 object
  5504. */
  5505. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5506. /**
  5507. * Creates a new Color3 from integer values (< 256)
  5508. * @param r defines the red component to read from (value between 0 and 255)
  5509. * @param g defines the green component to read from (value between 0 and 255)
  5510. * @param b defines the blue component to read from (value between 0 and 255)
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromInts(r: number, g: number, b: number): Color3;
  5514. /**
  5515. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5516. * @param start defines the start Color3 value
  5517. * @param end defines the end Color3 value
  5518. * @param amount defines the gradient value between start and end
  5519. * @returns a new Color3 object
  5520. */
  5521. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5522. /**
  5523. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5524. * @param left defines the start value
  5525. * @param right defines the end value
  5526. * @param amount defines the gradient factor
  5527. * @param result defines the Color3 object where to store the result
  5528. */
  5529. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5530. /**
  5531. * Returns a Color3 value containing a red color
  5532. * @returns a new Color3 object
  5533. */
  5534. static Red(): Color3;
  5535. /**
  5536. * Returns a Color3 value containing a green color
  5537. * @returns a new Color3 object
  5538. */
  5539. static Green(): Color3;
  5540. /**
  5541. * Returns a Color3 value containing a blue color
  5542. * @returns a new Color3 object
  5543. */
  5544. static Blue(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a black color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Black(): Color3;
  5550. /**
  5551. * Gets a Color3 value containing a black color that must not be updated
  5552. */
  5553. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5554. /**
  5555. * Returns a Color3 value containing a white color
  5556. * @returns a new Color3 object
  5557. */
  5558. static White(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a purple color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Purple(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a magenta color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Magenta(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a yellow color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Yellow(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a gray color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Gray(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a teal color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Teal(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a random color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Random(): Color3;
  5589. }
  5590. /**
  5591. * Class used to hold a RBGA color
  5592. */
  5593. export class Color4 {
  5594. /**
  5595. * Defines the red component (between 0 and 1, default is 0)
  5596. */
  5597. r: number;
  5598. /**
  5599. * Defines the green component (between 0 and 1, default is 0)
  5600. */
  5601. g: number;
  5602. /**
  5603. * Defines the blue component (between 0 and 1, default is 0)
  5604. */
  5605. b: number;
  5606. /**
  5607. * Defines the alpha component (between 0 and 1, default is 1)
  5608. */
  5609. a: number;
  5610. /**
  5611. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5612. * @param r defines the red component (between 0 and 1, default is 0)
  5613. * @param g defines the green component (between 0 and 1, default is 0)
  5614. * @param b defines the blue component (between 0 and 1, default is 0)
  5615. * @param a defines the alpha component (between 0 and 1, default is 1)
  5616. */
  5617. constructor(
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r?: number,
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g?: number,
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b?: number,
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a?: number);
  5634. /**
  5635. * Adds in place the given Color4 values to the current Color4 object
  5636. * @param right defines the second operand
  5637. * @returns the current updated Color4 object
  5638. */
  5639. addInPlace(right: DeepImmutable<Color4>): Color4;
  5640. /**
  5641. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5642. * @returns the new array
  5643. */
  5644. asArray(): number[];
  5645. /**
  5646. * Stores from the starting index in the given array the Color4 successive values
  5647. * @param array defines the array where to store the r,g,b components
  5648. * @param index defines an optional index in the target array to define where to start storing values
  5649. * @returns the current Color4 object
  5650. */
  5651. toArray(array: number[], index?: number): Color4;
  5652. /**
  5653. * Determines equality between Color4 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgba values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color4>): boolean;
  5658. /**
  5659. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5660. * @param right defines the second operand
  5661. * @returns a new Color4 object
  5662. */
  5663. add(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5666. * @param right defines the second operand
  5667. * @returns a new Color4 object
  5668. */
  5669. subtract(right: DeepImmutable<Color4>): Color4;
  5670. /**
  5671. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5672. * @param right defines the second operand
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the current Color4 object
  5675. */
  5676. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5677. /**
  5678. * Creates a new Color4 with the current Color4 values multiplied by scale
  5679. * @param scale defines the scaling factor to apply
  5680. * @returns a new Color4 object
  5681. */
  5682. scale(scale: number): Color4;
  5683. /**
  5684. * Multiplies the current Color4 values by scale and stores the result in "result"
  5685. * @param scale defines the scaling factor to apply
  5686. * @param result defines the Color4 object where to store the result
  5687. * @returns the current unmodified Color4
  5688. */
  5689. scaleToRef(scale: number, result: Color4): Color4;
  5690. /**
  5691. * Scale the current Color4 values by a factor and add the result to a given Color4
  5692. * @param scale defines the scale factor
  5693. * @param result defines the Color4 object where to store the result
  5694. * @returns the unmodified current Color4
  5695. */
  5696. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5697. /**
  5698. * Clamps the rgb values by the min and max values and stores the result into "result"
  5699. * @param min defines minimum clamping value (default is 0)
  5700. * @param max defines maximum clamping value (default is 1)
  5701. * @param result defines color to store the result into.
  5702. * @returns the cuurent Color4
  5703. */
  5704. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5705. /**
  5706. * Multipy an Color4 value by another and return a new Color4 object
  5707. * @param color defines the Color4 value to multiply by
  5708. * @returns a new Color4 object
  5709. */
  5710. multiply(color: Color4): Color4;
  5711. /**
  5712. * Multipy a Color4 value by another and push the result in a reference value
  5713. * @param color defines the Color4 value to multiply by
  5714. * @param result defines the Color4 to fill the result in
  5715. * @returns the result Color4
  5716. */
  5717. multiplyToRef(color: Color4, result: Color4): Color4;
  5718. /**
  5719. * Creates a string with the Color4 current values
  5720. * @returns the string representation of the Color4 object
  5721. */
  5722. toString(): string;
  5723. /**
  5724. * Returns the string "Color4"
  5725. * @returns "Color4"
  5726. */
  5727. getClassName(): string;
  5728. /**
  5729. * Compute the Color4 hash code
  5730. * @returns an unique number that can be used to hash Color4 objects
  5731. */
  5732. getHashCode(): number;
  5733. /**
  5734. * Creates a new Color4 copied from the current one
  5735. * @returns a new Color4 object
  5736. */
  5737. clone(): Color4;
  5738. /**
  5739. * Copies the given Color4 values into the current one
  5740. * @param source defines the source Color4 object
  5741. * @returns the current updated Color4 object
  5742. */
  5743. copyFrom(source: Color4): Color4;
  5744. /**
  5745. * Copies the given float values into the current one
  5746. * @param r defines the red component to read from
  5747. * @param g defines the green component to read from
  5748. * @param b defines the blue component to read from
  5749. * @param a defines the alpha component to read from
  5750. * @returns the current updated Color4 object
  5751. */
  5752. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5753. /**
  5754. * Copies the given float values into the current one
  5755. * @param r defines the red component to read from
  5756. * @param g defines the green component to read from
  5757. * @param b defines the blue component to read from
  5758. * @param a defines the alpha component to read from
  5759. * @returns the current updated Color4 object
  5760. */
  5761. set(r: number, g: number, b: number, a: number): Color4;
  5762. /**
  5763. * Compute the Color4 hexadecimal code as a string
  5764. * @returns a string containing the hexadecimal representation of the Color4 object
  5765. */
  5766. toHexString(): string;
  5767. /**
  5768. * Computes a new Color4 converted from the current one to linear space
  5769. * @returns a new Color4 object
  5770. */
  5771. toLinearSpace(): Color4;
  5772. /**
  5773. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5774. * @param convertedColor defines the Color4 object where to store the linear space version
  5775. * @returns the unmodified Color4
  5776. */
  5777. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5778. /**
  5779. * Computes a new Color4 converted from the current one to gamma space
  5780. * @returns a new Color4 object
  5781. */
  5782. toGammaSpace(): Color4;
  5783. /**
  5784. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5785. * @param convertedColor defines the Color4 object where to store the gamma space version
  5786. * @returns the unmodified Color4
  5787. */
  5788. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5789. /**
  5790. * Creates a new Color4 from the string containing valid hexadecimal values
  5791. * @param hex defines a string containing valid hexadecimal values
  5792. * @returns a new Color4 object
  5793. */
  5794. static FromHexString(hex: string): Color4;
  5795. /**
  5796. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5797. * @param left defines the start value
  5798. * @param right defines the end value
  5799. * @param amount defines the gradient factor
  5800. * @returns a new Color4 object
  5801. */
  5802. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5803. /**
  5804. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5805. * @param left defines the start value
  5806. * @param right defines the end value
  5807. * @param amount defines the gradient factor
  5808. * @param result defines the Color4 object where to store data
  5809. */
  5810. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5811. /**
  5812. * Creates a new Color4 from a Color3 and an alpha value
  5813. * @param color3 defines the source Color3 to read from
  5814. * @param alpha defines the alpha component (1.0 by default)
  5815. * @returns a new Color4 object
  5816. */
  5817. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5818. /**
  5819. * Creates a new Color4 from the starting index element of the given array
  5820. * @param array defines the source array to read from
  5821. * @param offset defines the offset in the source array
  5822. * @returns a new Color4 object
  5823. */
  5824. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5825. /**
  5826. * Creates a new Color3 from integer values (< 256)
  5827. * @param r defines the red component to read from (value between 0 and 255)
  5828. * @param g defines the green component to read from (value between 0 and 255)
  5829. * @param b defines the blue component to read from (value between 0 and 255)
  5830. * @param a defines the alpha component to read from (value between 0 and 255)
  5831. * @returns a new Color3 object
  5832. */
  5833. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5834. /**
  5835. * Check the content of a given array and convert it to an array containing RGBA data
  5836. * If the original array was already containing count * 4 values then it is returned directly
  5837. * @param colors defines the array to check
  5838. * @param count defines the number of RGBA data to expect
  5839. * @returns an array containing count * 4 values (RGBA)
  5840. */
  5841. static CheckColors4(colors: number[], count: number): number[];
  5842. }
  5843. /**
  5844. * @hidden
  5845. */
  5846. export class TmpColors {
  5847. static Color3: Color3[];
  5848. static Color4: Color4[];
  5849. }
  5850. }
  5851. declare module "babylonjs/Animations/animationKey" {
  5852. /**
  5853. * Defines an interface which represents an animation key frame
  5854. */
  5855. export interface IAnimationKey {
  5856. /**
  5857. * Frame of the key frame
  5858. */
  5859. frame: number;
  5860. /**
  5861. * Value at the specifies key frame
  5862. */
  5863. value: any;
  5864. /**
  5865. * The input tangent for the cubic hermite spline
  5866. */
  5867. inTangent?: any;
  5868. /**
  5869. * The output tangent for the cubic hermite spline
  5870. */
  5871. outTangent?: any;
  5872. /**
  5873. * The animation interpolation type
  5874. */
  5875. interpolation?: AnimationKeyInterpolation;
  5876. }
  5877. /**
  5878. * Enum for the animation key frame interpolation type
  5879. */
  5880. export enum AnimationKeyInterpolation {
  5881. /**
  5882. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5883. */
  5884. STEP = 1
  5885. }
  5886. }
  5887. declare module "babylonjs/Animations/animationRange" {
  5888. /**
  5889. * Represents the range of an animation
  5890. */
  5891. export class AnimationRange {
  5892. /**The name of the animation range**/
  5893. name: string;
  5894. /**The starting frame of the animation */
  5895. from: number;
  5896. /**The ending frame of the animation*/
  5897. to: number;
  5898. /**
  5899. * Initializes the range of an animation
  5900. * @param name The name of the animation range
  5901. * @param from The starting frame of the animation
  5902. * @param to The ending frame of the animation
  5903. */
  5904. constructor(
  5905. /**The name of the animation range**/
  5906. name: string,
  5907. /**The starting frame of the animation */
  5908. from: number,
  5909. /**The ending frame of the animation*/
  5910. to: number);
  5911. /**
  5912. * Makes a copy of the animation range
  5913. * @returns A copy of the animation range
  5914. */
  5915. clone(): AnimationRange;
  5916. }
  5917. }
  5918. declare module "babylonjs/Animations/animationEvent" {
  5919. /**
  5920. * Composed of a frame, and an action function
  5921. */
  5922. export class AnimationEvent {
  5923. /** The frame for which the event is triggered **/
  5924. frame: number;
  5925. /** The event to perform when triggered **/
  5926. action: (currentFrame: number) => void;
  5927. /** Specifies if the event should be triggered only once**/
  5928. onlyOnce?: boolean | undefined;
  5929. /**
  5930. * Specifies if the animation event is done
  5931. */
  5932. isDone: boolean;
  5933. /**
  5934. * Initializes the animation event
  5935. * @param frame The frame for which the event is triggered
  5936. * @param action The event to perform when triggered
  5937. * @param onlyOnce Specifies if the event should be triggered only once
  5938. */
  5939. constructor(
  5940. /** The frame for which the event is triggered **/
  5941. frame: number,
  5942. /** The event to perform when triggered **/
  5943. action: (currentFrame: number) => void,
  5944. /** Specifies if the event should be triggered only once**/
  5945. onlyOnce?: boolean | undefined);
  5946. /** @hidden */
  5947. _clone(): AnimationEvent;
  5948. }
  5949. }
  5950. declare module "babylonjs/Behaviors/behavior" {
  5951. import { Nullable } from "babylonjs/types";
  5952. /**
  5953. * Interface used to define a behavior
  5954. */
  5955. export interface Behavior<T> {
  5956. /** gets or sets behavior's name */
  5957. name: string;
  5958. /**
  5959. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5960. */
  5961. init(): void;
  5962. /**
  5963. * Called when the behavior is attached to a target
  5964. * @param target defines the target where the behavior is attached to
  5965. */
  5966. attach(target: T): void;
  5967. /**
  5968. * Called when the behavior is detached from its target
  5969. */
  5970. detach(): void;
  5971. }
  5972. /**
  5973. * Interface implemented by classes supporting behaviors
  5974. */
  5975. export interface IBehaviorAware<T> {
  5976. /**
  5977. * Attach a behavior
  5978. * @param behavior defines the behavior to attach
  5979. * @returns the current host
  5980. */
  5981. addBehavior(behavior: Behavior<T>): T;
  5982. /**
  5983. * Remove a behavior from the current object
  5984. * @param behavior defines the behavior to detach
  5985. * @returns the current host
  5986. */
  5987. removeBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Gets a behavior using its name to search
  5990. * @param name defines the name to search
  5991. * @returns the behavior or null if not found
  5992. */
  5993. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5994. }
  5995. }
  5996. declare module "babylonjs/Misc/smartArray" {
  5997. /**
  5998. * Defines an array and its length.
  5999. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6000. */
  6001. export interface ISmartArrayLike<T> {
  6002. /**
  6003. * The data of the array.
  6004. */
  6005. data: Array<T>;
  6006. /**
  6007. * The active length of the array.
  6008. */
  6009. length: number;
  6010. }
  6011. /**
  6012. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6013. */
  6014. export class SmartArray<T> implements ISmartArrayLike<T> {
  6015. /**
  6016. * The full set of data from the array.
  6017. */
  6018. data: Array<T>;
  6019. /**
  6020. * The active length of the array.
  6021. */
  6022. length: number;
  6023. protected _id: number;
  6024. /**
  6025. * Instantiates a Smart Array.
  6026. * @param capacity defines the default capacity of the array.
  6027. */
  6028. constructor(capacity: number);
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * @param value defines the object to push in the array.
  6032. */
  6033. push(value: T): void;
  6034. /**
  6035. * Iterates over the active data and apply the lambda to them.
  6036. * @param func defines the action to apply on each value.
  6037. */
  6038. forEach(func: (content: T) => void): void;
  6039. /**
  6040. * Sorts the full sets of data.
  6041. * @param compareFn defines the comparison function to apply.
  6042. */
  6043. sort(compareFn: (a: T, b: T) => number): void;
  6044. /**
  6045. * Resets the active data to an empty array.
  6046. */
  6047. reset(): void;
  6048. /**
  6049. * Releases all the data from the array as well as the array.
  6050. */
  6051. dispose(): void;
  6052. /**
  6053. * Concats the active data with a given array.
  6054. * @param array defines the data to concatenate with.
  6055. */
  6056. concat(array: any): void;
  6057. /**
  6058. * Returns the position of a value in the active data.
  6059. * @param value defines the value to find the index for
  6060. * @returns the index if found in the active data otherwise -1
  6061. */
  6062. indexOf(value: T): number;
  6063. /**
  6064. * Returns whether an element is part of the active data.
  6065. * @param value defines the value to look for
  6066. * @returns true if found in the active data otherwise false
  6067. */
  6068. contains(value: T): boolean;
  6069. private static _GlobalId;
  6070. }
  6071. /**
  6072. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6073. * The data in this array can only be present once
  6074. */
  6075. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6076. private _duplicateId;
  6077. /**
  6078. * Pushes a value at the end of the active data.
  6079. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6080. * @param value defines the object to push in the array.
  6081. */
  6082. push(value: T): void;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * If the data is already present, it won t be added again
  6086. * @param value defines the object to push in the array.
  6087. * @returns true if added false if it was already present
  6088. */
  6089. pushNoDuplicate(value: T): boolean;
  6090. /**
  6091. * Resets the active data to an empty array.
  6092. */
  6093. reset(): void;
  6094. /**
  6095. * Concats the active data with a given array.
  6096. * This ensures no dupplicate will be present in the result.
  6097. * @param array defines the data to concatenate with.
  6098. */
  6099. concatWithNoDuplicate(array: any): void;
  6100. }
  6101. }
  6102. declare module "babylonjs/Cameras/cameraInputsManager" {
  6103. import { Nullable } from "babylonjs/types";
  6104. import { Camera } from "babylonjs/Cameras/camera";
  6105. /**
  6106. * @ignore
  6107. * This is a list of all the different input types that are available in the application.
  6108. * Fo instance: ArcRotateCameraGamepadInput...
  6109. */
  6110. export var CameraInputTypes: {};
  6111. /**
  6112. * This is the contract to implement in order to create a new input class.
  6113. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6114. */
  6115. export interface ICameraInput<TCamera extends Camera> {
  6116. /**
  6117. * Defines the camera the input is attached to.
  6118. */
  6119. camera: Nullable<TCamera>;
  6120. /**
  6121. * Gets the class name of the current intput.
  6122. * @returns the class name
  6123. */
  6124. getClassName(): string;
  6125. /**
  6126. * Get the friendly name associated with the input class.
  6127. * @returns the input friendly name
  6128. */
  6129. getSimpleName(): string;
  6130. /**
  6131. * Attach the input controls to a specific dom element to get the input from.
  6132. * @param element Defines the element the controls should be listened from
  6133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6134. */
  6135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6136. /**
  6137. * Detach the current controls from the specified dom element.
  6138. * @param element Defines the element to stop listening the inputs from
  6139. */
  6140. detachControl(element: Nullable<HTMLElement>): void;
  6141. /**
  6142. * Update the current camera state depending on the inputs that have been used this frame.
  6143. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6144. */
  6145. checkInputs?: () => void;
  6146. }
  6147. /**
  6148. * Represents a map of input types to input instance or input index to input instance.
  6149. */
  6150. export interface CameraInputsMap<TCamera extends Camera> {
  6151. /**
  6152. * Accessor to the input by input type.
  6153. */
  6154. [name: string]: ICameraInput<TCamera>;
  6155. /**
  6156. * Accessor to the input by input index.
  6157. */
  6158. [idx: number]: ICameraInput<TCamera>;
  6159. }
  6160. /**
  6161. * This represents the input manager used within a camera.
  6162. * It helps dealing with all the different kind of input attached to a camera.
  6163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6164. */
  6165. export class CameraInputsManager<TCamera extends Camera> {
  6166. /**
  6167. * Defines the list of inputs attahed to the camera.
  6168. */
  6169. attached: CameraInputsMap<TCamera>;
  6170. /**
  6171. * Defines the dom element the camera is collecting inputs from.
  6172. * This is null if the controls have not been attached.
  6173. */
  6174. attachedElement: Nullable<HTMLElement>;
  6175. /**
  6176. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6177. */
  6178. noPreventDefault: boolean;
  6179. /**
  6180. * Defined the camera the input manager belongs to.
  6181. */
  6182. camera: TCamera;
  6183. /**
  6184. * Update the current camera state depending on the inputs that have been used this frame.
  6185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6186. */
  6187. checkInputs: () => void;
  6188. /**
  6189. * Instantiate a new Camera Input Manager.
  6190. * @param camera Defines the camera the input manager blongs to
  6191. */
  6192. constructor(camera: TCamera);
  6193. /**
  6194. * Add an input method to a camera
  6195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6196. * @param input camera input method
  6197. */
  6198. add(input: ICameraInput<TCamera>): void;
  6199. /**
  6200. * Remove a specific input method from a camera
  6201. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6202. * @param inputToRemove camera input method
  6203. */
  6204. remove(inputToRemove: ICameraInput<TCamera>): void;
  6205. /**
  6206. * Remove a specific input type from a camera
  6207. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6208. * @param inputType the type of the input to remove
  6209. */
  6210. removeByType(inputType: string): void;
  6211. private _addCheckInputs;
  6212. /**
  6213. * Attach the input controls to the currently attached dom element to listen the events from.
  6214. * @param input Defines the input to attach
  6215. */
  6216. attachInput(input: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6219. * @param element Defines the dom element to collect the events from
  6220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6221. */
  6222. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6223. /**
  6224. * Detach the current manager inputs controls from a specific dom element.
  6225. * @param element Defines the dom element to collect the events from
  6226. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6227. */
  6228. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6229. /**
  6230. * Rebuild the dynamic inputCheck function from the current list of
  6231. * defined inputs in the manager.
  6232. */
  6233. rebuildInputCheck(): void;
  6234. /**
  6235. * Remove all attached input methods from a camera
  6236. */
  6237. clear(): void;
  6238. /**
  6239. * Serialize the current input manager attached to a camera.
  6240. * This ensures than once parsed,
  6241. * the input associated to the camera will be identical to the current ones
  6242. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6243. */
  6244. serialize(serializedCamera: any): void;
  6245. /**
  6246. * Parses an input manager serialized JSON to restore the previous list of inputs
  6247. * and states associated to a camera.
  6248. * @param parsedCamera Defines the JSON to parse
  6249. */
  6250. parse(parsedCamera: any): void;
  6251. }
  6252. }
  6253. declare module "babylonjs/Meshes/buffer" {
  6254. import { Nullable, DataArray } from "babylonjs/types";
  6255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6256. /**
  6257. * Class used to store data that will be store in GPU memory
  6258. */
  6259. export class Buffer {
  6260. private _engine;
  6261. private _buffer;
  6262. /** @hidden */
  6263. _data: Nullable<DataArray>;
  6264. private _updatable;
  6265. private _instanced;
  6266. private _divisor;
  6267. /**
  6268. * Gets the byte stride.
  6269. */
  6270. readonly byteStride: number;
  6271. /**
  6272. * Constructor
  6273. * @param engine the engine
  6274. * @param data the data to use for this buffer
  6275. * @param updatable whether the data is updatable
  6276. * @param stride the stride (optional)
  6277. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6278. * @param instanced whether the buffer is instanced (optional)
  6279. * @param useBytes set to true if the stride in in bytes (optional)
  6280. * @param divisor sets an optional divisor for instances (1 by default)
  6281. */
  6282. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6283. /**
  6284. * Create a new VertexBuffer based on the current buffer
  6285. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6286. * @param offset defines offset in the buffer (0 by default)
  6287. * @param size defines the size in floats of attributes (position is 3 for instance)
  6288. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6289. * @param instanced defines if the vertex buffer contains indexed data
  6290. * @param useBytes defines if the offset and stride are in bytes *
  6291. * @param divisor sets an optional divisor for instances (1 by default)
  6292. * @returns the new vertex buffer
  6293. */
  6294. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6295. /**
  6296. * Gets a boolean indicating if the Buffer is updatable?
  6297. * @returns true if the buffer is updatable
  6298. */
  6299. isUpdatable(): boolean;
  6300. /**
  6301. * Gets current buffer's data
  6302. * @returns a DataArray or null
  6303. */
  6304. getData(): Nullable<DataArray>;
  6305. /**
  6306. * Gets underlying native buffer
  6307. * @returns underlying native buffer
  6308. */
  6309. getBuffer(): Nullable<DataBuffer>;
  6310. /**
  6311. * Gets the stride in float32 units (i.e. byte stride / 4).
  6312. * May not be an integer if the byte stride is not divisible by 4.
  6313. * DEPRECATED. Use byteStride instead.
  6314. * @returns the stride in float32 units
  6315. */
  6316. getStrideSize(): number;
  6317. /**
  6318. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6319. * @param data defines the data to store
  6320. */
  6321. create(data?: Nullable<DataArray>): void;
  6322. /** @hidden */
  6323. _rebuild(): void;
  6324. /**
  6325. * Update current buffer data
  6326. * @param data defines the data to store
  6327. */
  6328. update(data: DataArray): void;
  6329. /**
  6330. * Updates the data directly.
  6331. * @param data the new data
  6332. * @param offset the new offset
  6333. * @param vertexCount the vertex count (optional)
  6334. * @param useBytes set to true if the offset is in bytes
  6335. */
  6336. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6337. /**
  6338. * Release all resources
  6339. */
  6340. dispose(): void;
  6341. }
  6342. /**
  6343. * Specialized buffer used to store vertex data
  6344. */
  6345. export class VertexBuffer {
  6346. /** @hidden */
  6347. _buffer: Buffer;
  6348. private _kind;
  6349. private _size;
  6350. private _ownsBuffer;
  6351. private _instanced;
  6352. private _instanceDivisor;
  6353. /**
  6354. * The byte type.
  6355. */
  6356. static readonly BYTE: number;
  6357. /**
  6358. * The unsigned byte type.
  6359. */
  6360. static readonly UNSIGNED_BYTE: number;
  6361. /**
  6362. * The short type.
  6363. */
  6364. static readonly SHORT: number;
  6365. /**
  6366. * The unsigned short type.
  6367. */
  6368. static readonly UNSIGNED_SHORT: number;
  6369. /**
  6370. * The integer type.
  6371. */
  6372. static readonly INT: number;
  6373. /**
  6374. * The unsigned integer type.
  6375. */
  6376. static readonly UNSIGNED_INT: number;
  6377. /**
  6378. * The float type.
  6379. */
  6380. static readonly FLOAT: number;
  6381. /**
  6382. * Gets or sets the instance divisor when in instanced mode
  6383. */
  6384. instanceDivisor: number;
  6385. /**
  6386. * Gets the byte stride.
  6387. */
  6388. readonly byteStride: number;
  6389. /**
  6390. * Gets the byte offset.
  6391. */
  6392. readonly byteOffset: number;
  6393. /**
  6394. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6395. */
  6396. readonly normalized: boolean;
  6397. /**
  6398. * Gets the data type of each component in the array.
  6399. */
  6400. readonly type: number;
  6401. /**
  6402. * Constructor
  6403. * @param engine the engine
  6404. * @param data the data to use for this vertex buffer
  6405. * @param kind the vertex buffer kind
  6406. * @param updatable whether the data is updatable
  6407. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6408. * @param stride the stride (optional)
  6409. * @param instanced whether the buffer is instanced (optional)
  6410. * @param offset the offset of the data (optional)
  6411. * @param size the number of components (optional)
  6412. * @param type the type of the component (optional)
  6413. * @param normalized whether the data contains normalized data (optional)
  6414. * @param useBytes set to true if stride and offset are in bytes (optional)
  6415. * @param divisor defines the instance divisor to use (1 by default)
  6416. */
  6417. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6418. /** @hidden */
  6419. _rebuild(): void;
  6420. /**
  6421. * Returns the kind of the VertexBuffer (string)
  6422. * @returns a string
  6423. */
  6424. getKind(): string;
  6425. /**
  6426. * Gets a boolean indicating if the VertexBuffer is updatable?
  6427. * @returns true if the buffer is updatable
  6428. */
  6429. isUpdatable(): boolean;
  6430. /**
  6431. * Gets current buffer's data
  6432. * @returns a DataArray or null
  6433. */
  6434. getData(): Nullable<DataArray>;
  6435. /**
  6436. * Gets underlying native buffer
  6437. * @returns underlying native buffer
  6438. */
  6439. getBuffer(): Nullable<DataBuffer>;
  6440. /**
  6441. * Gets the stride in float32 units (i.e. byte stride / 4).
  6442. * May not be an integer if the byte stride is not divisible by 4.
  6443. * DEPRECATED. Use byteStride instead.
  6444. * @returns the stride in float32 units
  6445. */
  6446. getStrideSize(): number;
  6447. /**
  6448. * Returns the offset as a multiple of the type byte length.
  6449. * DEPRECATED. Use byteOffset instead.
  6450. * @returns the offset in bytes
  6451. */
  6452. getOffset(): number;
  6453. /**
  6454. * Returns the number of components per vertex attribute (integer)
  6455. * @returns the size in float
  6456. */
  6457. getSize(): number;
  6458. /**
  6459. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6460. * @returns true if this buffer is instanced
  6461. */
  6462. getIsInstanced(): boolean;
  6463. /**
  6464. * Returns the instancing divisor, zero for non-instanced (integer).
  6465. * @returns a number
  6466. */
  6467. getInstanceDivisor(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: DataArray): void;
  6473. /**
  6474. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6475. * This function will create a new buffer if the current one is not updatable
  6476. * @param data defines the data to store
  6477. */
  6478. update(data: DataArray): void;
  6479. /**
  6480. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6481. * Returns the directly updated WebGLBuffer.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param useBytes set to true if the offset is in bytes
  6485. */
  6486. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6487. /**
  6488. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6489. */
  6490. dispose(): void;
  6491. /**
  6492. * Enumerates each value of this vertex buffer as numbers.
  6493. * @param count the number of values to enumerate
  6494. * @param callback the callback function called for each value
  6495. */
  6496. forEach(count: number, callback: (value: number, index: number) => void): void;
  6497. /**
  6498. * Positions
  6499. */
  6500. static readonly PositionKind: string;
  6501. /**
  6502. * Normals
  6503. */
  6504. static readonly NormalKind: string;
  6505. /**
  6506. * Tangents
  6507. */
  6508. static readonly TangentKind: string;
  6509. /**
  6510. * Texture coordinates
  6511. */
  6512. static readonly UVKind: string;
  6513. /**
  6514. * Texture coordinates 2
  6515. */
  6516. static readonly UV2Kind: string;
  6517. /**
  6518. * Texture coordinates 3
  6519. */
  6520. static readonly UV3Kind: string;
  6521. /**
  6522. * Texture coordinates 4
  6523. */
  6524. static readonly UV4Kind: string;
  6525. /**
  6526. * Texture coordinates 5
  6527. */
  6528. static readonly UV5Kind: string;
  6529. /**
  6530. * Texture coordinates 6
  6531. */
  6532. static readonly UV6Kind: string;
  6533. /**
  6534. * Colors
  6535. */
  6536. static readonly ColorKind: string;
  6537. /**
  6538. * Matrix indices (for bones)
  6539. */
  6540. static readonly MatricesIndicesKind: string;
  6541. /**
  6542. * Matrix weights (for bones)
  6543. */
  6544. static readonly MatricesWeightsKind: string;
  6545. /**
  6546. * Additional matrix indices (for bones)
  6547. */
  6548. static readonly MatricesIndicesExtraKind: string;
  6549. /**
  6550. * Additional matrix weights (for bones)
  6551. */
  6552. static readonly MatricesWeightsExtraKind: string;
  6553. /**
  6554. * Deduces the stride given a kind.
  6555. * @param kind The kind string to deduce
  6556. * @returns The deduced stride
  6557. */
  6558. static DeduceStride(kind: string): number;
  6559. /**
  6560. * Gets the byte length of the given type.
  6561. * @param type the type
  6562. * @returns the number of bytes
  6563. */
  6564. static GetTypeByteLength(type: number): number;
  6565. /**
  6566. * Enumerates each value of the given parameters as numbers.
  6567. * @param data the data to enumerate
  6568. * @param byteOffset the byte offset of the data
  6569. * @param byteStride the byte stride of the data
  6570. * @param componentCount the number of components per element
  6571. * @param componentType the type of the component
  6572. * @param count the number of values to enumerate
  6573. * @param normalized whether the data is normalized
  6574. * @param callback the callback function called for each value
  6575. */
  6576. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6577. private static _GetFloatValue;
  6578. }
  6579. }
  6580. declare module "babylonjs/Collisions/intersectionInfo" {
  6581. import { Nullable } from "babylonjs/types";
  6582. /**
  6583. * @hidden
  6584. */
  6585. export class IntersectionInfo {
  6586. bu: Nullable<number>;
  6587. bv: Nullable<number>;
  6588. distance: number;
  6589. faceId: number;
  6590. subMeshId: number;
  6591. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6592. }
  6593. }
  6594. declare module "babylonjs/Maths/math.plane" {
  6595. import { DeepImmutable } from "babylonjs/types";
  6596. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6597. /**
  6598. * Represens a plane by the equation ax + by + cz + d = 0
  6599. */
  6600. export class Plane {
  6601. private static _TmpMatrix;
  6602. /**
  6603. * Normal of the plane (a,b,c)
  6604. */
  6605. normal: Vector3;
  6606. /**
  6607. * d component of the plane
  6608. */
  6609. d: number;
  6610. /**
  6611. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6612. * @param a a component of the plane
  6613. * @param b b component of the plane
  6614. * @param c c component of the plane
  6615. * @param d d component of the plane
  6616. */
  6617. constructor(a: number, b: number, c: number, d: number);
  6618. /**
  6619. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6620. */
  6621. asArray(): number[];
  6622. /**
  6623. * @returns a new plane copied from the current Plane.
  6624. */
  6625. clone(): Plane;
  6626. /**
  6627. * @returns the string "Plane".
  6628. */
  6629. getClassName(): string;
  6630. /**
  6631. * @returns the Plane hash code.
  6632. */
  6633. getHashCode(): number;
  6634. /**
  6635. * Normalize the current Plane in place.
  6636. * @returns the updated Plane.
  6637. */
  6638. normalize(): Plane;
  6639. /**
  6640. * Applies a transformation the plane and returns the result
  6641. * @param transformation the transformation matrix to be applied to the plane
  6642. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6643. */
  6644. transform(transformation: DeepImmutable<Matrix>): Plane;
  6645. /**
  6646. * Calcualtte the dot product between the point and the plane normal
  6647. * @param point point to calculate the dot product with
  6648. * @returns the dot product (float) of the point coordinates and the plane normal.
  6649. */
  6650. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6651. /**
  6652. * Updates the current Plane from the plane defined by the three given points.
  6653. * @param point1 one of the points used to contruct the plane
  6654. * @param point2 one of the points used to contruct the plane
  6655. * @param point3 one of the points used to contruct the plane
  6656. * @returns the updated Plane.
  6657. */
  6658. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6659. /**
  6660. * Checks if the plane is facing a given direction
  6661. * @param direction the direction to check if the plane is facing
  6662. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6663. * @returns True is the vector "direction" is the same side than the plane normal.
  6664. */
  6665. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6666. /**
  6667. * Calculates the distance to a point
  6668. * @param point point to calculate distance to
  6669. * @returns the signed distance (float) from the given point to the Plane.
  6670. */
  6671. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6672. /**
  6673. * Creates a plane from an array
  6674. * @param array the array to create a plane from
  6675. * @returns a new Plane from the given array.
  6676. */
  6677. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6678. /**
  6679. * Creates a plane from three points
  6680. * @param point1 point used to create the plane
  6681. * @param point2 point used to create the plane
  6682. * @param point3 point used to create the plane
  6683. * @returns a new Plane defined by the three given points.
  6684. */
  6685. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6686. /**
  6687. * Creates a plane from an origin point and a normal
  6688. * @param origin origin of the plane to be constructed
  6689. * @param normal normal of the plane to be constructed
  6690. * @returns a new Plane the normal vector to this plane at the given origin point.
  6691. * Note : the vector "normal" is updated because normalized.
  6692. */
  6693. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Calculates the distance from a plane and a point
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @param point point to calculate distance to
  6699. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6700. */
  6701. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6702. }
  6703. }
  6704. declare module "babylonjs/Culling/boundingSphere" {
  6705. import { DeepImmutable } from "babylonjs/types";
  6706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6707. import { Plane } from "babylonjs/Maths/math.plane";
  6708. /**
  6709. * Class used to store bounding sphere information
  6710. */
  6711. export class BoundingSphere {
  6712. /**
  6713. * Gets the center of the bounding sphere in local space
  6714. */
  6715. readonly center: Vector3;
  6716. /**
  6717. * Radius of the bounding sphere in local space
  6718. */
  6719. radius: number;
  6720. /**
  6721. * Gets the center of the bounding sphere in world space
  6722. */
  6723. readonly centerWorld: Vector3;
  6724. /**
  6725. * Radius of the bounding sphere in world space
  6726. */
  6727. radiusWorld: number;
  6728. /**
  6729. * Gets the minimum vector in local space
  6730. */
  6731. readonly minimum: Vector3;
  6732. /**
  6733. * Gets the maximum vector in local space
  6734. */
  6735. readonly maximum: Vector3;
  6736. private _worldMatrix;
  6737. private static readonly TmpVector3;
  6738. /**
  6739. * Creates a new bounding sphere
  6740. * @param min defines the minimum vector (in local space)
  6741. * @param max defines the maximum vector (in local space)
  6742. * @param worldMatrix defines the new world matrix
  6743. */
  6744. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6745. /**
  6746. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6747. * @param min defines the new minimum vector (in local space)
  6748. * @param max defines the new maximum vector (in local space)
  6749. * @param worldMatrix defines the new world matrix
  6750. */
  6751. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6752. /**
  6753. * Scale the current bounding sphere by applying a scale factor
  6754. * @param factor defines the scale factor to apply
  6755. * @returns the current bounding box
  6756. */
  6757. scale(factor: number): BoundingSphere;
  6758. /**
  6759. * Gets the world matrix of the bounding box
  6760. * @returns a matrix
  6761. */
  6762. getWorldMatrix(): DeepImmutable<Matrix>;
  6763. /** @hidden */
  6764. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6765. /**
  6766. * Tests if the bounding sphere is intersecting the frustum planes
  6767. * @param frustumPlanes defines the frustum planes to test
  6768. * @returns true if there is an intersection
  6769. */
  6770. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6771. /**
  6772. * Tests if the bounding sphere center is in between the frustum planes.
  6773. * Used for optimistic fast inclusion.
  6774. * @param frustumPlanes defines the frustum planes to test
  6775. * @returns true if the sphere center is in between the frustum planes
  6776. */
  6777. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6778. /**
  6779. * Tests if a point is inside the bounding sphere
  6780. * @param point defines the point to test
  6781. * @returns true if the point is inside the bounding sphere
  6782. */
  6783. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6784. /**
  6785. * Checks if two sphere intersct
  6786. * @param sphere0 sphere 0
  6787. * @param sphere1 sphere 1
  6788. * @returns true if the speres intersect
  6789. */
  6790. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6791. }
  6792. }
  6793. declare module "babylonjs/Culling/boundingBox" {
  6794. import { DeepImmutable } from "babylonjs/types";
  6795. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6796. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6797. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6798. import { Plane } from "babylonjs/Maths/math.plane";
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/collider" {
  6944. import { Nullable, IndicesArray } from "babylonjs/types";
  6945. import { Vector3 } from "babylonjs/Maths/math.vector";
  6946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6947. import { Plane } from "babylonjs/Maths/math.plane";
  6948. /** @hidden */
  6949. export class Collider {
  6950. /** Define if a collision was found */
  6951. collisionFound: boolean;
  6952. /**
  6953. * Define last intersection point in local space
  6954. */
  6955. intersectionPoint: Vector3;
  6956. /**
  6957. * Define last collided mesh
  6958. */
  6959. collidedMesh: Nullable<AbstractMesh>;
  6960. private _collisionPoint;
  6961. private _planeIntersectionPoint;
  6962. private _tempVector;
  6963. private _tempVector2;
  6964. private _tempVector3;
  6965. private _tempVector4;
  6966. private _edge;
  6967. private _baseToVertex;
  6968. private _destinationPoint;
  6969. private _slidePlaneNormal;
  6970. private _displacementVector;
  6971. /** @hidden */
  6972. _radius: Vector3;
  6973. /** @hidden */
  6974. _retry: number;
  6975. private _velocity;
  6976. private _basePoint;
  6977. private _epsilon;
  6978. /** @hidden */
  6979. _velocityWorldLength: number;
  6980. /** @hidden */
  6981. _basePointWorld: Vector3;
  6982. private _velocityWorld;
  6983. private _normalizedVelocity;
  6984. /** @hidden */
  6985. _initialVelocity: Vector3;
  6986. /** @hidden */
  6987. _initialPosition: Vector3;
  6988. private _nearestDistance;
  6989. private _collisionMask;
  6990. collisionMask: number;
  6991. /**
  6992. * Gets the plane normal used to compute the sliding response (in local space)
  6993. */
  6994. readonly slidePlaneNormal: Vector3;
  6995. /** @hidden */
  6996. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6997. /** @hidden */
  6998. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6999. /** @hidden */
  7000. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7001. /** @hidden */
  7002. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7003. /** @hidden */
  7004. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _getResponse(pos: Vector3, vel: Vector3): void;
  7007. }
  7008. }
  7009. declare module "babylonjs/Culling/boundingInfo" {
  7010. import { DeepImmutable } from "babylonjs/types";
  7011. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7012. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7013. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7014. import { Plane } from "babylonjs/Maths/math.plane";
  7015. import { Collider } from "babylonjs/Collisions/collider";
  7016. /**
  7017. * Interface for cullable objects
  7018. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7019. */
  7020. export interface ICullable {
  7021. /**
  7022. * Checks if the object or part of the object is in the frustum
  7023. * @param frustumPlanes Camera near/planes
  7024. * @returns true if the object is in frustum otherwise false
  7025. */
  7026. isInFrustum(frustumPlanes: Plane[]): boolean;
  7027. /**
  7028. * Checks if a cullable object (mesh...) is in the camera frustum
  7029. * Unlike isInFrustum this cheks the full bounding box
  7030. * @param frustumPlanes Camera near/planes
  7031. * @returns true if the object is in frustum otherwise false
  7032. */
  7033. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7034. }
  7035. /**
  7036. * Info for a bounding data of a mesh
  7037. */
  7038. export class BoundingInfo implements ICullable {
  7039. /**
  7040. * Bounding box for the mesh
  7041. */
  7042. readonly boundingBox: BoundingBox;
  7043. /**
  7044. * Bounding sphere for the mesh
  7045. */
  7046. readonly boundingSphere: BoundingSphere;
  7047. private _isLocked;
  7048. private static readonly TmpVector3;
  7049. /**
  7050. * Constructs bounding info
  7051. * @param minimum min vector of the bounding box/sphere
  7052. * @param maximum max vector of the bounding box/sphere
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * min vector of the bounding box/sphere
  7065. */
  7066. readonly minimum: Vector3;
  7067. /**
  7068. * max vector of the bounding box/sphere
  7069. */
  7070. readonly maximum: Vector3;
  7071. /**
  7072. * If the info is locked and won't be updated to avoid perf overhead
  7073. */
  7074. isLocked: boolean;
  7075. /**
  7076. * Updates the bounding sphere and box
  7077. * @param world world matrix to be used to update
  7078. */
  7079. update(world: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7082. * @param center New center of the bounding info
  7083. * @param extend New extend of the bounding info
  7084. * @returns the current bounding info
  7085. */
  7086. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7087. /**
  7088. * Scale the current bounding info by applying a scale factor
  7089. * @param factor defines the scale factor to apply
  7090. * @returns the current bounding info
  7091. */
  7092. scale(factor: number): BoundingInfo;
  7093. /**
  7094. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7095. * @param frustumPlanes defines the frustum to test
  7096. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7097. * @returns true if the bounding info is in the frustum planes
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7100. /**
  7101. * Gets the world distance between the min and max points of the bounding box
  7102. */
  7103. readonly diagonalLength: number;
  7104. /**
  7105. * Checks if a cullable object (mesh...) is in the camera frustum
  7106. * Unlike isInFrustum this cheks the full bounding box
  7107. * @param frustumPlanes Camera near/planes
  7108. * @returns true if the object is in frustum otherwise false
  7109. */
  7110. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7111. /** @hidden */
  7112. _checkCollision(collider: Collider): boolean;
  7113. /**
  7114. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7116. * @param point the point to check intersection with
  7117. * @returns if the point intersects
  7118. */
  7119. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7120. /**
  7121. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7122. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7123. * @param boundingInfo the bounding info to check intersection with
  7124. * @param precise if the intersection should be done using OBB
  7125. * @returns if the bounding info intersects
  7126. */
  7127. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7128. }
  7129. }
  7130. declare module "babylonjs/Maths/math.functions" {
  7131. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7132. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7161. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7162. /** @hidden */
  7163. export class WebGLDataBuffer extends DataBuffer {
  7164. private _buffer;
  7165. constructor(resource: WebGLBuffer);
  7166. readonly underlyingResource: any;
  7167. }
  7168. }
  7169. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7170. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7171. import { Nullable } from "babylonjs/types";
  7172. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7173. /** @hidden */
  7174. export class WebGLPipelineContext implements IPipelineContext {
  7175. engine: ThinEngine;
  7176. program: Nullable<WebGLProgram>;
  7177. context?: WebGLRenderingContext;
  7178. vertexShader?: WebGLShader;
  7179. fragmentShader?: WebGLShader;
  7180. isParallelCompiled: boolean;
  7181. onCompiled?: () => void;
  7182. transformFeedback?: WebGLTransformFeedback | null;
  7183. readonly isAsync: boolean;
  7184. readonly isReady: boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. }
  7187. }
  7188. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7189. import { FloatArray, Nullable } from "babylonjs/types";
  7190. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7192. module "babylonjs/Engines/thinEngine" {
  7193. interface ThinEngine {
  7194. /**
  7195. * Create an uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Create a dynamic uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param elements defines the content of the uniform buffer
  7205. * @returns the webGL uniform buffer
  7206. */
  7207. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7208. /**
  7209. * Update an existing uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param uniformBuffer defines the target uniform buffer
  7212. * @param elements defines the content to update
  7213. * @param offset defines the offset in the uniform buffer where update should start
  7214. * @param count defines the size of the data to update
  7215. */
  7216. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7217. /**
  7218. * Bind an uniform buffer to the current webGL context
  7219. * @param buffer defines the buffer to bind
  7220. */
  7221. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7222. /**
  7223. * Bind a buffer to the current webGL context at a given location
  7224. * @param buffer defines the buffer to bind
  7225. * @param location defines the index where to bind the buffer
  7226. */
  7227. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7228. /**
  7229. * Bind a specific block at a given index in a specific shader program
  7230. * @param pipelineContext defines the pipeline context to use
  7231. * @param blockName defines the block name
  7232. * @param index defines the index where to bind the block
  7233. */
  7234. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7235. }
  7236. }
  7237. }
  7238. declare module "babylonjs/Materials/uniformBuffer" {
  7239. import { Nullable, FloatArray } from "babylonjs/types";
  7240. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7241. import { Engine } from "babylonjs/Engines/engine";
  7242. import { Effect } from "babylonjs/Materials/effect";
  7243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7244. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7245. import { Color3 } from "babylonjs/Maths/math.color";
  7246. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7247. /**
  7248. * Uniform buffer objects.
  7249. *
  7250. * Handles blocks of uniform on the GPU.
  7251. *
  7252. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7253. *
  7254. * For more information, please refer to :
  7255. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7256. */
  7257. export class UniformBuffer {
  7258. private _engine;
  7259. private _buffer;
  7260. private _data;
  7261. private _bufferData;
  7262. private _dynamic?;
  7263. private _uniformLocations;
  7264. private _uniformSizes;
  7265. private _uniformLocationPointer;
  7266. private _needSync;
  7267. private _noUBO;
  7268. private _currentEffect;
  7269. /** @hidden */
  7270. _alreadyBound: boolean;
  7271. private static _MAX_UNIFORM_SIZE;
  7272. private static _tempBuffer;
  7273. /**
  7274. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7279. /**
  7280. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7285. /**
  7286. * Lambda to Update a single float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat: (name: string, x: number) => void;
  7291. /**
  7292. * Lambda to Update a vec2 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a vec3 of float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7303. /**
  7304. * Lambda to Update a vec4 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateMatrix: (name: string, mat: Matrix) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateVector3: (name: string, vector: Vector3) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateVector4: (name: string, vector: Vector4) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7339. /**
  7340. * Instantiates a new Uniform buffer objects.
  7341. *
  7342. * Handles blocks of uniform on the GPU.
  7343. *
  7344. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7345. *
  7346. * For more information, please refer to :
  7347. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7348. * @param engine Define the engine the buffer is associated with
  7349. * @param data Define the data contained in the buffer
  7350. * @param dynamic Define if the buffer is updatable
  7351. */
  7352. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7353. /**
  7354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7355. * or just falling back on setUniformXXX calls.
  7356. */
  7357. readonly useUbo: boolean;
  7358. /**
  7359. * Indicates if the WebGL underlying uniform buffer is in sync
  7360. * with the javascript cache data.
  7361. */
  7362. readonly isSync: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7365. * Also, a dynamic UniformBuffer will disable cache verification and always
  7366. * update the underlying WebGL uniform buffer to the GPU.
  7367. * @returns if Dynamic, otherwise false
  7368. */
  7369. isDynamic(): boolean;
  7370. /**
  7371. * The data cache on JS side.
  7372. * @returns the underlying data as a float array
  7373. */
  7374. getData(): Float32Array;
  7375. /**
  7376. * The underlying WebGL Uniform buffer.
  7377. * @returns the webgl buffer
  7378. */
  7379. getBuffer(): Nullable<DataBuffer>;
  7380. /**
  7381. * std140 layout specifies how to align data within an UBO structure.
  7382. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7383. * for specs.
  7384. */
  7385. private _fillAlignment;
  7386. /**
  7387. * Adds an uniform in the buffer.
  7388. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7389. * for the layout to be correct !
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param size Data size, or data directly.
  7392. */
  7393. addUniform(name: string, size: number | number[]): void;
  7394. /**
  7395. * Adds a Matrix 4x4 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param mat A 4x4 matrix.
  7398. */
  7399. addMatrix(name: string, mat: Matrix): void;
  7400. /**
  7401. * Adds a vec2 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param x Define the x component value of the vec2
  7404. * @param y Define the y component value of the vec2
  7405. */
  7406. addFloat2(name: string, x: number, y: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param x Define the x component value of the vec3
  7411. * @param y Define the y component value of the vec3
  7412. * @param z Define the z component value of the vec3
  7413. */
  7414. addFloat3(name: string, x: number, y: number, z: number): void;
  7415. /**
  7416. * Adds a vec3 to the uniform buffer.
  7417. * @param name Name of the uniform, as used in the uniform block in the shader.
  7418. * @param color Define the vec3 from a Color
  7419. */
  7420. addColor3(name: string, color: Color3): void;
  7421. /**
  7422. * Adds a vec4 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param color Define the rgb components from a Color
  7425. * @param alpha Define the a component of the vec4
  7426. */
  7427. addColor4(name: string, color: Color3, alpha: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param vector Define the vec3 components from a Vector
  7432. */
  7433. addVector3(name: string, vector: Vector3): void;
  7434. /**
  7435. * Adds a Matrix 3x3 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. */
  7438. addMatrix3x3(name: string): void;
  7439. /**
  7440. * Adds a Matrix 2x2 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix2x2(name: string): void;
  7444. /**
  7445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7446. */
  7447. create(): void;
  7448. /** @hidden */
  7449. _rebuild(): void;
  7450. /**
  7451. * Updates the WebGL Uniform Buffer on the GPU.
  7452. * If the `dynamic` flag is set to true, no cache comparison is done.
  7453. * Otherwise, the buffer will be updated only if the cache differs.
  7454. */
  7455. update(): void;
  7456. /**
  7457. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7458. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7459. * @param data Define the flattened data
  7460. * @param size Define the size of the data.
  7461. */
  7462. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7463. private _valueCache;
  7464. private _cacheMatrix;
  7465. private _updateMatrix3x3ForUniform;
  7466. private _updateMatrix3x3ForEffect;
  7467. private _updateMatrix2x2ForEffect;
  7468. private _updateMatrix2x2ForUniform;
  7469. private _updateFloatForEffect;
  7470. private _updateFloatForUniform;
  7471. private _updateFloat2ForEffect;
  7472. private _updateFloat2ForUniform;
  7473. private _updateFloat3ForEffect;
  7474. private _updateFloat3ForUniform;
  7475. private _updateFloat4ForEffect;
  7476. private _updateFloat4ForUniform;
  7477. private _updateMatrixForEffect;
  7478. private _updateMatrixForUniform;
  7479. private _updateVector3ForEffect;
  7480. private _updateVector3ForUniform;
  7481. private _updateVector4ForEffect;
  7482. private _updateVector4ForUniform;
  7483. private _updateColor3ForEffect;
  7484. private _updateColor3ForUniform;
  7485. private _updateColor4ForEffect;
  7486. private _updateColor4ForUniform;
  7487. /**
  7488. * Sets a sampler uniform on the effect.
  7489. * @param name Define the name of the sampler.
  7490. * @param texture Define the texture to set in the sampler
  7491. */
  7492. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7493. /**
  7494. * Directly updates the value of the uniform in the cache AND on the GPU.
  7495. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7496. * @param data Define the flattened data
  7497. */
  7498. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7499. /**
  7500. * Binds this uniform buffer to an effect.
  7501. * @param effect Define the effect to bind the buffer to
  7502. * @param name Name of the uniform block in the shader.
  7503. */
  7504. bindToEffect(effect: Effect, name: string): void;
  7505. /**
  7506. * Disposes the uniform buffer.
  7507. */
  7508. dispose(): void;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/iInspectable" {
  7512. /**
  7513. * Enum that determines the text-wrapping mode to use.
  7514. */
  7515. export enum InspectableType {
  7516. /**
  7517. * Checkbox for booleans
  7518. */
  7519. Checkbox = 0,
  7520. /**
  7521. * Sliders for numbers
  7522. */
  7523. Slider = 1,
  7524. /**
  7525. * Vector3
  7526. */
  7527. Vector3 = 2,
  7528. /**
  7529. * Quaternions
  7530. */
  7531. Quaternion = 3,
  7532. /**
  7533. * Color3
  7534. */
  7535. Color3 = 4,
  7536. /**
  7537. * String
  7538. */
  7539. String = 5
  7540. }
  7541. /**
  7542. * Interface used to define custom inspectable properties.
  7543. * This interface is used by the inspector to display custom property grids
  7544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7545. */
  7546. export interface IInspectable {
  7547. /**
  7548. * Gets the label to display
  7549. */
  7550. label: string;
  7551. /**
  7552. * Gets the name of the property to edit
  7553. */
  7554. propertyName: string;
  7555. /**
  7556. * Gets the type of the editor to use
  7557. */
  7558. type: InspectableType;
  7559. /**
  7560. * Gets the minimum value of the property when using in "slider" mode
  7561. */
  7562. min?: number;
  7563. /**
  7564. * Gets the maximum value of the property when using in "slider" mode
  7565. */
  7566. max?: number;
  7567. /**
  7568. * Gets the setp to use when using in "slider" mode
  7569. */
  7570. step?: number;
  7571. }
  7572. }
  7573. declare module "babylonjs/Misc/timingTools" {
  7574. /**
  7575. * Class used to provide helper for timing
  7576. */
  7577. export class TimingTools {
  7578. /**
  7579. * Polyfill for setImmediate
  7580. * @param action defines the action to execute after the current execution block
  7581. */
  7582. static SetImmediate(action: () => void): void;
  7583. }
  7584. }
  7585. declare module "babylonjs/Misc/instantiationTools" {
  7586. /**
  7587. * Class used to enable instatition of objects by class name
  7588. */
  7589. export class InstantiationTools {
  7590. /**
  7591. * Use this object to register external classes like custom textures or material
  7592. * to allow the laoders to instantiate them
  7593. */
  7594. static RegisteredExternalClasses: {
  7595. [key: string]: Object;
  7596. };
  7597. /**
  7598. * Tries to instantiate a new object from a given class name
  7599. * @param className defines the class name to instantiate
  7600. * @returns the new object or null if the system was not able to do the instantiation
  7601. */
  7602. static Instantiate(className: string): any;
  7603. }
  7604. }
  7605. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7606. /**
  7607. * Define options used to create a depth texture
  7608. */
  7609. export class DepthTextureCreationOptions {
  7610. /** Specifies whether or not a stencil should be allocated in the texture */
  7611. generateStencil?: boolean;
  7612. /** Specifies whether or not bilinear filtering is enable on the texture */
  7613. bilinearFiltering?: boolean;
  7614. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7615. comparisonFunction?: number;
  7616. /** Specifies if the created texture is a cube texture */
  7617. isCube?: boolean;
  7618. }
  7619. }
  7620. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7622. import { Nullable } from "babylonjs/types";
  7623. import { Scene } from "babylonjs/scene";
  7624. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7626. module "babylonjs/Engines/thinEngine" {
  7627. interface ThinEngine {
  7628. /**
  7629. * Creates a depth stencil cube texture.
  7630. * This is only available in WebGL 2.
  7631. * @param size The size of face edge in the cube texture.
  7632. * @param options The options defining the cube texture.
  7633. * @returns The cube texture
  7634. */
  7635. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7649. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7650. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7654. /**
  7655. * Creates a cube texture
  7656. * @param rootUrl defines the url where the files to load is located
  7657. * @param scene defines the current scene
  7658. * @param files defines the list of files to load (1 per face)
  7659. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7660. * @param onLoad defines an optional callback raised when the texture is loaded
  7661. * @param onError defines an optional callback raised if there is an issue to load the texture
  7662. * @param format defines the format of the data
  7663. * @param forcedExtension defines the extension to use to pick the right loader
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7667. /**
  7668. * Creates a cube texture
  7669. * @param rootUrl defines the url where the files to load is located
  7670. * @param scene defines the current scene
  7671. * @param files defines the list of files to load (1 per face)
  7672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7673. * @param onLoad defines an optional callback raised when the texture is loaded
  7674. * @param onError defines an optional callback raised if there is an issue to load the texture
  7675. * @param format defines the format of the data
  7676. * @param forcedExtension defines the extension to use to pick the right loader
  7677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @returns the cube texture as an InternalTexture
  7681. */
  7682. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7683. /** @hidden */
  7684. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7687. /** @hidden */
  7688. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /** @hidden */
  7690. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7691. /**
  7692. * @hidden
  7693. */
  7694. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7695. }
  7696. }
  7697. }
  7698. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7699. import { Nullable } from "babylonjs/types";
  7700. import { Scene } from "babylonjs/scene";
  7701. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7703. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * The url of the texture
  7711. */
  7712. url: string;
  7713. /**
  7714. * Gets or sets the center of the bounding box associated with the cube texture.
  7715. * It must define where the camera used to render the texture was set
  7716. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7717. */
  7718. boundingBoxPosition: Vector3;
  7719. private _boundingBoxSize;
  7720. /**
  7721. * Gets or sets the size of the bounding box associated with the cube texture
  7722. * When defined, the cubemap will switch to local mode
  7723. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7724. * @example https://www.babylonjs-playground.com/#RNASML
  7725. */
  7726. /**
  7727. * Returns the bounding box size
  7728. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7729. */
  7730. boundingBoxSize: Vector3;
  7731. protected _rotationY: number;
  7732. /**
  7733. * Sets texture matrix rotation angle around Y axis in radians.
  7734. */
  7735. /**
  7736. * Gets texture matrix rotation angle around Y axis radians.
  7737. */
  7738. rotationY: number;
  7739. /**
  7740. * Are mip maps generated for this texture or not.
  7741. */
  7742. readonly noMipmap: boolean;
  7743. private _noMipmap;
  7744. private _files;
  7745. protected _forcedExtension: Nullable<string>;
  7746. private _extensions;
  7747. private _textureMatrix;
  7748. private _format;
  7749. private _createPolynomials;
  7750. /** @hidden */
  7751. _prefiltered: boolean;
  7752. /**
  7753. * Creates a cube texture from an array of image urls
  7754. * @param files defines an array of image urls
  7755. * @param scene defines the hosting scene
  7756. * @param noMipmap specifies if mip maps are not used
  7757. * @returns a cube texture
  7758. */
  7759. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7760. /**
  7761. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7762. * @param url defines the url of the prefiltered texture
  7763. * @param scene defines the scene the texture is attached to
  7764. * @param forcedExtension defines the extension of the file if different from the url
  7765. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7766. * @return the prefiltered texture
  7767. */
  7768. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7769. /**
  7770. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7771. * as prefiltered data.
  7772. * @param rootUrl defines the url of the texture or the root name of the six images
  7773. * @param scene defines the scene the texture is attached to
  7774. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7775. * @param noMipmap defines if mipmaps should be created or not
  7776. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7777. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7778. * @param onError defines a callback triggered in case of error during load
  7779. * @param format defines the internal format to use for the texture once loaded
  7780. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7781. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7782. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7783. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7784. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7785. * @return the cube texture
  7786. */
  7787. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7788. /**
  7789. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7790. */
  7791. readonly isPrefiltered: boolean;
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module "babylonjs/Materials/materialDefines" {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. readonly isDirty: boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module "babylonjs/Materials/colorCurves" {
  7935. import { Effect } from "babylonjs/Materials/effect";
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7958. */
  7959. /**
  7960. * Sets the global Hue value.
  7961. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7962. */
  7963. globalHue: number;
  7964. /**
  7965. * Gets the global Density value.
  7966. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. /**
  7970. * Sets the global Density value.
  7971. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. globalDensity: number;
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7978. */
  7979. /**
  7980. * Sets the global Saturation value.
  7981. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7982. */
  7983. globalSaturation: number;
  7984. /**
  7985. * Gets the global Exposure value.
  7986. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7987. */
  7988. /**
  7989. * Sets the global Exposure value.
  7990. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7991. */
  7992. globalExposure: number;
  7993. private _highlightsHue;
  7994. private _highlightsDensity;
  7995. private _highlightsSaturation;
  7996. private _highlightsExposure;
  7997. /**
  7998. * Gets the highlights Hue value.
  7999. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8000. */
  8001. /**
  8002. * Sets the highlights Hue value.
  8003. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8004. */
  8005. highlightsHue: number;
  8006. /**
  8007. * Gets the highlights Density value.
  8008. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8009. * Values less than zero provide a filter of opposite hue.
  8010. */
  8011. /**
  8012. * Sets the highlights Density value.
  8013. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. highlightsDensity: number;
  8017. /**
  8018. * Gets the highlights Saturation value.
  8019. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8020. */
  8021. /**
  8022. * Sets the highlights Saturation value.
  8023. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8024. */
  8025. highlightsSaturation: number;
  8026. /**
  8027. * Gets the highlights Exposure value.
  8028. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8029. */
  8030. /**
  8031. * Sets the highlights Exposure value.
  8032. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8033. */
  8034. highlightsExposure: number;
  8035. private _midtonesHue;
  8036. private _midtonesDensity;
  8037. private _midtonesSaturation;
  8038. private _midtonesExposure;
  8039. /**
  8040. * Gets the midtones Hue value.
  8041. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8042. */
  8043. /**
  8044. * Sets the midtones Hue value.
  8045. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8046. */
  8047. midtonesHue: number;
  8048. /**
  8049. * Gets the midtones Density value.
  8050. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8051. * Values less than zero provide a filter of opposite hue.
  8052. */
  8053. /**
  8054. * Sets the midtones Density value.
  8055. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. midtonesDensity: number;
  8059. /**
  8060. * Gets the midtones Saturation value.
  8061. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8062. */
  8063. /**
  8064. * Sets the midtones Saturation value.
  8065. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8066. */
  8067. midtonesSaturation: number;
  8068. /**
  8069. * Gets the midtones Exposure value.
  8070. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8071. */
  8072. /**
  8073. * Sets the midtones Exposure value.
  8074. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8075. */
  8076. midtonesExposure: number;
  8077. private _shadowsHue;
  8078. private _shadowsDensity;
  8079. private _shadowsSaturation;
  8080. private _shadowsExposure;
  8081. /**
  8082. * Gets the shadows Hue value.
  8083. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8084. */
  8085. /**
  8086. * Sets the shadows Hue value.
  8087. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8088. */
  8089. shadowsHue: number;
  8090. /**
  8091. * Gets the shadows Density value.
  8092. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8093. * Values less than zero provide a filter of opposite hue.
  8094. */
  8095. /**
  8096. * Sets the shadows Density value.
  8097. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. shadowsDensity: number;
  8101. /**
  8102. * Gets the shadows Saturation value.
  8103. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8104. */
  8105. /**
  8106. * Sets the shadows Saturation value.
  8107. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8108. */
  8109. shadowsSaturation: number;
  8110. /**
  8111. * Gets the shadows Exposure value.
  8112. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8113. */
  8114. /**
  8115. * Sets the shadows Exposure value.
  8116. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8117. */
  8118. shadowsExposure: number;
  8119. /**
  8120. * Returns the class name
  8121. * @returns The class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Binds the color curves to the shader.
  8126. * @param colorCurves The color curve to bind
  8127. * @param effect The effect to bind to
  8128. * @param positiveUniform The positive uniform shader parameter
  8129. * @param neutralUniform The neutral uniform shader parameter
  8130. * @param negativeUniform The negative uniform shader parameter
  8131. */
  8132. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8133. /**
  8134. * Prepare the list of uniforms associated with the ColorCurves effects.
  8135. * @param uniformsList The list of uniforms used in the effect
  8136. */
  8137. static PrepareUniforms(uniformsList: string[]): void;
  8138. /**
  8139. * Returns color grading data based on a hue, density, saturation and exposure value.
  8140. * @param filterHue The hue of the color filter.
  8141. * @param filterDensity The density of the color filter.
  8142. * @param saturation The saturation.
  8143. * @param exposure The exposure.
  8144. * @param result The result data container.
  8145. */
  8146. private getColorGradingDataToRef;
  8147. /**
  8148. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8149. * @param value The input slider value in range [-100,100].
  8150. * @returns Adjusted value.
  8151. */
  8152. private static applyColorGradingSliderNonlinear;
  8153. /**
  8154. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8155. * @param hue The hue (H) input.
  8156. * @param saturation The saturation (S) input.
  8157. * @param brightness The brightness (B) input.
  8158. * @result An RGBA color represented as Vector4.
  8159. */
  8160. private static fromHSBToRef;
  8161. /**
  8162. * Returns a value clamped between min and max
  8163. * @param value The value to clamp
  8164. * @param min The minimum of value
  8165. * @param max The maximum of value
  8166. * @returns The clamped value.
  8167. */
  8168. private static clamp;
  8169. /**
  8170. * Clones the current color curve instance.
  8171. * @return The cloned curves
  8172. */
  8173. clone(): ColorCurves;
  8174. /**
  8175. * Serializes the current color curve instance to a json representation.
  8176. * @return a JSON representation
  8177. */
  8178. serialize(): any;
  8179. /**
  8180. * Parses the color curve from a json representation.
  8181. * @param source the JSON source to parse
  8182. * @return The parsed curves
  8183. */
  8184. static Parse(source: any): ColorCurves;
  8185. }
  8186. }
  8187. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8188. import { Observable } from "babylonjs/Misc/observable";
  8189. import { Nullable } from "babylonjs/types";
  8190. import { Color4 } from "babylonjs/Maths/math.color";
  8191. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8192. import { Effect } from "babylonjs/Materials/effect";
  8193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8194. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8195. /**
  8196. * Interface to follow in your material defines to integrate easily the
  8197. * Image proccessing functions.
  8198. * @hidden
  8199. */
  8200. export interface IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. EXPOSURE: boolean;
  8209. COLORCURVES: boolean;
  8210. COLORGRADING: boolean;
  8211. COLORGRADING3D: boolean;
  8212. SAMPLER3DGREENDEPTH: boolean;
  8213. SAMPLER3DBGRMAP: boolean;
  8214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8215. }
  8216. /**
  8217. * @hidden
  8218. */
  8219. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8220. IMAGEPROCESSING: boolean;
  8221. VIGNETTE: boolean;
  8222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8223. VIGNETTEBLENDMODEOPAQUE: boolean;
  8224. TONEMAPPING: boolean;
  8225. TONEMAPPING_ACES: boolean;
  8226. CONTRAST: boolean;
  8227. COLORCURVES: boolean;
  8228. COLORGRADING: boolean;
  8229. COLORGRADING3D: boolean;
  8230. SAMPLER3DGREENDEPTH: boolean;
  8231. SAMPLER3DBGRMAP: boolean;
  8232. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8233. EXPOSURE: boolean;
  8234. constructor();
  8235. }
  8236. /**
  8237. * This groups together the common properties used for image processing either in direct forward pass
  8238. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8239. * or not.
  8240. */
  8241. export class ImageProcessingConfiguration {
  8242. /**
  8243. * Default tone mapping applied in BabylonJS.
  8244. */
  8245. static readonly TONEMAPPING_STANDARD: number;
  8246. /**
  8247. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8248. * to other engines rendering to increase portability.
  8249. */
  8250. static readonly TONEMAPPING_ACES: number;
  8251. /**
  8252. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8253. */
  8254. colorCurves: Nullable<ColorCurves>;
  8255. private _colorCurvesEnabled;
  8256. /**
  8257. * Gets wether the color curves effect is enabled.
  8258. */
  8259. /**
  8260. * Sets wether the color curves effect is enabled.
  8261. */
  8262. colorCurvesEnabled: boolean;
  8263. private _colorGradingTexture;
  8264. /**
  8265. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8266. */
  8267. /**
  8268. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8269. */
  8270. colorGradingTexture: Nullable<BaseTexture>;
  8271. private _colorGradingEnabled;
  8272. /**
  8273. * Gets wether the color grading effect is enabled.
  8274. */
  8275. /**
  8276. * Sets wether the color grading effect is enabled.
  8277. */
  8278. colorGradingEnabled: boolean;
  8279. private _colorGradingWithGreenDepth;
  8280. /**
  8281. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8282. */
  8283. /**
  8284. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8285. */
  8286. colorGradingWithGreenDepth: boolean;
  8287. private _colorGradingBGR;
  8288. /**
  8289. * Gets wether the color grading texture contains BGR values.
  8290. */
  8291. /**
  8292. * Sets wether the color grading texture contains BGR values.
  8293. */
  8294. colorGradingBGR: boolean;
  8295. /** @hidden */
  8296. _exposure: number;
  8297. /**
  8298. * Gets the Exposure used in the effect.
  8299. */
  8300. /**
  8301. * Sets the Exposure used in the effect.
  8302. */
  8303. exposure: number;
  8304. private _toneMappingEnabled;
  8305. /**
  8306. * Gets wether the tone mapping effect is enabled.
  8307. */
  8308. /**
  8309. * Sets wether the tone mapping effect is enabled.
  8310. */
  8311. toneMappingEnabled: boolean;
  8312. private _toneMappingType;
  8313. /**
  8314. * Gets the type of tone mapping effect.
  8315. */
  8316. /**
  8317. * Sets the type of tone mapping effect used in BabylonJS.
  8318. */
  8319. toneMappingType: number;
  8320. protected _contrast: number;
  8321. /**
  8322. * Gets the contrast used in the effect.
  8323. */
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. contrast: number;
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. /**
  8358. * Sets the vignette blend mode allowing different kind of effect.
  8359. */
  8360. vignetteBlendMode: number;
  8361. private _vignetteEnabled;
  8362. /**
  8363. * Gets wether the vignette effect is enabled.
  8364. */
  8365. /**
  8366. * Sets wether the vignette effect is enabled.
  8367. */
  8368. vignetteEnabled: boolean;
  8369. private _applyByPostProcess;
  8370. /**
  8371. * Gets wether the image processing is applied through a post process or not.
  8372. */
  8373. /**
  8374. * Sets wether the image processing is applied through a post process or not.
  8375. */
  8376. applyByPostProcess: boolean;
  8377. private _isEnabled;
  8378. /**
  8379. * Gets wether the image processing is enabled or not.
  8380. */
  8381. /**
  8382. * Sets wether the image processing is enabled or not.
  8383. */
  8384. isEnabled: boolean;
  8385. /**
  8386. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8387. */
  8388. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8389. /**
  8390. * Method called each time the image processing information changes requires to recompile the effect.
  8391. */
  8392. protected _updateParameters(): void;
  8393. /**
  8394. * Gets the current class name.
  8395. * @return "ImageProcessingConfiguration"
  8396. */
  8397. getClassName(): string;
  8398. /**
  8399. * Prepare the list of uniforms associated with the Image Processing effects.
  8400. * @param uniforms The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of samplers associated with the Image Processing effects.
  8406. * @param samplersList The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of defines associated to the shader.
  8412. * @param defines the list of defines to complete
  8413. * @param forPostProcess Define if we are currently in post process mode or not
  8414. */
  8415. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8416. /**
  8417. * Returns true if all the image processing information are ready.
  8418. * @returns True if ready, otherwise, false
  8419. */
  8420. isReady(): boolean;
  8421. /**
  8422. * Binds the image processing to the shader.
  8423. * @param effect The effect to bind to
  8424. * @param overrideAspectRatio Override the aspect ratio of the effect
  8425. */
  8426. bind(effect: Effect, overrideAspectRatio?: number): void;
  8427. /**
  8428. * Clones the current image processing instance.
  8429. * @return The cloned image processing
  8430. */
  8431. clone(): ImageProcessingConfiguration;
  8432. /**
  8433. * Serializes the current image processing instance to a json representation.
  8434. * @return a JSON representation
  8435. */
  8436. serialize(): any;
  8437. /**
  8438. * Parses the image processing from a json representation.
  8439. * @param source the JSON source to parse
  8440. * @return The parsed image processing
  8441. */
  8442. static Parse(source: any): ImageProcessingConfiguration;
  8443. private static _VIGNETTEMODE_MULTIPLY;
  8444. private static _VIGNETTEMODE_OPAQUE;
  8445. /**
  8446. * Used to apply the vignette as a mix with the pixel color.
  8447. */
  8448. static readonly VIGNETTEMODE_MULTIPLY: number;
  8449. /**
  8450. * Used to apply the vignette as a replacement of the pixel color.
  8451. */
  8452. static readonly VIGNETTEMODE_OPAQUE: number;
  8453. }
  8454. }
  8455. declare module "babylonjs/Shaders/postprocess.vertex" {
  8456. /** @hidden */
  8457. export var postprocessVertexShader: {
  8458. name: string;
  8459. shader: string;
  8460. };
  8461. }
  8462. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8464. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8465. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8466. module "babylonjs/Engines/thinEngine" {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8478. /**
  8479. * Creates a depth stencil texture.
  8480. * This is only available in WebGL 2 or with the depth texture extension available.
  8481. * @param size The size of face edge in the texture.
  8482. * @param options The options defining the texture.
  8483. * @returns The texture
  8484. */
  8485. createDepthStencilTexture(size: number | {
  8486. width: number;
  8487. height: number;
  8488. }, options: DepthTextureCreationOptions): InternalTexture;
  8489. /** @hidden */
  8490. _createDepthStencilTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. }, options: DepthTextureCreationOptions): InternalTexture;
  8494. }
  8495. }
  8496. }
  8497. declare module "babylonjs/Maths/math.axis" {
  8498. import { Vector3 } from "babylonjs/Maths/math.vector";
  8499. /** Defines supported spaces */
  8500. export enum Space {
  8501. /** Local (object) space */
  8502. LOCAL = 0,
  8503. /** World space */
  8504. WORLD = 1,
  8505. /** Bone space */
  8506. BONE = 2
  8507. }
  8508. /** Defines the 3 main axes */
  8509. export class Axis {
  8510. /** X axis */
  8511. static X: Vector3;
  8512. /** Y axis */
  8513. static Y: Vector3;
  8514. /** Z axis */
  8515. static Z: Vector3;
  8516. }
  8517. }
  8518. declare module "babylonjs/Cameras/targetCamera" {
  8519. import { Nullable } from "babylonjs/types";
  8520. import { Camera } from "babylonjs/Cameras/camera";
  8521. import { Scene } from "babylonjs/scene";
  8522. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8523. /**
  8524. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8525. * This is the base of the follow, arc rotate cameras and Free camera
  8526. * @see http://doc.babylonjs.com/features/cameras
  8527. */
  8528. export class TargetCamera extends Camera {
  8529. private static _RigCamTransformMatrix;
  8530. private static _TargetTransformMatrix;
  8531. private static _TargetFocalPoint;
  8532. /**
  8533. * Define the current direction the camera is moving to
  8534. */
  8535. cameraDirection: Vector3;
  8536. /**
  8537. * Define the current rotation the camera is rotating to
  8538. */
  8539. cameraRotation: Vector2;
  8540. /**
  8541. * When set, the up vector of the camera will be updated by the rotation of the camera
  8542. */
  8543. updateUpVectorFromRotation: boolean;
  8544. private _tmpQuaternion;
  8545. /**
  8546. * Define the current rotation of the camera
  8547. */
  8548. rotation: Vector3;
  8549. /**
  8550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8551. */
  8552. rotationQuaternion: Quaternion;
  8553. /**
  8554. * Define the current speed of the camera
  8555. */
  8556. speed: number;
  8557. /**
  8558. * Add constraint to the camera to prevent it to move freely in all directions and
  8559. * around all axis.
  8560. */
  8561. noRotationConstraint: boolean;
  8562. /**
  8563. * Define the current target of the camera as an object or a position.
  8564. */
  8565. lockedTarget: any;
  8566. /** @hidden */
  8567. _currentTarget: Vector3;
  8568. /** @hidden */
  8569. _initialFocalDistance: number;
  8570. /** @hidden */
  8571. _viewMatrix: Matrix;
  8572. /** @hidden */
  8573. _camMatrix: Matrix;
  8574. /** @hidden */
  8575. _cameraTransformMatrix: Matrix;
  8576. /** @hidden */
  8577. _cameraRotationMatrix: Matrix;
  8578. /** @hidden */
  8579. _referencePoint: Vector3;
  8580. /** @hidden */
  8581. _transformedReferencePoint: Vector3;
  8582. protected _globalCurrentTarget: Vector3;
  8583. protected _globalCurrentUpVector: Vector3;
  8584. /** @hidden */
  8585. _reset: () => void;
  8586. private _defaultUp;
  8587. /**
  8588. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8589. * This is the base of the follow, arc rotate cameras and Free camera
  8590. * @see http://doc.babylonjs.com/features/cameras
  8591. * @param name Defines the name of the camera in the scene
  8592. * @param position Defines the start position of the camera in the scene
  8593. * @param scene Defines the scene the camera belongs to
  8594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8595. */
  8596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8597. /**
  8598. * Gets the position in front of the camera at a given distance.
  8599. * @param distance The distance from the camera we want the position to be
  8600. * @returns the position
  8601. */
  8602. getFrontPosition(distance: number): Vector3;
  8603. /** @hidden */
  8604. _getLockedTargetPosition(): Nullable<Vector3>;
  8605. private _storedPosition;
  8606. private _storedRotation;
  8607. private _storedRotationQuaternion;
  8608. /**
  8609. * Store current camera state of the camera (fov, position, rotation, etc..)
  8610. * @returns the camera
  8611. */
  8612. storeState(): Camera;
  8613. /**
  8614. * Restored camera state. You must call storeState() first
  8615. * @returns whether it was successful or not
  8616. * @hidden
  8617. */
  8618. _restoreStateValues(): boolean;
  8619. /** @hidden */
  8620. _initCache(): void;
  8621. /** @hidden */
  8622. _updateCache(ignoreParentClass?: boolean): void;
  8623. /** @hidden */
  8624. _isSynchronizedViewMatrix(): boolean;
  8625. /** @hidden */
  8626. _computeLocalCameraSpeed(): number;
  8627. /**
  8628. * Defines the target the camera should look at.
  8629. * @param target Defines the new target as a Vector or a mesh
  8630. */
  8631. setTarget(target: Vector3): void;
  8632. /**
  8633. * Return the current target position of the camera. This value is expressed in local space.
  8634. * @returns the target position
  8635. */
  8636. getTarget(): Vector3;
  8637. /** @hidden */
  8638. _decideIfNeedsToMove(): boolean;
  8639. /** @hidden */
  8640. _updatePosition(): void;
  8641. /** @hidden */
  8642. _checkInputs(): void;
  8643. protected _updateCameraRotationMatrix(): void;
  8644. /**
  8645. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8646. * @returns the current camera
  8647. */
  8648. private _rotateUpVectorWithCameraRotationMatrix;
  8649. private _cachedRotationZ;
  8650. private _cachedQuaternionRotationZ;
  8651. /** @hidden */
  8652. _getViewMatrix(): Matrix;
  8653. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8654. /**
  8655. * @hidden
  8656. */
  8657. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8658. /**
  8659. * @hidden
  8660. */
  8661. _updateRigCameras(): void;
  8662. private _getRigCamPositionAndTarget;
  8663. /**
  8664. * Gets the current object class name.
  8665. * @return the class name
  8666. */
  8667. getClassName(): string;
  8668. }
  8669. }
  8670. declare module "babylonjs/Events/keyboardEvents" {
  8671. /**
  8672. * Gather the list of keyboard event types as constants.
  8673. */
  8674. export class KeyboardEventTypes {
  8675. /**
  8676. * The keydown event is fired when a key becomes active (pressed).
  8677. */
  8678. static readonly KEYDOWN: number;
  8679. /**
  8680. * The keyup event is fired when a key has been released.
  8681. */
  8682. static readonly KEYUP: number;
  8683. }
  8684. /**
  8685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8686. */
  8687. export class KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Instantiates a new keyboard info.
  8698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. /**
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8715. */
  8716. export class KeyboardInfoPre extends KeyboardInfo {
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number;
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent;
  8725. /**
  8726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8727. */
  8728. skipOnPointerObservable: boolean;
  8729. /**
  8730. * Instantiates a new keyboard pre info.
  8731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8732. * @param type Defines the type of event (KeyboardEventTypes)
  8733. * @param event Defines the related dom event
  8734. */
  8735. constructor(
  8736. /**
  8737. * Defines the type of event (KeyboardEventTypes)
  8738. */
  8739. type: number,
  8740. /**
  8741. * Defines the related dom event
  8742. */
  8743. event: KeyboardEvent);
  8744. }
  8745. }
  8746. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8747. import { Nullable } from "babylonjs/types";
  8748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8750. /**
  8751. * Manage the keyboard inputs to control the movement of a free camera.
  8752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8753. */
  8754. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8755. /**
  8756. * Defines the camera the input is attached to.
  8757. */
  8758. camera: FreeCamera;
  8759. /**
  8760. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8761. */
  8762. keysUp: number[];
  8763. /**
  8764. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8765. */
  8766. keysDown: number[];
  8767. /**
  8768. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8769. */
  8770. keysLeft: number[];
  8771. /**
  8772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8773. */
  8774. keysRight: number[];
  8775. private _keys;
  8776. private _onCanvasBlurObserver;
  8777. private _onKeyboardObserver;
  8778. private _engine;
  8779. private _scene;
  8780. /**
  8781. * Attach the input controls to a specific dom element to get the input from.
  8782. * @param element Defines the element the controls should be listened from
  8783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8784. */
  8785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8786. /**
  8787. * Detach the current controls from the specified dom element.
  8788. * @param element Defines the element to stop listening the inputs from
  8789. */
  8790. detachControl(element: Nullable<HTMLElement>): void;
  8791. /**
  8792. * Update the current camera state depending on the inputs that have been used this frame.
  8793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8794. */
  8795. checkInputs(): void;
  8796. /**
  8797. * Gets the class name of the current intput.
  8798. * @returns the class name
  8799. */
  8800. getClassName(): string;
  8801. /** @hidden */
  8802. _onLostFocus(): void;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. }
  8809. }
  8810. declare module "babylonjs/Lights/shadowLight" {
  8811. import { Camera } from "babylonjs/Cameras/camera";
  8812. import { Scene } from "babylonjs/scene";
  8813. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8815. import { Light } from "babylonjs/Lights/light";
  8816. /**
  8817. * Interface describing all the common properties and methods a shadow light needs to implement.
  8818. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8819. * as well as binding the different shadow properties to the effects.
  8820. */
  8821. export interface IShadowLight extends Light {
  8822. /**
  8823. * The light id in the scene (used in scene.findLighById for instance)
  8824. */
  8825. id: string;
  8826. /**
  8827. * The position the shdow will be casted from.
  8828. */
  8829. position: Vector3;
  8830. /**
  8831. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8832. */
  8833. direction: Vector3;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. /**
  8843. * The friendly name of the light in the scene.
  8844. */
  8845. name: string;
  8846. /**
  8847. * Defines the shadow projection clipping minimum z value.
  8848. */
  8849. shadowMinZ: number;
  8850. /**
  8851. * Defines the shadow projection clipping maximum z value.
  8852. */
  8853. shadowMaxZ: number;
  8854. /**
  8855. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8856. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8857. */
  8858. computeTransformedInformation(): boolean;
  8859. /**
  8860. * Gets the scene the light belongs to.
  8861. * @returns The scene
  8862. */
  8863. getScene(): Scene;
  8864. /**
  8865. * Callback defining a custom Projection Matrix Builder.
  8866. * This can be used to override the default projection matrix computation.
  8867. */
  8868. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8869. /**
  8870. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8871. * @param matrix The materix to updated with the projection information
  8872. * @param viewMatrix The transform matrix of the light
  8873. * @param renderList The list of mesh to render in the map
  8874. * @returns The current light
  8875. */
  8876. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8877. /**
  8878. * Gets the current depth scale used in ESM.
  8879. * @returns The scale
  8880. */
  8881. getDepthScale(): number;
  8882. /**
  8883. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8884. * @returns true if a cube texture needs to be use
  8885. */
  8886. needCube(): boolean;
  8887. /**
  8888. * Detects if the projection matrix requires to be recomputed this frame.
  8889. * @returns true if it requires to be recomputed otherwise, false.
  8890. */
  8891. needProjectionMatrixCompute(): boolean;
  8892. /**
  8893. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8894. */
  8895. forceProjectionMatrixCompute(): void;
  8896. /**
  8897. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8900. */
  8901. getShadowDirection(faceIndex?: number): Vector3;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. }
  8915. /**
  8916. * Base implementation IShadowLight
  8917. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8918. */
  8919. export abstract class ShadowLight extends Light implements IShadowLight {
  8920. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8921. protected _position: Vector3;
  8922. protected _setPosition(value: Vector3): void;
  8923. /**
  8924. * Sets the position the shadow will be casted from. Also use as the light position for both
  8925. * point and spot lights.
  8926. */
  8927. /**
  8928. * Sets the position the shadow will be casted from. Also use as the light position for both
  8929. * point and spot lights.
  8930. */
  8931. position: Vector3;
  8932. protected _direction: Vector3;
  8933. protected _setDirection(value: Vector3): void;
  8934. /**
  8935. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8936. * Also use as the light direction on spot and directional lights.
  8937. */
  8938. /**
  8939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8940. * Also use as the light direction on spot and directional lights.
  8941. */
  8942. direction: Vector3;
  8943. private _shadowMinZ;
  8944. /**
  8945. * Gets the shadow projection clipping minimum z value.
  8946. */
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. shadowMinZ: number;
  8951. private _shadowMaxZ;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module "babylonjs/Materials/effectFallbacks" {
  9052. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9053. import { Effect } from "babylonjs/Materials/effect";
  9054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9055. /**
  9056. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9057. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9058. */
  9059. export class EffectFallbacks implements IEffectFallbacks {
  9060. private _defines;
  9061. private _currentRank;
  9062. private _maxRank;
  9063. private _mesh;
  9064. /**
  9065. * Removes the fallback from the bound mesh.
  9066. */
  9067. unBindMesh(): void;
  9068. /**
  9069. * Adds a fallback on the specified property.
  9070. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9071. * @param define The name of the define in the shader
  9072. */
  9073. addFallback(rank: number, define: string): void;
  9074. /**
  9075. * Sets the mesh to use CPU skinning when needing to fallback.
  9076. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9077. * @param mesh The mesh to use the fallbacks.
  9078. */
  9079. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9080. /**
  9081. * Checks to see if more fallbacks are still availible.
  9082. */
  9083. readonly hasMoreFallbacks: boolean;
  9084. /**
  9085. * Removes the defines that should be removed when falling back.
  9086. * @param currentDefines defines the current define statements for the shader.
  9087. * @param effect defines the current effect we try to compile
  9088. * @returns The resulting defines with defines of the current rank removed.
  9089. */
  9090. reduce(currentDefines: string, effect: Effect): string;
  9091. }
  9092. }
  9093. declare module "babylonjs/Materials/materialHelper" {
  9094. import { Nullable } from "babylonjs/types";
  9095. import { Scene } from "babylonjs/scene";
  9096. import { Engine } from "babylonjs/Engines/engine";
  9097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9098. import { Light } from "babylonjs/Lights/light";
  9099. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9100. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9103. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9104. /**
  9105. * "Static Class" containing the most commonly used helper while dealing with material for
  9106. * rendering purpose.
  9107. *
  9108. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9109. *
  9110. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9111. */
  9112. export class MaterialHelper {
  9113. /**
  9114. * Bind the current view position to an effect.
  9115. * @param effect The effect to be bound
  9116. * @param scene The scene the eyes position is used from
  9117. */
  9118. static BindEyePosition(effect: Effect, scene: Scene): void;
  9119. /**
  9120. * Helps preparing the defines values about the UVs in used in the effect.
  9121. * UVs are shared as much as we can accross channels in the shaders.
  9122. * @param texture The texture we are preparing the UVs for
  9123. * @param defines The defines to update
  9124. * @param key The channel key "diffuse", "specular"... used in the shader
  9125. */
  9126. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9127. /**
  9128. * Binds a texture matrix value to its corrsponding uniform
  9129. * @param texture The texture to bind the matrix for
  9130. * @param uniformBuffer The uniform buffer receivin the data
  9131. * @param key The channel key "diffuse", "specular"... used in the shader
  9132. */
  9133. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9134. /**
  9135. * Gets the current status of the fog (should it be enabled?)
  9136. * @param mesh defines the mesh to evaluate for fog support
  9137. * @param scene defines the hosting scene
  9138. * @returns true if fog must be enabled
  9139. */
  9140. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9141. /**
  9142. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9143. * @param mesh defines the current mesh
  9144. * @param scene defines the current scene
  9145. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9146. * @param pointsCloud defines if point cloud rendering has to be turned on
  9147. * @param fogEnabled defines if fog has to be turned on
  9148. * @param alphaTest defines if alpha testing has to be turned on
  9149. * @param defines defines the current list of defines
  9150. */
  9151. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9152. /**
  9153. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9154. * @param scene defines the current scene
  9155. * @param engine defines the current engine
  9156. * @param defines specifies the list of active defines
  9157. * @param useInstances defines if instances have to be turned on
  9158. * @param useClipPlane defines if clip plane have to be turned on
  9159. */
  9160. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9161. /**
  9162. * Prepares the defines for bones
  9163. * @param mesh The mesh containing the geometry data we will draw
  9164. * @param defines The defines to update
  9165. */
  9166. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9167. /**
  9168. * Prepares the defines for morph targets
  9169. * @param mesh The mesh containing the geometry data we will draw
  9170. * @param defines The defines to update
  9171. */
  9172. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9173. /**
  9174. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9175. * @param mesh The mesh containing the geometry data we will draw
  9176. * @param defines The defines to update
  9177. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9178. * @param useBones Precise whether bones should be used or not (override mesh info)
  9179. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9180. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9181. * @returns false if defines are considered not dirty and have not been checked
  9182. */
  9183. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9184. /**
  9185. * Prepares the defines related to multiview
  9186. * @param scene The scene we are intending to draw
  9187. * @param defines The defines to update
  9188. */
  9189. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9190. /**
  9191. * Prepares the defines related to the light information passed in parameter
  9192. * @param scene The scene we are intending to draw
  9193. * @param mesh The mesh the effect is compiling for
  9194. * @param light The light the effect is compiling for
  9195. * @param lightIndex The index of the light
  9196. * @param defines The defines to update
  9197. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9198. * @param state Defines the current state regarding what is needed (normals, etc...)
  9199. */
  9200. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9201. needNormals: boolean;
  9202. needRebuild: boolean;
  9203. shadowEnabled: boolean;
  9204. specularEnabled: boolean;
  9205. lightmapMode: boolean;
  9206. }): void;
  9207. /**
  9208. * Prepares the defines related to the light information passed in parameter
  9209. * @param scene The scene we are intending to draw
  9210. * @param mesh The mesh the effect is compiling for
  9211. * @param defines The defines to update
  9212. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9213. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9214. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9215. * @returns true if normals will be required for the rest of the effect
  9216. */
  9217. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9218. /**
  9219. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9220. * @param lightIndex defines the light index
  9221. * @param uniformsList The uniform list
  9222. * @param samplersList The sampler list
  9223. * @param projectedLightTexture defines if projected texture must be used
  9224. * @param uniformBuffersList defines an optional list of uniform buffers
  9225. */
  9226. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9227. /**
  9228. * Prepares the uniforms and samplers list to be used in the effect
  9229. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9230. * @param samplersList The sampler list
  9231. * @param defines The defines helping in the list generation
  9232. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9233. */
  9234. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9235. /**
  9236. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9237. * @param defines The defines to update while falling back
  9238. * @param fallbacks The authorized effect fallbacks
  9239. * @param maxSimultaneousLights The maximum number of lights allowed
  9240. * @param rank the current rank of the Effect
  9241. * @returns The newly affected rank
  9242. */
  9243. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9244. private static _TmpMorphInfluencers;
  9245. /**
  9246. * Prepares the list of attributes required for morph targets according to the effect defines.
  9247. * @param attribs The current list of supported attribs
  9248. * @param mesh The mesh to prepare the morph targets attributes for
  9249. * @param influencers The number of influencers
  9250. */
  9251. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9252. /**
  9253. * Prepares the list of attributes required for morph targets according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param mesh The mesh to prepare the morph targets attributes for
  9256. * @param defines The current Defines of the effect
  9257. */
  9258. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9259. /**
  9260. * Prepares the list of attributes required for bones according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param mesh The mesh to prepare the bones attributes for
  9263. * @param defines The current Defines of the effect
  9264. * @param fallbacks The current efffect fallback strategy
  9265. */
  9266. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9267. /**
  9268. * Check and prepare the list of attributes required for instances according to the effect defines.
  9269. * @param attribs The current list of supported attribs
  9270. * @param defines The current MaterialDefines of the effect
  9271. */
  9272. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9273. /**
  9274. * Add the list of attributes required for instances to the attribs array.
  9275. * @param attribs The current list of supported attribs
  9276. */
  9277. static PushAttributesForInstances(attribs: string[]): void;
  9278. /**
  9279. * Binds the light information to the effect.
  9280. * @param light The light containing the generator
  9281. * @param effect The effect we are binding the data to
  9282. * @param lightIndex The light index in the effect used to render
  9283. */
  9284. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9285. /**
  9286. * Binds the lights information from the scene to the effect for the given mesh.
  9287. * @param light Light to bind
  9288. * @param lightIndex Light index
  9289. * @param scene The scene where the light belongs to
  9290. * @param effect The effect we are binding the data to
  9291. * @param useSpecular Defines if specular is supported
  9292. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9293. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9294. */
  9295. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9296. /**
  9297. * Binds the lights information from the scene to the effect for the given mesh.
  9298. * @param scene The scene the lights belongs to
  9299. * @param mesh The mesh we are binding the information to render
  9300. * @param effect The effect we are binding the data to
  9301. * @param defines The generated defines for the effect
  9302. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9303. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9304. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9305. */
  9306. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9307. private static _tempFogColor;
  9308. /**
  9309. * Binds the fog information from the scene to the effect for the given mesh.
  9310. * @param scene The scene the lights belongs to
  9311. * @param mesh The mesh we are binding the information to render
  9312. * @param effect The effect we are binding the data to
  9313. * @param linearSpace Defines if the fog effect is applied in linear space
  9314. */
  9315. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9316. /**
  9317. * Binds the bones information from the mesh to the effect.
  9318. * @param mesh The mesh we are binding the information to render
  9319. * @param effect The effect we are binding the data to
  9320. */
  9321. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9322. /**
  9323. * Binds the morph targets information from the mesh to the effect.
  9324. * @param abstractMesh The mesh we are binding the information to render
  9325. * @param effect The effect we are binding the data to
  9326. */
  9327. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9328. /**
  9329. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9330. * @param defines The generated defines used in the effect
  9331. * @param effect The effect we are binding the data to
  9332. * @param scene The scene we are willing to render with logarithmic scale for
  9333. */
  9334. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9335. /**
  9336. * Binds the clip plane information from the scene to the effect.
  9337. * @param scene The scene the clip plane information are extracted from
  9338. * @param effect The effect we are binding the data to
  9339. */
  9340. static BindClipPlane(effect: Effect, scene: Scene): void;
  9341. }
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9344. /** @hidden */
  9345. export var packingFunctions: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9351. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9352. /** @hidden */
  9353. export var shadowMapPixelShader: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9359. /** @hidden */
  9360. export var bonesDeclaration: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9366. /** @hidden */
  9367. export var morphTargetsVertexGlobalDeclaration: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9373. /** @hidden */
  9374. export var morphTargetsVertexDeclaration: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9380. /** @hidden */
  9381. export var instancesDeclaration: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9387. /** @hidden */
  9388. export var helperFunctions: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9394. /** @hidden */
  9395. export var morphTargetsVertex: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9401. /** @hidden */
  9402. export var instancesVertex: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9408. /** @hidden */
  9409. export var bonesVertex: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9415. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9418. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9421. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9422. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9423. /** @hidden */
  9424. export var shadowMapVertexShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9430. /** @hidden */
  9431. export var depthBoxBlurPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9437. import { Nullable } from "babylonjs/types";
  9438. import { Scene } from "babylonjs/scene";
  9439. import { Matrix } from "babylonjs/Maths/math.vector";
  9440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9442. import { Mesh } from "babylonjs/Meshes/mesh";
  9443. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9444. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9445. import { Effect } from "babylonjs/Materials/effect";
  9446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9447. import "babylonjs/Shaders/shadowMap.fragment";
  9448. import "babylonjs/Shaders/shadowMap.vertex";
  9449. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. /**
  9452. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9453. */
  9454. export interface ICustomShaderOptions {
  9455. /**
  9456. * Gets or sets the custom shader name to use
  9457. */
  9458. shaderName: string;
  9459. /**
  9460. * The list of attribute names used in the shader
  9461. */
  9462. attributes?: string[];
  9463. /**
  9464. * The list of unifrom names used in the shader
  9465. */
  9466. uniforms?: string[];
  9467. /**
  9468. * The list of sampler names used in the shader
  9469. */
  9470. samplers?: string[];
  9471. /**
  9472. * The list of defines used in the shader
  9473. */
  9474. defines?: string[];
  9475. }
  9476. /**
  9477. * Interface to implement to create a shadow generator compatible with BJS.
  9478. */
  9479. export interface IShadowGenerator {
  9480. /**
  9481. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9482. * @returns The render target texture if present otherwise, null
  9483. */
  9484. getShadowMap(): Nullable<RenderTargetTexture>;
  9485. /**
  9486. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9487. * @returns The render target texture if the shadow map is present otherwise, null
  9488. */
  9489. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9490. /**
  9491. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9492. * @param subMesh The submesh we want to render in the shadow map
  9493. * @param useInstances Defines wether will draw in the map using instances
  9494. * @returns true if ready otherwise, false
  9495. */
  9496. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9497. /**
  9498. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9499. * @param defines Defines of the material we want to update
  9500. * @param lightIndex Index of the light in the enabled light list of the material
  9501. */
  9502. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9503. /**
  9504. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9505. * defined in the generator but impacting the effect).
  9506. * It implies the unifroms available on the materials are the standard BJS ones.
  9507. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9508. * @param effect The effect we are binfing the information for
  9509. */
  9510. bindShadowLight(lightIndex: string, effect: Effect): void;
  9511. /**
  9512. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9513. * (eq to shadow prjection matrix * light transform matrix)
  9514. * @returns The transform matrix used to create the shadow map
  9515. */
  9516. getTransformMatrix(): Matrix;
  9517. /**
  9518. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9519. * Cube and 2D textures for instance.
  9520. */
  9521. recreateShadowMap(): void;
  9522. /**
  9523. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9524. * @param onCompiled Callback triggered at the and of the effects compilation
  9525. * @param options Sets of optional options forcing the compilation with different modes
  9526. */
  9527. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9528. useInstances: boolean;
  9529. }>): void;
  9530. /**
  9531. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9532. * @param options Sets of optional options forcing the compilation with different modes
  9533. * @returns A promise that resolves when the compilation completes
  9534. */
  9535. forceCompilationAsync(options?: Partial<{
  9536. useInstances: boolean;
  9537. }>): Promise<void>;
  9538. /**
  9539. * Serializes the shadow generator setup to a json object.
  9540. * @returns The serialized JSON object
  9541. */
  9542. serialize(): any;
  9543. /**
  9544. * Disposes the Shadow map and related Textures and effects.
  9545. */
  9546. dispose(): void;
  9547. }
  9548. /**
  9549. * Default implementation IShadowGenerator.
  9550. * This is the main object responsible of generating shadows in the framework.
  9551. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9552. */
  9553. export class ShadowGenerator implements IShadowGenerator {
  9554. /**
  9555. * Shadow generator mode None: no filtering applied.
  9556. */
  9557. static readonly FILTER_NONE: number;
  9558. /**
  9559. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9561. */
  9562. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9563. /**
  9564. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9565. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9566. */
  9567. static readonly FILTER_POISSONSAMPLING: number;
  9568. /**
  9569. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9570. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9571. */
  9572. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9573. /**
  9574. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9575. * edge artifacts on steep falloff.
  9576. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9577. */
  9578. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9579. /**
  9580. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9581. * edge artifacts on steep falloff.
  9582. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9583. */
  9584. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9585. /**
  9586. * Shadow generator mode PCF: Percentage Closer Filtering
  9587. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9588. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9589. */
  9590. static readonly FILTER_PCF: number;
  9591. /**
  9592. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9593. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9594. * Contact Hardening
  9595. */
  9596. static readonly FILTER_PCSS: number;
  9597. /**
  9598. * Reserved for PCF and PCSS
  9599. * Highest Quality.
  9600. *
  9601. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9602. *
  9603. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9604. */
  9605. static readonly QUALITY_HIGH: number;
  9606. /**
  9607. * Reserved for PCF and PCSS
  9608. * Good tradeoff for quality/perf cross devices
  9609. *
  9610. * Execute PCF on a 3*3 kernel.
  9611. *
  9612. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9613. */
  9614. static readonly QUALITY_MEDIUM: number;
  9615. /**
  9616. * Reserved for PCF and PCSS
  9617. * The lowest quality but the fastest.
  9618. *
  9619. * Execute PCF on a 1*1 kernel.
  9620. *
  9621. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9622. */
  9623. static readonly QUALITY_LOW: number;
  9624. /** Gets or sets the custom shader name to use */
  9625. customShaderOptions: ICustomShaderOptions;
  9626. /**
  9627. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9628. */
  9629. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9630. /**
  9631. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9632. */
  9633. onAfterShadowMapRenderObservable: Observable<Effect>;
  9634. /**
  9635. * Observable triggered before a mesh is rendered in the shadow map.
  9636. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9637. */
  9638. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9639. /**
  9640. * Observable triggered after a mesh is rendered in the shadow map.
  9641. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9642. */
  9643. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9644. private _bias;
  9645. /**
  9646. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9647. */
  9648. /**
  9649. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9650. */
  9651. bias: number;
  9652. private _normalBias;
  9653. /**
  9654. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9655. */
  9656. /**
  9657. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9658. */
  9659. normalBias: number;
  9660. private _blurBoxOffset;
  9661. /**
  9662. * Gets the blur box offset: offset applied during the blur pass.
  9663. * Only useful if useKernelBlur = false
  9664. */
  9665. /**
  9666. * Sets the blur box offset: offset applied during the blur pass.
  9667. * Only useful if useKernelBlur = false
  9668. */
  9669. blurBoxOffset: number;
  9670. private _blurScale;
  9671. /**
  9672. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9673. * 2 means half of the size.
  9674. */
  9675. /**
  9676. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9677. * 2 means half of the size.
  9678. */
  9679. blurScale: number;
  9680. private _blurKernel;
  9681. /**
  9682. * Gets the blur kernel: kernel size of the blur pass.
  9683. * Only useful if useKernelBlur = true
  9684. */
  9685. /**
  9686. * Sets the blur kernel: kernel size of the blur pass.
  9687. * Only useful if useKernelBlur = true
  9688. */
  9689. blurKernel: number;
  9690. private _useKernelBlur;
  9691. /**
  9692. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9693. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9694. */
  9695. /**
  9696. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9697. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9698. */
  9699. useKernelBlur: boolean;
  9700. private _depthScale;
  9701. /**
  9702. * Gets the depth scale used in ESM mode.
  9703. */
  9704. /**
  9705. * Sets the depth scale used in ESM mode.
  9706. * This can override the scale stored on the light.
  9707. */
  9708. depthScale: number;
  9709. private _filter;
  9710. /**
  9711. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9712. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9713. */
  9714. /**
  9715. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9716. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9717. */
  9718. filter: number;
  9719. /**
  9720. * Gets if the current filter is set to Poisson Sampling.
  9721. */
  9722. /**
  9723. * Sets the current filter to Poisson Sampling.
  9724. */
  9725. usePoissonSampling: boolean;
  9726. /**
  9727. * Gets if the current filter is set to ESM.
  9728. */
  9729. /**
  9730. * Sets the current filter is to ESM.
  9731. */
  9732. useExponentialShadowMap: boolean;
  9733. /**
  9734. * Gets if the current filter is set to filtered ESM.
  9735. */
  9736. /**
  9737. * Gets if the current filter is set to filtered ESM.
  9738. */
  9739. useBlurExponentialShadowMap: boolean;
  9740. /**
  9741. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9742. * exponential to prevent steep falloff artifacts).
  9743. */
  9744. /**
  9745. * Sets the current filter to "close ESM" (using the inverse of the
  9746. * exponential to prevent steep falloff artifacts).
  9747. */
  9748. useCloseExponentialShadowMap: boolean;
  9749. /**
  9750. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9751. * exponential to prevent steep falloff artifacts).
  9752. */
  9753. /**
  9754. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9755. * exponential to prevent steep falloff artifacts).
  9756. */
  9757. useBlurCloseExponentialShadowMap: boolean;
  9758. /**
  9759. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9760. */
  9761. /**
  9762. * Sets the current filter to "PCF" (percentage closer filtering).
  9763. */
  9764. usePercentageCloserFiltering: boolean;
  9765. private _filteringQuality;
  9766. /**
  9767. * Gets the PCF or PCSS Quality.
  9768. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9769. */
  9770. /**
  9771. * Sets the PCF or PCSS Quality.
  9772. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9773. */
  9774. filteringQuality: number;
  9775. /**
  9776. * Gets if the current filter is set to "PCSS" (contact hardening).
  9777. */
  9778. /**
  9779. * Sets the current filter to "PCSS" (contact hardening).
  9780. */
  9781. useContactHardeningShadow: boolean;
  9782. private _contactHardeningLightSizeUVRatio;
  9783. /**
  9784. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9785. * Using a ratio helps keeping shape stability independently of the map size.
  9786. *
  9787. * It does not account for the light projection as it was having too much
  9788. * instability during the light setup or during light position changes.
  9789. *
  9790. * Only valid if useContactHardeningShadow is true.
  9791. */
  9792. /**
  9793. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9794. * Using a ratio helps keeping shape stability independently of the map size.
  9795. *
  9796. * It does not account for the light projection as it was having too much
  9797. * instability during the light setup or during light position changes.
  9798. *
  9799. * Only valid if useContactHardeningShadow is true.
  9800. */
  9801. contactHardeningLightSizeUVRatio: number;
  9802. private _darkness;
  9803. /** Gets or sets the actual darkness of a shadow */
  9804. darkness: number;
  9805. /**
  9806. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9807. * 0 means strongest and 1 would means no shadow.
  9808. * @returns the darkness.
  9809. */
  9810. getDarkness(): number;
  9811. /**
  9812. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9813. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9814. * @returns the shadow generator allowing fluent coding.
  9815. */
  9816. setDarkness(darkness: number): ShadowGenerator;
  9817. private _transparencyShadow;
  9818. /** Gets or sets the ability to have transparent shadow */
  9819. transparencyShadow: boolean;
  9820. /**
  9821. * Sets the ability to have transparent shadow (boolean).
  9822. * @param transparent True if transparent else False
  9823. * @returns the shadow generator allowing fluent coding
  9824. */
  9825. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9826. private _shadowMap;
  9827. private _shadowMap2;
  9828. /**
  9829. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9830. * @returns The render target texture if present otherwise, null
  9831. */
  9832. getShadowMap(): Nullable<RenderTargetTexture>;
  9833. /**
  9834. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9835. * @returns The render target texture if the shadow map is present otherwise, null
  9836. */
  9837. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9838. /**
  9839. * Gets the class name of that object
  9840. * @returns "ShadowGenerator"
  9841. */
  9842. getClassName(): string;
  9843. /**
  9844. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9845. * @param mesh Mesh to add
  9846. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9847. * @returns the Shadow Generator itself
  9848. */
  9849. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9850. /**
  9851. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9852. * @param mesh Mesh to remove
  9853. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9854. * @returns the Shadow Generator itself
  9855. */
  9856. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9857. /**
  9858. * Controls the extent to which the shadows fade out at the edge of the frustum
  9859. * Used only by directionals and spots
  9860. */
  9861. frustumEdgeFalloff: number;
  9862. private _light;
  9863. /**
  9864. * Returns the associated light object.
  9865. * @returns the light generating the shadow
  9866. */
  9867. getLight(): IShadowLight;
  9868. /**
  9869. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9870. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9871. * It might on the other hand introduce peter panning.
  9872. */
  9873. forceBackFacesOnly: boolean;
  9874. private _scene;
  9875. private _lightDirection;
  9876. private _effect;
  9877. private _viewMatrix;
  9878. private _projectionMatrix;
  9879. private _transformMatrix;
  9880. private _cachedPosition;
  9881. private _cachedDirection;
  9882. private _cachedDefines;
  9883. private _currentRenderID;
  9884. private _boxBlurPostprocess;
  9885. private _kernelBlurXPostprocess;
  9886. private _kernelBlurYPostprocess;
  9887. private _blurPostProcesses;
  9888. private _mapSize;
  9889. private _currentFaceIndex;
  9890. private _currentFaceIndexCache;
  9891. private _textureType;
  9892. private _defaultTextureMatrix;
  9893. private _storedUniqueId;
  9894. /** @hidden */
  9895. static _SceneComponentInitialization: (scene: Scene) => void;
  9896. /**
  9897. * Creates a ShadowGenerator object.
  9898. * A ShadowGenerator is the required tool to use the shadows.
  9899. * Each light casting shadows needs to use its own ShadowGenerator.
  9900. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9901. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9902. * @param light The light object generating the shadows.
  9903. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9904. */
  9905. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9906. private _initializeGenerator;
  9907. private _initializeShadowMap;
  9908. private _initializeBlurRTTAndPostProcesses;
  9909. private _renderForShadowMap;
  9910. private _renderSubMeshForShadowMap;
  9911. private _applyFilterValues;
  9912. /**
  9913. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9914. * @param onCompiled Callback triggered at the and of the effects compilation
  9915. * @param options Sets of optional options forcing the compilation with different modes
  9916. */
  9917. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9918. useInstances: boolean;
  9919. }>): void;
  9920. /**
  9921. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9922. * @param options Sets of optional options forcing the compilation with different modes
  9923. * @returns A promise that resolves when the compilation completes
  9924. */
  9925. forceCompilationAsync(options?: Partial<{
  9926. useInstances: boolean;
  9927. }>): Promise<void>;
  9928. /**
  9929. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9930. * @param subMesh The submesh we want to render in the shadow map
  9931. * @param useInstances Defines wether will draw in the map using instances
  9932. * @returns true if ready otherwise, false
  9933. */
  9934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9935. /**
  9936. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9937. * @param defines Defines of the material we want to update
  9938. * @param lightIndex Index of the light in the enabled light list of the material
  9939. */
  9940. prepareDefines(defines: any, lightIndex: number): void;
  9941. /**
  9942. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9943. * defined in the generator but impacting the effect).
  9944. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9945. * @param effect The effect we are binfing the information for
  9946. */
  9947. bindShadowLight(lightIndex: string, effect: Effect): void;
  9948. /**
  9949. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9950. * (eq to shadow prjection matrix * light transform matrix)
  9951. * @returns The transform matrix used to create the shadow map
  9952. */
  9953. getTransformMatrix(): Matrix;
  9954. /**
  9955. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9956. * Cube and 2D textures for instance.
  9957. */
  9958. recreateShadowMap(): void;
  9959. private _disposeBlurPostProcesses;
  9960. private _disposeRTTandPostProcesses;
  9961. /**
  9962. * Disposes the ShadowGenerator.
  9963. * Returns nothing.
  9964. */
  9965. dispose(): void;
  9966. /**
  9967. * Serializes the shadow generator setup to a json object.
  9968. * @returns The serialized JSON object
  9969. */
  9970. serialize(): any;
  9971. /**
  9972. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9973. * @param parsedShadowGenerator The JSON object to parse
  9974. * @param scene The scene to create the shadow map for
  9975. * @returns The parsed shadow generator
  9976. */
  9977. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9978. }
  9979. }
  9980. declare module "babylonjs/Lights/light" {
  9981. import { Nullable } from "babylonjs/types";
  9982. import { Scene } from "babylonjs/scene";
  9983. import { Vector3 } from "babylonjs/Maths/math.vector";
  9984. import { Color3 } from "babylonjs/Maths/math.color";
  9985. import { Node } from "babylonjs/node";
  9986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9987. import { Effect } from "babylonjs/Materials/effect";
  9988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9989. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9990. /**
  9991. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9992. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9993. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9994. */
  9995. export abstract class Light extends Node {
  9996. /**
  9997. * Falloff Default: light is falling off following the material specification:
  9998. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9999. */
  10000. static readonly FALLOFF_DEFAULT: number;
  10001. /**
  10002. * Falloff Physical: light is falling off following the inverse squared distance law.
  10003. */
  10004. static readonly FALLOFF_PHYSICAL: number;
  10005. /**
  10006. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10007. * to enhance interoperability with other engines.
  10008. */
  10009. static readonly FALLOFF_GLTF: number;
  10010. /**
  10011. * Falloff Standard: light is falling off like in the standard material
  10012. * to enhance interoperability with other materials.
  10013. */
  10014. static readonly FALLOFF_STANDARD: number;
  10015. /**
  10016. * If every light affecting the material is in this lightmapMode,
  10017. * material.lightmapTexture adds or multiplies
  10018. * (depends on material.useLightmapAsShadowmap)
  10019. * after every other light calculations.
  10020. */
  10021. static readonly LIGHTMAP_DEFAULT: number;
  10022. /**
  10023. * material.lightmapTexture as only diffuse lighting from this light
  10024. * adds only specular lighting from this light
  10025. * adds dynamic shadows
  10026. */
  10027. static readonly LIGHTMAP_SPECULAR: number;
  10028. /**
  10029. * material.lightmapTexture as only lighting
  10030. * no light calculation from this light
  10031. * only adds dynamic shadows from this light
  10032. */
  10033. static readonly LIGHTMAP_SHADOWSONLY: number;
  10034. /**
  10035. * Each light type uses the default quantity according to its type:
  10036. * point/spot lights use luminous intensity
  10037. * directional lights use illuminance
  10038. */
  10039. static readonly INTENSITYMODE_AUTOMATIC: number;
  10040. /**
  10041. * lumen (lm)
  10042. */
  10043. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10044. /**
  10045. * candela (lm/sr)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10048. /**
  10049. * lux (lm/m^2)
  10050. */
  10051. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10052. /**
  10053. * nit (cd/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINANCE: number;
  10056. /**
  10057. * Light type const id of the point light.
  10058. */
  10059. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10060. /**
  10061. * Light type const id of the directional light.
  10062. */
  10063. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10064. /**
  10065. * Light type const id of the spot light.
  10066. */
  10067. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10068. /**
  10069. * Light type const id of the hemispheric light.
  10070. */
  10071. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10072. /**
  10073. * Diffuse gives the basic color to an object.
  10074. */
  10075. diffuse: Color3;
  10076. /**
  10077. * Specular produces a highlight color on an object.
  10078. * Note: This is note affecting PBR materials.
  10079. */
  10080. specular: Color3;
  10081. /**
  10082. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10083. * falling off base on range or angle.
  10084. * This can be set to any values in Light.FALLOFF_x.
  10085. *
  10086. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10087. * other types of materials.
  10088. */
  10089. falloffType: number;
  10090. /**
  10091. * Strength of the light.
  10092. * Note: By default it is define in the framework own unit.
  10093. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10094. */
  10095. intensity: number;
  10096. private _range;
  10097. protected _inverseSquaredRange: number;
  10098. /**
  10099. * Defines how far from the source the light is impacting in scene units.
  10100. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10101. */
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. range: number;
  10107. /**
  10108. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10109. * of light.
  10110. */
  10111. private _photometricScale;
  10112. private _intensityMode;
  10113. /**
  10114. * Gets the photometric scale used to interpret the intensity.
  10115. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10116. */
  10117. /**
  10118. * Sets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. intensityMode: number;
  10122. private _radius;
  10123. /**
  10124. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10125. */
  10126. /**
  10127. * sets the light radius used by PBR Materials to simulate soft area lights.
  10128. */
  10129. radius: number;
  10130. private _renderPriority;
  10131. /**
  10132. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10133. * exceeding the number allowed of the materials.
  10134. */
  10135. renderPriority: number;
  10136. private _shadowEnabled;
  10137. /**
  10138. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. /**
  10142. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. shadowEnabled: boolean;
  10146. private _includedOnlyMeshes;
  10147. /**
  10148. * Gets the only meshes impacted by this light.
  10149. */
  10150. /**
  10151. * Sets the only meshes impacted by this light.
  10152. */
  10153. includedOnlyMeshes: AbstractMesh[];
  10154. private _excludedMeshes;
  10155. /**
  10156. * Gets the meshes not impacted by this light.
  10157. */
  10158. /**
  10159. * Sets the meshes not impacted by this light.
  10160. */
  10161. excludedMeshes: AbstractMesh[];
  10162. private _excludeWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are not impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. excludeWithLayerMask: number;
  10172. private _includeOnlyWithLayerMask;
  10173. /**
  10174. * Gets the layer id use to find what meshes are impacted by the light.
  10175. * Inactive if 0
  10176. */
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. includeOnlyWithLayerMask: number;
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. /**
  10187. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10188. */
  10189. lightmapMode: number;
  10190. /**
  10191. * Shadow generator associted to the light.
  10192. * @hidden Internal use only.
  10193. */
  10194. _shadowGenerator: Nullable<IShadowGenerator>;
  10195. /**
  10196. * @hidden Internal use only.
  10197. */
  10198. _excludedMeshesIds: string[];
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _includedOnlyMeshesIds: string[];
  10203. /**
  10204. * The current light unifom buffer.
  10205. * @hidden Internal use only.
  10206. */
  10207. _uniformBuffer: UniformBuffer;
  10208. /** @hidden */
  10209. _renderId: number;
  10210. /**
  10211. * Creates a Light object in the scene.
  10212. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10213. * @param name The firendly name of the light
  10214. * @param scene The scene the light belongs too
  10215. */
  10216. constructor(name: string, scene: Scene);
  10217. protected abstract _buildUniformLayout(): void;
  10218. /**
  10219. * Sets the passed Effect "effect" with the Light information.
  10220. * @param effect The effect to update
  10221. * @param lightIndex The index of the light in the effect to update
  10222. * @returns The light
  10223. */
  10224. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10225. /**
  10226. * Sets the passed Effect "effect" with the Light information.
  10227. * @param effect The effect to update
  10228. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10229. * @returns The light
  10230. */
  10231. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10232. /**
  10233. * Returns the string "Light".
  10234. * @returns the class name
  10235. */
  10236. getClassName(): string;
  10237. /** @hidden */
  10238. readonly _isLight: boolean;
  10239. /**
  10240. * Converts the light information to a readable string for debug purpose.
  10241. * @param fullDetails Supports for multiple levels of logging within scene loading
  10242. * @returns the human readable light info
  10243. */
  10244. toString(fullDetails?: boolean): string;
  10245. /** @hidden */
  10246. protected _syncParentEnabledState(): void;
  10247. /**
  10248. * Set the enabled state of this node.
  10249. * @param value - the new enabled state
  10250. */
  10251. setEnabled(value: boolean): void;
  10252. /**
  10253. * Returns the Light associated shadow generator if any.
  10254. * @return the associated shadow generator.
  10255. */
  10256. getShadowGenerator(): Nullable<IShadowGenerator>;
  10257. /**
  10258. * Returns a Vector3, the absolute light position in the World.
  10259. * @returns the world space position of the light
  10260. */
  10261. getAbsolutePosition(): Vector3;
  10262. /**
  10263. * Specifies if the light will affect the passed mesh.
  10264. * @param mesh The mesh to test against the light
  10265. * @return true the mesh is affected otherwise, false.
  10266. */
  10267. canAffectMesh(mesh: AbstractMesh): boolean;
  10268. /**
  10269. * Sort function to order lights for rendering.
  10270. * @param a First Light object to compare to second.
  10271. * @param b Second Light object to compare first.
  10272. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10273. */
  10274. static CompareLightsPriority(a: Light, b: Light): number;
  10275. /**
  10276. * Releases resources associated with this node.
  10277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10279. */
  10280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10281. /**
  10282. * Returns the light type ID (integer).
  10283. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10284. */
  10285. getTypeID(): number;
  10286. /**
  10287. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10288. * @returns the scaled intensity in intensity mode unit
  10289. */
  10290. getScaledIntensity(): number;
  10291. /**
  10292. * Returns a new Light object, named "name", from the current one.
  10293. * @param name The name of the cloned light
  10294. * @returns the new created light
  10295. */
  10296. clone(name: string): Nullable<Light>;
  10297. /**
  10298. * Serializes the current light into a Serialization object.
  10299. * @returns the serialized object.
  10300. */
  10301. serialize(): any;
  10302. /**
  10303. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10304. * This new light is named "name" and added to the passed scene.
  10305. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10306. * @param name The friendly name of the light
  10307. * @param scene The scene the new light will belong to
  10308. * @returns the constructor function
  10309. */
  10310. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10311. /**
  10312. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10313. * @param parsedLight The JSON representation of the light
  10314. * @param scene The scene to create the parsed light in
  10315. * @returns the created light after parsing
  10316. */
  10317. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10318. private _hookArrayForExcluded;
  10319. private _hookArrayForIncludedOnly;
  10320. private _resyncMeshes;
  10321. /**
  10322. * Forces the meshes to update their light related information in their rendering used effects
  10323. * @hidden Internal Use Only
  10324. */
  10325. _markMeshesAsLightDirty(): void;
  10326. /**
  10327. * Recomputes the cached photometric scale if needed.
  10328. */
  10329. private _computePhotometricScale;
  10330. /**
  10331. * Returns the Photometric Scale according to the light type and intensity mode.
  10332. */
  10333. private _getPhotometricScale;
  10334. /**
  10335. * Reorder the light in the scene according to their defined priority.
  10336. * @hidden Internal Use Only
  10337. */
  10338. _reorderLightsInScene(): void;
  10339. /**
  10340. * Prepares the list of defines specific to the light type.
  10341. * @param defines the list of defines
  10342. * @param lightIndex defines the index of the light for the effect
  10343. */
  10344. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10345. }
  10346. }
  10347. declare module "babylonjs/Actions/action" {
  10348. import { Observable } from "babylonjs/Misc/observable";
  10349. import { Condition } from "babylonjs/Actions/condition";
  10350. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10351. import { ActionManager } from "babylonjs/Actions/actionManager";
  10352. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10353. /**
  10354. * Interface used to define Action
  10355. */
  10356. export interface IAction {
  10357. /**
  10358. * Trigger for the action
  10359. */
  10360. trigger: number;
  10361. /** Options of the trigger */
  10362. triggerOptions: any;
  10363. /**
  10364. * Gets the trigger parameters
  10365. * @returns the trigger parameters
  10366. */
  10367. getTriggerParameter(): any;
  10368. /**
  10369. * Internal only - executes current action event
  10370. * @hidden
  10371. */
  10372. _executeCurrent(evt?: ActionEvent): void;
  10373. /**
  10374. * Serialize placeholder for child classes
  10375. * @param parent of child
  10376. * @returns the serialized object
  10377. */
  10378. serialize(parent: any): any;
  10379. /**
  10380. * Internal only
  10381. * @hidden
  10382. */
  10383. _prepare(): void;
  10384. /**
  10385. * Internal only - manager for action
  10386. * @hidden
  10387. */
  10388. _actionManager: AbstractActionManager;
  10389. /**
  10390. * Adds action to chain of actions, may be a DoNothingAction
  10391. * @param action defines the next action to execute
  10392. * @returns The action passed in
  10393. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10394. */
  10395. then(action: IAction): IAction;
  10396. }
  10397. /**
  10398. * The action to be carried out following a trigger
  10399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10400. */
  10401. export class Action implements IAction {
  10402. /** the trigger, with or without parameters, for the action */
  10403. triggerOptions: any;
  10404. /**
  10405. * Trigger for the action
  10406. */
  10407. trigger: number;
  10408. /**
  10409. * Internal only - manager for action
  10410. * @hidden
  10411. */
  10412. _actionManager: ActionManager;
  10413. private _nextActiveAction;
  10414. private _child;
  10415. private _condition?;
  10416. private _triggerParameter;
  10417. /**
  10418. * An event triggered prior to action being executed.
  10419. */
  10420. onBeforeExecuteObservable: Observable<Action>;
  10421. /**
  10422. * Creates a new Action
  10423. * @param triggerOptions the trigger, with or without parameters, for the action
  10424. * @param condition an optional determinant of action
  10425. */
  10426. constructor(
  10427. /** the trigger, with or without parameters, for the action */
  10428. triggerOptions: any, condition?: Condition);
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. _prepare(): void;
  10434. /**
  10435. * Gets the trigger parameters
  10436. * @returns the trigger parameters
  10437. */
  10438. getTriggerParameter(): any;
  10439. /**
  10440. * Internal only - executes current action event
  10441. * @hidden
  10442. */
  10443. _executeCurrent(evt?: ActionEvent): void;
  10444. /**
  10445. * Execute placeholder for child classes
  10446. * @param evt optional action event
  10447. */
  10448. execute(evt?: ActionEvent): void;
  10449. /**
  10450. * Skips to next active action
  10451. */
  10452. skipToNextActiveAction(): void;
  10453. /**
  10454. * Adds action to chain of actions, may be a DoNothingAction
  10455. * @param action defines the next action to execute
  10456. * @returns The action passed in
  10457. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10458. */
  10459. then(action: Action): Action;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _getProperty(propertyPath: string): string;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. _getEffectiveTarget(target: any, propertyPath: string): any;
  10470. /**
  10471. * Serialize placeholder for child classes
  10472. * @param parent of child
  10473. * @returns the serialized object
  10474. */
  10475. serialize(parent: any): any;
  10476. /**
  10477. * Internal only called by serialize
  10478. * @hidden
  10479. */
  10480. protected _serialize(serializedAction: any, parent?: any): any;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. static _SerializeValueAsString: (value: any) => string;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10491. name: string;
  10492. targetType: string;
  10493. value: string;
  10494. };
  10495. }
  10496. }
  10497. declare module "babylonjs/Actions/condition" {
  10498. import { ActionManager } from "babylonjs/Actions/actionManager";
  10499. /**
  10500. * A Condition applied to an Action
  10501. */
  10502. export class Condition {
  10503. /**
  10504. * Internal only - manager for action
  10505. * @hidden
  10506. */
  10507. _actionManager: ActionManager;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _evaluationId: number;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _currentResult: boolean;
  10518. /**
  10519. * Creates a new Condition
  10520. * @param actionManager the manager of the action the condition is applied to
  10521. */
  10522. constructor(actionManager: ActionManager);
  10523. /**
  10524. * Check if the current condition is valid
  10525. * @returns a boolean
  10526. */
  10527. isValid(): boolean;
  10528. /**
  10529. * Internal only
  10530. * @hidden
  10531. */
  10532. _getProperty(propertyPath: string): string;
  10533. /**
  10534. * Internal only
  10535. * @hidden
  10536. */
  10537. _getEffectiveTarget(target: any, propertyPath: string): any;
  10538. /**
  10539. * Serialize placeholder for child classes
  10540. * @returns the serialized object
  10541. */
  10542. serialize(): any;
  10543. /**
  10544. * Internal only
  10545. * @hidden
  10546. */
  10547. protected _serialize(serializedCondition: any): any;
  10548. }
  10549. /**
  10550. * Defines specific conditional operators as extensions of Condition
  10551. */
  10552. export class ValueCondition extends Condition {
  10553. /** path to specify the property of the target the conditional operator uses */
  10554. propertyPath: string;
  10555. /** the value compared by the conditional operator against the current value of the property */
  10556. value: any;
  10557. /** the conditional operator, default ValueCondition.IsEqual */
  10558. operator: number;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. private static _IsEqual;
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. private static _IsDifferent;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. private static _IsGreater;
  10574. /**
  10575. * Internal only
  10576. * @hidden
  10577. */
  10578. private static _IsLesser;
  10579. /**
  10580. * returns the number for IsEqual
  10581. */
  10582. static readonly IsEqual: number;
  10583. /**
  10584. * Returns the number for IsDifferent
  10585. */
  10586. static readonly IsDifferent: number;
  10587. /**
  10588. * Returns the number for IsGreater
  10589. */
  10590. static readonly IsGreater: number;
  10591. /**
  10592. * Returns the number for IsLesser
  10593. */
  10594. static readonly IsLesser: number;
  10595. /**
  10596. * Internal only The action manager for the condition
  10597. * @hidden
  10598. */
  10599. _actionManager: ActionManager;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. private _target;
  10605. /**
  10606. * Internal only
  10607. * @hidden
  10608. */
  10609. private _effectiveTarget;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. private _property;
  10615. /**
  10616. * Creates a new ValueCondition
  10617. * @param actionManager manager for the action the condition applies to
  10618. * @param target for the action
  10619. * @param propertyPath path to specify the property of the target the conditional operator uses
  10620. * @param value the value compared by the conditional operator against the current value of the property
  10621. * @param operator the conditional operator, default ValueCondition.IsEqual
  10622. */
  10623. constructor(actionManager: ActionManager, target: any,
  10624. /** path to specify the property of the target the conditional operator uses */
  10625. propertyPath: string,
  10626. /** the value compared by the conditional operator against the current value of the property */
  10627. value: any,
  10628. /** the conditional operator, default ValueCondition.IsEqual */
  10629. operator?: number);
  10630. /**
  10631. * Compares the given value with the property value for the specified conditional operator
  10632. * @returns the result of the comparison
  10633. */
  10634. isValid(): boolean;
  10635. /**
  10636. * Serialize the ValueCondition into a JSON compatible object
  10637. * @returns serialization object
  10638. */
  10639. serialize(): any;
  10640. /**
  10641. * Gets the name of the conditional operator for the ValueCondition
  10642. * @param operator the conditional operator
  10643. * @returns the name
  10644. */
  10645. static GetOperatorName(operator: number): string;
  10646. }
  10647. /**
  10648. * Defines a predicate condition as an extension of Condition
  10649. */
  10650. export class PredicateCondition extends Condition {
  10651. /** defines the predicate function used to validate the condition */
  10652. predicate: () => boolean;
  10653. /**
  10654. * Internal only - manager for action
  10655. * @hidden
  10656. */
  10657. _actionManager: ActionManager;
  10658. /**
  10659. * Creates a new PredicateCondition
  10660. * @param actionManager manager for the action the condition applies to
  10661. * @param predicate defines the predicate function used to validate the condition
  10662. */
  10663. constructor(actionManager: ActionManager,
  10664. /** defines the predicate function used to validate the condition */
  10665. predicate: () => boolean);
  10666. /**
  10667. * @returns the validity of the predicate condition
  10668. */
  10669. isValid(): boolean;
  10670. }
  10671. /**
  10672. * Defines a state condition as an extension of Condition
  10673. */
  10674. export class StateCondition extends Condition {
  10675. /** Value to compare with target state */
  10676. value: string;
  10677. /**
  10678. * Internal only - manager for action
  10679. * @hidden
  10680. */
  10681. _actionManager: ActionManager;
  10682. /**
  10683. * Internal only
  10684. * @hidden
  10685. */
  10686. private _target;
  10687. /**
  10688. * Creates a new StateCondition
  10689. * @param actionManager manager for the action the condition applies to
  10690. * @param target of the condition
  10691. * @param value to compare with target state
  10692. */
  10693. constructor(actionManager: ActionManager, target: any,
  10694. /** Value to compare with target state */
  10695. value: string);
  10696. /**
  10697. * Gets a boolean indicating if the current condition is met
  10698. * @returns the validity of the state
  10699. */
  10700. isValid(): boolean;
  10701. /**
  10702. * Serialize the StateCondition into a JSON compatible object
  10703. * @returns serialization object
  10704. */
  10705. serialize(): any;
  10706. }
  10707. }
  10708. declare module "babylonjs/Actions/directActions" {
  10709. import { Action } from "babylonjs/Actions/action";
  10710. import { Condition } from "babylonjs/Actions/condition";
  10711. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10712. /**
  10713. * This defines an action responsible to toggle a boolean once triggered.
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10715. */
  10716. export class SwitchBooleanAction extends Action {
  10717. /**
  10718. * The path to the boolean property in the target object
  10719. */
  10720. propertyPath: string;
  10721. private _target;
  10722. private _effectiveTarget;
  10723. private _property;
  10724. /**
  10725. * Instantiate the action
  10726. * @param triggerOptions defines the trigger options
  10727. * @param target defines the object containing the boolean
  10728. * @param propertyPath defines the path to the boolean property in the target object
  10729. * @param condition defines the trigger related conditions
  10730. */
  10731. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10732. /** @hidden */
  10733. _prepare(): void;
  10734. /**
  10735. * Execute the action toggle the boolean value.
  10736. */
  10737. execute(): void;
  10738. /**
  10739. * Serializes the actions and its related information.
  10740. * @param parent defines the object to serialize in
  10741. * @returns the serialized object
  10742. */
  10743. serialize(parent: any): any;
  10744. }
  10745. /**
  10746. * This defines an action responsible to set a the state field of the target
  10747. * to a desired value once triggered.
  10748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10749. */
  10750. export class SetStateAction extends Action {
  10751. /**
  10752. * The value to store in the state field.
  10753. */
  10754. value: string;
  10755. private _target;
  10756. /**
  10757. * Instantiate the action
  10758. * @param triggerOptions defines the trigger options
  10759. * @param target defines the object containing the state property
  10760. * @param value defines the value to store in the state field
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10764. /**
  10765. * Execute the action and store the value on the target state property.
  10766. */
  10767. execute(): void;
  10768. /**
  10769. * Serializes the actions and its related information.
  10770. * @param parent defines the object to serialize in
  10771. * @returns the serialized object
  10772. */
  10773. serialize(parent: any): any;
  10774. }
  10775. /**
  10776. * This defines an action responsible to set a property of the target
  10777. * to a desired value once triggered.
  10778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10779. */
  10780. export class SetValueAction extends Action {
  10781. /**
  10782. * The path of the property to set in the target.
  10783. */
  10784. propertyPath: string;
  10785. /**
  10786. * The value to set in the property
  10787. */
  10788. value: any;
  10789. private _target;
  10790. private _effectiveTarget;
  10791. private _property;
  10792. /**
  10793. * Instantiate the action
  10794. * @param triggerOptions defines the trigger options
  10795. * @param target defines the object containing the property
  10796. * @param propertyPath defines the path of the property to set in the target
  10797. * @param value defines the value to set in the property
  10798. * @param condition defines the trigger related conditions
  10799. */
  10800. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10801. /** @hidden */
  10802. _prepare(): void;
  10803. /**
  10804. * Execute the action and set the targetted property to the desired value.
  10805. */
  10806. execute(): void;
  10807. /**
  10808. * Serializes the actions and its related information.
  10809. * @param parent defines the object to serialize in
  10810. * @returns the serialized object
  10811. */
  10812. serialize(parent: any): any;
  10813. }
  10814. /**
  10815. * This defines an action responsible to increment the target value
  10816. * to a desired value once triggered.
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10818. */
  10819. export class IncrementValueAction extends Action {
  10820. /**
  10821. * The path of the property to increment in the target.
  10822. */
  10823. propertyPath: string;
  10824. /**
  10825. * The value we should increment the property by.
  10826. */
  10827. value: any;
  10828. private _target;
  10829. private _effectiveTarget;
  10830. private _property;
  10831. /**
  10832. * Instantiate the action
  10833. * @param triggerOptions defines the trigger options
  10834. * @param target defines the object containing the property
  10835. * @param propertyPath defines the path of the property to increment in the target
  10836. * @param value defines the value value we should increment the property by
  10837. * @param condition defines the trigger related conditions
  10838. */
  10839. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10840. /** @hidden */
  10841. _prepare(): void;
  10842. /**
  10843. * Execute the action and increment the target of the value amount.
  10844. */
  10845. execute(): void;
  10846. /**
  10847. * Serializes the actions and its related information.
  10848. * @param parent defines the object to serialize in
  10849. * @returns the serialized object
  10850. */
  10851. serialize(parent: any): any;
  10852. }
  10853. /**
  10854. * This defines an action responsible to start an animation once triggered.
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10856. */
  10857. export class PlayAnimationAction extends Action {
  10858. /**
  10859. * Where the animation should start (animation frame)
  10860. */
  10861. from: number;
  10862. /**
  10863. * Where the animation should stop (animation frame)
  10864. */
  10865. to: number;
  10866. /**
  10867. * Define if the animation should loop or stop after the first play.
  10868. */
  10869. loop?: boolean;
  10870. private _target;
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param target defines the target animation or animation name
  10875. * @param from defines from where the animation should start (animation frame)
  10876. * @param end defines where the animation should stop (animation frame)
  10877. * @param loop defines if the animation should loop or stop after the first play
  10878. * @param condition defines the trigger related conditions
  10879. */
  10880. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10881. /** @hidden */
  10882. _prepare(): void;
  10883. /**
  10884. * Execute the action and play the animation.
  10885. */
  10886. execute(): void;
  10887. /**
  10888. * Serializes the actions and its related information.
  10889. * @param parent defines the object to serialize in
  10890. * @returns the serialized object
  10891. */
  10892. serialize(parent: any): any;
  10893. }
  10894. /**
  10895. * This defines an action responsible to stop an animation once triggered.
  10896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10897. */
  10898. export class StopAnimationAction extends Action {
  10899. private _target;
  10900. /**
  10901. * Instantiate the action
  10902. * @param triggerOptions defines the trigger options
  10903. * @param target defines the target animation or animation name
  10904. * @param condition defines the trigger related conditions
  10905. */
  10906. constructor(triggerOptions: any, target: any, condition?: Condition);
  10907. /** @hidden */
  10908. _prepare(): void;
  10909. /**
  10910. * Execute the action and stop the animation.
  10911. */
  10912. execute(): void;
  10913. /**
  10914. * Serializes the actions and its related information.
  10915. * @param parent defines the object to serialize in
  10916. * @returns the serialized object
  10917. */
  10918. serialize(parent: any): any;
  10919. }
  10920. /**
  10921. * This defines an action responsible that does nothing once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class DoNothingAction extends Action {
  10925. /**
  10926. * Instantiate the action
  10927. * @param triggerOptions defines the trigger options
  10928. * @param condition defines the trigger related conditions
  10929. */
  10930. constructor(triggerOptions?: any, condition?: Condition);
  10931. /**
  10932. * Execute the action and do nothing.
  10933. */
  10934. execute(): void;
  10935. /**
  10936. * Serializes the actions and its related information.
  10937. * @param parent defines the object to serialize in
  10938. * @returns the serialized object
  10939. */
  10940. serialize(parent: any): any;
  10941. }
  10942. /**
  10943. * This defines an action responsible to trigger several actions once triggered.
  10944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10945. */
  10946. export class CombineAction extends Action {
  10947. /**
  10948. * The list of aggregated animations to run.
  10949. */
  10950. children: Action[];
  10951. /**
  10952. * Instantiate the action
  10953. * @param triggerOptions defines the trigger options
  10954. * @param children defines the list of aggregated animations to run
  10955. * @param condition defines the trigger related conditions
  10956. */
  10957. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10958. /** @hidden */
  10959. _prepare(): void;
  10960. /**
  10961. * Execute the action and executes all the aggregated actions.
  10962. */
  10963. execute(evt: ActionEvent): void;
  10964. /**
  10965. * Serializes the actions and its related information.
  10966. * @param parent defines the object to serialize in
  10967. * @returns the serialized object
  10968. */
  10969. serialize(parent: any): any;
  10970. }
  10971. /**
  10972. * This defines an action responsible to run code (external event) once triggered.
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10974. */
  10975. export class ExecuteCodeAction extends Action {
  10976. /**
  10977. * The callback function to run.
  10978. */
  10979. func: (evt: ActionEvent) => void;
  10980. /**
  10981. * Instantiate the action
  10982. * @param triggerOptions defines the trigger options
  10983. * @param func defines the callback function to run
  10984. * @param condition defines the trigger related conditions
  10985. */
  10986. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10987. /**
  10988. * Execute the action and run the attached code.
  10989. */
  10990. execute(evt: ActionEvent): void;
  10991. }
  10992. /**
  10993. * This defines an action responsible to set the parent property of the target once triggered.
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10995. */
  10996. export class SetParentAction extends Action {
  10997. private _parent;
  10998. private _target;
  10999. /**
  11000. * Instantiate the action
  11001. * @param triggerOptions defines the trigger options
  11002. * @param target defines the target containing the parent property
  11003. * @param parent defines from where the animation should start (animation frame)
  11004. * @param condition defines the trigger related conditions
  11005. */
  11006. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11007. /** @hidden */
  11008. _prepare(): void;
  11009. /**
  11010. * Execute the action and set the parent property.
  11011. */
  11012. execute(): void;
  11013. /**
  11014. * Serializes the actions and its related information.
  11015. * @param parent defines the object to serialize in
  11016. * @returns the serialized object
  11017. */
  11018. serialize(parent: any): any;
  11019. }
  11020. }
  11021. declare module "babylonjs/Actions/actionManager" {
  11022. import { Nullable } from "babylonjs/types";
  11023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11024. import { Scene } from "babylonjs/scene";
  11025. import { IAction } from "babylonjs/Actions/action";
  11026. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11027. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11028. /**
  11029. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11030. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11032. */
  11033. export class ActionManager extends AbstractActionManager {
  11034. /**
  11035. * Nothing
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly NothingTrigger: number;
  11039. /**
  11040. * On pick
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPickTrigger: number;
  11044. /**
  11045. * On left pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnLeftPickTrigger: number;
  11049. /**
  11050. * On right pick
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnRightPickTrigger: number;
  11054. /**
  11055. * On center pick
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnCenterPickTrigger: number;
  11059. /**
  11060. * On pick down
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnPickDownTrigger: number;
  11064. /**
  11065. * On double pick
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnDoublePickTrigger: number;
  11069. /**
  11070. * On pick up
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11072. */
  11073. static readonly OnPickUpTrigger: number;
  11074. /**
  11075. * On pick out.
  11076. * This trigger will only be raised if you also declared a OnPickDown
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnPickOutTrigger: number;
  11080. /**
  11081. * On long press
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnLongPressTrigger: number;
  11085. /**
  11086. * On pointer over
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnPointerOverTrigger: number;
  11090. /**
  11091. * On pointer out
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnPointerOutTrigger: number;
  11095. /**
  11096. * On every frame
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnEveryFrameTrigger: number;
  11100. /**
  11101. * On intersection enter
  11102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11103. */
  11104. static readonly OnIntersectionEnterTrigger: number;
  11105. /**
  11106. * On intersection exit
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11108. */
  11109. static readonly OnIntersectionExitTrigger: number;
  11110. /**
  11111. * On key down
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11113. */
  11114. static readonly OnKeyDownTrigger: number;
  11115. /**
  11116. * On key up
  11117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11118. */
  11119. static readonly OnKeyUpTrigger: number;
  11120. private _scene;
  11121. /**
  11122. * Creates a new action manager
  11123. * @param scene defines the hosting scene
  11124. */
  11125. constructor(scene: Scene);
  11126. /**
  11127. * Releases all associated resources
  11128. */
  11129. dispose(): void;
  11130. /**
  11131. * Gets hosting scene
  11132. * @returns the hosting scene
  11133. */
  11134. getScene(): Scene;
  11135. /**
  11136. * Does this action manager handles actions of any of the given triggers
  11137. * @param triggers defines the triggers to be tested
  11138. * @return a boolean indicating whether one (or more) of the triggers is handled
  11139. */
  11140. hasSpecificTriggers(triggers: number[]): boolean;
  11141. /**
  11142. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11143. * speed.
  11144. * @param triggerA defines the trigger to be tested
  11145. * @param triggerB defines the trigger to be tested
  11146. * @return a boolean indicating whether one (or more) of the triggers is handled
  11147. */
  11148. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11149. /**
  11150. * Does this action manager handles actions of a given trigger
  11151. * @param trigger defines the trigger to be tested
  11152. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11153. * @return whether the trigger is handled
  11154. */
  11155. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11156. /**
  11157. * Does this action manager has pointer triggers
  11158. */
  11159. readonly hasPointerTriggers: boolean;
  11160. /**
  11161. * Does this action manager has pick triggers
  11162. */
  11163. readonly hasPickTriggers: boolean;
  11164. /**
  11165. * Registers an action to this action manager
  11166. * @param action defines the action to be registered
  11167. * @return the action amended (prepared) after registration
  11168. */
  11169. registerAction(action: IAction): Nullable<IAction>;
  11170. /**
  11171. * Unregisters an action to this action manager
  11172. * @param action defines the action to be unregistered
  11173. * @return a boolean indicating whether the action has been unregistered
  11174. */
  11175. unregisterAction(action: IAction): Boolean;
  11176. /**
  11177. * Process a specific trigger
  11178. * @param trigger defines the trigger to process
  11179. * @param evt defines the event details to be processed
  11180. */
  11181. processTrigger(trigger: number, evt?: IActionEvent): void;
  11182. /** @hidden */
  11183. _getEffectiveTarget(target: any, propertyPath: string): any;
  11184. /** @hidden */
  11185. _getProperty(propertyPath: string): string;
  11186. /**
  11187. * Serialize this manager to a JSON object
  11188. * @param name defines the property name to store this manager
  11189. * @returns a JSON representation of this manager
  11190. */
  11191. serialize(name: string): any;
  11192. /**
  11193. * Creates a new ActionManager from a JSON data
  11194. * @param parsedActions defines the JSON data to read from
  11195. * @param object defines the hosting mesh
  11196. * @param scene defines the hosting scene
  11197. */
  11198. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11199. /**
  11200. * Get a trigger name by index
  11201. * @param trigger defines the trigger index
  11202. * @returns a trigger name
  11203. */
  11204. static GetTriggerName(trigger: number): string;
  11205. }
  11206. }
  11207. declare module "babylonjs/Culling/ray" {
  11208. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11209. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11211. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11212. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11213. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11214. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11215. import { Plane } from "babylonjs/Maths/math.plane";
  11216. /**
  11217. * Class representing a ray with position and direction
  11218. */
  11219. export class Ray {
  11220. /** origin point */
  11221. origin: Vector3;
  11222. /** direction */
  11223. direction: Vector3;
  11224. /** length of the ray */
  11225. length: number;
  11226. private static readonly TmpVector3;
  11227. private _tmpRay;
  11228. /**
  11229. * Creates a new ray
  11230. * @param origin origin point
  11231. * @param direction direction
  11232. * @param length length of the ray
  11233. */
  11234. constructor(
  11235. /** origin point */
  11236. origin: Vector3,
  11237. /** direction */
  11238. direction: Vector3,
  11239. /** length of the ray */
  11240. length?: number);
  11241. /**
  11242. * Checks if the ray intersects a box
  11243. * @param minimum bound of the box
  11244. * @param maximum bound of the box
  11245. * @param intersectionTreshold extra extend to be added to the box in all direction
  11246. * @returns if the box was hit
  11247. */
  11248. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11249. /**
  11250. * Checks if the ray intersects a box
  11251. * @param box the bounding box to check
  11252. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11253. * @returns if the box was hit
  11254. */
  11255. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11256. /**
  11257. * If the ray hits a sphere
  11258. * @param sphere the bounding sphere to check
  11259. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11260. * @returns true if it hits the sphere
  11261. */
  11262. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11263. /**
  11264. * If the ray hits a triange
  11265. * @param vertex0 triangle vertex
  11266. * @param vertex1 triangle vertex
  11267. * @param vertex2 triangle vertex
  11268. * @returns intersection information if hit
  11269. */
  11270. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11271. /**
  11272. * Checks if ray intersects a plane
  11273. * @param plane the plane to check
  11274. * @returns the distance away it was hit
  11275. */
  11276. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11277. /**
  11278. * Calculate the intercept of a ray on a given axis
  11279. * @param axis to check 'x' | 'y' | 'z'
  11280. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11281. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11282. */
  11283. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11284. /**
  11285. * Checks if ray intersects a mesh
  11286. * @param mesh the mesh to check
  11287. * @param fastCheck if only the bounding box should checked
  11288. * @returns picking info of the intersecton
  11289. */
  11290. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11291. /**
  11292. * Checks if ray intersects a mesh
  11293. * @param meshes the meshes to check
  11294. * @param fastCheck if only the bounding box should checked
  11295. * @param results array to store result in
  11296. * @returns Array of picking infos
  11297. */
  11298. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11299. private _comparePickingInfo;
  11300. private static smallnum;
  11301. private static rayl;
  11302. /**
  11303. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11304. * @param sega the first point of the segment to test the intersection against
  11305. * @param segb the second point of the segment to test the intersection against
  11306. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11307. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11308. */
  11309. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11310. /**
  11311. * Update the ray from viewport position
  11312. * @param x position
  11313. * @param y y position
  11314. * @param viewportWidth viewport width
  11315. * @param viewportHeight viewport height
  11316. * @param world world matrix
  11317. * @param view view matrix
  11318. * @param projection projection matrix
  11319. * @returns this ray updated
  11320. */
  11321. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11322. /**
  11323. * Creates a ray with origin and direction of 0,0,0
  11324. * @returns the new ray
  11325. */
  11326. static Zero(): Ray;
  11327. /**
  11328. * Creates a new ray from screen space and viewport
  11329. * @param x position
  11330. * @param y y position
  11331. * @param viewportWidth viewport width
  11332. * @param viewportHeight viewport height
  11333. * @param world world matrix
  11334. * @param view view matrix
  11335. * @param projection projection matrix
  11336. * @returns new ray
  11337. */
  11338. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11339. /**
  11340. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11341. * transformed to the given world matrix.
  11342. * @param origin The origin point
  11343. * @param end The end point
  11344. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11345. * @returns the new ray
  11346. */
  11347. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11348. /**
  11349. * Transforms a ray by a matrix
  11350. * @param ray ray to transform
  11351. * @param matrix matrix to apply
  11352. * @returns the resulting new ray
  11353. */
  11354. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11355. /**
  11356. * Transforms a ray by a matrix
  11357. * @param ray ray to transform
  11358. * @param matrix matrix to apply
  11359. * @param result ray to store result in
  11360. */
  11361. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11362. /**
  11363. * Unproject a ray from screen space to object space
  11364. * @param sourceX defines the screen space x coordinate to use
  11365. * @param sourceY defines the screen space y coordinate to use
  11366. * @param viewportWidth defines the current width of the viewport
  11367. * @param viewportHeight defines the current height of the viewport
  11368. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11369. * @param view defines the view matrix to use
  11370. * @param projection defines the projection matrix to use
  11371. */
  11372. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11373. }
  11374. /**
  11375. * Type used to define predicate used to select faces when a mesh intersection is detected
  11376. */
  11377. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11378. module "babylonjs/scene" {
  11379. interface Scene {
  11380. /** @hidden */
  11381. _tempPickingRay: Nullable<Ray>;
  11382. /** @hidden */
  11383. _cachedRayForTransform: Ray;
  11384. /** @hidden */
  11385. _pickWithRayInverseMatrix: Matrix;
  11386. /** @hidden */
  11387. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11388. /** @hidden */
  11389. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11390. }
  11391. }
  11392. }
  11393. declare module "babylonjs/sceneComponent" {
  11394. import { Scene } from "babylonjs/scene";
  11395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11396. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11397. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11398. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11399. import { Nullable } from "babylonjs/types";
  11400. import { Camera } from "babylonjs/Cameras/camera";
  11401. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11402. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11403. import { AbstractScene } from "babylonjs/abstractScene";
  11404. import { Mesh } from "babylonjs/Meshes/mesh";
  11405. /**
  11406. * Groups all the scene component constants in one place to ease maintenance.
  11407. * @hidden
  11408. */
  11409. export class SceneComponentConstants {
  11410. static readonly NAME_EFFECTLAYER: string;
  11411. static readonly NAME_LAYER: string;
  11412. static readonly NAME_LENSFLARESYSTEM: string;
  11413. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11414. static readonly NAME_PARTICLESYSTEM: string;
  11415. static readonly NAME_GAMEPAD: string;
  11416. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11417. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11418. static readonly NAME_DEPTHRENDERER: string;
  11419. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11420. static readonly NAME_SPRITE: string;
  11421. static readonly NAME_OUTLINERENDERER: string;
  11422. static readonly NAME_PROCEDURALTEXTURE: string;
  11423. static readonly NAME_SHADOWGENERATOR: string;
  11424. static readonly NAME_OCTREE: string;
  11425. static readonly NAME_PHYSICSENGINE: string;
  11426. static readonly NAME_AUDIO: string;
  11427. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11428. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11429. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11430. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11431. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11432. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11433. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11434. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11435. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11436. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11437. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11438. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11439. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11440. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11441. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11442. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11443. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11444. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11445. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11446. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11447. static readonly STEP_AFTERRENDER_AUDIO: number;
  11448. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11449. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11450. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11451. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11452. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11453. static readonly STEP_POINTERMOVE_SPRITE: number;
  11454. static readonly STEP_POINTERDOWN_SPRITE: number;
  11455. static readonly STEP_POINTERUP_SPRITE: number;
  11456. }
  11457. /**
  11458. * This represents a scene component.
  11459. *
  11460. * This is used to decouple the dependency the scene is having on the different workloads like
  11461. * layers, post processes...
  11462. */
  11463. export interface ISceneComponent {
  11464. /**
  11465. * The name of the component. Each component must have a unique name.
  11466. */
  11467. name: string;
  11468. /**
  11469. * The scene the component belongs to.
  11470. */
  11471. scene: Scene;
  11472. /**
  11473. * Register the component to one instance of a scene.
  11474. */
  11475. register(): void;
  11476. /**
  11477. * Rebuilds the elements related to this component in case of
  11478. * context lost for instance.
  11479. */
  11480. rebuild(): void;
  11481. /**
  11482. * Disposes the component and the associated ressources.
  11483. */
  11484. dispose(): void;
  11485. }
  11486. /**
  11487. * This represents a SERIALIZABLE scene component.
  11488. *
  11489. * This extends Scene Component to add Serialization methods on top.
  11490. */
  11491. export interface ISceneSerializableComponent extends ISceneComponent {
  11492. /**
  11493. * Adds all the elements from the container to the scene
  11494. * @param container the container holding the elements
  11495. */
  11496. addFromContainer(container: AbstractScene): void;
  11497. /**
  11498. * Removes all the elements in the container from the scene
  11499. * @param container contains the elements to remove
  11500. * @param dispose if the removed element should be disposed (default: false)
  11501. */
  11502. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11503. /**
  11504. * Serializes the component data to the specified json object
  11505. * @param serializationObject The object to serialize to
  11506. */
  11507. serialize(serializationObject: any): void;
  11508. }
  11509. /**
  11510. * Strong typing of a Mesh related stage step action
  11511. */
  11512. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11513. /**
  11514. * Strong typing of a Evaluate Sub Mesh related stage step action
  11515. */
  11516. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11517. /**
  11518. * Strong typing of a Active Mesh related stage step action
  11519. */
  11520. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11521. /**
  11522. * Strong typing of a Camera related stage step action
  11523. */
  11524. export type CameraStageAction = (camera: Camera) => void;
  11525. /**
  11526. * Strong typing of a Camera Frame buffer related stage step action
  11527. */
  11528. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11529. /**
  11530. * Strong typing of a Render Target related stage step action
  11531. */
  11532. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11533. /**
  11534. * Strong typing of a RenderingGroup related stage step action
  11535. */
  11536. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11537. /**
  11538. * Strong typing of a Mesh Render related stage step action
  11539. */
  11540. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11541. /**
  11542. * Strong typing of a simple stage step action
  11543. */
  11544. export type SimpleStageAction = () => void;
  11545. /**
  11546. * Strong typing of a render target action.
  11547. */
  11548. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11549. /**
  11550. * Strong typing of a pointer move action.
  11551. */
  11552. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11553. /**
  11554. * Strong typing of a pointer up/down action.
  11555. */
  11556. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11557. /**
  11558. * Representation of a stage in the scene (Basically a list of ordered steps)
  11559. * @hidden
  11560. */
  11561. export class Stage<T extends Function> extends Array<{
  11562. index: number;
  11563. component: ISceneComponent;
  11564. action: T;
  11565. }> {
  11566. /**
  11567. * Hide ctor from the rest of the world.
  11568. * @param items The items to add.
  11569. */
  11570. private constructor();
  11571. /**
  11572. * Creates a new Stage.
  11573. * @returns A new instance of a Stage
  11574. */
  11575. static Create<T extends Function>(): Stage<T>;
  11576. /**
  11577. * Registers a step in an ordered way in the targeted stage.
  11578. * @param index Defines the position to register the step in
  11579. * @param component Defines the component attached to the step
  11580. * @param action Defines the action to launch during the step
  11581. */
  11582. registerStep(index: number, component: ISceneComponent, action: T): void;
  11583. /**
  11584. * Clears all the steps from the stage.
  11585. */
  11586. clear(): void;
  11587. }
  11588. }
  11589. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11590. import { Nullable } from "babylonjs/types";
  11591. import { Observable } from "babylonjs/Misc/observable";
  11592. import { Scene } from "babylonjs/scene";
  11593. import { Sprite } from "babylonjs/Sprites/sprite";
  11594. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11595. import { Ray } from "babylonjs/Culling/ray";
  11596. import { Camera } from "babylonjs/Cameras/camera";
  11597. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11598. import { ISceneComponent } from "babylonjs/sceneComponent";
  11599. module "babylonjs/scene" {
  11600. interface Scene {
  11601. /** @hidden */
  11602. _pointerOverSprite: Nullable<Sprite>;
  11603. /** @hidden */
  11604. _pickedDownSprite: Nullable<Sprite>;
  11605. /** @hidden */
  11606. _tempSpritePickingRay: Nullable<Ray>;
  11607. /**
  11608. * All of the sprite managers added to this scene
  11609. * @see http://doc.babylonjs.com/babylon101/sprites
  11610. */
  11611. spriteManagers: Array<ISpriteManager>;
  11612. /**
  11613. * An event triggered when sprites rendering is about to start
  11614. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11615. */
  11616. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11617. /**
  11618. * An event triggered when sprites rendering is done
  11619. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11620. */
  11621. onAfterSpritesRenderingObservable: Observable<Scene>;
  11622. /** @hidden */
  11623. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11624. /** Launch a ray to try to pick a sprite in the scene
  11625. * @param x position on screen
  11626. * @param y position on screen
  11627. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11628. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11629. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11630. * @returns a PickingInfo
  11631. */
  11632. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11633. /** Use the given ray to pick a sprite in the scene
  11634. * @param ray The ray (in world space) to use to pick meshes
  11635. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11636. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11637. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11638. * @returns a PickingInfo
  11639. */
  11640. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11641. /** @hidden */
  11642. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11643. /** Launch a ray to try to pick sprites in the scene
  11644. * @param x position on screen
  11645. * @param y position on screen
  11646. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11647. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11648. * @returns a PickingInfo array
  11649. */
  11650. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11651. /** Use the given ray to pick sprites in the scene
  11652. * @param ray The ray (in world space) to use to pick meshes
  11653. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11654. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11655. * @returns a PickingInfo array
  11656. */
  11657. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11658. /**
  11659. * Force the sprite under the pointer
  11660. * @param sprite defines the sprite to use
  11661. */
  11662. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11663. /**
  11664. * Gets the sprite under the pointer
  11665. * @returns a Sprite or null if no sprite is under the pointer
  11666. */
  11667. getPointerOverSprite(): Nullable<Sprite>;
  11668. }
  11669. }
  11670. /**
  11671. * Defines the sprite scene component responsible to manage sprites
  11672. * in a given scene.
  11673. */
  11674. export class SpriteSceneComponent implements ISceneComponent {
  11675. /**
  11676. * The component name helpfull to identify the component in the list of scene components.
  11677. */
  11678. readonly name: string;
  11679. /**
  11680. * The scene the component belongs to.
  11681. */
  11682. scene: Scene;
  11683. /** @hidden */
  11684. private _spritePredicate;
  11685. /**
  11686. * Creates a new instance of the component for the given scene
  11687. * @param scene Defines the scene to register the component in
  11688. */
  11689. constructor(scene: Scene);
  11690. /**
  11691. * Registers the component in a given scene
  11692. */
  11693. register(): void;
  11694. /**
  11695. * Rebuilds the elements related to this component in case of
  11696. * context lost for instance.
  11697. */
  11698. rebuild(): void;
  11699. /**
  11700. * Disposes the component and the associated ressources.
  11701. */
  11702. dispose(): void;
  11703. private _pickSpriteButKeepRay;
  11704. private _pointerMove;
  11705. private _pointerDown;
  11706. private _pointerUp;
  11707. }
  11708. }
  11709. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11710. /** @hidden */
  11711. export var fogFragmentDeclaration: {
  11712. name: string;
  11713. shader: string;
  11714. };
  11715. }
  11716. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11717. /** @hidden */
  11718. export var fogFragment: {
  11719. name: string;
  11720. shader: string;
  11721. };
  11722. }
  11723. declare module "babylonjs/Shaders/sprites.fragment" {
  11724. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11725. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11726. /** @hidden */
  11727. export var spritesPixelShader: {
  11728. name: string;
  11729. shader: string;
  11730. };
  11731. }
  11732. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11733. /** @hidden */
  11734. export var fogVertexDeclaration: {
  11735. name: string;
  11736. shader: string;
  11737. };
  11738. }
  11739. declare module "babylonjs/Shaders/sprites.vertex" {
  11740. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11741. /** @hidden */
  11742. export var spritesVertexShader: {
  11743. name: string;
  11744. shader: string;
  11745. };
  11746. }
  11747. declare module "babylonjs/Sprites/spriteManager" {
  11748. import { IDisposable, Scene } from "babylonjs/scene";
  11749. import { Nullable } from "babylonjs/types";
  11750. import { Observable } from "babylonjs/Misc/observable";
  11751. import { Sprite } from "babylonjs/Sprites/sprite";
  11752. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11753. import { Camera } from "babylonjs/Cameras/camera";
  11754. import { Texture } from "babylonjs/Materials/Textures/texture";
  11755. import "babylonjs/Shaders/sprites.fragment";
  11756. import "babylonjs/Shaders/sprites.vertex";
  11757. import { Ray } from "babylonjs/Culling/ray";
  11758. /**
  11759. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11760. */
  11761. export interface ISpriteManager extends IDisposable {
  11762. /**
  11763. * Restricts the camera to viewing objects with the same layerMask.
  11764. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11765. */
  11766. layerMask: number;
  11767. /**
  11768. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11769. */
  11770. isPickable: boolean;
  11771. /**
  11772. * Specifies the rendering group id for this mesh (0 by default)
  11773. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11774. */
  11775. renderingGroupId: number;
  11776. /**
  11777. * Defines the list of sprites managed by the manager.
  11778. */
  11779. sprites: Array<Sprite>;
  11780. /**
  11781. * Tests the intersection of a sprite with a specific ray.
  11782. * @param ray The ray we are sending to test the collision
  11783. * @param camera The camera space we are sending rays in
  11784. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11785. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11786. * @returns picking info or null.
  11787. */
  11788. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11789. /**
  11790. * Intersects the sprites with a ray
  11791. * @param ray defines the ray to intersect with
  11792. * @param camera defines the current active camera
  11793. * @param predicate defines a predicate used to select candidate sprites
  11794. * @returns null if no hit or a PickingInfo array
  11795. */
  11796. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11797. /**
  11798. * Renders the list of sprites on screen.
  11799. */
  11800. render(): void;
  11801. }
  11802. /**
  11803. * Class used to manage multiple sprites on the same spritesheet
  11804. * @see http://doc.babylonjs.com/babylon101/sprites
  11805. */
  11806. export class SpriteManager implements ISpriteManager {
  11807. /** defines the manager's name */
  11808. name: string;
  11809. /** Gets the list of sprites */
  11810. sprites: Sprite[];
  11811. /** Gets or sets the rendering group id (0 by default) */
  11812. renderingGroupId: number;
  11813. /** Gets or sets camera layer mask */
  11814. layerMask: number;
  11815. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11816. fogEnabled: boolean;
  11817. /** Gets or sets a boolean indicating if the sprites are pickable */
  11818. isPickable: boolean;
  11819. /** Defines the default width of a cell in the spritesheet */
  11820. cellWidth: number;
  11821. /** Defines the default height of a cell in the spritesheet */
  11822. cellHeight: number;
  11823. /** Associative array from JSON sprite data file */
  11824. private _cellData;
  11825. /** Array of sprite names from JSON sprite data file */
  11826. private _spriteMap;
  11827. /** True when packed cell data from JSON file is ready*/
  11828. private _packedAndReady;
  11829. /**
  11830. * An event triggered when the manager is disposed.
  11831. */
  11832. onDisposeObservable: Observable<SpriteManager>;
  11833. private _onDisposeObserver;
  11834. /**
  11835. * Callback called when the manager is disposed
  11836. */
  11837. onDispose: () => void;
  11838. private _capacity;
  11839. private _fromPacked;
  11840. private _spriteTexture;
  11841. private _epsilon;
  11842. private _scene;
  11843. private _vertexData;
  11844. private _buffer;
  11845. private _vertexBuffers;
  11846. private _indexBuffer;
  11847. private _effectBase;
  11848. private _effectFog;
  11849. /**
  11850. * Gets or sets the spritesheet texture
  11851. */
  11852. texture: Texture;
  11853. /**
  11854. * Creates a new sprite manager
  11855. * @param name defines the manager's name
  11856. * @param imgUrl defines the sprite sheet url
  11857. * @param capacity defines the maximum allowed number of sprites
  11858. * @param cellSize defines the size of a sprite cell
  11859. * @param scene defines the hosting scene
  11860. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11861. * @param samplingMode defines the smapling mode to use with spritesheet
  11862. * @param fromPacked set to false; do not alter
  11863. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11864. */
  11865. constructor(
  11866. /** defines the manager's name */
  11867. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11868. private _makePacked;
  11869. private _appendSpriteVertex;
  11870. /**
  11871. * Intersects the sprites with a ray
  11872. * @param ray defines the ray to intersect with
  11873. * @param camera defines the current active camera
  11874. * @param predicate defines a predicate used to select candidate sprites
  11875. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11876. * @returns null if no hit or a PickingInfo
  11877. */
  11878. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11879. /**
  11880. * Intersects the sprites with a ray
  11881. * @param ray defines the ray to intersect with
  11882. * @param camera defines the current active camera
  11883. * @param predicate defines a predicate used to select candidate sprites
  11884. * @returns null if no hit or a PickingInfo array
  11885. */
  11886. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11887. /**
  11888. * Render all child sprites
  11889. */
  11890. render(): void;
  11891. /**
  11892. * Release associated resources
  11893. */
  11894. dispose(): void;
  11895. }
  11896. }
  11897. declare module "babylonjs/Sprites/sprite" {
  11898. import { Vector3 } from "babylonjs/Maths/math.vector";
  11899. import { Nullable } from "babylonjs/types";
  11900. import { ActionManager } from "babylonjs/Actions/actionManager";
  11901. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11902. import { Color4 } from "babylonjs/Maths/math.color";
  11903. /**
  11904. * Class used to represent a sprite
  11905. * @see http://doc.babylonjs.com/babylon101/sprites
  11906. */
  11907. export class Sprite {
  11908. /** defines the name */
  11909. name: string;
  11910. /** Gets or sets the current world position */
  11911. position: Vector3;
  11912. /** Gets or sets the main color */
  11913. color: Color4;
  11914. /** Gets or sets the width */
  11915. width: number;
  11916. /** Gets or sets the height */
  11917. height: number;
  11918. /** Gets or sets rotation angle */
  11919. angle: number;
  11920. /** Gets or sets the cell index in the sprite sheet */
  11921. cellIndex: number;
  11922. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11923. cellRef: string;
  11924. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11925. invertU: number;
  11926. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11927. invertV: number;
  11928. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11929. disposeWhenFinishedAnimating: boolean;
  11930. /** Gets the list of attached animations */
  11931. animations: Animation[];
  11932. /** Gets or sets a boolean indicating if the sprite can be picked */
  11933. isPickable: boolean;
  11934. /**
  11935. * Gets or sets the associated action manager
  11936. */
  11937. actionManager: Nullable<ActionManager>;
  11938. private _animationStarted;
  11939. private _loopAnimation;
  11940. private _fromIndex;
  11941. private _toIndex;
  11942. private _delay;
  11943. private _direction;
  11944. private _manager;
  11945. private _time;
  11946. private _onAnimationEnd;
  11947. /**
  11948. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11949. */
  11950. isVisible: boolean;
  11951. /**
  11952. * Gets or sets the sprite size
  11953. */
  11954. size: number;
  11955. /**
  11956. * Creates a new Sprite
  11957. * @param name defines the name
  11958. * @param manager defines the manager
  11959. */
  11960. constructor(
  11961. /** defines the name */
  11962. name: string, manager: ISpriteManager);
  11963. /**
  11964. * Starts an animation
  11965. * @param from defines the initial key
  11966. * @param to defines the end key
  11967. * @param loop defines if the animation must loop
  11968. * @param delay defines the start delay (in ms)
  11969. * @param onAnimationEnd defines a callback to call when animation ends
  11970. */
  11971. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11972. /** Stops current animation (if any) */
  11973. stopAnimation(): void;
  11974. /** @hidden */
  11975. _animate(deltaTime: number): void;
  11976. /** Release associated resources */
  11977. dispose(): void;
  11978. }
  11979. }
  11980. declare module "babylonjs/Collisions/pickingInfo" {
  11981. import { Nullable } from "babylonjs/types";
  11982. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11984. import { Sprite } from "babylonjs/Sprites/sprite";
  11985. import { Ray } from "babylonjs/Culling/ray";
  11986. /**
  11987. * Information about the result of picking within a scene
  11988. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11989. */
  11990. export class PickingInfo {
  11991. /** @hidden */
  11992. _pickingUnavailable: boolean;
  11993. /**
  11994. * If the pick collided with an object
  11995. */
  11996. hit: boolean;
  11997. /**
  11998. * Distance away where the pick collided
  11999. */
  12000. distance: number;
  12001. /**
  12002. * The location of pick collision
  12003. */
  12004. pickedPoint: Nullable<Vector3>;
  12005. /**
  12006. * The mesh corresponding the the pick collision
  12007. */
  12008. pickedMesh: Nullable<AbstractMesh>;
  12009. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12010. bu: number;
  12011. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12012. bv: number;
  12013. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12014. faceId: number;
  12015. /** Id of the the submesh that was picked */
  12016. subMeshId: number;
  12017. /** If a sprite was picked, this will be the sprite the pick collided with */
  12018. pickedSprite: Nullable<Sprite>;
  12019. /**
  12020. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12021. */
  12022. originMesh: Nullable<AbstractMesh>;
  12023. /**
  12024. * The ray that was used to perform the picking.
  12025. */
  12026. ray: Nullable<Ray>;
  12027. /**
  12028. * Gets the normal correspodning to the face the pick collided with
  12029. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12030. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12031. * @returns The normal correspodning to the face the pick collided with
  12032. */
  12033. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12034. /**
  12035. * Gets the texture coordinates of where the pick occured
  12036. * @returns the vector containing the coordnates of the texture
  12037. */
  12038. getTextureCoordinates(): Nullable<Vector2>;
  12039. }
  12040. }
  12041. declare module "babylonjs/Events/pointerEvents" {
  12042. import { Nullable } from "babylonjs/types";
  12043. import { Vector2 } from "babylonjs/Maths/math.vector";
  12044. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12045. import { Ray } from "babylonjs/Culling/ray";
  12046. /**
  12047. * Gather the list of pointer event types as constants.
  12048. */
  12049. export class PointerEventTypes {
  12050. /**
  12051. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  12052. */
  12053. static readonly POINTERDOWN: number;
  12054. /**
  12055. * The pointerup event is fired when a pointer is no longer active.
  12056. */
  12057. static readonly POINTERUP: number;
  12058. /**
  12059. * The pointermove event is fired when a pointer changes coordinates.
  12060. */
  12061. static readonly POINTERMOVE: number;
  12062. /**
  12063. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12064. */
  12065. static readonly POINTERWHEEL: number;
  12066. /**
  12067. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12068. */
  12069. static readonly POINTERPICK: number;
  12070. /**
  12071. * The pointertap event is fired when a the object has been touched and released without drag.
  12072. */
  12073. static readonly POINTERTAP: number;
  12074. /**
  12075. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12076. */
  12077. static readonly POINTERDOUBLETAP: number;
  12078. }
  12079. /**
  12080. * Base class of pointer info types.
  12081. */
  12082. export class PointerInfoBase {
  12083. /**
  12084. * Defines the type of event (PointerEventTypes)
  12085. */
  12086. type: number;
  12087. /**
  12088. * Defines the related dom event
  12089. */
  12090. event: PointerEvent | MouseWheelEvent;
  12091. /**
  12092. * Instantiates the base class of pointers info.
  12093. * @param type Defines the type of event (PointerEventTypes)
  12094. * @param event Defines the related dom event
  12095. */
  12096. constructor(
  12097. /**
  12098. * Defines the type of event (PointerEventTypes)
  12099. */
  12100. type: number,
  12101. /**
  12102. * Defines the related dom event
  12103. */
  12104. event: PointerEvent | MouseWheelEvent);
  12105. }
  12106. /**
  12107. * This class is used to store pointer related info for the onPrePointerObservable event.
  12108. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12109. */
  12110. export class PointerInfoPre extends PointerInfoBase {
  12111. /**
  12112. * Ray from a pointer if availible (eg. 6dof controller)
  12113. */
  12114. ray: Nullable<Ray>;
  12115. /**
  12116. * Defines the local position of the pointer on the canvas.
  12117. */
  12118. localPosition: Vector2;
  12119. /**
  12120. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12121. */
  12122. skipOnPointerObservable: boolean;
  12123. /**
  12124. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12125. * @param type Defines the type of event (PointerEventTypes)
  12126. * @param event Defines the related dom event
  12127. * @param localX Defines the local x coordinates of the pointer when the event occured
  12128. * @param localY Defines the local y coordinates of the pointer when the event occured
  12129. */
  12130. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12131. }
  12132. /**
  12133. * This type contains all the data related to a pointer event in Babylon.js.
  12134. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12135. */
  12136. export class PointerInfo extends PointerInfoBase {
  12137. /**
  12138. * Defines the picking info associated to the info (if any)\
  12139. */
  12140. pickInfo: Nullable<PickingInfo>;
  12141. /**
  12142. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12143. * @param type Defines the type of event (PointerEventTypes)
  12144. * @param event Defines the related dom event
  12145. * @param pickInfo Defines the picking info associated to the info (if any)\
  12146. */
  12147. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12148. /**
  12149. * Defines the picking info associated to the info (if any)\
  12150. */
  12151. pickInfo: Nullable<PickingInfo>);
  12152. }
  12153. /**
  12154. * Data relating to a touch event on the screen.
  12155. */
  12156. export interface PointerTouch {
  12157. /**
  12158. * X coordinate of touch.
  12159. */
  12160. x: number;
  12161. /**
  12162. * Y coordinate of touch.
  12163. */
  12164. y: number;
  12165. /**
  12166. * Id of touch. Unique for each finger.
  12167. */
  12168. pointerId: number;
  12169. /**
  12170. * Event type passed from DOM.
  12171. */
  12172. type: any;
  12173. }
  12174. }
  12175. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12176. import { Observable } from "babylonjs/Misc/observable";
  12177. import { Nullable } from "babylonjs/types";
  12178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12179. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12180. /**
  12181. * Manage the mouse inputs to control the movement of a free camera.
  12182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12183. */
  12184. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12185. /**
  12186. * Define if touch is enabled in the mouse input
  12187. */
  12188. touchEnabled: boolean;
  12189. /**
  12190. * Defines the camera the input is attached to.
  12191. */
  12192. camera: FreeCamera;
  12193. /**
  12194. * Defines the buttons associated with the input to handle camera move.
  12195. */
  12196. buttons: number[];
  12197. /**
  12198. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12199. */
  12200. angularSensibility: number;
  12201. private _pointerInput;
  12202. private _onMouseMove;
  12203. private _observer;
  12204. private previousPosition;
  12205. /**
  12206. * Observable for when a pointer move event occurs containing the move offset
  12207. */
  12208. onPointerMovedObservable: Observable<{
  12209. offsetX: number;
  12210. offsetY: number;
  12211. }>;
  12212. /**
  12213. * @hidden
  12214. * If the camera should be rotated automatically based on pointer movement
  12215. */
  12216. _allowCameraRotation: boolean;
  12217. /**
  12218. * Manage the mouse inputs to control the movement of a free camera.
  12219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12220. * @param touchEnabled Defines if touch is enabled or not
  12221. */
  12222. constructor(
  12223. /**
  12224. * Define if touch is enabled in the mouse input
  12225. */
  12226. touchEnabled?: boolean);
  12227. /**
  12228. * Attach the input controls to a specific dom element to get the input from.
  12229. * @param element Defines the element the controls should be listened from
  12230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12231. */
  12232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12233. /**
  12234. * Called on JS contextmenu event.
  12235. * Override this method to provide functionality.
  12236. */
  12237. protected onContextMenu(evt: PointerEvent): void;
  12238. /**
  12239. * Detach the current controls from the specified dom element.
  12240. * @param element Defines the element to stop listening the inputs from
  12241. */
  12242. detachControl(element: Nullable<HTMLElement>): void;
  12243. /**
  12244. * Gets the class name of the current intput.
  12245. * @returns the class name
  12246. */
  12247. getClassName(): string;
  12248. /**
  12249. * Get the friendly name associated with the input class.
  12250. * @returns the input friendly name
  12251. */
  12252. getSimpleName(): string;
  12253. }
  12254. }
  12255. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12256. import { Nullable } from "babylonjs/types";
  12257. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12258. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12259. /**
  12260. * Manage the touch inputs to control the movement of a free camera.
  12261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12262. */
  12263. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12264. /**
  12265. * Defines the camera the input is attached to.
  12266. */
  12267. camera: FreeCamera;
  12268. /**
  12269. * Defines the touch sensibility for rotation.
  12270. * The higher the faster.
  12271. */
  12272. touchAngularSensibility: number;
  12273. /**
  12274. * Defines the touch sensibility for move.
  12275. * The higher the faster.
  12276. */
  12277. touchMoveSensibility: number;
  12278. private _offsetX;
  12279. private _offsetY;
  12280. private _pointerPressed;
  12281. private _pointerInput;
  12282. private _observer;
  12283. private _onLostFocus;
  12284. /**
  12285. * Attach the input controls to a specific dom element to get the input from.
  12286. * @param element Defines the element the controls should be listened from
  12287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12288. */
  12289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12290. /**
  12291. * Detach the current controls from the specified dom element.
  12292. * @param element Defines the element to stop listening the inputs from
  12293. */
  12294. detachControl(element: Nullable<HTMLElement>): void;
  12295. /**
  12296. * Update the current camera state depending on the inputs that have been used this frame.
  12297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12298. */
  12299. checkInputs(): void;
  12300. /**
  12301. * Gets the class name of the current intput.
  12302. * @returns the class name
  12303. */
  12304. getClassName(): string;
  12305. /**
  12306. * Get the friendly name associated with the input class.
  12307. * @returns the input friendly name
  12308. */
  12309. getSimpleName(): string;
  12310. }
  12311. }
  12312. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12313. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12314. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12315. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12316. import { Nullable } from "babylonjs/types";
  12317. /**
  12318. * Default Inputs manager for the FreeCamera.
  12319. * It groups all the default supported inputs for ease of use.
  12320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12321. */
  12322. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12323. /**
  12324. * @hidden
  12325. */
  12326. _mouseInput: Nullable<FreeCameraMouseInput>;
  12327. /**
  12328. * Instantiates a new FreeCameraInputsManager.
  12329. * @param camera Defines the camera the inputs belong to
  12330. */
  12331. constructor(camera: FreeCamera);
  12332. /**
  12333. * Add keyboard input support to the input manager.
  12334. * @returns the current input manager
  12335. */
  12336. addKeyboard(): FreeCameraInputsManager;
  12337. /**
  12338. * Add mouse input support to the input manager.
  12339. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12340. * @returns the current input manager
  12341. */
  12342. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12343. /**
  12344. * Removes the mouse input support from the manager
  12345. * @returns the current input manager
  12346. */
  12347. removeMouse(): FreeCameraInputsManager;
  12348. /**
  12349. * Add touch input support to the input manager.
  12350. * @returns the current input manager
  12351. */
  12352. addTouch(): FreeCameraInputsManager;
  12353. /**
  12354. * Remove all attached input methods from a camera
  12355. */
  12356. clear(): void;
  12357. }
  12358. }
  12359. declare module "babylonjs/Cameras/freeCamera" {
  12360. import { Vector3 } from "babylonjs/Maths/math.vector";
  12361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12362. import { Scene } from "babylonjs/scene";
  12363. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12364. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12365. /**
  12366. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12367. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12368. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12369. */
  12370. export class FreeCamera extends TargetCamera {
  12371. /**
  12372. * Define the collision ellipsoid of the camera.
  12373. * This is helpful to simulate a camera body like the player body around the camera
  12374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12375. */
  12376. ellipsoid: Vector3;
  12377. /**
  12378. * Define an offset for the position of the ellipsoid around the camera.
  12379. * This can be helpful to determine the center of the body near the gravity center of the body
  12380. * instead of its head.
  12381. */
  12382. ellipsoidOffset: Vector3;
  12383. /**
  12384. * Enable or disable collisions of the camera with the rest of the scene objects.
  12385. */
  12386. checkCollisions: boolean;
  12387. /**
  12388. * Enable or disable gravity on the camera.
  12389. */
  12390. applyGravity: boolean;
  12391. /**
  12392. * Define the input manager associated to the camera.
  12393. */
  12394. inputs: FreeCameraInputsManager;
  12395. /**
  12396. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12397. * Higher values reduce sensitivity.
  12398. */
  12399. /**
  12400. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12401. * Higher values reduce sensitivity.
  12402. */
  12403. angularSensibility: number;
  12404. /**
  12405. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12406. */
  12407. keysUp: number[];
  12408. /**
  12409. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12410. */
  12411. keysDown: number[];
  12412. /**
  12413. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12414. */
  12415. keysLeft: number[];
  12416. /**
  12417. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12418. */
  12419. keysRight: number[];
  12420. /**
  12421. * Event raised when the camera collide with a mesh in the scene.
  12422. */
  12423. onCollide: (collidedMesh: AbstractMesh) => void;
  12424. private _collider;
  12425. private _needMoveForGravity;
  12426. private _oldPosition;
  12427. private _diffPosition;
  12428. private _newPosition;
  12429. /** @hidden */
  12430. _localDirection: Vector3;
  12431. /** @hidden */
  12432. _transformedDirection: Vector3;
  12433. /**
  12434. * Instantiates a Free Camera.
  12435. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12436. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12437. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12438. * @param name Define the name of the camera in the scene
  12439. * @param position Define the start position of the camera in the scene
  12440. * @param scene Define the scene the camera belongs to
  12441. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12442. */
  12443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12444. /**
  12445. * Attached controls to the current camera.
  12446. * @param element Defines the element the controls should be listened from
  12447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12448. */
  12449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12450. /**
  12451. * Detach the current controls from the camera.
  12452. * The camera will stop reacting to inputs.
  12453. * @param element Defines the element to stop listening the inputs from
  12454. */
  12455. detachControl(element: HTMLElement): void;
  12456. private _collisionMask;
  12457. /**
  12458. * Define a collision mask to limit the list of object the camera can collide with
  12459. */
  12460. collisionMask: number;
  12461. /** @hidden */
  12462. _collideWithWorld(displacement: Vector3): void;
  12463. private _onCollisionPositionChange;
  12464. /** @hidden */
  12465. _checkInputs(): void;
  12466. /** @hidden */
  12467. _decideIfNeedsToMove(): boolean;
  12468. /** @hidden */
  12469. _updatePosition(): void;
  12470. /**
  12471. * Destroy the camera and release the current resources hold by it.
  12472. */
  12473. dispose(): void;
  12474. /**
  12475. * Gets the current object class name.
  12476. * @return the class name
  12477. */
  12478. getClassName(): string;
  12479. }
  12480. }
  12481. declare module "babylonjs/Gamepads/gamepad" {
  12482. import { Observable } from "babylonjs/Misc/observable";
  12483. /**
  12484. * Represents a gamepad control stick position
  12485. */
  12486. export class StickValues {
  12487. /**
  12488. * The x component of the control stick
  12489. */
  12490. x: number;
  12491. /**
  12492. * The y component of the control stick
  12493. */
  12494. y: number;
  12495. /**
  12496. * Initializes the gamepad x and y control stick values
  12497. * @param x The x component of the gamepad control stick value
  12498. * @param y The y component of the gamepad control stick value
  12499. */
  12500. constructor(
  12501. /**
  12502. * The x component of the control stick
  12503. */
  12504. x: number,
  12505. /**
  12506. * The y component of the control stick
  12507. */
  12508. y: number);
  12509. }
  12510. /**
  12511. * An interface which manages callbacks for gamepad button changes
  12512. */
  12513. export interface GamepadButtonChanges {
  12514. /**
  12515. * Called when a gamepad has been changed
  12516. */
  12517. changed: boolean;
  12518. /**
  12519. * Called when a gamepad press event has been triggered
  12520. */
  12521. pressChanged: boolean;
  12522. /**
  12523. * Called when a touch event has been triggered
  12524. */
  12525. touchChanged: boolean;
  12526. /**
  12527. * Called when a value has changed
  12528. */
  12529. valueChanged: boolean;
  12530. }
  12531. /**
  12532. * Represents a gamepad
  12533. */
  12534. export class Gamepad {
  12535. /**
  12536. * The id of the gamepad
  12537. */
  12538. id: string;
  12539. /**
  12540. * The index of the gamepad
  12541. */
  12542. index: number;
  12543. /**
  12544. * The browser gamepad
  12545. */
  12546. browserGamepad: any;
  12547. /**
  12548. * Specifies what type of gamepad this represents
  12549. */
  12550. type: number;
  12551. private _leftStick;
  12552. private _rightStick;
  12553. /** @hidden */
  12554. _isConnected: boolean;
  12555. private _leftStickAxisX;
  12556. private _leftStickAxisY;
  12557. private _rightStickAxisX;
  12558. private _rightStickAxisY;
  12559. /**
  12560. * Triggered when the left control stick has been changed
  12561. */
  12562. private _onleftstickchanged;
  12563. /**
  12564. * Triggered when the right control stick has been changed
  12565. */
  12566. private _onrightstickchanged;
  12567. /**
  12568. * Represents a gamepad controller
  12569. */
  12570. static GAMEPAD: number;
  12571. /**
  12572. * Represents a generic controller
  12573. */
  12574. static GENERIC: number;
  12575. /**
  12576. * Represents an XBox controller
  12577. */
  12578. static XBOX: number;
  12579. /**
  12580. * Represents a pose-enabled controller
  12581. */
  12582. static POSE_ENABLED: number;
  12583. /**
  12584. * Represents an Dual Shock controller
  12585. */
  12586. static DUALSHOCK: number;
  12587. /**
  12588. * Specifies whether the left control stick should be Y-inverted
  12589. */
  12590. protected _invertLeftStickY: boolean;
  12591. /**
  12592. * Specifies if the gamepad has been connected
  12593. */
  12594. readonly isConnected: boolean;
  12595. /**
  12596. * Initializes the gamepad
  12597. * @param id The id of the gamepad
  12598. * @param index The index of the gamepad
  12599. * @param browserGamepad The browser gamepad
  12600. * @param leftStickX The x component of the left joystick
  12601. * @param leftStickY The y component of the left joystick
  12602. * @param rightStickX The x component of the right joystick
  12603. * @param rightStickY The y component of the right joystick
  12604. */
  12605. constructor(
  12606. /**
  12607. * The id of the gamepad
  12608. */
  12609. id: string,
  12610. /**
  12611. * The index of the gamepad
  12612. */
  12613. index: number,
  12614. /**
  12615. * The browser gamepad
  12616. */
  12617. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12618. /**
  12619. * Callback triggered when the left joystick has changed
  12620. * @param callback
  12621. */
  12622. onleftstickchanged(callback: (values: StickValues) => void): void;
  12623. /**
  12624. * Callback triggered when the right joystick has changed
  12625. * @param callback
  12626. */
  12627. onrightstickchanged(callback: (values: StickValues) => void): void;
  12628. /**
  12629. * Gets the left joystick
  12630. */
  12631. /**
  12632. * Sets the left joystick values
  12633. */
  12634. leftStick: StickValues;
  12635. /**
  12636. * Gets the right joystick
  12637. */
  12638. /**
  12639. * Sets the right joystick value
  12640. */
  12641. rightStick: StickValues;
  12642. /**
  12643. * Updates the gamepad joystick positions
  12644. */
  12645. update(): void;
  12646. /**
  12647. * Disposes the gamepad
  12648. */
  12649. dispose(): void;
  12650. }
  12651. /**
  12652. * Represents a generic gamepad
  12653. */
  12654. export class GenericPad extends Gamepad {
  12655. private _buttons;
  12656. private _onbuttondown;
  12657. private _onbuttonup;
  12658. /**
  12659. * Observable triggered when a button has been pressed
  12660. */
  12661. onButtonDownObservable: Observable<number>;
  12662. /**
  12663. * Observable triggered when a button has been released
  12664. */
  12665. onButtonUpObservable: Observable<number>;
  12666. /**
  12667. * Callback triggered when a button has been pressed
  12668. * @param callback Called when a button has been pressed
  12669. */
  12670. onbuttondown(callback: (buttonPressed: number) => void): void;
  12671. /**
  12672. * Callback triggered when a button has been released
  12673. * @param callback Called when a button has been released
  12674. */
  12675. onbuttonup(callback: (buttonReleased: number) => void): void;
  12676. /**
  12677. * Initializes the generic gamepad
  12678. * @param id The id of the generic gamepad
  12679. * @param index The index of the generic gamepad
  12680. * @param browserGamepad The browser gamepad
  12681. */
  12682. constructor(id: string, index: number, browserGamepad: any);
  12683. private _setButtonValue;
  12684. /**
  12685. * Updates the generic gamepad
  12686. */
  12687. update(): void;
  12688. /**
  12689. * Disposes the generic gamepad
  12690. */
  12691. dispose(): void;
  12692. }
  12693. }
  12694. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12695. import { Nullable } from "babylonjs/types";
  12696. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12697. import { Scene } from "babylonjs/scene";
  12698. module "babylonjs/Engines/engine" {
  12699. interface Engine {
  12700. /**
  12701. * Creates a raw texture
  12702. * @param data defines the data to store in the texture
  12703. * @param width defines the width of the texture
  12704. * @param height defines the height of the texture
  12705. * @param format defines the format of the data
  12706. * @param generateMipMaps defines if the engine should generate the mip levels
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12709. * @param compression defines the compression used (null by default)
  12710. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12711. * @returns the raw texture inside an InternalTexture
  12712. */
  12713. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12714. /**
  12715. * Update a raw texture
  12716. * @param texture defines the texture to update
  12717. * @param data defines the data to store in the texture
  12718. * @param format defines the format of the data
  12719. * @param invertY defines if data must be stored with Y axis inverted
  12720. */
  12721. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12722. /**
  12723. * Update a raw texture
  12724. * @param texture defines the texture to update
  12725. * @param data defines the data to store in the texture
  12726. * @param format defines the format of the data
  12727. * @param invertY defines if data must be stored with Y axis inverted
  12728. * @param compression defines the compression used (null by default)
  12729. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12730. */
  12731. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12732. /**
  12733. * Creates a new raw cube texture
  12734. * @param data defines the array of data to use to create each face
  12735. * @param size defines the size of the textures
  12736. * @param format defines the format of the data
  12737. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12738. * @param generateMipMaps defines if the engine should generate the mip levels
  12739. * @param invertY defines if data must be stored with Y axis inverted
  12740. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12741. * @param compression defines the compression used (null by default)
  12742. * @returns the cube texture as an InternalTexture
  12743. */
  12744. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12745. /**
  12746. * Update a raw cube texture
  12747. * @param texture defines the texture to udpdate
  12748. * @param data defines the data to store
  12749. * @param format defines the data format
  12750. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12751. * @param invertY defines if data must be stored with Y axis inverted
  12752. */
  12753. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12754. /**
  12755. * Update a raw cube texture
  12756. * @param texture defines the texture to udpdate
  12757. * @param data defines the data to store
  12758. * @param format defines the data format
  12759. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12760. * @param invertY defines if data must be stored with Y axis inverted
  12761. * @param compression defines the compression used (null by default)
  12762. */
  12763. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12764. /**
  12765. * Update a raw cube texture
  12766. * @param texture defines the texture to udpdate
  12767. * @param data defines the data to store
  12768. * @param format defines the data format
  12769. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12770. * @param invertY defines if data must be stored with Y axis inverted
  12771. * @param compression defines the compression used (null by default)
  12772. * @param level defines which level of the texture to update
  12773. */
  12774. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12775. /**
  12776. * Creates a new raw cube texture from a specified url
  12777. * @param url defines the url where the data is located
  12778. * @param scene defines the current scene
  12779. * @param size defines the size of the textures
  12780. * @param format defines the format of the data
  12781. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12782. * @param noMipmap defines if the engine should avoid generating the mip levels
  12783. * @param callback defines a callback used to extract texture data from loaded data
  12784. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12785. * @param onLoad defines a callback called when texture is loaded
  12786. * @param onError defines a callback called if there is an error
  12787. * @returns the cube texture as an InternalTexture
  12788. */
  12789. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12790. /**
  12791. * Creates a new raw cube texture from a specified url
  12792. * @param url defines the url where the data is located
  12793. * @param scene defines the current scene
  12794. * @param size defines the size of the textures
  12795. * @param format defines the format of the data
  12796. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12797. * @param noMipmap defines if the engine should avoid generating the mip levels
  12798. * @param callback defines a callback used to extract texture data from loaded data
  12799. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12800. * @param onLoad defines a callback called when texture is loaded
  12801. * @param onError defines a callback called if there is an error
  12802. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12803. * @param invertY defines if data must be stored with Y axis inverted
  12804. * @returns the cube texture as an InternalTexture
  12805. */
  12806. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12807. /**
  12808. * Creates a new raw 3D texture
  12809. * @param data defines the data used to create the texture
  12810. * @param width defines the width of the texture
  12811. * @param height defines the height of the texture
  12812. * @param depth defines the depth of the texture
  12813. * @param format defines the format of the texture
  12814. * @param generateMipMaps defines if the engine must generate mip levels
  12815. * @param invertY defines if data must be stored with Y axis inverted
  12816. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12817. * @param compression defines the compressed used (can be null)
  12818. * @param textureType defines the compressed used (can be null)
  12819. * @returns a new raw 3D texture (stored in an InternalTexture)
  12820. */
  12821. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12822. /**
  12823. * Update a raw 3D texture
  12824. * @param texture defines the texture to update
  12825. * @param data defines the data to store
  12826. * @param format defines the data format
  12827. * @param invertY defines if data must be stored with Y axis inverted
  12828. */
  12829. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12830. /**
  12831. * Update a raw 3D texture
  12832. * @param texture defines the texture to update
  12833. * @param data defines the data to store
  12834. * @param format defines the data format
  12835. * @param invertY defines if data must be stored with Y axis inverted
  12836. * @param compression defines the used compression (can be null)
  12837. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12838. */
  12839. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12840. /**
  12841. * Creates a new raw 2D array texture
  12842. * @param data defines the data used to create the texture
  12843. * @param width defines the width of the texture
  12844. * @param height defines the height of the texture
  12845. * @param depth defines the number of layers of the texture
  12846. * @param format defines the format of the texture
  12847. * @param generateMipMaps defines if the engine must generate mip levels
  12848. * @param invertY defines if data must be stored with Y axis inverted
  12849. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12850. * @param compression defines the compressed used (can be null)
  12851. * @param textureType defines the compressed used (can be null)
  12852. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12853. */
  12854. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12855. /**
  12856. * Update a raw 2D array texture
  12857. * @param texture defines the texture to update
  12858. * @param data defines the data to store
  12859. * @param format defines the data format
  12860. * @param invertY defines if data must be stored with Y axis inverted
  12861. */
  12862. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12863. /**
  12864. * Update a raw 2D array texture
  12865. * @param texture defines the texture to update
  12866. * @param data defines the data to store
  12867. * @param format defines the data format
  12868. * @param invertY defines if data must be stored with Y axis inverted
  12869. * @param compression defines the used compression (can be null)
  12870. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12871. */
  12872. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12873. }
  12874. }
  12875. }
  12876. declare module "babylonjs/Materials/Textures/rawTexture" {
  12877. import { Scene } from "babylonjs/scene";
  12878. import { Texture } from "babylonjs/Materials/Textures/texture";
  12879. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12880. /**
  12881. * Raw texture can help creating a texture directly from an array of data.
  12882. * This can be super useful if you either get the data from an uncompressed source or
  12883. * if you wish to create your texture pixel by pixel.
  12884. */
  12885. export class RawTexture extends Texture {
  12886. /**
  12887. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12888. */
  12889. format: number;
  12890. private _engine;
  12891. /**
  12892. * Instantiates a new RawTexture.
  12893. * Raw texture can help creating a texture directly from an array of data.
  12894. * This can be super useful if you either get the data from an uncompressed source or
  12895. * if you wish to create your texture pixel by pixel.
  12896. * @param data define the array of data to use to create the texture
  12897. * @param width define the width of the texture
  12898. * @param height define the height of the texture
  12899. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12900. * @param scene define the scene the texture belongs to
  12901. * @param generateMipMaps define whether mip maps should be generated or not
  12902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12904. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12905. */
  12906. constructor(data: ArrayBufferView, width: number, height: number,
  12907. /**
  12908. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12909. */
  12910. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12911. /**
  12912. * Updates the texture underlying data.
  12913. * @param data Define the new data of the texture
  12914. */
  12915. update(data: ArrayBufferView): void;
  12916. /**
  12917. * Creates a luminance texture from some data.
  12918. * @param data Define the texture data
  12919. * @param width Define the width of the texture
  12920. * @param height Define the height of the texture
  12921. * @param scene Define the scene the texture belongs to
  12922. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12923. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12924. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12925. * @returns the luminance texture
  12926. */
  12927. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12928. /**
  12929. * Creates a luminance alpha texture from some data.
  12930. * @param data Define the texture data
  12931. * @param width Define the width of the texture
  12932. * @param height Define the height of the texture
  12933. * @param scene Define the scene the texture belongs to
  12934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12937. * @returns the luminance alpha texture
  12938. */
  12939. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12940. /**
  12941. * Creates an alpha texture from some data.
  12942. * @param data Define the texture data
  12943. * @param width Define the width of the texture
  12944. * @param height Define the height of the texture
  12945. * @param scene Define the scene the texture belongs to
  12946. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12947. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12948. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12949. * @returns the alpha texture
  12950. */
  12951. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12952. /**
  12953. * Creates a RGB texture from some data.
  12954. * @param data Define the texture data
  12955. * @param width Define the width of the texture
  12956. * @param height Define the height of the texture
  12957. * @param scene Define the scene the texture belongs to
  12958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12962. * @returns the RGB alpha texture
  12963. */
  12964. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12965. /**
  12966. * Creates a RGBA texture from some data.
  12967. * @param data Define the texture data
  12968. * @param width Define the width of the texture
  12969. * @param height Define the height of the texture
  12970. * @param scene Define the scene the texture belongs to
  12971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12975. * @returns the RGBA texture
  12976. */
  12977. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12978. /**
  12979. * Creates a R texture from some data.
  12980. * @param data Define the texture data
  12981. * @param width Define the width of the texture
  12982. * @param height Define the height of the texture
  12983. * @param scene Define the scene the texture belongs to
  12984. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12985. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12986. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12987. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12988. * @returns the R texture
  12989. */
  12990. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12991. }
  12992. }
  12993. declare module "babylonjs/Maths/math.size" {
  12994. /**
  12995. * Interface for the size containing width and height
  12996. */
  12997. export interface ISize {
  12998. /**
  12999. * Width
  13000. */
  13001. width: number;
  13002. /**
  13003. * Heighht
  13004. */
  13005. height: number;
  13006. }
  13007. /**
  13008. * Size containing widht and height
  13009. */
  13010. export class Size implements ISize {
  13011. /**
  13012. * Width
  13013. */
  13014. width: number;
  13015. /**
  13016. * Height
  13017. */
  13018. height: number;
  13019. /**
  13020. * Creates a Size object from the given width and height (floats).
  13021. * @param width width of the new size
  13022. * @param height height of the new size
  13023. */
  13024. constructor(width: number, height: number);
  13025. /**
  13026. * Returns a string with the Size width and height
  13027. * @returns a string with the Size width and height
  13028. */
  13029. toString(): string;
  13030. /**
  13031. * "Size"
  13032. * @returns the string "Size"
  13033. */
  13034. getClassName(): string;
  13035. /**
  13036. * Returns the Size hash code.
  13037. * @returns a hash code for a unique width and height
  13038. */
  13039. getHashCode(): number;
  13040. /**
  13041. * Updates the current size from the given one.
  13042. * @param src the given size
  13043. */
  13044. copyFrom(src: Size): void;
  13045. /**
  13046. * Updates in place the current Size from the given floats.
  13047. * @param width width of the new size
  13048. * @param height height of the new size
  13049. * @returns the updated Size.
  13050. */
  13051. copyFromFloats(width: number, height: number): Size;
  13052. /**
  13053. * Updates in place the current Size from the given floats.
  13054. * @param width width to set
  13055. * @param height height to set
  13056. * @returns the updated Size.
  13057. */
  13058. set(width: number, height: number): Size;
  13059. /**
  13060. * Multiplies the width and height by numbers
  13061. * @param w factor to multiple the width by
  13062. * @param h factor to multiple the height by
  13063. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13064. */
  13065. multiplyByFloats(w: number, h: number): Size;
  13066. /**
  13067. * Clones the size
  13068. * @returns a new Size copied from the given one.
  13069. */
  13070. clone(): Size;
  13071. /**
  13072. * True if the current Size and the given one width and height are strictly equal.
  13073. * @param other the other size to compare against
  13074. * @returns True if the current Size and the given one width and height are strictly equal.
  13075. */
  13076. equals(other: Size): boolean;
  13077. /**
  13078. * The surface of the Size : width * height (float).
  13079. */
  13080. readonly surface: number;
  13081. /**
  13082. * Create a new size of zero
  13083. * @returns a new Size set to (0.0, 0.0)
  13084. */
  13085. static Zero(): Size;
  13086. /**
  13087. * Sums the width and height of two sizes
  13088. * @param otherSize size to add to this size
  13089. * @returns a new Size set as the addition result of the current Size and the given one.
  13090. */
  13091. add(otherSize: Size): Size;
  13092. /**
  13093. * Subtracts the width and height of two
  13094. * @param otherSize size to subtract to this size
  13095. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13096. */
  13097. subtract(otherSize: Size): Size;
  13098. /**
  13099. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13100. * @param start starting size to lerp between
  13101. * @param end end size to lerp between
  13102. * @param amount amount to lerp between the start and end values
  13103. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13104. */
  13105. static Lerp(start: Size, end: Size, amount: number): Size;
  13106. }
  13107. }
  13108. declare module "babylonjs/Animations/runtimeAnimation" {
  13109. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13110. import { Animatable } from "babylonjs/Animations/animatable";
  13111. import { Scene } from "babylonjs/scene";
  13112. /**
  13113. * Defines a runtime animation
  13114. */
  13115. export class RuntimeAnimation {
  13116. private _events;
  13117. /**
  13118. * The current frame of the runtime animation
  13119. */
  13120. private _currentFrame;
  13121. /**
  13122. * The animation used by the runtime animation
  13123. */
  13124. private _animation;
  13125. /**
  13126. * The target of the runtime animation
  13127. */
  13128. private _target;
  13129. /**
  13130. * The initiating animatable
  13131. */
  13132. private _host;
  13133. /**
  13134. * The original value of the runtime animation
  13135. */
  13136. private _originalValue;
  13137. /**
  13138. * The original blend value of the runtime animation
  13139. */
  13140. private _originalBlendValue;
  13141. /**
  13142. * The offsets cache of the runtime animation
  13143. */
  13144. private _offsetsCache;
  13145. /**
  13146. * The high limits cache of the runtime animation
  13147. */
  13148. private _highLimitsCache;
  13149. /**
  13150. * Specifies if the runtime animation has been stopped
  13151. */
  13152. private _stopped;
  13153. /**
  13154. * The blending factor of the runtime animation
  13155. */
  13156. private _blendingFactor;
  13157. /**
  13158. * The BabylonJS scene
  13159. */
  13160. private _scene;
  13161. /**
  13162. * The current value of the runtime animation
  13163. */
  13164. private _currentValue;
  13165. /** @hidden */
  13166. _animationState: _IAnimationState;
  13167. /**
  13168. * The active target of the runtime animation
  13169. */
  13170. private _activeTargets;
  13171. private _currentActiveTarget;
  13172. private _directTarget;
  13173. /**
  13174. * The target path of the runtime animation
  13175. */
  13176. private _targetPath;
  13177. /**
  13178. * The weight of the runtime animation
  13179. */
  13180. private _weight;
  13181. /**
  13182. * The ratio offset of the runtime animation
  13183. */
  13184. private _ratioOffset;
  13185. /**
  13186. * The previous delay of the runtime animation
  13187. */
  13188. private _previousDelay;
  13189. /**
  13190. * The previous ratio of the runtime animation
  13191. */
  13192. private _previousRatio;
  13193. private _enableBlending;
  13194. private _keys;
  13195. private _minFrame;
  13196. private _maxFrame;
  13197. private _minValue;
  13198. private _maxValue;
  13199. private _targetIsArray;
  13200. /**
  13201. * Gets the current frame of the runtime animation
  13202. */
  13203. readonly currentFrame: number;
  13204. /**
  13205. * Gets the weight of the runtime animation
  13206. */
  13207. readonly weight: number;
  13208. /**
  13209. * Gets the current value of the runtime animation
  13210. */
  13211. readonly currentValue: any;
  13212. /**
  13213. * Gets the target path of the runtime animation
  13214. */
  13215. readonly targetPath: string;
  13216. /**
  13217. * Gets the actual target of the runtime animation
  13218. */
  13219. readonly target: any;
  13220. /** @hidden */
  13221. _onLoop: () => void;
  13222. /**
  13223. * Create a new RuntimeAnimation object
  13224. * @param target defines the target of the animation
  13225. * @param animation defines the source animation object
  13226. * @param scene defines the hosting scene
  13227. * @param host defines the initiating Animatable
  13228. */
  13229. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13230. private _preparePath;
  13231. /**
  13232. * Gets the animation from the runtime animation
  13233. */
  13234. readonly animation: Animation;
  13235. /**
  13236. * Resets the runtime animation to the beginning
  13237. * @param restoreOriginal defines whether to restore the target property to the original value
  13238. */
  13239. reset(restoreOriginal?: boolean): void;
  13240. /**
  13241. * Specifies if the runtime animation is stopped
  13242. * @returns Boolean specifying if the runtime animation is stopped
  13243. */
  13244. isStopped(): boolean;
  13245. /**
  13246. * Disposes of the runtime animation
  13247. */
  13248. dispose(): void;
  13249. /**
  13250. * Apply the interpolated value to the target
  13251. * @param currentValue defines the value computed by the animation
  13252. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13253. */
  13254. setValue(currentValue: any, weight: number): void;
  13255. private _getOriginalValues;
  13256. private _setValue;
  13257. /**
  13258. * Gets the loop pmode of the runtime animation
  13259. * @returns Loop Mode
  13260. */
  13261. private _getCorrectLoopMode;
  13262. /**
  13263. * Move the current animation to a given frame
  13264. * @param frame defines the frame to move to
  13265. */
  13266. goToFrame(frame: number): void;
  13267. /**
  13268. * @hidden Internal use only
  13269. */
  13270. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13271. /**
  13272. * Execute the current animation
  13273. * @param delay defines the delay to add to the current frame
  13274. * @param from defines the lower bound of the animation range
  13275. * @param to defines the upper bound of the animation range
  13276. * @param loop defines if the current animation must loop
  13277. * @param speedRatio defines the current speed ratio
  13278. * @param weight defines the weight of the animation (default is -1 so no weight)
  13279. * @param onLoop optional callback called when animation loops
  13280. * @returns a boolean indicating if the animation is running
  13281. */
  13282. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13283. }
  13284. }
  13285. declare module "babylonjs/Animations/animatable" {
  13286. import { Animation } from "babylonjs/Animations/animation";
  13287. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13288. import { Nullable } from "babylonjs/types";
  13289. import { Observable } from "babylonjs/Misc/observable";
  13290. import { Scene } from "babylonjs/scene";
  13291. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13292. import { Node } from "babylonjs/node";
  13293. /**
  13294. * Class used to store an actual running animation
  13295. */
  13296. export class Animatable {
  13297. /** defines the target object */
  13298. target: any;
  13299. /** defines the starting frame number (default is 0) */
  13300. fromFrame: number;
  13301. /** defines the ending frame number (default is 100) */
  13302. toFrame: number;
  13303. /** defines if the animation must loop (default is false) */
  13304. loopAnimation: boolean;
  13305. /** defines a callback to call when animation ends if it is not looping */
  13306. onAnimationEnd?: (() => void) | null | undefined;
  13307. /** defines a callback to call when animation loops */
  13308. onAnimationLoop?: (() => void) | null | undefined;
  13309. private _localDelayOffset;
  13310. private _pausedDelay;
  13311. private _runtimeAnimations;
  13312. private _paused;
  13313. private _scene;
  13314. private _speedRatio;
  13315. private _weight;
  13316. private _syncRoot;
  13317. /**
  13318. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13319. * This will only apply for non looping animation (default is true)
  13320. */
  13321. disposeOnEnd: boolean;
  13322. /**
  13323. * Gets a boolean indicating if the animation has started
  13324. */
  13325. animationStarted: boolean;
  13326. /**
  13327. * Observer raised when the animation ends
  13328. */
  13329. onAnimationEndObservable: Observable<Animatable>;
  13330. /**
  13331. * Observer raised when the animation loops
  13332. */
  13333. onAnimationLoopObservable: Observable<Animatable>;
  13334. /**
  13335. * Gets the root Animatable used to synchronize and normalize animations
  13336. */
  13337. readonly syncRoot: Nullable<Animatable>;
  13338. /**
  13339. * Gets the current frame of the first RuntimeAnimation
  13340. * Used to synchronize Animatables
  13341. */
  13342. readonly masterFrame: number;
  13343. /**
  13344. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13345. */
  13346. weight: number;
  13347. /**
  13348. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13349. */
  13350. speedRatio: number;
  13351. /**
  13352. * Creates a new Animatable
  13353. * @param scene defines the hosting scene
  13354. * @param target defines the target object
  13355. * @param fromFrame defines the starting frame number (default is 0)
  13356. * @param toFrame defines the ending frame number (default is 100)
  13357. * @param loopAnimation defines if the animation must loop (default is false)
  13358. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13359. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13360. * @param animations defines a group of animation to add to the new Animatable
  13361. * @param onAnimationLoop defines a callback to call when animation loops
  13362. */
  13363. constructor(scene: Scene,
  13364. /** defines the target object */
  13365. target: any,
  13366. /** defines the starting frame number (default is 0) */
  13367. fromFrame?: number,
  13368. /** defines the ending frame number (default is 100) */
  13369. toFrame?: number,
  13370. /** defines if the animation must loop (default is false) */
  13371. loopAnimation?: boolean, speedRatio?: number,
  13372. /** defines a callback to call when animation ends if it is not looping */
  13373. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13374. /** defines a callback to call when animation loops */
  13375. onAnimationLoop?: (() => void) | null | undefined);
  13376. /**
  13377. * Synchronize and normalize current Animatable with a source Animatable
  13378. * This is useful when using animation weights and when animations are not of the same length
  13379. * @param root defines the root Animatable to synchronize with
  13380. * @returns the current Animatable
  13381. */
  13382. syncWith(root: Animatable): Animatable;
  13383. /**
  13384. * Gets the list of runtime animations
  13385. * @returns an array of RuntimeAnimation
  13386. */
  13387. getAnimations(): RuntimeAnimation[];
  13388. /**
  13389. * Adds more animations to the current animatable
  13390. * @param target defines the target of the animations
  13391. * @param animations defines the new animations to add
  13392. */
  13393. appendAnimations(target: any, animations: Animation[]): void;
  13394. /**
  13395. * Gets the source animation for a specific property
  13396. * @param property defines the propertyu to look for
  13397. * @returns null or the source animation for the given property
  13398. */
  13399. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13400. /**
  13401. * Gets the runtime animation for a specific property
  13402. * @param property defines the propertyu to look for
  13403. * @returns null or the runtime animation for the given property
  13404. */
  13405. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13406. /**
  13407. * Resets the animatable to its original state
  13408. */
  13409. reset(): void;
  13410. /**
  13411. * Allows the animatable to blend with current running animations
  13412. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13413. * @param blendingSpeed defines the blending speed to use
  13414. */
  13415. enableBlending(blendingSpeed: number): void;
  13416. /**
  13417. * Disable animation blending
  13418. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13419. */
  13420. disableBlending(): void;
  13421. /**
  13422. * Jump directly to a given frame
  13423. * @param frame defines the frame to jump to
  13424. */
  13425. goToFrame(frame: number): void;
  13426. /**
  13427. * Pause the animation
  13428. */
  13429. pause(): void;
  13430. /**
  13431. * Restart the animation
  13432. */
  13433. restart(): void;
  13434. private _raiseOnAnimationEnd;
  13435. /**
  13436. * Stop and delete the current animation
  13437. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13438. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13439. */
  13440. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13441. /**
  13442. * Wait asynchronously for the animation to end
  13443. * @returns a promise which will be fullfilled when the animation ends
  13444. */
  13445. waitAsync(): Promise<Animatable>;
  13446. /** @hidden */
  13447. _animate(delay: number): boolean;
  13448. }
  13449. module "babylonjs/scene" {
  13450. interface Scene {
  13451. /** @hidden */
  13452. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13453. /** @hidden */
  13454. _processLateAnimationBindingsForMatrices(holder: {
  13455. totalWeight: number;
  13456. animations: RuntimeAnimation[];
  13457. originalValue: Matrix;
  13458. }): any;
  13459. /** @hidden */
  13460. _processLateAnimationBindingsForQuaternions(holder: {
  13461. totalWeight: number;
  13462. animations: RuntimeAnimation[];
  13463. originalValue: Quaternion;
  13464. }, refQuaternion: Quaternion): Quaternion;
  13465. /** @hidden */
  13466. _processLateAnimationBindings(): void;
  13467. /**
  13468. * Will start the animation sequence of a given target
  13469. * @param target defines the target
  13470. * @param from defines from which frame should animation start
  13471. * @param to defines until which frame should animation run.
  13472. * @param weight defines the weight to apply to the animation (1.0 by default)
  13473. * @param loop defines if the animation loops
  13474. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13475. * @param onAnimationEnd defines the function to be executed when the animation ends
  13476. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13477. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13478. * @param onAnimationLoop defines the callback to call when an animation loops
  13479. * @returns the animatable object created for this animation
  13480. */
  13481. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13482. /**
  13483. * Will start the animation sequence of a given target
  13484. * @param target defines the target
  13485. * @param from defines from which frame should animation start
  13486. * @param to defines until which frame should animation run.
  13487. * @param loop defines if the animation loops
  13488. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13489. * @param onAnimationEnd defines the function to be executed when the animation ends
  13490. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13491. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13492. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13493. * @param onAnimationLoop defines the callback to call when an animation loops
  13494. * @returns the animatable object created for this animation
  13495. */
  13496. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13497. /**
  13498. * Will start the animation sequence of a given target and its hierarchy
  13499. * @param target defines the target
  13500. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13501. * @param from defines from which frame should animation start
  13502. * @param to defines until which frame should animation run.
  13503. * @param loop defines if the animation loops
  13504. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13505. * @param onAnimationEnd defines the function to be executed when the animation ends
  13506. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13507. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13508. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13509. * @param onAnimationLoop defines the callback to call when an animation loops
  13510. * @returns the list of created animatables
  13511. */
  13512. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13513. /**
  13514. * Begin a new animation on a given node
  13515. * @param target defines the target where the animation will take place
  13516. * @param animations defines the list of animations to start
  13517. * @param from defines the initial value
  13518. * @param to defines the final value
  13519. * @param loop defines if you want animation to loop (off by default)
  13520. * @param speedRatio defines the speed ratio to apply to all animations
  13521. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13522. * @param onAnimationLoop defines the callback to call when an animation loops
  13523. * @returns the list of created animatables
  13524. */
  13525. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13526. /**
  13527. * Begin a new animation on a given node and its hierarchy
  13528. * @param target defines the root node where the animation will take place
  13529. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13530. * @param animations defines the list of animations to start
  13531. * @param from defines the initial value
  13532. * @param to defines the final value
  13533. * @param loop defines if you want animation to loop (off by default)
  13534. * @param speedRatio defines the speed ratio to apply to all animations
  13535. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13536. * @param onAnimationLoop defines the callback to call when an animation loops
  13537. * @returns the list of animatables created for all nodes
  13538. */
  13539. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13540. /**
  13541. * Gets the animatable associated with a specific target
  13542. * @param target defines the target of the animatable
  13543. * @returns the required animatable if found
  13544. */
  13545. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13546. /**
  13547. * Gets all animatables associated with a given target
  13548. * @param target defines the target to look animatables for
  13549. * @returns an array of Animatables
  13550. */
  13551. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13552. /**
  13553. * Stops and removes all animations that have been applied to the scene
  13554. */
  13555. stopAllAnimations(): void;
  13556. /**
  13557. * Gets the current delta time used by animation engine
  13558. */
  13559. deltaTime: number;
  13560. }
  13561. }
  13562. module "babylonjs/Bones/bone" {
  13563. interface Bone {
  13564. /**
  13565. * Copy an animation range from another bone
  13566. * @param source defines the source bone
  13567. * @param rangeName defines the range name to copy
  13568. * @param frameOffset defines the frame offset
  13569. * @param rescaleAsRequired defines if rescaling must be applied if required
  13570. * @param skelDimensionsRatio defines the scaling ratio
  13571. * @returns true if operation was successful
  13572. */
  13573. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13574. }
  13575. }
  13576. }
  13577. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13578. /**
  13579. * Class used to override all child animations of a given target
  13580. */
  13581. export class AnimationPropertiesOverride {
  13582. /**
  13583. * Gets or sets a value indicating if animation blending must be used
  13584. */
  13585. enableBlending: boolean;
  13586. /**
  13587. * Gets or sets the blending speed to use when enableBlending is true
  13588. */
  13589. blendingSpeed: number;
  13590. /**
  13591. * Gets or sets the default loop mode to use
  13592. */
  13593. loopMode: number;
  13594. }
  13595. }
  13596. declare module "babylonjs/Bones/skeleton" {
  13597. import { Bone } from "babylonjs/Bones/bone";
  13598. import { Observable } from "babylonjs/Misc/observable";
  13599. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13600. import { Scene } from "babylonjs/scene";
  13601. import { Nullable } from "babylonjs/types";
  13602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13603. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13604. import { Animatable } from "babylonjs/Animations/animatable";
  13605. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13606. import { Animation } from "babylonjs/Animations/animation";
  13607. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13608. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13609. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13610. /**
  13611. * Class used to handle skinning animations
  13612. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13613. */
  13614. export class Skeleton implements IAnimatable {
  13615. /** defines the skeleton name */
  13616. name: string;
  13617. /** defines the skeleton Id */
  13618. id: string;
  13619. /**
  13620. * Defines the list of child bones
  13621. */
  13622. bones: Bone[];
  13623. /**
  13624. * Defines an estimate of the dimension of the skeleton at rest
  13625. */
  13626. dimensionsAtRest: Vector3;
  13627. /**
  13628. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13629. */
  13630. needInitialSkinMatrix: boolean;
  13631. /**
  13632. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13633. */
  13634. overrideMesh: Nullable<AbstractMesh>;
  13635. /**
  13636. * Gets the list of animations attached to this skeleton
  13637. */
  13638. animations: Array<Animation>;
  13639. private _scene;
  13640. private _isDirty;
  13641. private _transformMatrices;
  13642. private _transformMatrixTexture;
  13643. private _meshesWithPoseMatrix;
  13644. private _animatables;
  13645. private _identity;
  13646. private _synchronizedWithMesh;
  13647. private _ranges;
  13648. private _lastAbsoluteTransformsUpdateId;
  13649. private _canUseTextureForBones;
  13650. private _uniqueId;
  13651. /** @hidden */
  13652. _numBonesWithLinkedTransformNode: number;
  13653. /** @hidden */
  13654. _hasWaitingData: Nullable<boolean>;
  13655. /**
  13656. * Specifies if the skeleton should be serialized
  13657. */
  13658. doNotSerialize: boolean;
  13659. private _useTextureToStoreBoneMatrices;
  13660. /**
  13661. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13662. * Please note that this option is not available if the hardware does not support it
  13663. */
  13664. useTextureToStoreBoneMatrices: boolean;
  13665. private _animationPropertiesOverride;
  13666. /**
  13667. * Gets or sets the animation properties override
  13668. */
  13669. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13670. /**
  13671. * List of inspectable custom properties (used by the Inspector)
  13672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13673. */
  13674. inspectableCustomProperties: IInspectable[];
  13675. /**
  13676. * An observable triggered before computing the skeleton's matrices
  13677. */
  13678. onBeforeComputeObservable: Observable<Skeleton>;
  13679. /**
  13680. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13681. */
  13682. readonly isUsingTextureForMatrices: boolean;
  13683. /**
  13684. * Gets the unique ID of this skeleton
  13685. */
  13686. readonly uniqueId: number;
  13687. /**
  13688. * Creates a new skeleton
  13689. * @param name defines the skeleton name
  13690. * @param id defines the skeleton Id
  13691. * @param scene defines the hosting scene
  13692. */
  13693. constructor(
  13694. /** defines the skeleton name */
  13695. name: string,
  13696. /** defines the skeleton Id */
  13697. id: string, scene: Scene);
  13698. /**
  13699. * Gets the current object class name.
  13700. * @return the class name
  13701. */
  13702. getClassName(): string;
  13703. /**
  13704. * Returns an array containing the root bones
  13705. * @returns an array containing the root bones
  13706. */
  13707. getChildren(): Array<Bone>;
  13708. /**
  13709. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13710. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13711. * @returns a Float32Array containing matrices data
  13712. */
  13713. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13714. /**
  13715. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13716. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13717. * @returns a raw texture containing the data
  13718. */
  13719. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13720. /**
  13721. * Gets the current hosting scene
  13722. * @returns a scene object
  13723. */
  13724. getScene(): Scene;
  13725. /**
  13726. * Gets a string representing the current skeleton data
  13727. * @param fullDetails defines a boolean indicating if we want a verbose version
  13728. * @returns a string representing the current skeleton data
  13729. */
  13730. toString(fullDetails?: boolean): string;
  13731. /**
  13732. * Get bone's index searching by name
  13733. * @param name defines bone's name to search for
  13734. * @return the indice of the bone. Returns -1 if not found
  13735. */
  13736. getBoneIndexByName(name: string): number;
  13737. /**
  13738. * Creater a new animation range
  13739. * @param name defines the name of the range
  13740. * @param from defines the start key
  13741. * @param to defines the end key
  13742. */
  13743. createAnimationRange(name: string, from: number, to: number): void;
  13744. /**
  13745. * Delete a specific animation range
  13746. * @param name defines the name of the range
  13747. * @param deleteFrames defines if frames must be removed as well
  13748. */
  13749. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13750. /**
  13751. * Gets a specific animation range
  13752. * @param name defines the name of the range to look for
  13753. * @returns the requested animation range or null if not found
  13754. */
  13755. getAnimationRange(name: string): Nullable<AnimationRange>;
  13756. /**
  13757. * Gets the list of all animation ranges defined on this skeleton
  13758. * @returns an array
  13759. */
  13760. getAnimationRanges(): Nullable<AnimationRange>[];
  13761. /**
  13762. * Copy animation range from a source skeleton.
  13763. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13764. * @param source defines the source skeleton
  13765. * @param name defines the name of the range to copy
  13766. * @param rescaleAsRequired defines if rescaling must be applied if required
  13767. * @returns true if operation was successful
  13768. */
  13769. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13770. /**
  13771. * Forces the skeleton to go to rest pose
  13772. */
  13773. returnToRest(): void;
  13774. private _getHighestAnimationFrame;
  13775. /**
  13776. * Begin a specific animation range
  13777. * @param name defines the name of the range to start
  13778. * @param loop defines if looping must be turned on (false by default)
  13779. * @param speedRatio defines the speed ratio to apply (1 by default)
  13780. * @param onAnimationEnd defines a callback which will be called when animation will end
  13781. * @returns a new animatable
  13782. */
  13783. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13784. /** @hidden */
  13785. _markAsDirty(): void;
  13786. /** @hidden */
  13787. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13788. /** @hidden */
  13789. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13790. private _computeTransformMatrices;
  13791. /**
  13792. * Build all resources required to render a skeleton
  13793. */
  13794. prepare(): void;
  13795. /**
  13796. * Gets the list of animatables currently running for this skeleton
  13797. * @returns an array of animatables
  13798. */
  13799. getAnimatables(): IAnimatable[];
  13800. /**
  13801. * Clone the current skeleton
  13802. * @param name defines the name of the new skeleton
  13803. * @param id defines the id of the new skeleton
  13804. * @returns the new skeleton
  13805. */
  13806. clone(name: string, id?: string): Skeleton;
  13807. /**
  13808. * Enable animation blending for this skeleton
  13809. * @param blendingSpeed defines the blending speed to apply
  13810. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13811. */
  13812. enableBlending(blendingSpeed?: number): void;
  13813. /**
  13814. * Releases all resources associated with the current skeleton
  13815. */
  13816. dispose(): void;
  13817. /**
  13818. * Serialize the skeleton in a JSON object
  13819. * @returns a JSON object
  13820. */
  13821. serialize(): any;
  13822. /**
  13823. * Creates a new skeleton from serialized data
  13824. * @param parsedSkeleton defines the serialized data
  13825. * @param scene defines the hosting scene
  13826. * @returns a new skeleton
  13827. */
  13828. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13829. /**
  13830. * Compute all node absolute transforms
  13831. * @param forceUpdate defines if computation must be done even if cache is up to date
  13832. */
  13833. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13834. /**
  13835. * Gets the root pose matrix
  13836. * @returns a matrix
  13837. */
  13838. getPoseMatrix(): Nullable<Matrix>;
  13839. /**
  13840. * Sorts bones per internal index
  13841. */
  13842. sortBones(): void;
  13843. private _sortBones;
  13844. }
  13845. }
  13846. declare module "babylonjs/Bones/bone" {
  13847. import { Skeleton } from "babylonjs/Bones/skeleton";
  13848. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13849. import { Nullable } from "babylonjs/types";
  13850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13851. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13852. import { Node } from "babylonjs/node";
  13853. import { Space } from "babylonjs/Maths/math.axis";
  13854. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13855. /**
  13856. * Class used to store bone information
  13857. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13858. */
  13859. export class Bone extends Node {
  13860. /**
  13861. * defines the bone name
  13862. */
  13863. name: string;
  13864. private static _tmpVecs;
  13865. private static _tmpQuat;
  13866. private static _tmpMats;
  13867. /**
  13868. * Gets the list of child bones
  13869. */
  13870. children: Bone[];
  13871. /** Gets the animations associated with this bone */
  13872. animations: import("babylonjs/Animations/animation").Animation[];
  13873. /**
  13874. * Gets or sets bone length
  13875. */
  13876. length: number;
  13877. /**
  13878. * @hidden Internal only
  13879. * Set this value to map this bone to a different index in the transform matrices
  13880. * Set this value to -1 to exclude the bone from the transform matrices
  13881. */
  13882. _index: Nullable<number>;
  13883. private _skeleton;
  13884. private _localMatrix;
  13885. private _restPose;
  13886. private _baseMatrix;
  13887. private _absoluteTransform;
  13888. private _invertedAbsoluteTransform;
  13889. private _parent;
  13890. private _scalingDeterminant;
  13891. private _worldTransform;
  13892. private _localScaling;
  13893. private _localRotation;
  13894. private _localPosition;
  13895. private _needToDecompose;
  13896. private _needToCompose;
  13897. /** @hidden */
  13898. _linkedTransformNode: Nullable<TransformNode>;
  13899. /** @hidden */
  13900. _waitingTransformNodeId: Nullable<string>;
  13901. /** @hidden */
  13902. /** @hidden */
  13903. _matrix: Matrix;
  13904. /**
  13905. * Create a new bone
  13906. * @param name defines the bone name
  13907. * @param skeleton defines the parent skeleton
  13908. * @param parentBone defines the parent (can be null if the bone is the root)
  13909. * @param localMatrix defines the local matrix
  13910. * @param restPose defines the rest pose matrix
  13911. * @param baseMatrix defines the base matrix
  13912. * @param index defines index of the bone in the hiearchy
  13913. */
  13914. constructor(
  13915. /**
  13916. * defines the bone name
  13917. */
  13918. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13919. /**
  13920. * Gets the current object class name.
  13921. * @return the class name
  13922. */
  13923. getClassName(): string;
  13924. /**
  13925. * Gets the parent skeleton
  13926. * @returns a skeleton
  13927. */
  13928. getSkeleton(): Skeleton;
  13929. /**
  13930. * Gets parent bone
  13931. * @returns a bone or null if the bone is the root of the bone hierarchy
  13932. */
  13933. getParent(): Nullable<Bone>;
  13934. /**
  13935. * Returns an array containing the root bones
  13936. * @returns an array containing the root bones
  13937. */
  13938. getChildren(): Array<Bone>;
  13939. /**
  13940. * Gets the node index in matrix array generated for rendering
  13941. * @returns the node index
  13942. */
  13943. getIndex(): number;
  13944. /**
  13945. * Sets the parent bone
  13946. * @param parent defines the parent (can be null if the bone is the root)
  13947. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13948. */
  13949. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13950. /**
  13951. * Gets the local matrix
  13952. * @returns a matrix
  13953. */
  13954. getLocalMatrix(): Matrix;
  13955. /**
  13956. * Gets the base matrix (initial matrix which remains unchanged)
  13957. * @returns a matrix
  13958. */
  13959. getBaseMatrix(): Matrix;
  13960. /**
  13961. * Gets the rest pose matrix
  13962. * @returns a matrix
  13963. */
  13964. getRestPose(): Matrix;
  13965. /**
  13966. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13967. */
  13968. getWorldMatrix(): Matrix;
  13969. /**
  13970. * Sets the local matrix to rest pose matrix
  13971. */
  13972. returnToRest(): void;
  13973. /**
  13974. * Gets the inverse of the absolute transform matrix.
  13975. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13976. * @returns a matrix
  13977. */
  13978. getInvertedAbsoluteTransform(): Matrix;
  13979. /**
  13980. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13981. * @returns a matrix
  13982. */
  13983. getAbsoluteTransform(): Matrix;
  13984. /**
  13985. * Links with the given transform node.
  13986. * The local matrix of this bone is copied from the transform node every frame.
  13987. * @param transformNode defines the transform node to link to
  13988. */
  13989. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13990. /**
  13991. * Gets the node used to drive the bone's transformation
  13992. * @returns a transform node or null
  13993. */
  13994. getTransformNode(): Nullable<TransformNode>;
  13995. /** Gets or sets current position (in local space) */
  13996. position: Vector3;
  13997. /** Gets or sets current rotation (in local space) */
  13998. rotation: Vector3;
  13999. /** Gets or sets current rotation quaternion (in local space) */
  14000. rotationQuaternion: Quaternion;
  14001. /** Gets or sets current scaling (in local space) */
  14002. scaling: Vector3;
  14003. /**
  14004. * Gets the animation properties override
  14005. */
  14006. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14007. private _decompose;
  14008. private _compose;
  14009. /**
  14010. * Update the base and local matrices
  14011. * @param matrix defines the new base or local matrix
  14012. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14013. * @param updateLocalMatrix defines if the local matrix should be updated
  14014. */
  14015. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14016. /** @hidden */
  14017. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14018. /**
  14019. * Flag the bone as dirty (Forcing it to update everything)
  14020. */
  14021. markAsDirty(): void;
  14022. /** @hidden */
  14023. _markAsDirtyAndCompose(): void;
  14024. private _markAsDirtyAndDecompose;
  14025. /**
  14026. * Translate the bone in local or world space
  14027. * @param vec The amount to translate the bone
  14028. * @param space The space that the translation is in
  14029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14030. */
  14031. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14032. /**
  14033. * Set the postion of the bone in local or world space
  14034. * @param position The position to set the bone
  14035. * @param space The space that the position is in
  14036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14037. */
  14038. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14039. /**
  14040. * Set the absolute position of the bone (world space)
  14041. * @param position The position to set the bone
  14042. * @param mesh The mesh that this bone is attached to
  14043. */
  14044. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14045. /**
  14046. * Scale the bone on the x, y and z axes (in local space)
  14047. * @param x The amount to scale the bone on the x axis
  14048. * @param y The amount to scale the bone on the y axis
  14049. * @param z The amount to scale the bone on the z axis
  14050. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14051. */
  14052. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14053. /**
  14054. * Set the bone scaling in local space
  14055. * @param scale defines the scaling vector
  14056. */
  14057. setScale(scale: Vector3): void;
  14058. /**
  14059. * Gets the current scaling in local space
  14060. * @returns the current scaling vector
  14061. */
  14062. getScale(): Vector3;
  14063. /**
  14064. * Gets the current scaling in local space and stores it in a target vector
  14065. * @param result defines the target vector
  14066. */
  14067. getScaleToRef(result: Vector3): void;
  14068. /**
  14069. * Set the yaw, pitch, and roll of the bone in local or world space
  14070. * @param yaw The rotation of the bone on the y axis
  14071. * @param pitch The rotation of the bone on the x axis
  14072. * @param roll The rotation of the bone on the z axis
  14073. * @param space The space that the axes of rotation are in
  14074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14075. */
  14076. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14077. /**
  14078. * Add a rotation to the bone on an axis in local or world space
  14079. * @param axis The axis to rotate the bone on
  14080. * @param amount The amount to rotate the bone
  14081. * @param space The space that the axis is in
  14082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14083. */
  14084. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14085. /**
  14086. * Set the rotation of the bone to a particular axis angle in local or world space
  14087. * @param axis The axis to rotate the bone on
  14088. * @param angle The angle that the bone should be rotated to
  14089. * @param space The space that the axis is in
  14090. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14091. */
  14092. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14093. /**
  14094. * Set the euler rotation of the bone in local of world space
  14095. * @param rotation The euler rotation that the bone should be set to
  14096. * @param space The space that the rotation is in
  14097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14098. */
  14099. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14100. /**
  14101. * Set the quaternion rotation of the bone in local of world space
  14102. * @param quat The quaternion rotation that the bone should be set to
  14103. * @param space The space that the rotation is in
  14104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14105. */
  14106. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14107. /**
  14108. * Set the rotation matrix of the bone in local of world space
  14109. * @param rotMat The rotation matrix that the bone should be set to
  14110. * @param space The space that the rotation is in
  14111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14112. */
  14113. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14114. private _rotateWithMatrix;
  14115. private _getNegativeRotationToRef;
  14116. /**
  14117. * Get the position of the bone in local or world space
  14118. * @param space The space that the returned position is in
  14119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14120. * @returns The position of the bone
  14121. */
  14122. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14123. /**
  14124. * Copy the position of the bone to a vector3 in local or world space
  14125. * @param space The space that the returned position is in
  14126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14127. * @param result The vector3 to copy the position to
  14128. */
  14129. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14130. /**
  14131. * Get the absolute position of the bone (world space)
  14132. * @param mesh The mesh that this bone is attached to
  14133. * @returns The absolute position of the bone
  14134. */
  14135. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14136. /**
  14137. * Copy the absolute position of the bone (world space) to the result param
  14138. * @param mesh The mesh that this bone is attached to
  14139. * @param result The vector3 to copy the absolute position to
  14140. */
  14141. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14142. /**
  14143. * Compute the absolute transforms of this bone and its children
  14144. */
  14145. computeAbsoluteTransforms(): void;
  14146. /**
  14147. * Get the world direction from an axis that is in the local space of the bone
  14148. * @param localAxis The local direction that is used to compute the world direction
  14149. * @param mesh The mesh that this bone is attached to
  14150. * @returns The world direction
  14151. */
  14152. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14153. /**
  14154. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14155. * @param localAxis The local direction that is used to compute the world direction
  14156. * @param mesh The mesh that this bone is attached to
  14157. * @param result The vector3 that the world direction will be copied to
  14158. */
  14159. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14160. /**
  14161. * Get the euler rotation of the bone in local or world space
  14162. * @param space The space that the rotation should be in
  14163. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14164. * @returns The euler rotation
  14165. */
  14166. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14167. /**
  14168. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14169. * @param space The space that the rotation should be in
  14170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14171. * @param result The vector3 that the rotation should be copied to
  14172. */
  14173. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14174. /**
  14175. * Get the quaternion rotation of the bone in either local or world space
  14176. * @param space The space that the rotation should be in
  14177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14178. * @returns The quaternion rotation
  14179. */
  14180. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14181. /**
  14182. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14183. * @param space The space that the rotation should be in
  14184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14185. * @param result The quaternion that the rotation should be copied to
  14186. */
  14187. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14188. /**
  14189. * Get the rotation matrix of the bone in local or world space
  14190. * @param space The space that the rotation should be in
  14191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14192. * @returns The rotation matrix
  14193. */
  14194. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14195. /**
  14196. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14197. * @param space The space that the rotation should be in
  14198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14199. * @param result The quaternion that the rotation should be copied to
  14200. */
  14201. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14202. /**
  14203. * Get the world position of a point that is in the local space of the bone
  14204. * @param position The local position
  14205. * @param mesh The mesh that this bone is attached to
  14206. * @returns The world position
  14207. */
  14208. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14209. /**
  14210. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14211. * @param position The local position
  14212. * @param mesh The mesh that this bone is attached to
  14213. * @param result The vector3 that the world position should be copied to
  14214. */
  14215. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14216. /**
  14217. * Get the local position of a point that is in world space
  14218. * @param position The world position
  14219. * @param mesh The mesh that this bone is attached to
  14220. * @returns The local position
  14221. */
  14222. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14223. /**
  14224. * Get the local position of a point that is in world space and copy it to the result param
  14225. * @param position The world position
  14226. * @param mesh The mesh that this bone is attached to
  14227. * @param result The vector3 that the local position should be copied to
  14228. */
  14229. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14230. }
  14231. }
  14232. declare module "babylonjs/Meshes/transformNode" {
  14233. import { DeepImmutable } from "babylonjs/types";
  14234. import { Observable } from "babylonjs/Misc/observable";
  14235. import { Nullable } from "babylonjs/types";
  14236. import { Camera } from "babylonjs/Cameras/camera";
  14237. import { Scene } from "babylonjs/scene";
  14238. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14239. import { Node } from "babylonjs/node";
  14240. import { Bone } from "babylonjs/Bones/bone";
  14241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14242. import { Space } from "babylonjs/Maths/math.axis";
  14243. /**
  14244. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14245. * @see https://doc.babylonjs.com/how_to/transformnode
  14246. */
  14247. export class TransformNode extends Node {
  14248. /**
  14249. * Object will not rotate to face the camera
  14250. */
  14251. static BILLBOARDMODE_NONE: number;
  14252. /**
  14253. * Object will rotate to face the camera but only on the x axis
  14254. */
  14255. static BILLBOARDMODE_X: number;
  14256. /**
  14257. * Object will rotate to face the camera but only on the y axis
  14258. */
  14259. static BILLBOARDMODE_Y: number;
  14260. /**
  14261. * Object will rotate to face the camera but only on the z axis
  14262. */
  14263. static BILLBOARDMODE_Z: number;
  14264. /**
  14265. * Object will rotate to face the camera
  14266. */
  14267. static BILLBOARDMODE_ALL: number;
  14268. /**
  14269. * Object will rotate to face the camera's position instead of orientation
  14270. */
  14271. static BILLBOARDMODE_USE_POSITION: number;
  14272. private _forward;
  14273. private _forwardInverted;
  14274. private _up;
  14275. private _right;
  14276. private _rightInverted;
  14277. private _position;
  14278. private _rotation;
  14279. private _rotationQuaternion;
  14280. protected _scaling: Vector3;
  14281. protected _isDirty: boolean;
  14282. private _transformToBoneReferal;
  14283. private _isAbsoluteSynced;
  14284. private _billboardMode;
  14285. /**
  14286. * Gets or sets the billboard mode. Default is 0.
  14287. *
  14288. * | Value | Type | Description |
  14289. * | --- | --- | --- |
  14290. * | 0 | BILLBOARDMODE_NONE | |
  14291. * | 1 | BILLBOARDMODE_X | |
  14292. * | 2 | BILLBOARDMODE_Y | |
  14293. * | 4 | BILLBOARDMODE_Z | |
  14294. * | 7 | BILLBOARDMODE_ALL | |
  14295. *
  14296. */
  14297. billboardMode: number;
  14298. private _preserveParentRotationForBillboard;
  14299. /**
  14300. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14301. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14302. */
  14303. preserveParentRotationForBillboard: boolean;
  14304. /**
  14305. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14306. */
  14307. scalingDeterminant: number;
  14308. private _infiniteDistance;
  14309. /**
  14310. * Gets or sets the distance of the object to max, often used by skybox
  14311. */
  14312. infiniteDistance: boolean;
  14313. /**
  14314. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14315. * By default the system will update normals to compensate
  14316. */
  14317. ignoreNonUniformScaling: boolean;
  14318. /**
  14319. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14320. */
  14321. reIntegrateRotationIntoRotationQuaternion: boolean;
  14322. /** @hidden */
  14323. _poseMatrix: Nullable<Matrix>;
  14324. /** @hidden */
  14325. _localMatrix: Matrix;
  14326. private _usePivotMatrix;
  14327. private _absolutePosition;
  14328. private _absoluteScaling;
  14329. private _absoluteRotationQuaternion;
  14330. private _pivotMatrix;
  14331. private _pivotMatrixInverse;
  14332. protected _postMultiplyPivotMatrix: boolean;
  14333. protected _isWorldMatrixFrozen: boolean;
  14334. /** @hidden */
  14335. _indexInSceneTransformNodesArray: number;
  14336. /**
  14337. * An event triggered after the world matrix is updated
  14338. */
  14339. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14340. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14341. /**
  14342. * Gets a string identifying the name of the class
  14343. * @returns "TransformNode" string
  14344. */
  14345. getClassName(): string;
  14346. /**
  14347. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14348. */
  14349. position: Vector3;
  14350. /**
  14351. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14352. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14353. */
  14354. rotation: Vector3;
  14355. /**
  14356. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14357. */
  14358. scaling: Vector3;
  14359. /**
  14360. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14361. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14362. */
  14363. rotationQuaternion: Nullable<Quaternion>;
  14364. /**
  14365. * The forward direction of that transform in world space.
  14366. */
  14367. readonly forward: Vector3;
  14368. /**
  14369. * The up direction of that transform in world space.
  14370. */
  14371. readonly up: Vector3;
  14372. /**
  14373. * The right direction of that transform in world space.
  14374. */
  14375. readonly right: Vector3;
  14376. /**
  14377. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14378. * @param matrix the matrix to copy the pose from
  14379. * @returns this TransformNode.
  14380. */
  14381. updatePoseMatrix(matrix: Matrix): TransformNode;
  14382. /**
  14383. * Returns the mesh Pose matrix.
  14384. * @returns the pose matrix
  14385. */
  14386. getPoseMatrix(): Matrix;
  14387. /** @hidden */
  14388. _isSynchronized(): boolean;
  14389. /** @hidden */
  14390. _initCache(): void;
  14391. /**
  14392. * Flag the transform node as dirty (Forcing it to update everything)
  14393. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14394. * @returns this transform node
  14395. */
  14396. markAsDirty(property: string): TransformNode;
  14397. /**
  14398. * Returns the current mesh absolute position.
  14399. * Returns a Vector3.
  14400. */
  14401. readonly absolutePosition: Vector3;
  14402. /**
  14403. * Returns the current mesh absolute scaling.
  14404. * Returns a Vector3.
  14405. */
  14406. readonly absoluteScaling: Vector3;
  14407. /**
  14408. * Returns the current mesh absolute rotation.
  14409. * Returns a Quaternion.
  14410. */
  14411. readonly absoluteRotationQuaternion: Quaternion;
  14412. /**
  14413. * Sets a new matrix to apply before all other transformation
  14414. * @param matrix defines the transform matrix
  14415. * @returns the current TransformNode
  14416. */
  14417. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14418. /**
  14419. * Sets a new pivot matrix to the current node
  14420. * @param matrix defines the new pivot matrix to use
  14421. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14422. * @returns the current TransformNode
  14423. */
  14424. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14425. /**
  14426. * Returns the mesh pivot matrix.
  14427. * Default : Identity.
  14428. * @returns the matrix
  14429. */
  14430. getPivotMatrix(): Matrix;
  14431. /**
  14432. * Instantiate (when possible) or clone that node with its hierarchy
  14433. * @param newParent defines the new parent to use for the instance (or clone)
  14434. * @param options defines options to configure how copy is done
  14435. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14436. * @returns an instance (or a clone) of the current node with its hiearchy
  14437. */
  14438. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14439. doNotInstantiate: boolean;
  14440. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14441. /**
  14442. * Prevents the World matrix to be computed any longer
  14443. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14444. * @returns the TransformNode.
  14445. */
  14446. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14447. /**
  14448. * Allows back the World matrix computation.
  14449. * @returns the TransformNode.
  14450. */
  14451. unfreezeWorldMatrix(): this;
  14452. /**
  14453. * True if the World matrix has been frozen.
  14454. */
  14455. readonly isWorldMatrixFrozen: boolean;
  14456. /**
  14457. * Retuns the mesh absolute position in the World.
  14458. * @returns a Vector3.
  14459. */
  14460. getAbsolutePosition(): Vector3;
  14461. /**
  14462. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14463. * @param absolutePosition the absolute position to set
  14464. * @returns the TransformNode.
  14465. */
  14466. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14467. /**
  14468. * Sets the mesh position in its local space.
  14469. * @param vector3 the position to set in localspace
  14470. * @returns the TransformNode.
  14471. */
  14472. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14473. /**
  14474. * Returns the mesh position in the local space from the current World matrix values.
  14475. * @returns a new Vector3.
  14476. */
  14477. getPositionExpressedInLocalSpace(): Vector3;
  14478. /**
  14479. * Translates the mesh along the passed Vector3 in its local space.
  14480. * @param vector3 the distance to translate in localspace
  14481. * @returns the TransformNode.
  14482. */
  14483. locallyTranslate(vector3: Vector3): TransformNode;
  14484. private static _lookAtVectorCache;
  14485. /**
  14486. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14487. * @param targetPoint the position (must be in same space as current mesh) to look at
  14488. * @param yawCor optional yaw (y-axis) correction in radians
  14489. * @param pitchCor optional pitch (x-axis) correction in radians
  14490. * @param rollCor optional roll (z-axis) correction in radians
  14491. * @param space the choosen space of the target
  14492. * @returns the TransformNode.
  14493. */
  14494. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14495. /**
  14496. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14497. * This Vector3 is expressed in the World space.
  14498. * @param localAxis axis to rotate
  14499. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14500. */
  14501. getDirection(localAxis: Vector3): Vector3;
  14502. /**
  14503. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14504. * localAxis is expressed in the mesh local space.
  14505. * result is computed in the Wordl space from the mesh World matrix.
  14506. * @param localAxis axis to rotate
  14507. * @param result the resulting transformnode
  14508. * @returns this TransformNode.
  14509. */
  14510. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14511. /**
  14512. * Sets this transform node rotation to the given local axis.
  14513. * @param localAxis the axis in local space
  14514. * @param yawCor optional yaw (y-axis) correction in radians
  14515. * @param pitchCor optional pitch (x-axis) correction in radians
  14516. * @param rollCor optional roll (z-axis) correction in radians
  14517. * @returns this TransformNode
  14518. */
  14519. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14520. /**
  14521. * Sets a new pivot point to the current node
  14522. * @param point defines the new pivot point to use
  14523. * @param space defines if the point is in world or local space (local by default)
  14524. * @returns the current TransformNode
  14525. */
  14526. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14527. /**
  14528. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14529. * @returns the pivot point
  14530. */
  14531. getPivotPoint(): Vector3;
  14532. /**
  14533. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14534. * @param result the vector3 to store the result
  14535. * @returns this TransformNode.
  14536. */
  14537. getPivotPointToRef(result: Vector3): TransformNode;
  14538. /**
  14539. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14540. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14541. */
  14542. getAbsolutePivotPoint(): Vector3;
  14543. /**
  14544. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14545. * @param result vector3 to store the result
  14546. * @returns this TransformNode.
  14547. */
  14548. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14549. /**
  14550. * Defines the passed node as the parent of the current node.
  14551. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14552. * @see https://doc.babylonjs.com/how_to/parenting
  14553. * @param node the node ot set as the parent
  14554. * @returns this TransformNode.
  14555. */
  14556. setParent(node: Nullable<Node>): TransformNode;
  14557. private _nonUniformScaling;
  14558. /**
  14559. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14560. */
  14561. readonly nonUniformScaling: boolean;
  14562. /** @hidden */
  14563. _updateNonUniformScalingState(value: boolean): boolean;
  14564. /**
  14565. * Attach the current TransformNode to another TransformNode associated with a bone
  14566. * @param bone Bone affecting the TransformNode
  14567. * @param affectedTransformNode TransformNode associated with the bone
  14568. * @returns this object
  14569. */
  14570. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14571. /**
  14572. * Detach the transform node if its associated with a bone
  14573. * @returns this object
  14574. */
  14575. detachFromBone(): TransformNode;
  14576. private static _rotationAxisCache;
  14577. /**
  14578. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14579. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14580. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14581. * The passed axis is also normalized.
  14582. * @param axis the axis to rotate around
  14583. * @param amount the amount to rotate in radians
  14584. * @param space Space to rotate in (Default: local)
  14585. * @returns the TransformNode.
  14586. */
  14587. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14588. /**
  14589. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14590. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14591. * The passed axis is also normalized. .
  14592. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14593. * @param point the point to rotate around
  14594. * @param axis the axis to rotate around
  14595. * @param amount the amount to rotate in radians
  14596. * @returns the TransformNode
  14597. */
  14598. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14599. /**
  14600. * Translates the mesh along the axis vector for the passed distance in the given space.
  14601. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14602. * @param axis the axis to translate in
  14603. * @param distance the distance to translate
  14604. * @param space Space to rotate in (Default: local)
  14605. * @returns the TransformNode.
  14606. */
  14607. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14608. /**
  14609. * Adds a rotation step to the mesh current rotation.
  14610. * x, y, z are Euler angles expressed in radians.
  14611. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14612. * This means this rotation is made in the mesh local space only.
  14613. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14614. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14615. * ```javascript
  14616. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14617. * ```
  14618. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14619. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14620. * @param x Rotation to add
  14621. * @param y Rotation to add
  14622. * @param z Rotation to add
  14623. * @returns the TransformNode.
  14624. */
  14625. addRotation(x: number, y: number, z: number): TransformNode;
  14626. /**
  14627. * @hidden
  14628. */
  14629. protected _getEffectiveParent(): Nullable<Node>;
  14630. /**
  14631. * Computes the world matrix of the node
  14632. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14633. * @returns the world matrix
  14634. */
  14635. computeWorldMatrix(force?: boolean): Matrix;
  14636. protected _afterComputeWorldMatrix(): void;
  14637. /**
  14638. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14639. * @param func callback function to add
  14640. *
  14641. * @returns the TransformNode.
  14642. */
  14643. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14644. /**
  14645. * Removes a registered callback function.
  14646. * @param func callback function to remove
  14647. * @returns the TransformNode.
  14648. */
  14649. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14650. /**
  14651. * Gets the position of the current mesh in camera space
  14652. * @param camera defines the camera to use
  14653. * @returns a position
  14654. */
  14655. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14656. /**
  14657. * Returns the distance from the mesh to the active camera
  14658. * @param camera defines the camera to use
  14659. * @returns the distance
  14660. */
  14661. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14662. /**
  14663. * Clone the current transform node
  14664. * @param name Name of the new clone
  14665. * @param newParent New parent for the clone
  14666. * @param doNotCloneChildren Do not clone children hierarchy
  14667. * @returns the new transform node
  14668. */
  14669. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14670. /**
  14671. * Serializes the objects information.
  14672. * @param currentSerializationObject defines the object to serialize in
  14673. * @returns the serialized object
  14674. */
  14675. serialize(currentSerializationObject?: any): any;
  14676. /**
  14677. * Returns a new TransformNode object parsed from the source provided.
  14678. * @param parsedTransformNode is the source.
  14679. * @param scene the scne the object belongs to
  14680. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14681. * @returns a new TransformNode object parsed from the source provided.
  14682. */
  14683. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14684. /**
  14685. * Get all child-transformNodes of this node
  14686. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14687. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14688. * @returns an array of TransformNode
  14689. */
  14690. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14691. /**
  14692. * Releases resources associated with this transform node.
  14693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14695. */
  14696. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14697. /**
  14698. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14699. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14700. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14701. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14702. * @returns the current mesh
  14703. */
  14704. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14705. private _syncAbsoluteScalingAndRotation;
  14706. }
  14707. }
  14708. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14709. import { Observable } from "babylonjs/Misc/observable";
  14710. import { Nullable } from "babylonjs/types";
  14711. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14712. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14714. import { Ray } from "babylonjs/Culling/ray";
  14715. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14716. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14717. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14718. /**
  14719. * Defines the types of pose enabled controllers that are supported
  14720. */
  14721. export enum PoseEnabledControllerType {
  14722. /**
  14723. * HTC Vive
  14724. */
  14725. VIVE = 0,
  14726. /**
  14727. * Oculus Rift
  14728. */
  14729. OCULUS = 1,
  14730. /**
  14731. * Windows mixed reality
  14732. */
  14733. WINDOWS = 2,
  14734. /**
  14735. * Samsung gear VR
  14736. */
  14737. GEAR_VR = 3,
  14738. /**
  14739. * Google Daydream
  14740. */
  14741. DAYDREAM = 4,
  14742. /**
  14743. * Generic
  14744. */
  14745. GENERIC = 5
  14746. }
  14747. /**
  14748. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14749. */
  14750. export interface MutableGamepadButton {
  14751. /**
  14752. * Value of the button/trigger
  14753. */
  14754. value: number;
  14755. /**
  14756. * If the button/trigger is currently touched
  14757. */
  14758. touched: boolean;
  14759. /**
  14760. * If the button/trigger is currently pressed
  14761. */
  14762. pressed: boolean;
  14763. }
  14764. /**
  14765. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14766. * @hidden
  14767. */
  14768. export interface ExtendedGamepadButton extends GamepadButton {
  14769. /**
  14770. * If the button/trigger is currently pressed
  14771. */
  14772. readonly pressed: boolean;
  14773. /**
  14774. * If the button/trigger is currently touched
  14775. */
  14776. readonly touched: boolean;
  14777. /**
  14778. * Value of the button/trigger
  14779. */
  14780. readonly value: number;
  14781. }
  14782. /** @hidden */
  14783. export interface _GamePadFactory {
  14784. /**
  14785. * Returns wether or not the current gamepad can be created for this type of controller.
  14786. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14787. * @returns true if it can be created, otherwise false
  14788. */
  14789. canCreate(gamepadInfo: any): boolean;
  14790. /**
  14791. * Creates a new instance of the Gamepad.
  14792. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14793. * @returns the new gamepad instance
  14794. */
  14795. create(gamepadInfo: any): Gamepad;
  14796. }
  14797. /**
  14798. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14799. */
  14800. export class PoseEnabledControllerHelper {
  14801. /** @hidden */
  14802. static _ControllerFactories: _GamePadFactory[];
  14803. /** @hidden */
  14804. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14805. /**
  14806. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14807. * @param vrGamepad the gamepad to initialized
  14808. * @returns a vr controller of the type the gamepad identified as
  14809. */
  14810. static InitiateController(vrGamepad: any): Gamepad;
  14811. }
  14812. /**
  14813. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14814. */
  14815. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14816. /**
  14817. * If the controller is used in a webXR session
  14818. */
  14819. isXR: boolean;
  14820. private _deviceRoomPosition;
  14821. private _deviceRoomRotationQuaternion;
  14822. /**
  14823. * The device position in babylon space
  14824. */
  14825. devicePosition: Vector3;
  14826. /**
  14827. * The device rotation in babylon space
  14828. */
  14829. deviceRotationQuaternion: Quaternion;
  14830. /**
  14831. * The scale factor of the device in babylon space
  14832. */
  14833. deviceScaleFactor: number;
  14834. /**
  14835. * (Likely devicePosition should be used instead) The device position in its room space
  14836. */
  14837. position: Vector3;
  14838. /**
  14839. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14840. */
  14841. rotationQuaternion: Quaternion;
  14842. /**
  14843. * The type of controller (Eg. Windows mixed reality)
  14844. */
  14845. controllerType: PoseEnabledControllerType;
  14846. protected _calculatedPosition: Vector3;
  14847. private _calculatedRotation;
  14848. /**
  14849. * The raw pose from the device
  14850. */
  14851. rawPose: DevicePose;
  14852. private _trackPosition;
  14853. private _maxRotationDistFromHeadset;
  14854. private _draggedRoomRotation;
  14855. /**
  14856. * @hidden
  14857. */
  14858. _disableTrackPosition(fixedPosition: Vector3): void;
  14859. /**
  14860. * Internal, the mesh attached to the controller
  14861. * @hidden
  14862. */
  14863. _mesh: Nullable<AbstractMesh>;
  14864. private _poseControlledCamera;
  14865. private _leftHandSystemQuaternion;
  14866. /**
  14867. * Internal, matrix used to convert room space to babylon space
  14868. * @hidden
  14869. */
  14870. _deviceToWorld: Matrix;
  14871. /**
  14872. * Node to be used when casting a ray from the controller
  14873. * @hidden
  14874. */
  14875. _pointingPoseNode: Nullable<TransformNode>;
  14876. /**
  14877. * Name of the child mesh that can be used to cast a ray from the controller
  14878. */
  14879. static readonly POINTING_POSE: string;
  14880. /**
  14881. * Creates a new PoseEnabledController from a gamepad
  14882. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14883. */
  14884. constructor(browserGamepad: any);
  14885. private _workingMatrix;
  14886. /**
  14887. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14888. */
  14889. update(): void;
  14890. /**
  14891. * Updates only the pose device and mesh without doing any button event checking
  14892. */
  14893. protected _updatePoseAndMesh(): void;
  14894. /**
  14895. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14896. * @param poseData raw pose fromthe device
  14897. */
  14898. updateFromDevice(poseData: DevicePose): void;
  14899. /**
  14900. * @hidden
  14901. */
  14902. _meshAttachedObservable: Observable<AbstractMesh>;
  14903. /**
  14904. * Attaches a mesh to the controller
  14905. * @param mesh the mesh to be attached
  14906. */
  14907. attachToMesh(mesh: AbstractMesh): void;
  14908. /**
  14909. * Attaches the controllers mesh to a camera
  14910. * @param camera the camera the mesh should be attached to
  14911. */
  14912. attachToPoseControlledCamera(camera: TargetCamera): void;
  14913. /**
  14914. * Disposes of the controller
  14915. */
  14916. dispose(): void;
  14917. /**
  14918. * The mesh that is attached to the controller
  14919. */
  14920. readonly mesh: Nullable<AbstractMesh>;
  14921. /**
  14922. * Gets the ray of the controller in the direction the controller is pointing
  14923. * @param length the length the resulting ray should be
  14924. * @returns a ray in the direction the controller is pointing
  14925. */
  14926. getForwardRay(length?: number): Ray;
  14927. }
  14928. }
  14929. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14930. import { Observable } from "babylonjs/Misc/observable";
  14931. import { Scene } from "babylonjs/scene";
  14932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14933. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14934. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14935. import { Nullable } from "babylonjs/types";
  14936. /**
  14937. * Defines the WebVRController object that represents controllers tracked in 3D space
  14938. */
  14939. export abstract class WebVRController extends PoseEnabledController {
  14940. /**
  14941. * Internal, the default controller model for the controller
  14942. */
  14943. protected _defaultModel: Nullable<AbstractMesh>;
  14944. /**
  14945. * Fired when the trigger state has changed
  14946. */
  14947. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14948. /**
  14949. * Fired when the main button state has changed
  14950. */
  14951. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14952. /**
  14953. * Fired when the secondary button state has changed
  14954. */
  14955. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14956. /**
  14957. * Fired when the pad state has changed
  14958. */
  14959. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14960. /**
  14961. * Fired when controllers stick values have changed
  14962. */
  14963. onPadValuesChangedObservable: Observable<StickValues>;
  14964. /**
  14965. * Array of button availible on the controller
  14966. */
  14967. protected _buttons: Array<MutableGamepadButton>;
  14968. private _onButtonStateChange;
  14969. /**
  14970. * Fired when a controller button's state has changed
  14971. * @param callback the callback containing the button that was modified
  14972. */
  14973. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14974. /**
  14975. * X and Y axis corresponding to the controllers joystick
  14976. */
  14977. pad: StickValues;
  14978. /**
  14979. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14980. */
  14981. hand: string;
  14982. /**
  14983. * The default controller model for the controller
  14984. */
  14985. readonly defaultModel: Nullable<AbstractMesh>;
  14986. /**
  14987. * Creates a new WebVRController from a gamepad
  14988. * @param vrGamepad the gamepad that the WebVRController should be created from
  14989. */
  14990. constructor(vrGamepad: any);
  14991. /**
  14992. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14993. */
  14994. update(): void;
  14995. /**
  14996. * Function to be called when a button is modified
  14997. */
  14998. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14999. /**
  15000. * Loads a mesh and attaches it to the controller
  15001. * @param scene the scene the mesh should be added to
  15002. * @param meshLoaded callback for when the mesh has been loaded
  15003. */
  15004. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15005. private _setButtonValue;
  15006. private _changes;
  15007. private _checkChanges;
  15008. /**
  15009. * Disposes of th webVRCOntroller
  15010. */
  15011. dispose(): void;
  15012. }
  15013. }
  15014. declare module "babylonjs/Lights/hemisphericLight" {
  15015. import { Nullable } from "babylonjs/types";
  15016. import { Scene } from "babylonjs/scene";
  15017. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15018. import { Color3 } from "babylonjs/Maths/math.color";
  15019. import { Effect } from "babylonjs/Materials/effect";
  15020. import { Light } from "babylonjs/Lights/light";
  15021. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15022. /**
  15023. * The HemisphericLight simulates the ambient environment light,
  15024. * so the passed direction is the light reflection direction, not the incoming direction.
  15025. */
  15026. export class HemisphericLight extends Light {
  15027. /**
  15028. * The groundColor is the light in the opposite direction to the one specified during creation.
  15029. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  15030. */
  15031. groundColor: Color3;
  15032. /**
  15033. * The light reflection direction, not the incoming direction.
  15034. */
  15035. direction: Vector3;
  15036. /**
  15037. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15038. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15039. * The HemisphericLight can't cast shadows.
  15040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15041. * @param name The friendly name of the light
  15042. * @param direction The direction of the light reflection
  15043. * @param scene The scene the light belongs to
  15044. */
  15045. constructor(name: string, direction: Vector3, scene: Scene);
  15046. protected _buildUniformLayout(): void;
  15047. /**
  15048. * Returns the string "HemisphericLight".
  15049. * @return The class name
  15050. */
  15051. getClassName(): string;
  15052. /**
  15053. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15054. * Returns the updated direction.
  15055. * @param target The target the direction should point to
  15056. * @return The computed direction
  15057. */
  15058. setDirectionToTarget(target: Vector3): Vector3;
  15059. /**
  15060. * Returns the shadow generator associated to the light.
  15061. * @returns Always null for hemispheric lights because it does not support shadows.
  15062. */
  15063. getShadowGenerator(): Nullable<IShadowGenerator>;
  15064. /**
  15065. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15066. * @param effect The effect to update
  15067. * @param lightIndex The index of the light in the effect to update
  15068. * @returns The hemispheric light
  15069. */
  15070. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15071. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15072. /**
  15073. * Computes the world matrix of the node
  15074. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15075. * @param useWasUpdatedFlag defines a reserved property
  15076. * @returns the world matrix
  15077. */
  15078. computeWorldMatrix(): Matrix;
  15079. /**
  15080. * Returns the integer 3.
  15081. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15082. */
  15083. getTypeID(): number;
  15084. /**
  15085. * Prepares the list of defines specific to the light type.
  15086. * @param defines the list of defines
  15087. * @param lightIndex defines the index of the light for the effect
  15088. */
  15089. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15090. }
  15091. }
  15092. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15093. /** @hidden */
  15094. export var vrMultiviewToSingleviewPixelShader: {
  15095. name: string;
  15096. shader: string;
  15097. };
  15098. }
  15099. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15100. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15101. import { Scene } from "babylonjs/scene";
  15102. /**
  15103. * Renders to multiple views with a single draw call
  15104. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15105. */
  15106. export class MultiviewRenderTarget extends RenderTargetTexture {
  15107. /**
  15108. * Creates a multiview render target
  15109. * @param scene scene used with the render target
  15110. * @param size the size of the render target (used for each view)
  15111. */
  15112. constructor(scene: Scene, size?: number | {
  15113. width: number;
  15114. height: number;
  15115. } | {
  15116. ratio: number;
  15117. });
  15118. /**
  15119. * @hidden
  15120. * @param faceIndex the face index, if its a cube texture
  15121. */
  15122. _bindFrameBuffer(faceIndex?: number): void;
  15123. /**
  15124. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15125. * @returns the view count
  15126. */
  15127. getViewCount(): number;
  15128. }
  15129. }
  15130. declare module "babylonjs/Maths/math.frustum" {
  15131. import { Matrix } from "babylonjs/Maths/math.vector";
  15132. import { DeepImmutable } from "babylonjs/types";
  15133. import { Plane } from "babylonjs/Maths/math.plane";
  15134. /**
  15135. * Represents a camera frustum
  15136. */
  15137. export class Frustum {
  15138. /**
  15139. * Gets the planes representing the frustum
  15140. * @param transform matrix to be applied to the returned planes
  15141. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15142. */
  15143. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15144. /**
  15145. * Gets the near frustum plane transformed by the transform matrix
  15146. * @param transform transformation matrix to be applied to the resulting frustum plane
  15147. * @param frustumPlane the resuling frustum plane
  15148. */
  15149. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15150. /**
  15151. * Gets the far frustum plane transformed by the transform matrix
  15152. * @param transform transformation matrix to be applied to the resulting frustum plane
  15153. * @param frustumPlane the resuling frustum plane
  15154. */
  15155. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15156. /**
  15157. * Gets the left frustum plane transformed by the transform matrix
  15158. * @param transform transformation matrix to be applied to the resulting frustum plane
  15159. * @param frustumPlane the resuling frustum plane
  15160. */
  15161. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15162. /**
  15163. * Gets the right frustum plane transformed by the transform matrix
  15164. * @param transform transformation matrix to be applied to the resulting frustum plane
  15165. * @param frustumPlane the resuling frustum plane
  15166. */
  15167. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15168. /**
  15169. * Gets the top frustum plane transformed by the transform matrix
  15170. * @param transform transformation matrix to be applied to the resulting frustum plane
  15171. * @param frustumPlane the resuling frustum plane
  15172. */
  15173. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15174. /**
  15175. * Gets the bottom frustum plane transformed by the transform matrix
  15176. * @param transform transformation matrix to be applied to the resulting frustum plane
  15177. * @param frustumPlane the resuling frustum plane
  15178. */
  15179. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15180. /**
  15181. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15182. * @param transform transformation matrix to be applied to the resulting frustum planes
  15183. * @param frustumPlanes the resuling frustum planes
  15184. */
  15185. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15186. }
  15187. }
  15188. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15189. import { Camera } from "babylonjs/Cameras/camera";
  15190. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15191. import { Nullable } from "babylonjs/types";
  15192. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15193. import { Matrix } from "babylonjs/Maths/math.vector";
  15194. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15195. module "babylonjs/Engines/engine" {
  15196. interface Engine {
  15197. /**
  15198. * Creates a new multiview render target
  15199. * @param width defines the width of the texture
  15200. * @param height defines the height of the texture
  15201. * @returns the created multiview texture
  15202. */
  15203. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15204. /**
  15205. * Binds a multiview framebuffer to be drawn to
  15206. * @param multiviewTexture texture to bind
  15207. */
  15208. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15209. }
  15210. }
  15211. module "babylonjs/Cameras/camera" {
  15212. interface Camera {
  15213. /**
  15214. * @hidden
  15215. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  15216. */
  15217. _useMultiviewToSingleView: boolean;
  15218. /**
  15219. * @hidden
  15220. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  15221. */
  15222. _multiviewTexture: Nullable<RenderTargetTexture>;
  15223. /**
  15224. * @hidden
  15225. * ensures the multiview texture of the camera exists and has the specified width/height
  15226. * @param width height to set on the multiview texture
  15227. * @param height width to set on the multiview texture
  15228. */
  15229. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15230. }
  15231. }
  15232. module "babylonjs/scene" {
  15233. interface Scene {
  15234. /** @hidden */
  15235. _transformMatrixR: Matrix;
  15236. /** @hidden */
  15237. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15238. /** @hidden */
  15239. _createMultiviewUbo(): void;
  15240. /** @hidden */
  15241. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15242. /** @hidden */
  15243. _renderMultiviewToSingleView(camera: Camera): void;
  15244. }
  15245. }
  15246. }
  15247. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15248. import { Camera } from "babylonjs/Cameras/camera";
  15249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15250. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15251. import "babylonjs/Engines/Extensions/engine.multiview";
  15252. /**
  15253. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15254. * This will not be used for webXR as it supports displaying texture arrays directly
  15255. */
  15256. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15257. /**
  15258. * Initializes a VRMultiviewToSingleview
  15259. * @param name name of the post process
  15260. * @param camera camera to be applied to
  15261. * @param scaleFactor scaling factor to the size of the output texture
  15262. */
  15263. constructor(name: string, camera: Camera, scaleFactor: number);
  15264. }
  15265. }
  15266. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15267. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15268. import { Nullable } from "babylonjs/types";
  15269. import { Size } from "babylonjs/Maths/math.size";
  15270. import { Observable } from "babylonjs/Misc/observable";
  15271. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15272. /**
  15273. * Interface used to define additional presentation attributes
  15274. */
  15275. export interface IVRPresentationAttributes {
  15276. /**
  15277. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15278. */
  15279. highRefreshRate: boolean;
  15280. /**
  15281. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15282. */
  15283. foveationLevel: number;
  15284. }
  15285. module "babylonjs/Engines/engine" {
  15286. interface Engine {
  15287. /** @hidden */
  15288. _vrDisplay: any;
  15289. /** @hidden */
  15290. _vrSupported: boolean;
  15291. /** @hidden */
  15292. _oldSize: Size;
  15293. /** @hidden */
  15294. _oldHardwareScaleFactor: number;
  15295. /** @hidden */
  15296. _vrExclusivePointerMode: boolean;
  15297. /** @hidden */
  15298. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15299. /** @hidden */
  15300. _onVRDisplayPointerRestricted: () => void;
  15301. /** @hidden */
  15302. _onVRDisplayPointerUnrestricted: () => void;
  15303. /** @hidden */
  15304. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15305. /** @hidden */
  15306. _onVrDisplayDisconnect: Nullable<() => void>;
  15307. /** @hidden */
  15308. _onVrDisplayPresentChange: Nullable<() => void>;
  15309. /**
  15310. * Observable signaled when VR display mode changes
  15311. */
  15312. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15313. /**
  15314. * Observable signaled when VR request present is complete
  15315. */
  15316. onVRRequestPresentComplete: Observable<boolean>;
  15317. /**
  15318. * Observable signaled when VR request present starts
  15319. */
  15320. onVRRequestPresentStart: Observable<Engine>;
  15321. /**
  15322. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15323. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15324. */
  15325. isInVRExclusivePointerMode: boolean;
  15326. /**
  15327. * Gets a boolean indicating if a webVR device was detected
  15328. * @returns true if a webVR device was detected
  15329. */
  15330. isVRDevicePresent(): boolean;
  15331. /**
  15332. * Gets the current webVR device
  15333. * @returns the current webVR device (or null)
  15334. */
  15335. getVRDevice(): any;
  15336. /**
  15337. * Initializes a webVR display and starts listening to display change events
  15338. * The onVRDisplayChangedObservable will be notified upon these changes
  15339. * @returns A promise containing a VRDisplay and if vr is supported
  15340. */
  15341. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15342. /** @hidden */
  15343. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15344. /**
  15345. * Gets or sets the presentation attributes used to configure VR rendering
  15346. */
  15347. vrPresentationAttributes?: IVRPresentationAttributes;
  15348. /**
  15349. * Call this function to switch to webVR mode
  15350. * Will do nothing if webVR is not supported or if there is no webVR device
  15351. * @param options the webvr options provided to the camera. mainly used for multiview
  15352. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15353. */
  15354. enableVR(options: WebVROptions): void;
  15355. /** @hidden */
  15356. _onVRFullScreenTriggered(): void;
  15357. }
  15358. }
  15359. }
  15360. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15361. import { Nullable } from "babylonjs/types";
  15362. import { Observable } from "babylonjs/Misc/observable";
  15363. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15364. import { Scene } from "babylonjs/scene";
  15365. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15366. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15367. import { Node } from "babylonjs/node";
  15368. import { Ray } from "babylonjs/Culling/ray";
  15369. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15370. import "babylonjs/Engines/Extensions/engine.webVR";
  15371. /**
  15372. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15373. * IMPORTANT!! The data is right-hand data.
  15374. * @export
  15375. * @interface DevicePose
  15376. */
  15377. export interface DevicePose {
  15378. /**
  15379. * The position of the device, values in array are [x,y,z].
  15380. */
  15381. readonly position: Nullable<Float32Array>;
  15382. /**
  15383. * The linearVelocity of the device, values in array are [x,y,z].
  15384. */
  15385. readonly linearVelocity: Nullable<Float32Array>;
  15386. /**
  15387. * The linearAcceleration of the device, values in array are [x,y,z].
  15388. */
  15389. readonly linearAcceleration: Nullable<Float32Array>;
  15390. /**
  15391. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15392. */
  15393. readonly orientation: Nullable<Float32Array>;
  15394. /**
  15395. * The angularVelocity of the device, values in array are [x,y,z].
  15396. */
  15397. readonly angularVelocity: Nullable<Float32Array>;
  15398. /**
  15399. * The angularAcceleration of the device, values in array are [x,y,z].
  15400. */
  15401. readonly angularAcceleration: Nullable<Float32Array>;
  15402. }
  15403. /**
  15404. * Interface representing a pose controlled object in Babylon.
  15405. * A pose controlled object has both regular pose values as well as pose values
  15406. * from an external device such as a VR head mounted display
  15407. */
  15408. export interface PoseControlled {
  15409. /**
  15410. * The position of the object in babylon space.
  15411. */
  15412. position: Vector3;
  15413. /**
  15414. * The rotation quaternion of the object in babylon space.
  15415. */
  15416. rotationQuaternion: Quaternion;
  15417. /**
  15418. * The position of the device in babylon space.
  15419. */
  15420. devicePosition?: Vector3;
  15421. /**
  15422. * The rotation quaternion of the device in babylon space.
  15423. */
  15424. deviceRotationQuaternion: Quaternion;
  15425. /**
  15426. * The raw pose coming from the device.
  15427. */
  15428. rawPose: Nullable<DevicePose>;
  15429. /**
  15430. * The scale of the device to be used when translating from device space to babylon space.
  15431. */
  15432. deviceScaleFactor: number;
  15433. /**
  15434. * Updates the poseControlled values based on the input device pose.
  15435. * @param poseData the pose data to update the object with
  15436. */
  15437. updateFromDevice(poseData: DevicePose): void;
  15438. }
  15439. /**
  15440. * Set of options to customize the webVRCamera
  15441. */
  15442. export interface WebVROptions {
  15443. /**
  15444. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15445. */
  15446. trackPosition?: boolean;
  15447. /**
  15448. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15449. */
  15450. positionScale?: number;
  15451. /**
  15452. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15453. */
  15454. displayName?: string;
  15455. /**
  15456. * Should the native controller meshes be initialized. (default: true)
  15457. */
  15458. controllerMeshes?: boolean;
  15459. /**
  15460. * Creating a default HemiLight only on controllers. (default: true)
  15461. */
  15462. defaultLightingOnControllers?: boolean;
  15463. /**
  15464. * If you don't want to use the default VR button of the helper. (default: false)
  15465. */
  15466. useCustomVRButton?: boolean;
  15467. /**
  15468. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15469. */
  15470. customVRButton?: HTMLButtonElement;
  15471. /**
  15472. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15473. */
  15474. rayLength?: number;
  15475. /**
  15476. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15477. */
  15478. defaultHeight?: number;
  15479. /**
  15480. * If multiview should be used if availible (default: false)
  15481. */
  15482. useMultiview?: boolean;
  15483. }
  15484. /**
  15485. * This represents a WebVR camera.
  15486. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15487. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15488. */
  15489. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15490. private webVROptions;
  15491. /**
  15492. * @hidden
  15493. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15494. */
  15495. _vrDevice: any;
  15496. /**
  15497. * The rawPose of the vrDevice.
  15498. */
  15499. rawPose: Nullable<DevicePose>;
  15500. private _onVREnabled;
  15501. private _specsVersion;
  15502. private _attached;
  15503. private _frameData;
  15504. protected _descendants: Array<Node>;
  15505. private _deviceRoomPosition;
  15506. /** @hidden */
  15507. _deviceRoomRotationQuaternion: Quaternion;
  15508. private _standingMatrix;
  15509. /**
  15510. * Represents device position in babylon space.
  15511. */
  15512. devicePosition: Vector3;
  15513. /**
  15514. * Represents device rotation in babylon space.
  15515. */
  15516. deviceRotationQuaternion: Quaternion;
  15517. /**
  15518. * The scale of the device to be used when translating from device space to babylon space.
  15519. */
  15520. deviceScaleFactor: number;
  15521. private _deviceToWorld;
  15522. private _worldToDevice;
  15523. /**
  15524. * References to the webVR controllers for the vrDevice.
  15525. */
  15526. controllers: Array<WebVRController>;
  15527. /**
  15528. * Emits an event when a controller is attached.
  15529. */
  15530. onControllersAttachedObservable: Observable<WebVRController[]>;
  15531. /**
  15532. * Emits an event when a controller's mesh has been loaded;
  15533. */
  15534. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15535. /**
  15536. * Emits an event when the HMD's pose has been updated.
  15537. */
  15538. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15539. private _poseSet;
  15540. /**
  15541. * If the rig cameras be used as parent instead of this camera.
  15542. */
  15543. rigParenting: boolean;
  15544. private _lightOnControllers;
  15545. private _defaultHeight?;
  15546. /**
  15547. * Instantiates a WebVRFreeCamera.
  15548. * @param name The name of the WebVRFreeCamera
  15549. * @param position The starting anchor position for the camera
  15550. * @param scene The scene the camera belongs to
  15551. * @param webVROptions a set of customizable options for the webVRCamera
  15552. */
  15553. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15554. /**
  15555. * Gets the device distance from the ground in meters.
  15556. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  15557. */
  15558. deviceDistanceToRoomGround(): number;
  15559. /**
  15560. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15561. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15562. */
  15563. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15564. /**
  15565. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15566. * @returns A promise with a boolean set to if the standing matrix is supported.
  15567. */
  15568. useStandingMatrixAsync(): Promise<boolean>;
  15569. /**
  15570. * Disposes the camera
  15571. */
  15572. dispose(): void;
  15573. /**
  15574. * Gets a vrController by name.
  15575. * @param name The name of the controller to retreive
  15576. * @returns the controller matching the name specified or null if not found
  15577. */
  15578. getControllerByName(name: string): Nullable<WebVRController>;
  15579. private _leftController;
  15580. /**
  15581. * The controller corresponding to the users left hand.
  15582. */
  15583. readonly leftController: Nullable<WebVRController>;
  15584. private _rightController;
  15585. /**
  15586. * The controller corresponding to the users right hand.
  15587. */
  15588. readonly rightController: Nullable<WebVRController>;
  15589. /**
  15590. * Casts a ray forward from the vrCamera's gaze.
  15591. * @param length Length of the ray (default: 100)
  15592. * @returns the ray corresponding to the gaze
  15593. */
  15594. getForwardRay(length?: number): Ray;
  15595. /**
  15596. * @hidden
  15597. * Updates the camera based on device's frame data
  15598. */
  15599. _checkInputs(): void;
  15600. /**
  15601. * Updates the poseControlled values based on the input device pose.
  15602. * @param poseData Pose coming from the device
  15603. */
  15604. updateFromDevice(poseData: DevicePose): void;
  15605. private _htmlElementAttached;
  15606. private _detachIfAttached;
  15607. /**
  15608. * WebVR's attach control will start broadcasting frames to the device.
  15609. * Note that in certain browsers (chrome for example) this function must be called
  15610. * within a user-interaction callback. Example:
  15611. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15612. *
  15613. * @param element html element to attach the vrDevice to
  15614. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15615. */
  15616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15617. /**
  15618. * Detaches the camera from the html element and disables VR
  15619. *
  15620. * @param element html element to detach from
  15621. */
  15622. detachControl(element: HTMLElement): void;
  15623. /**
  15624. * @returns the name of this class
  15625. */
  15626. getClassName(): string;
  15627. /**
  15628. * Calls resetPose on the vrDisplay
  15629. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15630. */
  15631. resetToCurrentRotation(): void;
  15632. /**
  15633. * @hidden
  15634. * Updates the rig cameras (left and right eye)
  15635. */
  15636. _updateRigCameras(): void;
  15637. private _workingVector;
  15638. private _oneVector;
  15639. private _workingMatrix;
  15640. private updateCacheCalled;
  15641. private _correctPositionIfNotTrackPosition;
  15642. /**
  15643. * @hidden
  15644. * Updates the cached values of the camera
  15645. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15646. */
  15647. _updateCache(ignoreParentClass?: boolean): void;
  15648. /**
  15649. * @hidden
  15650. * Get current device position in babylon world
  15651. */
  15652. _computeDevicePosition(): void;
  15653. /**
  15654. * Updates the current device position and rotation in the babylon world
  15655. */
  15656. update(): void;
  15657. /**
  15658. * @hidden
  15659. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15660. * @returns an identity matrix
  15661. */
  15662. _getViewMatrix(): Matrix;
  15663. private _tmpMatrix;
  15664. /**
  15665. * This function is called by the two RIG cameras.
  15666. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15667. * @hidden
  15668. */
  15669. _getWebVRViewMatrix(): Matrix;
  15670. /** @hidden */
  15671. _getWebVRProjectionMatrix(): Matrix;
  15672. private _onGamepadConnectedObserver;
  15673. private _onGamepadDisconnectedObserver;
  15674. private _updateCacheWhenTrackingDisabledObserver;
  15675. /**
  15676. * Initializes the controllers and their meshes
  15677. */
  15678. initControllers(): void;
  15679. }
  15680. }
  15681. declare module "babylonjs/PostProcesses/postProcess" {
  15682. import { Nullable } from "babylonjs/types";
  15683. import { SmartArray } from "babylonjs/Misc/smartArray";
  15684. import { Observable } from "babylonjs/Misc/observable";
  15685. import { Vector2 } from "babylonjs/Maths/math.vector";
  15686. import { Camera } from "babylonjs/Cameras/camera";
  15687. import { Effect } from "babylonjs/Materials/effect";
  15688. import "babylonjs/Shaders/postprocess.vertex";
  15689. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15690. import { Engine } from "babylonjs/Engines/engine";
  15691. import { Color4 } from "babylonjs/Maths/math.color";
  15692. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15693. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15694. /**
  15695. * Size options for a post process
  15696. */
  15697. export type PostProcessOptions = {
  15698. width: number;
  15699. height: number;
  15700. };
  15701. /**
  15702. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15703. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15704. */
  15705. export class PostProcess {
  15706. /** Name of the PostProcess. */
  15707. name: string;
  15708. /**
  15709. * Gets or sets the unique id of the post process
  15710. */
  15711. uniqueId: number;
  15712. /**
  15713. * Width of the texture to apply the post process on
  15714. */
  15715. width: number;
  15716. /**
  15717. * Height of the texture to apply the post process on
  15718. */
  15719. height: number;
  15720. /**
  15721. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15722. * @hidden
  15723. */
  15724. _outputTexture: Nullable<InternalTexture>;
  15725. /**
  15726. * Sampling mode used by the shader
  15727. * See https://doc.babylonjs.com/classes/3.1/texture
  15728. */
  15729. renderTargetSamplingMode: number;
  15730. /**
  15731. * Clear color to use when screen clearing
  15732. */
  15733. clearColor: Color4;
  15734. /**
  15735. * If the buffer needs to be cleared before applying the post process. (default: true)
  15736. * Should be set to false if shader will overwrite all previous pixels.
  15737. */
  15738. autoClear: boolean;
  15739. /**
  15740. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15741. */
  15742. alphaMode: number;
  15743. /**
  15744. * Sets the setAlphaBlendConstants of the babylon engine
  15745. */
  15746. alphaConstants: Color4;
  15747. /**
  15748. * Animations to be used for the post processing
  15749. */
  15750. animations: import("babylonjs/Animations/animation").Animation[];
  15751. /**
  15752. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15753. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15754. */
  15755. enablePixelPerfectMode: boolean;
  15756. /**
  15757. * Force the postprocess to be applied without taking in account viewport
  15758. */
  15759. forceFullscreenViewport: boolean;
  15760. /**
  15761. * List of inspectable custom properties (used by the Inspector)
  15762. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15763. */
  15764. inspectableCustomProperties: IInspectable[];
  15765. /**
  15766. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15767. *
  15768. * | Value | Type | Description |
  15769. * | ----- | ----------------------------------- | ----------- |
  15770. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15771. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15772. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15773. *
  15774. */
  15775. scaleMode: number;
  15776. /**
  15777. * Force textures to be a power of two (default: false)
  15778. */
  15779. alwaysForcePOT: boolean;
  15780. private _samples;
  15781. /**
  15782. * Number of sample textures (default: 1)
  15783. */
  15784. samples: number;
  15785. /**
  15786. * Modify the scale of the post process to be the same as the viewport (default: false)
  15787. */
  15788. adaptScaleToCurrentViewport: boolean;
  15789. private _camera;
  15790. private _scene;
  15791. private _engine;
  15792. private _options;
  15793. private _reusable;
  15794. private _textureType;
  15795. /**
  15796. * Smart array of input and output textures for the post process.
  15797. * @hidden
  15798. */
  15799. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15800. /**
  15801. * The index in _textures that corresponds to the output texture.
  15802. * @hidden
  15803. */
  15804. _currentRenderTextureInd: number;
  15805. private _effect;
  15806. private _samplers;
  15807. private _fragmentUrl;
  15808. private _vertexUrl;
  15809. private _parameters;
  15810. private _scaleRatio;
  15811. protected _indexParameters: any;
  15812. private _shareOutputWithPostProcess;
  15813. private _texelSize;
  15814. private _forcedOutputTexture;
  15815. /**
  15816. * Returns the fragment url or shader name used in the post process.
  15817. * @returns the fragment url or name in the shader store.
  15818. */
  15819. getEffectName(): string;
  15820. /**
  15821. * An event triggered when the postprocess is activated.
  15822. */
  15823. onActivateObservable: Observable<Camera>;
  15824. private _onActivateObserver;
  15825. /**
  15826. * A function that is added to the onActivateObservable
  15827. */
  15828. onActivate: Nullable<(camera: Camera) => void>;
  15829. /**
  15830. * An event triggered when the postprocess changes its size.
  15831. */
  15832. onSizeChangedObservable: Observable<PostProcess>;
  15833. private _onSizeChangedObserver;
  15834. /**
  15835. * A function that is added to the onSizeChangedObservable
  15836. */
  15837. onSizeChanged: (postProcess: PostProcess) => void;
  15838. /**
  15839. * An event triggered when the postprocess applies its effect.
  15840. */
  15841. onApplyObservable: Observable<Effect>;
  15842. private _onApplyObserver;
  15843. /**
  15844. * A function that is added to the onApplyObservable
  15845. */
  15846. onApply: (effect: Effect) => void;
  15847. /**
  15848. * An event triggered before rendering the postprocess
  15849. */
  15850. onBeforeRenderObservable: Observable<Effect>;
  15851. private _onBeforeRenderObserver;
  15852. /**
  15853. * A function that is added to the onBeforeRenderObservable
  15854. */
  15855. onBeforeRender: (effect: Effect) => void;
  15856. /**
  15857. * An event triggered after rendering the postprocess
  15858. */
  15859. onAfterRenderObservable: Observable<Effect>;
  15860. private _onAfterRenderObserver;
  15861. /**
  15862. * A function that is added to the onAfterRenderObservable
  15863. */
  15864. onAfterRender: (efect: Effect) => void;
  15865. /**
  15866. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15867. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15868. */
  15869. inputTexture: InternalTexture;
  15870. /**
  15871. * Gets the camera which post process is applied to.
  15872. * @returns The camera the post process is applied to.
  15873. */
  15874. getCamera(): Camera;
  15875. /**
  15876. * Gets the texel size of the postprocess.
  15877. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15878. */
  15879. readonly texelSize: Vector2;
  15880. /**
  15881. * Creates a new instance PostProcess
  15882. * @param name The name of the PostProcess.
  15883. * @param fragmentUrl The url of the fragment shader to be used.
  15884. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15885. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15886. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15887. * @param camera The camera to apply the render pass to.
  15888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15889. * @param engine The engine which the post process will be applied. (default: current engine)
  15890. * @param reusable If the post process can be reused on the same frame. (default: false)
  15891. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15892. * @param textureType Type of textures used when performing the post process. (default: 0)
  15893. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15894. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15895. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15896. */
  15897. constructor(
  15898. /** Name of the PostProcess. */
  15899. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15900. /**
  15901. * Gets a string idenfifying the name of the class
  15902. * @returns "PostProcess" string
  15903. */
  15904. getClassName(): string;
  15905. /**
  15906. * Gets the engine which this post process belongs to.
  15907. * @returns The engine the post process was enabled with.
  15908. */
  15909. getEngine(): Engine;
  15910. /**
  15911. * The effect that is created when initializing the post process.
  15912. * @returns The created effect corresponding the the postprocess.
  15913. */
  15914. getEffect(): Effect;
  15915. /**
  15916. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15917. * @param postProcess The post process to share the output with.
  15918. * @returns This post process.
  15919. */
  15920. shareOutputWith(postProcess: PostProcess): PostProcess;
  15921. /**
  15922. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15923. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15924. */
  15925. useOwnOutput(): void;
  15926. /**
  15927. * Updates the effect with the current post process compile time values and recompiles the shader.
  15928. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15929. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15930. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15931. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15932. * @param onCompiled Called when the shader has been compiled.
  15933. * @param onError Called if there is an error when compiling a shader.
  15934. */
  15935. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15936. /**
  15937. * The post process is reusable if it can be used multiple times within one frame.
  15938. * @returns If the post process is reusable
  15939. */
  15940. isReusable(): boolean;
  15941. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15942. markTextureDirty(): void;
  15943. /**
  15944. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15945. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15946. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15947. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15948. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15949. * @returns The target texture that was bound to be written to.
  15950. */
  15951. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15952. /**
  15953. * If the post process is supported.
  15954. */
  15955. readonly isSupported: boolean;
  15956. /**
  15957. * The aspect ratio of the output texture.
  15958. */
  15959. readonly aspectRatio: number;
  15960. /**
  15961. * Get a value indicating if the post-process is ready to be used
  15962. * @returns true if the post-process is ready (shader is compiled)
  15963. */
  15964. isReady(): boolean;
  15965. /**
  15966. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15967. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15968. */
  15969. apply(): Nullable<Effect>;
  15970. private _disposeTextures;
  15971. /**
  15972. * Disposes the post process.
  15973. * @param camera The camera to dispose the post process on.
  15974. */
  15975. dispose(camera?: Camera): void;
  15976. }
  15977. }
  15978. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15979. /** @hidden */
  15980. export var kernelBlurVaryingDeclaration: {
  15981. name: string;
  15982. shader: string;
  15983. };
  15984. }
  15985. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15986. /** @hidden */
  15987. export var kernelBlurFragment: {
  15988. name: string;
  15989. shader: string;
  15990. };
  15991. }
  15992. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15993. /** @hidden */
  15994. export var kernelBlurFragment2: {
  15995. name: string;
  15996. shader: string;
  15997. };
  15998. }
  15999. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16000. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16001. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16002. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16003. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16004. /** @hidden */
  16005. export var kernelBlurPixelShader: {
  16006. name: string;
  16007. shader: string;
  16008. };
  16009. }
  16010. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16011. /** @hidden */
  16012. export var kernelBlurVertex: {
  16013. name: string;
  16014. shader: string;
  16015. };
  16016. }
  16017. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16018. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16019. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16020. /** @hidden */
  16021. export var kernelBlurVertexShader: {
  16022. name: string;
  16023. shader: string;
  16024. };
  16025. }
  16026. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16027. import { Vector2 } from "babylonjs/Maths/math.vector";
  16028. import { Nullable } from "babylonjs/types";
  16029. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16030. import { Camera } from "babylonjs/Cameras/camera";
  16031. import { Effect } from "babylonjs/Materials/effect";
  16032. import { Engine } from "babylonjs/Engines/engine";
  16033. import "babylonjs/Shaders/kernelBlur.fragment";
  16034. import "babylonjs/Shaders/kernelBlur.vertex";
  16035. /**
  16036. * The Blur Post Process which blurs an image based on a kernel and direction.
  16037. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16038. */
  16039. export class BlurPostProcess extends PostProcess {
  16040. /** The direction in which to blur the image. */
  16041. direction: Vector2;
  16042. private blockCompilation;
  16043. protected _kernel: number;
  16044. protected _idealKernel: number;
  16045. protected _packedFloat: boolean;
  16046. private _staticDefines;
  16047. /**
  16048. * Sets the length in pixels of the blur sample region
  16049. */
  16050. /**
  16051. * Gets the length in pixels of the blur sample region
  16052. */
  16053. kernel: number;
  16054. /**
  16055. * Sets wether or not the blur needs to unpack/repack floats
  16056. */
  16057. /**
  16058. * Gets wether or not the blur is unpacking/repacking floats
  16059. */
  16060. packedFloat: boolean;
  16061. /**
  16062. * Creates a new instance BlurPostProcess
  16063. * @param name The name of the effect.
  16064. * @param direction The direction in which to blur the image.
  16065. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  16066. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16067. * @param camera The camera to apply the render pass to.
  16068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16069. * @param engine The engine which the post process will be applied. (default: current engine)
  16070. * @param reusable If the post process can be reused on the same frame. (default: false)
  16071. * @param textureType Type of textures used when performing the post process. (default: 0)
  16072. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  16073. */
  16074. constructor(name: string,
  16075. /** The direction in which to blur the image. */
  16076. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16077. /**
  16078. * Updates the effect with the current post process compile time values and recompiles the shader.
  16079. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16080. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16081. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16082. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  16083. * @param onCompiled Called when the shader has been compiled.
  16084. * @param onError Called if there is an error when compiling a shader.
  16085. */
  16086. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16087. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16088. /**
  16089. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16090. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16091. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16092. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16093. * The gaps between physical kernels are compensated for in the weighting of the samples
  16094. * @param idealKernel Ideal blur kernel.
  16095. * @return Nearest best kernel.
  16096. */
  16097. protected _nearestBestKernel(idealKernel: number): number;
  16098. /**
  16099. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16100. * @param x The point on the Gaussian distribution to sample.
  16101. * @return the value of the Gaussian function at x.
  16102. */
  16103. protected _gaussianWeight(x: number): number;
  16104. /**
  16105. * Generates a string that can be used as a floating point number in GLSL.
  16106. * @param x Value to print.
  16107. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16108. * @return GLSL float string.
  16109. */
  16110. protected _glslFloat(x: number, decimalFigures?: number): string;
  16111. }
  16112. }
  16113. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16114. import { Scene } from "babylonjs/scene";
  16115. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16116. import { Plane } from "babylonjs/Maths/math.plane";
  16117. /**
  16118. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16119. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16120. * You can then easily use it as a reflectionTexture on a flat surface.
  16121. * In case the surface is not a plane, please consider relying on reflection probes.
  16122. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16123. */
  16124. export class MirrorTexture extends RenderTargetTexture {
  16125. private scene;
  16126. /**
  16127. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16128. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  16129. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16130. */
  16131. mirrorPlane: Plane;
  16132. /**
  16133. * Define the blur ratio used to blur the reflection if needed.
  16134. */
  16135. blurRatio: number;
  16136. /**
  16137. * Define the adaptive blur kernel used to blur the reflection if needed.
  16138. * This will autocompute the closest best match for the `blurKernel`
  16139. */
  16140. adaptiveBlurKernel: number;
  16141. /**
  16142. * Define the blur kernel used to blur the reflection if needed.
  16143. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16144. */
  16145. blurKernel: number;
  16146. /**
  16147. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16148. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16149. */
  16150. blurKernelX: number;
  16151. /**
  16152. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16153. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16154. */
  16155. blurKernelY: number;
  16156. private _autoComputeBlurKernel;
  16157. protected _onRatioRescale(): void;
  16158. private _updateGammaSpace;
  16159. private _imageProcessingConfigChangeObserver;
  16160. private _transformMatrix;
  16161. private _mirrorMatrix;
  16162. private _savedViewMatrix;
  16163. private _blurX;
  16164. private _blurY;
  16165. private _adaptiveBlurKernel;
  16166. private _blurKernelX;
  16167. private _blurKernelY;
  16168. private _blurRatio;
  16169. /**
  16170. * Instantiates a Mirror Texture.
  16171. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16172. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16173. * You can then easily use it as a reflectionTexture on a flat surface.
  16174. * In case the surface is not a plane, please consider relying on reflection probes.
  16175. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16176. * @param name
  16177. * @param size
  16178. * @param scene
  16179. * @param generateMipMaps
  16180. * @param type
  16181. * @param samplingMode
  16182. * @param generateDepthBuffer
  16183. */
  16184. constructor(name: string, size: number | {
  16185. width: number;
  16186. height: number;
  16187. } | {
  16188. ratio: number;
  16189. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16190. private _preparePostProcesses;
  16191. /**
  16192. * Clone the mirror texture.
  16193. * @returns the cloned texture
  16194. */
  16195. clone(): MirrorTexture;
  16196. /**
  16197. * Serialize the texture to a JSON representation you could use in Parse later on
  16198. * @returns the serialized JSON representation
  16199. */
  16200. serialize(): any;
  16201. /**
  16202. * Dispose the texture and release its associated resources.
  16203. */
  16204. dispose(): void;
  16205. }
  16206. }
  16207. declare module "babylonjs/Materials/Textures/texture" {
  16208. import { Observable } from "babylonjs/Misc/observable";
  16209. import { Nullable } from "babylonjs/types";
  16210. import { Matrix } from "babylonjs/Maths/math.vector";
  16211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16212. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16213. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16214. import { Scene } from "babylonjs/scene";
  16215. /**
  16216. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16217. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16218. */
  16219. export class Texture extends BaseTexture {
  16220. /**
  16221. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16222. */
  16223. static SerializeBuffers: boolean;
  16224. /** @hidden */
  16225. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16226. /** @hidden */
  16227. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16228. /** @hidden */
  16229. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16230. /** nearest is mag = nearest and min = nearest and mip = linear */
  16231. static readonly NEAREST_SAMPLINGMODE: number;
  16232. /** nearest is mag = nearest and min = nearest and mip = linear */
  16233. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16234. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16235. static readonly BILINEAR_SAMPLINGMODE: number;
  16236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16237. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16238. /** Trilinear is mag = linear and min = linear and mip = linear */
  16239. static readonly TRILINEAR_SAMPLINGMODE: number;
  16240. /** Trilinear is mag = linear and min = linear and mip = linear */
  16241. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16242. /** mag = nearest and min = nearest and mip = nearest */
  16243. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16244. /** mag = nearest and min = linear and mip = nearest */
  16245. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16246. /** mag = nearest and min = linear and mip = linear */
  16247. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16248. /** mag = nearest and min = linear and mip = none */
  16249. static readonly NEAREST_LINEAR: number;
  16250. /** mag = nearest and min = nearest and mip = none */
  16251. static readonly NEAREST_NEAREST: number;
  16252. /** mag = linear and min = nearest and mip = nearest */
  16253. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16254. /** mag = linear and min = nearest and mip = linear */
  16255. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16256. /** mag = linear and min = linear and mip = none */
  16257. static readonly LINEAR_LINEAR: number;
  16258. /** mag = linear and min = nearest and mip = none */
  16259. static readonly LINEAR_NEAREST: number;
  16260. /** Explicit coordinates mode */
  16261. static readonly EXPLICIT_MODE: number;
  16262. /** Spherical coordinates mode */
  16263. static readonly SPHERICAL_MODE: number;
  16264. /** Planar coordinates mode */
  16265. static readonly PLANAR_MODE: number;
  16266. /** Cubic coordinates mode */
  16267. static readonly CUBIC_MODE: number;
  16268. /** Projection coordinates mode */
  16269. static readonly PROJECTION_MODE: number;
  16270. /** Inverse Cubic coordinates mode */
  16271. static readonly SKYBOX_MODE: number;
  16272. /** Inverse Cubic coordinates mode */
  16273. static readonly INVCUBIC_MODE: number;
  16274. /** Equirectangular coordinates mode */
  16275. static readonly EQUIRECTANGULAR_MODE: number;
  16276. /** Equirectangular Fixed coordinates mode */
  16277. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16278. /** Equirectangular Fixed Mirrored coordinates mode */
  16279. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16280. /** Texture is not repeating outside of 0..1 UVs */
  16281. static readonly CLAMP_ADDRESSMODE: number;
  16282. /** Texture is repeating outside of 0..1 UVs */
  16283. static readonly WRAP_ADDRESSMODE: number;
  16284. /** Texture is repeating and mirrored */
  16285. static readonly MIRROR_ADDRESSMODE: number;
  16286. /**
  16287. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  16288. */
  16289. static UseSerializedUrlIfAny: boolean;
  16290. /**
  16291. * Define the url of the texture.
  16292. */
  16293. url: Nullable<string>;
  16294. /**
  16295. * Define an offset on the texture to offset the u coordinates of the UVs
  16296. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16297. */
  16298. uOffset: number;
  16299. /**
  16300. * Define an offset on the texture to offset the v coordinates of the UVs
  16301. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16302. */
  16303. vOffset: number;
  16304. /**
  16305. * Define an offset on the texture to scale the u coordinates of the UVs
  16306. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16307. */
  16308. uScale: number;
  16309. /**
  16310. * Define an offset on the texture to scale the v coordinates of the UVs
  16311. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16312. */
  16313. vScale: number;
  16314. /**
  16315. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16316. * @see http://doc.babylonjs.com/how_to/more_materials
  16317. */
  16318. uAng: number;
  16319. /**
  16320. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16321. * @see http://doc.babylonjs.com/how_to/more_materials
  16322. */
  16323. vAng: number;
  16324. /**
  16325. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16326. * @see http://doc.babylonjs.com/how_to/more_materials
  16327. */
  16328. wAng: number;
  16329. /**
  16330. * Defines the center of rotation (U)
  16331. */
  16332. uRotationCenter: number;
  16333. /**
  16334. * Defines the center of rotation (V)
  16335. */
  16336. vRotationCenter: number;
  16337. /**
  16338. * Defines the center of rotation (W)
  16339. */
  16340. wRotationCenter: number;
  16341. /**
  16342. * Are mip maps generated for this texture or not.
  16343. */
  16344. readonly noMipmap: boolean;
  16345. /**
  16346. * List of inspectable custom properties (used by the Inspector)
  16347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16348. */
  16349. inspectableCustomProperties: Nullable<IInspectable[]>;
  16350. private _noMipmap;
  16351. /** @hidden */
  16352. _invertY: boolean;
  16353. private _rowGenerationMatrix;
  16354. private _cachedTextureMatrix;
  16355. private _projectionModeMatrix;
  16356. private _t0;
  16357. private _t1;
  16358. private _t2;
  16359. private _cachedUOffset;
  16360. private _cachedVOffset;
  16361. private _cachedUScale;
  16362. private _cachedVScale;
  16363. private _cachedUAng;
  16364. private _cachedVAng;
  16365. private _cachedWAng;
  16366. private _cachedProjectionMatrixId;
  16367. private _cachedCoordinatesMode;
  16368. /** @hidden */
  16369. protected _initialSamplingMode: number;
  16370. /** @hidden */
  16371. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16372. private _deleteBuffer;
  16373. protected _format: Nullable<number>;
  16374. private _delayedOnLoad;
  16375. private _delayedOnError;
  16376. private _mimeType?;
  16377. /**
  16378. * Observable triggered once the texture has been loaded.
  16379. */
  16380. onLoadObservable: Observable<Texture>;
  16381. protected _isBlocking: boolean;
  16382. /**
  16383. * Is the texture preventing material to render while loading.
  16384. * If false, a default texture will be used instead of the loading one during the preparation step.
  16385. */
  16386. isBlocking: boolean;
  16387. /**
  16388. * Get the current sampling mode associated with the texture.
  16389. */
  16390. readonly samplingMode: number;
  16391. /**
  16392. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16393. */
  16394. readonly invertY: boolean;
  16395. /**
  16396. * Instantiates a new texture.
  16397. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16398. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16399. * @param url defines the url of the picture to load as a texture
  16400. * @param scene defines the scene or engine the texture will belong to
  16401. * @param noMipmap defines if the texture will require mip maps or not
  16402. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16403. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16404. * @param onLoad defines a callback triggered when the texture has been loaded
  16405. * @param onError defines a callback triggered when an error occurred during the loading session
  16406. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16407. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16408. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16409. * @param mimeType defines an optional mime type information
  16410. */
  16411. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16412. /**
  16413. * Update the url (and optional buffer) of this texture if url was null during construction.
  16414. * @param url the url of the texture
  16415. * @param buffer the buffer of the texture (defaults to null)
  16416. * @param onLoad callback called when the texture is loaded (defaults to null)
  16417. */
  16418. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16419. /**
  16420. * Finish the loading sequence of a texture flagged as delayed load.
  16421. * @hidden
  16422. */
  16423. delayLoad(): void;
  16424. private _prepareRowForTextureGeneration;
  16425. /**
  16426. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16427. * @returns the transform matrix of the texture.
  16428. */
  16429. getTextureMatrix(uBase?: number): Matrix;
  16430. /**
  16431. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16432. * @returns The reflection texture transform
  16433. */
  16434. getReflectionTextureMatrix(): Matrix;
  16435. /**
  16436. * Clones the texture.
  16437. * @returns the cloned texture
  16438. */
  16439. clone(): Texture;
  16440. /**
  16441. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16442. * @returns The JSON representation of the texture
  16443. */
  16444. serialize(): any;
  16445. /**
  16446. * Get the current class name of the texture useful for serialization or dynamic coding.
  16447. * @returns "Texture"
  16448. */
  16449. getClassName(): string;
  16450. /**
  16451. * Dispose the texture and release its associated resources.
  16452. */
  16453. dispose(): void;
  16454. /**
  16455. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16456. * @param parsedTexture Define the JSON representation of the texture
  16457. * @param scene Define the scene the parsed texture should be instantiated in
  16458. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16459. * @returns The parsed texture if successful
  16460. */
  16461. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16462. /**
  16463. * Creates a texture from its base 64 representation.
  16464. * @param data Define the base64 payload without the data: prefix
  16465. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16466. * @param scene Define the scene the texture should belong to
  16467. * @param noMipmap Forces the texture to not create mip map information if true
  16468. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16469. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16470. * @param onLoad define a callback triggered when the texture has been loaded
  16471. * @param onError define a callback triggered when an error occurred during the loading session
  16472. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16473. * @returns the created texture
  16474. */
  16475. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16476. /**
  16477. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16478. * @param data Define the base64 payload without the data: prefix
  16479. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16480. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16481. * @param scene Define the scene the texture should belong to
  16482. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16483. * @param noMipmap Forces the texture to not create mip map information if true
  16484. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16485. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16486. * @param onLoad define a callback triggered when the texture has been loaded
  16487. * @param onError define a callback triggered when an error occurred during the loading session
  16488. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16489. * @returns the created texture
  16490. */
  16491. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  16492. }
  16493. }
  16494. declare module "babylonjs/PostProcesses/postProcessManager" {
  16495. import { Nullable } from "babylonjs/types";
  16496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16497. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16498. import { Scene } from "babylonjs/scene";
  16499. /**
  16500. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16501. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16502. */
  16503. export class PostProcessManager {
  16504. private _scene;
  16505. private _indexBuffer;
  16506. private _vertexBuffers;
  16507. /**
  16508. * Creates a new instance PostProcess
  16509. * @param scene The scene that the post process is associated with.
  16510. */
  16511. constructor(scene: Scene);
  16512. private _prepareBuffers;
  16513. private _buildIndexBuffer;
  16514. /**
  16515. * Rebuilds the vertex buffers of the manager.
  16516. * @hidden
  16517. */
  16518. _rebuild(): void;
  16519. /**
  16520. * Prepares a frame to be run through a post process.
  16521. * @param sourceTexture The input texture to the post procesess. (default: null)
  16522. * @param postProcesses An array of post processes to be run. (default: null)
  16523. * @returns True if the post processes were able to be run.
  16524. * @hidden
  16525. */
  16526. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16527. /**
  16528. * Manually render a set of post processes to a texture.
  16529. * @param postProcesses An array of post processes to be run.
  16530. * @param targetTexture The target texture to render to.
  16531. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16532. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16533. * @param lodLevel defines which lod of the texture to render to
  16534. */
  16535. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16536. /**
  16537. * Finalize the result of the output of the postprocesses.
  16538. * @param doNotPresent If true the result will not be displayed to the screen.
  16539. * @param targetTexture The target texture to render to.
  16540. * @param faceIndex The index of the face to bind the target texture to.
  16541. * @param postProcesses The array of post processes to render.
  16542. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16543. * @hidden
  16544. */
  16545. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16546. /**
  16547. * Disposes of the post process manager.
  16548. */
  16549. dispose(): void;
  16550. }
  16551. }
  16552. declare module "babylonjs/Misc/gradients" {
  16553. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16554. /** Interface used by value gradients (color, factor, ...) */
  16555. export interface IValueGradient {
  16556. /**
  16557. * Gets or sets the gradient value (between 0 and 1)
  16558. */
  16559. gradient: number;
  16560. }
  16561. /** Class used to store color4 gradient */
  16562. export class ColorGradient implements IValueGradient {
  16563. /**
  16564. * Gets or sets the gradient value (between 0 and 1)
  16565. */
  16566. gradient: number;
  16567. /**
  16568. * Gets or sets first associated color
  16569. */
  16570. color1: Color4;
  16571. /**
  16572. * Gets or sets second associated color
  16573. */
  16574. color2?: Color4;
  16575. /**
  16576. * Will get a color picked randomly between color1 and color2.
  16577. * If color2 is undefined then color1 will be used
  16578. * @param result defines the target Color4 to store the result in
  16579. */
  16580. getColorToRef(result: Color4): void;
  16581. }
  16582. /** Class used to store color 3 gradient */
  16583. export class Color3Gradient implements IValueGradient {
  16584. /**
  16585. * Gets or sets the gradient value (between 0 and 1)
  16586. */
  16587. gradient: number;
  16588. /**
  16589. * Gets or sets the associated color
  16590. */
  16591. color: Color3;
  16592. }
  16593. /** Class used to store factor gradient */
  16594. export class FactorGradient implements IValueGradient {
  16595. /**
  16596. * Gets or sets the gradient value (between 0 and 1)
  16597. */
  16598. gradient: number;
  16599. /**
  16600. * Gets or sets first associated factor
  16601. */
  16602. factor1: number;
  16603. /**
  16604. * Gets or sets second associated factor
  16605. */
  16606. factor2?: number;
  16607. /**
  16608. * Will get a number picked randomly between factor1 and factor2.
  16609. * If factor2 is undefined then factor1 will be used
  16610. * @returns the picked number
  16611. */
  16612. getFactor(): number;
  16613. }
  16614. /**
  16615. * Helper used to simplify some generic gradient tasks
  16616. */
  16617. export class GradientHelper {
  16618. /**
  16619. * Gets the current gradient from an array of IValueGradient
  16620. * @param ratio defines the current ratio to get
  16621. * @param gradients defines the array of IValueGradient
  16622. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16623. */
  16624. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16625. }
  16626. }
  16627. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16628. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16629. import { Nullable } from "babylonjs/types";
  16630. module "babylonjs/Engines/thinEngine" {
  16631. interface ThinEngine {
  16632. /**
  16633. * Creates a dynamic texture
  16634. * @param width defines the width of the texture
  16635. * @param height defines the height of the texture
  16636. * @param generateMipMaps defines if the engine should generate the mip levels
  16637. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16638. * @returns the dynamic texture inside an InternalTexture
  16639. */
  16640. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16641. /**
  16642. * Update the content of a dynamic texture
  16643. * @param texture defines the texture to update
  16644. * @param canvas defines the canvas containing the source
  16645. * @param invertY defines if data must be stored with Y axis inverted
  16646. * @param premulAlpha defines if alpha is stored as premultiplied
  16647. * @param format defines the format of the data
  16648. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16649. */
  16650. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16651. }
  16652. }
  16653. }
  16654. declare module "babylonjs/Misc/canvasGenerator" {
  16655. /**
  16656. * Helper class used to generate a canvas to manipulate images
  16657. */
  16658. export class CanvasGenerator {
  16659. /**
  16660. * Create a new canvas (or offscreen canvas depending on the context)
  16661. * @param width defines the expected width
  16662. * @param height defines the expected height
  16663. * @return a new canvas or offscreen canvas
  16664. */
  16665. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16666. }
  16667. }
  16668. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16669. import { Scene } from "babylonjs/scene";
  16670. import { Texture } from "babylonjs/Materials/Textures/texture";
  16671. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16672. /**
  16673. * A class extending Texture allowing drawing on a texture
  16674. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16675. */
  16676. export class DynamicTexture extends Texture {
  16677. private _generateMipMaps;
  16678. private _canvas;
  16679. private _context;
  16680. private _engine;
  16681. /**
  16682. * Creates a DynamicTexture
  16683. * @param name defines the name of the texture
  16684. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  16685. * @param scene defines the scene where you want the texture
  16686. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16687. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16688. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16689. */
  16690. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16691. /**
  16692. * Get the current class name of the texture useful for serialization or dynamic coding.
  16693. * @returns "DynamicTexture"
  16694. */
  16695. getClassName(): string;
  16696. /**
  16697. * Gets the current state of canRescale
  16698. */
  16699. readonly canRescale: boolean;
  16700. private _recreate;
  16701. /**
  16702. * Scales the texture
  16703. * @param ratio the scale factor to apply to both width and height
  16704. */
  16705. scale(ratio: number): void;
  16706. /**
  16707. * Resizes the texture
  16708. * @param width the new width
  16709. * @param height the new height
  16710. */
  16711. scaleTo(width: number, height: number): void;
  16712. /**
  16713. * Gets the context of the canvas used by the texture
  16714. * @returns the canvas context of the dynamic texture
  16715. */
  16716. getContext(): CanvasRenderingContext2D;
  16717. /**
  16718. * Clears the texture
  16719. */
  16720. clear(): void;
  16721. /**
  16722. * Updates the texture
  16723. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16724. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16725. */
  16726. update(invertY?: boolean, premulAlpha?: boolean): void;
  16727. /**
  16728. * Draws text onto the texture
  16729. * @param text defines the text to be drawn
  16730. * @param x defines the placement of the text from the left
  16731. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16732. * @param font defines the font to be used with font-style, font-size, font-name
  16733. * @param color defines the color used for the text
  16734. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16735. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16736. * @param update defines whether texture is immediately update (default is true)
  16737. */
  16738. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16739. /**
  16740. * Clones the texture
  16741. * @returns the clone of the texture.
  16742. */
  16743. clone(): DynamicTexture;
  16744. /**
  16745. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16746. * @returns a serialized dynamic texture object
  16747. */
  16748. serialize(): any;
  16749. /** @hidden */
  16750. _rebuild(): void;
  16751. }
  16752. }
  16753. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16754. import { Scene } from "babylonjs/scene";
  16755. import { ISceneComponent } from "babylonjs/sceneComponent";
  16756. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16757. module "babylonjs/abstractScene" {
  16758. interface AbstractScene {
  16759. /**
  16760. * The list of procedural textures added to the scene
  16761. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16762. */
  16763. proceduralTextures: Array<ProceduralTexture>;
  16764. }
  16765. }
  16766. /**
  16767. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16768. * in a given scene.
  16769. */
  16770. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16771. /**
  16772. * The component name helpfull to identify the component in the list of scene components.
  16773. */
  16774. readonly name: string;
  16775. /**
  16776. * The scene the component belongs to.
  16777. */
  16778. scene: Scene;
  16779. /**
  16780. * Creates a new instance of the component for the given scene
  16781. * @param scene Defines the scene to register the component in
  16782. */
  16783. constructor(scene: Scene);
  16784. /**
  16785. * Registers the component in a given scene
  16786. */
  16787. register(): void;
  16788. /**
  16789. * Rebuilds the elements related to this component in case of
  16790. * context lost for instance.
  16791. */
  16792. rebuild(): void;
  16793. /**
  16794. * Disposes the component and the associated ressources.
  16795. */
  16796. dispose(): void;
  16797. private _beforeClear;
  16798. }
  16799. }
  16800. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16802. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16803. module "babylonjs/Engines/thinEngine" {
  16804. interface ThinEngine {
  16805. /**
  16806. * Creates a new render target cube texture
  16807. * @param size defines the size of the texture
  16808. * @param options defines the options used to create the texture
  16809. * @returns a new render target cube texture stored in an InternalTexture
  16810. */
  16811. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16812. }
  16813. }
  16814. }
  16815. declare module "babylonjs/Shaders/procedural.vertex" {
  16816. /** @hidden */
  16817. export var proceduralVertexShader: {
  16818. name: string;
  16819. shader: string;
  16820. };
  16821. }
  16822. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16823. import { Observable } from "babylonjs/Misc/observable";
  16824. import { Nullable } from "babylonjs/types";
  16825. import { Scene } from "babylonjs/scene";
  16826. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16827. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16828. import { Effect } from "babylonjs/Materials/effect";
  16829. import { Texture } from "babylonjs/Materials/Textures/texture";
  16830. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16831. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16832. import "babylonjs/Shaders/procedural.vertex";
  16833. /**
  16834. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  16835. * This is the base class of any Procedural texture and contains most of the shareable code.
  16836. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16837. */
  16838. export class ProceduralTexture extends Texture {
  16839. isCube: boolean;
  16840. /**
  16841. * Define if the texture is enabled or not (disabled texture will not render)
  16842. */
  16843. isEnabled: boolean;
  16844. /**
  16845. * Define if the texture must be cleared before rendering (default is true)
  16846. */
  16847. autoClear: boolean;
  16848. /**
  16849. * Callback called when the texture is generated
  16850. */
  16851. onGenerated: () => void;
  16852. /**
  16853. * Event raised when the texture is generated
  16854. */
  16855. onGeneratedObservable: Observable<ProceduralTexture>;
  16856. /** @hidden */
  16857. _generateMipMaps: boolean;
  16858. /** @hidden **/
  16859. _effect: Effect;
  16860. /** @hidden */
  16861. _textures: {
  16862. [key: string]: Texture;
  16863. };
  16864. private _size;
  16865. private _currentRefreshId;
  16866. private _refreshRate;
  16867. private _vertexBuffers;
  16868. private _indexBuffer;
  16869. private _uniforms;
  16870. private _samplers;
  16871. private _fragment;
  16872. private _floats;
  16873. private _ints;
  16874. private _floatsArrays;
  16875. private _colors3;
  16876. private _colors4;
  16877. private _vectors2;
  16878. private _vectors3;
  16879. private _matrices;
  16880. private _fallbackTexture;
  16881. private _fallbackTextureUsed;
  16882. private _engine;
  16883. private _cachedDefines;
  16884. private _contentUpdateId;
  16885. private _contentData;
  16886. /**
  16887. * Instantiates a new procedural texture.
  16888. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16889. * This is the base class of any Procedural texture and contains most of the shareable code.
  16890. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16891. * @param name Define the name of the texture
  16892. * @param size Define the size of the texture to create
  16893. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16894. * @param scene Define the scene the texture belongs to
  16895. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16896. * @param generateMipMaps Define if the texture should creates mip maps or not
  16897. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16898. */
  16899. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16900. /**
  16901. * The effect that is created when initializing the post process.
  16902. * @returns The created effect corresponding the the postprocess.
  16903. */
  16904. getEffect(): Effect;
  16905. /**
  16906. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16907. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16908. */
  16909. getContent(): Nullable<ArrayBufferView>;
  16910. private _createIndexBuffer;
  16911. /** @hidden */
  16912. _rebuild(): void;
  16913. /**
  16914. * Resets the texture in order to recreate its associated resources.
  16915. * This can be called in case of context loss
  16916. */
  16917. reset(): void;
  16918. protected _getDefines(): string;
  16919. /**
  16920. * Is the texture ready to be used ? (rendered at least once)
  16921. * @returns true if ready, otherwise, false.
  16922. */
  16923. isReady(): boolean;
  16924. /**
  16925. * Resets the refresh counter of the texture and start bak from scratch.
  16926. * Could be useful to regenerate the texture if it is setup to render only once.
  16927. */
  16928. resetRefreshCounter(): void;
  16929. /**
  16930. * Set the fragment shader to use in order to render the texture.
  16931. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16932. */
  16933. setFragment(fragment: any): void;
  16934. /**
  16935. * Define the refresh rate of the texture or the rendering frequency.
  16936. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16937. */
  16938. refreshRate: number;
  16939. /** @hidden */
  16940. _shouldRender(): boolean;
  16941. /**
  16942. * Get the size the texture is rendering at.
  16943. * @returns the size (texture is always squared)
  16944. */
  16945. getRenderSize(): number;
  16946. /**
  16947. * Resize the texture to new value.
  16948. * @param size Define the new size the texture should have
  16949. * @param generateMipMaps Define whether the new texture should create mip maps
  16950. */
  16951. resize(size: number, generateMipMaps: boolean): void;
  16952. private _checkUniform;
  16953. /**
  16954. * Set a texture in the shader program used to render.
  16955. * @param name Define the name of the uniform samplers as defined in the shader
  16956. * @param texture Define the texture to bind to this sampler
  16957. * @return the texture itself allowing "fluent" like uniform updates
  16958. */
  16959. setTexture(name: string, texture: Texture): ProceduralTexture;
  16960. /**
  16961. * Set a float in the shader.
  16962. * @param name Define the name of the uniform as defined in the shader
  16963. * @param value Define the value to give to the uniform
  16964. * @return the texture itself allowing "fluent" like uniform updates
  16965. */
  16966. setFloat(name: string, value: number): ProceduralTexture;
  16967. /**
  16968. * Set a int in the shader.
  16969. * @param name Define the name of the uniform as defined in the shader
  16970. * @param value Define the value to give to the uniform
  16971. * @return the texture itself allowing "fluent" like uniform updates
  16972. */
  16973. setInt(name: string, value: number): ProceduralTexture;
  16974. /**
  16975. * Set an array of floats in the shader.
  16976. * @param name Define the name of the uniform as defined in the shader
  16977. * @param value Define the value to give to the uniform
  16978. * @return the texture itself allowing "fluent" like uniform updates
  16979. */
  16980. setFloats(name: string, value: number[]): ProceduralTexture;
  16981. /**
  16982. * Set a vec3 in the shader from a Color3.
  16983. * @param name Define the name of the uniform as defined in the shader
  16984. * @param value Define the value to give to the uniform
  16985. * @return the texture itself allowing "fluent" like uniform updates
  16986. */
  16987. setColor3(name: string, value: Color3): ProceduralTexture;
  16988. /**
  16989. * Set a vec4 in the shader from a Color4.
  16990. * @param name Define the name of the uniform as defined in the shader
  16991. * @param value Define the value to give to the uniform
  16992. * @return the texture itself allowing "fluent" like uniform updates
  16993. */
  16994. setColor4(name: string, value: Color4): ProceduralTexture;
  16995. /**
  16996. * Set a vec2 in the shader from a Vector2.
  16997. * @param name Define the name of the uniform as defined in the shader
  16998. * @param value Define the value to give to the uniform
  16999. * @return the texture itself allowing "fluent" like uniform updates
  17000. */
  17001. setVector2(name: string, value: Vector2): ProceduralTexture;
  17002. /**
  17003. * Set a vec3 in the shader from a Vector3.
  17004. * @param name Define the name of the uniform as defined in the shader
  17005. * @param value Define the value to give to the uniform
  17006. * @return the texture itself allowing "fluent" like uniform updates
  17007. */
  17008. setVector3(name: string, value: Vector3): ProceduralTexture;
  17009. /**
  17010. * Set a mat4 in the shader from a MAtrix.
  17011. * @param name Define the name of the uniform as defined in the shader
  17012. * @param value Define the value to give to the uniform
  17013. * @return the texture itself allowing "fluent" like uniform updates
  17014. */
  17015. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17016. /**
  17017. * Render the texture to its associated render target.
  17018. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17019. */
  17020. render(useCameraPostProcess?: boolean): void;
  17021. /**
  17022. * Clone the texture.
  17023. * @returns the cloned texture
  17024. */
  17025. clone(): ProceduralTexture;
  17026. /**
  17027. * Dispose the texture and release its asoociated resources.
  17028. */
  17029. dispose(): void;
  17030. }
  17031. }
  17032. declare module "babylonjs/Particles/baseParticleSystem" {
  17033. import { Nullable } from "babylonjs/types";
  17034. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17036. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17037. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17038. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17039. import { Scene } from "babylonjs/scene";
  17040. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17041. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17042. import { Texture } from "babylonjs/Materials/Textures/texture";
  17043. import { Color4 } from "babylonjs/Maths/math.color";
  17044. import { Animation } from "babylonjs/Animations/animation";
  17045. /**
  17046. * This represents the base class for particle system in Babylon.
  17047. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17048. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17049. * @example https://doc.babylonjs.com/babylon101/particles
  17050. */
  17051. export class BaseParticleSystem {
  17052. /**
  17053. * Source color is added to the destination color without alpha affecting the result
  17054. */
  17055. static BLENDMODE_ONEONE: number;
  17056. /**
  17057. * Blend current color and particle color using particle’s alpha
  17058. */
  17059. static BLENDMODE_STANDARD: number;
  17060. /**
  17061. * Add current color and particle color multiplied by particle’s alpha
  17062. */
  17063. static BLENDMODE_ADD: number;
  17064. /**
  17065. * Multiply current color with particle color
  17066. */
  17067. static BLENDMODE_MULTIPLY: number;
  17068. /**
  17069. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17070. */
  17071. static BLENDMODE_MULTIPLYADD: number;
  17072. /**
  17073. * List of animations used by the particle system.
  17074. */
  17075. animations: Animation[];
  17076. /**
  17077. * The id of the Particle system.
  17078. */
  17079. id: string;
  17080. /**
  17081. * The friendly name of the Particle system.
  17082. */
  17083. name: string;
  17084. /**
  17085. * The rendering group used by the Particle system to chose when to render.
  17086. */
  17087. renderingGroupId: number;
  17088. /**
  17089. * The emitter represents the Mesh or position we are attaching the particle system to.
  17090. */
  17091. emitter: Nullable<AbstractMesh | Vector3>;
  17092. /**
  17093. * The maximum number of particles to emit per frame
  17094. */
  17095. emitRate: number;
  17096. /**
  17097. * If you want to launch only a few particles at once, that can be done, as well.
  17098. */
  17099. manualEmitCount: number;
  17100. /**
  17101. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17102. */
  17103. updateSpeed: number;
  17104. /**
  17105. * The amount of time the particle system is running (depends of the overall update speed).
  17106. */
  17107. targetStopDuration: number;
  17108. /**
  17109. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17110. */
  17111. disposeOnStop: boolean;
  17112. /**
  17113. * Minimum power of emitting particles.
  17114. */
  17115. minEmitPower: number;
  17116. /**
  17117. * Maximum power of emitting particles.
  17118. */
  17119. maxEmitPower: number;
  17120. /**
  17121. * Minimum life time of emitting particles.
  17122. */
  17123. minLifeTime: number;
  17124. /**
  17125. * Maximum life time of emitting particles.
  17126. */
  17127. maxLifeTime: number;
  17128. /**
  17129. * Minimum Size of emitting particles.
  17130. */
  17131. minSize: number;
  17132. /**
  17133. * Maximum Size of emitting particles.
  17134. */
  17135. maxSize: number;
  17136. /**
  17137. * Minimum scale of emitting particles on X axis.
  17138. */
  17139. minScaleX: number;
  17140. /**
  17141. * Maximum scale of emitting particles on X axis.
  17142. */
  17143. maxScaleX: number;
  17144. /**
  17145. * Minimum scale of emitting particles on Y axis.
  17146. */
  17147. minScaleY: number;
  17148. /**
  17149. * Maximum scale of emitting particles on Y axis.
  17150. */
  17151. maxScaleY: number;
  17152. /**
  17153. * Gets or sets the minimal initial rotation in radians.
  17154. */
  17155. minInitialRotation: number;
  17156. /**
  17157. * Gets or sets the maximal initial rotation in radians.
  17158. */
  17159. maxInitialRotation: number;
  17160. /**
  17161. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17162. */
  17163. minAngularSpeed: number;
  17164. /**
  17165. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17166. */
  17167. maxAngularSpeed: number;
  17168. /**
  17169. * The texture used to render each particle. (this can be a spritesheet)
  17170. */
  17171. particleTexture: Nullable<Texture>;
  17172. /**
  17173. * The layer mask we are rendering the particles through.
  17174. */
  17175. layerMask: number;
  17176. /**
  17177. * This can help using your own shader to render the particle system.
  17178. * The according effect will be created
  17179. */
  17180. customShader: any;
  17181. /**
  17182. * By default particle system starts as soon as they are created. This prevents the
  17183. * automatic start to happen and let you decide when to start emitting particles.
  17184. */
  17185. preventAutoStart: boolean;
  17186. private _noiseTexture;
  17187. /**
  17188. * Gets or sets a texture used to add random noise to particle positions
  17189. */
  17190. noiseTexture: Nullable<ProceduralTexture>;
  17191. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17192. noiseStrength: Vector3;
  17193. /**
  17194. * Callback triggered when the particle animation is ending.
  17195. */
  17196. onAnimationEnd: Nullable<() => void>;
  17197. /**
  17198. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17199. */
  17200. blendMode: number;
  17201. /**
  17202. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17203. * to override the particles.
  17204. */
  17205. forceDepthWrite: boolean;
  17206. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  17207. preWarmCycles: number;
  17208. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17209. preWarmStepOffset: number;
  17210. /**
  17211. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  17212. */
  17213. spriteCellChangeSpeed: number;
  17214. /**
  17215. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17216. */
  17217. startSpriteCellID: number;
  17218. /**
  17219. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17220. */
  17221. endSpriteCellID: number;
  17222. /**
  17223. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17224. */
  17225. spriteCellWidth: number;
  17226. /**
  17227. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17228. */
  17229. spriteCellHeight: number;
  17230. /**
  17231. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17232. */
  17233. spriteRandomStartCell: boolean;
  17234. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17235. translationPivot: Vector2;
  17236. /** @hidden */
  17237. protected _isAnimationSheetEnabled: boolean;
  17238. /**
  17239. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17240. */
  17241. beginAnimationOnStart: boolean;
  17242. /**
  17243. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17244. */
  17245. beginAnimationFrom: number;
  17246. /**
  17247. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17248. */
  17249. beginAnimationTo: number;
  17250. /**
  17251. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17252. */
  17253. beginAnimationLoop: boolean;
  17254. /**
  17255. * Gets or sets a world offset applied to all particles
  17256. */
  17257. worldOffset: Vector3;
  17258. /**
  17259. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17260. */
  17261. isAnimationSheetEnabled: boolean;
  17262. /**
  17263. * Get hosting scene
  17264. * @returns the scene
  17265. */
  17266. getScene(): Scene;
  17267. /**
  17268. * You can use gravity if you want to give an orientation to your particles.
  17269. */
  17270. gravity: Vector3;
  17271. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17272. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17273. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17274. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17275. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17276. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17277. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17278. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17279. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17280. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17281. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17282. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17283. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17284. /**
  17285. * Defines the delay in milliseconds before starting the system (0 by default)
  17286. */
  17287. startDelay: number;
  17288. /**
  17289. * Gets the current list of drag gradients.
  17290. * You must use addDragGradient and removeDragGradient to udpate this list
  17291. * @returns the list of drag gradients
  17292. */
  17293. getDragGradients(): Nullable<Array<FactorGradient>>;
  17294. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17295. limitVelocityDamping: number;
  17296. /**
  17297. * Gets the current list of limit velocity gradients.
  17298. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17299. * @returns the list of limit velocity gradients
  17300. */
  17301. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17302. /**
  17303. * Gets the current list of color gradients.
  17304. * You must use addColorGradient and removeColorGradient to udpate this list
  17305. * @returns the list of color gradients
  17306. */
  17307. getColorGradients(): Nullable<Array<ColorGradient>>;
  17308. /**
  17309. * Gets the current list of size gradients.
  17310. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17311. * @returns the list of size gradients
  17312. */
  17313. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17314. /**
  17315. * Gets the current list of color remap gradients.
  17316. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17317. * @returns the list of color remap gradients
  17318. */
  17319. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17320. /**
  17321. * Gets the current list of alpha remap gradients.
  17322. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17323. * @returns the list of alpha remap gradients
  17324. */
  17325. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17326. /**
  17327. * Gets the current list of life time gradients.
  17328. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17329. * @returns the list of life time gradients
  17330. */
  17331. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17332. /**
  17333. * Gets the current list of angular speed gradients.
  17334. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17335. * @returns the list of angular speed gradients
  17336. */
  17337. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17338. /**
  17339. * Gets the current list of velocity gradients.
  17340. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17341. * @returns the list of velocity gradients
  17342. */
  17343. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17344. /**
  17345. * Gets the current list of start size gradients.
  17346. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17347. * @returns the list of start size gradients
  17348. */
  17349. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17350. /**
  17351. * Gets the current list of emit rate gradients.
  17352. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17353. * @returns the list of emit rate gradients
  17354. */
  17355. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17356. /**
  17357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17358. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17359. */
  17360. direction1: Vector3;
  17361. /**
  17362. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17363. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17364. */
  17365. direction2: Vector3;
  17366. /**
  17367. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17368. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17369. */
  17370. minEmitBox: Vector3;
  17371. /**
  17372. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17373. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17374. */
  17375. maxEmitBox: Vector3;
  17376. /**
  17377. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17378. */
  17379. color1: Color4;
  17380. /**
  17381. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17382. */
  17383. color2: Color4;
  17384. /**
  17385. * Color the particle will have at the end of its lifetime
  17386. */
  17387. colorDead: Color4;
  17388. /**
  17389. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17390. */
  17391. textureMask: Color4;
  17392. /**
  17393. * The particle emitter type defines the emitter used by the particle system.
  17394. * It can be for example box, sphere, or cone...
  17395. */
  17396. particleEmitterType: IParticleEmitterType;
  17397. /** @hidden */
  17398. _isSubEmitter: boolean;
  17399. /**
  17400. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17401. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17402. */
  17403. billboardMode: number;
  17404. protected _isBillboardBased: boolean;
  17405. /**
  17406. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17407. */
  17408. isBillboardBased: boolean;
  17409. /**
  17410. * The scene the particle system belongs to.
  17411. */
  17412. protected _scene: Scene;
  17413. /**
  17414. * Local cache of defines for image processing.
  17415. */
  17416. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17417. /**
  17418. * Default configuration related to image processing available in the standard Material.
  17419. */
  17420. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17421. /**
  17422. * Gets the image processing configuration used either in this material.
  17423. */
  17424. /**
  17425. * Sets the Default image processing configuration used either in the this material.
  17426. *
  17427. * If sets to null, the scene one is in use.
  17428. */
  17429. imageProcessingConfiguration: ImageProcessingConfiguration;
  17430. /**
  17431. * Attaches a new image processing configuration to the Standard Material.
  17432. * @param configuration
  17433. */
  17434. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17435. /** @hidden */
  17436. protected _reset(): void;
  17437. /** @hidden */
  17438. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17439. /**
  17440. * Instantiates a particle system.
  17441. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17442. * @param name The name of the particle system
  17443. */
  17444. constructor(name: string);
  17445. /**
  17446. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17449. * @returns the emitter
  17450. */
  17451. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17452. /**
  17453. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17454. * @param radius The radius of the hemisphere to emit from
  17455. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17456. * @returns the emitter
  17457. */
  17458. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17459. /**
  17460. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17461. * @param radius The radius of the sphere to emit from
  17462. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17463. * @returns the emitter
  17464. */
  17465. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17466. /**
  17467. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17468. * @param radius The radius of the sphere to emit from
  17469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17471. * @returns the emitter
  17472. */
  17473. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17474. /**
  17475. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17476. * @param radius The radius of the emission cylinder
  17477. * @param height The height of the emission cylinder
  17478. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17479. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17480. * @returns the emitter
  17481. */
  17482. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17483. /**
  17484. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17485. * @param radius The radius of the cylinder to emit from
  17486. * @param height The height of the emission cylinder
  17487. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17490. * @returns the emitter
  17491. */
  17492. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17493. /**
  17494. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17495. * @param radius The radius of the cone to emit from
  17496. * @param angle The base angle of the cone
  17497. * @returns the emitter
  17498. */
  17499. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17500. /**
  17501. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17502. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17503. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17504. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17505. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17506. * @returns the emitter
  17507. */
  17508. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17509. }
  17510. }
  17511. declare module "babylonjs/Particles/subEmitter" {
  17512. import { Scene } from "babylonjs/scene";
  17513. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17514. /**
  17515. * Type of sub emitter
  17516. */
  17517. export enum SubEmitterType {
  17518. /**
  17519. * Attached to the particle over it's lifetime
  17520. */
  17521. ATTACHED = 0,
  17522. /**
  17523. * Created when the particle dies
  17524. */
  17525. END = 1
  17526. }
  17527. /**
  17528. * Sub emitter class used to emit particles from an existing particle
  17529. */
  17530. export class SubEmitter {
  17531. /**
  17532. * the particle system to be used by the sub emitter
  17533. */
  17534. particleSystem: ParticleSystem;
  17535. /**
  17536. * Type of the submitter (Default: END)
  17537. */
  17538. type: SubEmitterType;
  17539. /**
  17540. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  17541. * Note: This only is supported when using an emitter of type Mesh
  17542. */
  17543. inheritDirection: boolean;
  17544. /**
  17545. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17546. */
  17547. inheritedVelocityAmount: number;
  17548. /**
  17549. * Creates a sub emitter
  17550. * @param particleSystem the particle system to be used by the sub emitter
  17551. */
  17552. constructor(
  17553. /**
  17554. * the particle system to be used by the sub emitter
  17555. */
  17556. particleSystem: ParticleSystem);
  17557. /**
  17558. * Clones the sub emitter
  17559. * @returns the cloned sub emitter
  17560. */
  17561. clone(): SubEmitter;
  17562. /**
  17563. * Serialize current object to a JSON object
  17564. * @returns the serialized object
  17565. */
  17566. serialize(): any;
  17567. /** @hidden */
  17568. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17569. /**
  17570. * Creates a new SubEmitter from a serialized JSON version
  17571. * @param serializationObject defines the JSON object to read from
  17572. * @param scene defines the hosting scene
  17573. * @param rootUrl defines the rootUrl for data loading
  17574. * @returns a new SubEmitter
  17575. */
  17576. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17577. /** Release associated resources */
  17578. dispose(): void;
  17579. }
  17580. }
  17581. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17582. /** @hidden */
  17583. export var clipPlaneFragmentDeclaration: {
  17584. name: string;
  17585. shader: string;
  17586. };
  17587. }
  17588. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17589. /** @hidden */
  17590. export var imageProcessingDeclaration: {
  17591. name: string;
  17592. shader: string;
  17593. };
  17594. }
  17595. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17596. /** @hidden */
  17597. export var imageProcessingFunctions: {
  17598. name: string;
  17599. shader: string;
  17600. };
  17601. }
  17602. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17603. /** @hidden */
  17604. export var clipPlaneFragment: {
  17605. name: string;
  17606. shader: string;
  17607. };
  17608. }
  17609. declare module "babylonjs/Shaders/particles.fragment" {
  17610. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17611. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17612. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17613. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17614. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17615. /** @hidden */
  17616. export var particlesPixelShader: {
  17617. name: string;
  17618. shader: string;
  17619. };
  17620. }
  17621. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17622. /** @hidden */
  17623. export var clipPlaneVertexDeclaration: {
  17624. name: string;
  17625. shader: string;
  17626. };
  17627. }
  17628. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17629. /** @hidden */
  17630. export var clipPlaneVertex: {
  17631. name: string;
  17632. shader: string;
  17633. };
  17634. }
  17635. declare module "babylonjs/Shaders/particles.vertex" {
  17636. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17638. /** @hidden */
  17639. export var particlesVertexShader: {
  17640. name: string;
  17641. shader: string;
  17642. };
  17643. }
  17644. declare module "babylonjs/Particles/particleSystem" {
  17645. import { Nullable } from "babylonjs/types";
  17646. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17647. import { Observable } from "babylonjs/Misc/observable";
  17648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17649. import { Effect } from "babylonjs/Materials/effect";
  17650. import { Scene, IDisposable } from "babylonjs/scene";
  17651. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17652. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17653. import { Particle } from "babylonjs/Particles/particle";
  17654. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17655. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17656. import "babylonjs/Shaders/particles.fragment";
  17657. import "babylonjs/Shaders/particles.vertex";
  17658. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17659. /**
  17660. * This represents a particle system in Babylon.
  17661. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17662. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17663. * @example https://doc.babylonjs.com/babylon101/particles
  17664. */
  17665. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17666. /**
  17667. * Billboard mode will only apply to Y axis
  17668. */
  17669. static readonly BILLBOARDMODE_Y: number;
  17670. /**
  17671. * Billboard mode will apply to all axes
  17672. */
  17673. static readonly BILLBOARDMODE_ALL: number;
  17674. /**
  17675. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17676. */
  17677. static readonly BILLBOARDMODE_STRETCHED: number;
  17678. /**
  17679. * This function can be defined to provide custom update for active particles.
  17680. * This function will be called instead of regular update (age, position, color, etc.).
  17681. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17682. */
  17683. updateFunction: (particles: Particle[]) => void;
  17684. private _emitterWorldMatrix;
  17685. /**
  17686. * This function can be defined to specify initial direction for every new particle.
  17687. * It by default use the emitterType defined function
  17688. */
  17689. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17690. /**
  17691. * This function can be defined to specify initial position for every new particle.
  17692. * It by default use the emitterType defined function
  17693. */
  17694. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17695. /**
  17696. * @hidden
  17697. */
  17698. _inheritedVelocityOffset: Vector3;
  17699. /**
  17700. * An event triggered when the system is disposed
  17701. */
  17702. onDisposeObservable: Observable<ParticleSystem>;
  17703. private _onDisposeObserver;
  17704. /**
  17705. * Sets a callback that will be triggered when the system is disposed
  17706. */
  17707. onDispose: () => void;
  17708. private _particles;
  17709. private _epsilon;
  17710. private _capacity;
  17711. private _stockParticles;
  17712. private _newPartsExcess;
  17713. private _vertexData;
  17714. private _vertexBuffer;
  17715. private _vertexBuffers;
  17716. private _spriteBuffer;
  17717. private _indexBuffer;
  17718. private _effect;
  17719. private _customEffect;
  17720. private _cachedDefines;
  17721. private _scaledColorStep;
  17722. private _colorDiff;
  17723. private _scaledDirection;
  17724. private _scaledGravity;
  17725. private _currentRenderId;
  17726. private _alive;
  17727. private _useInstancing;
  17728. private _started;
  17729. private _stopped;
  17730. private _actualFrame;
  17731. private _scaledUpdateSpeed;
  17732. private _vertexBufferSize;
  17733. /** @hidden */
  17734. _currentEmitRateGradient: Nullable<FactorGradient>;
  17735. /** @hidden */
  17736. _currentEmitRate1: number;
  17737. /** @hidden */
  17738. _currentEmitRate2: number;
  17739. /** @hidden */
  17740. _currentStartSizeGradient: Nullable<FactorGradient>;
  17741. /** @hidden */
  17742. _currentStartSize1: number;
  17743. /** @hidden */
  17744. _currentStartSize2: number;
  17745. private readonly _rawTextureWidth;
  17746. private _rampGradientsTexture;
  17747. private _useRampGradients;
  17748. /** Gets or sets a boolean indicating that ramp gradients must be used
  17749. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17750. */
  17751. useRampGradients: boolean;
  17752. /**
  17753. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  17754. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  17755. */
  17756. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17757. private _subEmitters;
  17758. /**
  17759. * @hidden
  17760. * If the particle systems emitter should be disposed when the particle system is disposed
  17761. */
  17762. _disposeEmitterOnDispose: boolean;
  17763. /**
  17764. * The current active Sub-systems, this property is used by the root particle system only.
  17765. */
  17766. activeSubSystems: Array<ParticleSystem>;
  17767. private _rootParticleSystem;
  17768. /**
  17769. * Gets the current list of active particles
  17770. */
  17771. readonly particles: Particle[];
  17772. /**
  17773. * Returns the string "ParticleSystem"
  17774. * @returns a string containing the class name
  17775. */
  17776. getClassName(): string;
  17777. /**
  17778. * Instantiates a particle system.
  17779. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17780. * @param name The name of the particle system
  17781. * @param capacity The max number of particles alive at the same time
  17782. * @param scene The scene the particle system belongs to
  17783. * @param customEffect a custom effect used to change the way particles are rendered by default
  17784. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17785. * @param epsilon Offset used to render the particles
  17786. */
  17787. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17788. private _addFactorGradient;
  17789. private _removeFactorGradient;
  17790. /**
  17791. * Adds a new life time gradient
  17792. * @param gradient defines the gradient to use (between 0 and 1)
  17793. * @param factor defines the life time factor to affect to the specified gradient
  17794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17795. * @returns the current particle system
  17796. */
  17797. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17798. /**
  17799. * Remove a specific life time gradient
  17800. * @param gradient defines the gradient to remove
  17801. * @returns the current particle system
  17802. */
  17803. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17804. /**
  17805. * Adds a new size gradient
  17806. * @param gradient defines the gradient to use (between 0 and 1)
  17807. * @param factor defines the size factor to affect to the specified gradient
  17808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17809. * @returns the current particle system
  17810. */
  17811. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17812. /**
  17813. * Remove a specific size gradient
  17814. * @param gradient defines the gradient to remove
  17815. * @returns the current particle system
  17816. */
  17817. removeSizeGradient(gradient: number): IParticleSystem;
  17818. /**
  17819. * Adds a new color remap gradient
  17820. * @param gradient defines the gradient to use (between 0 and 1)
  17821. * @param min defines the color remap minimal range
  17822. * @param max defines the color remap maximal range
  17823. * @returns the current particle system
  17824. */
  17825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17826. /**
  17827. * Remove a specific color remap gradient
  17828. * @param gradient defines the gradient to remove
  17829. * @returns the current particle system
  17830. */
  17831. removeColorRemapGradient(gradient: number): IParticleSystem;
  17832. /**
  17833. * Adds a new alpha remap gradient
  17834. * @param gradient defines the gradient to use (between 0 and 1)
  17835. * @param min defines the alpha remap minimal range
  17836. * @param max defines the alpha remap maximal range
  17837. * @returns the current particle system
  17838. */
  17839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17840. /**
  17841. * Remove a specific alpha remap gradient
  17842. * @param gradient defines the gradient to remove
  17843. * @returns the current particle system
  17844. */
  17845. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17846. /**
  17847. * Adds a new angular speed gradient
  17848. * @param gradient defines the gradient to use (between 0 and 1)
  17849. * @param factor defines the angular speed to affect to the specified gradient
  17850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17851. * @returns the current particle system
  17852. */
  17853. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17854. /**
  17855. * Remove a specific angular speed gradient
  17856. * @param gradient defines the gradient to remove
  17857. * @returns the current particle system
  17858. */
  17859. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17860. /**
  17861. * Adds a new velocity gradient
  17862. * @param gradient defines the gradient to use (between 0 and 1)
  17863. * @param factor defines the velocity to affect to the specified gradient
  17864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17865. * @returns the current particle system
  17866. */
  17867. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17868. /**
  17869. * Remove a specific velocity gradient
  17870. * @param gradient defines the gradient to remove
  17871. * @returns the current particle system
  17872. */
  17873. removeVelocityGradient(gradient: number): IParticleSystem;
  17874. /**
  17875. * Adds a new limit velocity gradient
  17876. * @param gradient defines the gradient to use (between 0 and 1)
  17877. * @param factor defines the limit velocity value to affect to the specified gradient
  17878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17879. * @returns the current particle system
  17880. */
  17881. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17882. /**
  17883. * Remove a specific limit velocity gradient
  17884. * @param gradient defines the gradient to remove
  17885. * @returns the current particle system
  17886. */
  17887. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17888. /**
  17889. * Adds a new drag gradient
  17890. * @param gradient defines the gradient to use (between 0 and 1)
  17891. * @param factor defines the drag value to affect to the specified gradient
  17892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17893. * @returns the current particle system
  17894. */
  17895. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17896. /**
  17897. * Remove a specific drag gradient
  17898. * @param gradient defines the gradient to remove
  17899. * @returns the current particle system
  17900. */
  17901. removeDragGradient(gradient: number): IParticleSystem;
  17902. /**
  17903. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17904. * @param gradient defines the gradient to use (between 0 and 1)
  17905. * @param factor defines the emit rate value to affect to the specified gradient
  17906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17907. * @returns the current particle system
  17908. */
  17909. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17910. /**
  17911. * Remove a specific emit rate gradient
  17912. * @param gradient defines the gradient to remove
  17913. * @returns the current particle system
  17914. */
  17915. removeEmitRateGradient(gradient: number): IParticleSystem;
  17916. /**
  17917. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17918. * @param gradient defines the gradient to use (between 0 and 1)
  17919. * @param factor defines the start size value to affect to the specified gradient
  17920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17921. * @returns the current particle system
  17922. */
  17923. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17924. /**
  17925. * Remove a specific start size gradient
  17926. * @param gradient defines the gradient to remove
  17927. * @returns the current particle system
  17928. */
  17929. removeStartSizeGradient(gradient: number): IParticleSystem;
  17930. private _createRampGradientTexture;
  17931. /**
  17932. * Gets the current list of ramp gradients.
  17933. * You must use addRampGradient and removeRampGradient to udpate this list
  17934. * @returns the list of ramp gradients
  17935. */
  17936. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17937. /**
  17938. * Adds a new ramp gradient used to remap particle colors
  17939. * @param gradient defines the gradient to use (between 0 and 1)
  17940. * @param color defines the color to affect to the specified gradient
  17941. * @returns the current particle system
  17942. */
  17943. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17944. /**
  17945. * Remove a specific ramp gradient
  17946. * @param gradient defines the gradient to remove
  17947. * @returns the current particle system
  17948. */
  17949. removeRampGradient(gradient: number): ParticleSystem;
  17950. /**
  17951. * Adds a new color gradient
  17952. * @param gradient defines the gradient to use (between 0 and 1)
  17953. * @param color1 defines the color to affect to the specified gradient
  17954. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17955. * @returns this particle system
  17956. */
  17957. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17958. /**
  17959. * Remove a specific color gradient
  17960. * @param gradient defines the gradient to remove
  17961. * @returns this particle system
  17962. */
  17963. removeColorGradient(gradient: number): IParticleSystem;
  17964. private _fetchR;
  17965. protected _reset(): void;
  17966. private _resetEffect;
  17967. private _createVertexBuffers;
  17968. private _createIndexBuffer;
  17969. /**
  17970. * Gets the maximum number of particles active at the same time.
  17971. * @returns The max number of active particles.
  17972. */
  17973. getCapacity(): number;
  17974. /**
  17975. * Gets whether there are still active particles in the system.
  17976. * @returns True if it is alive, otherwise false.
  17977. */
  17978. isAlive(): boolean;
  17979. /**
  17980. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17981. * @returns True if it has been started, otherwise false.
  17982. */
  17983. isStarted(): boolean;
  17984. private _prepareSubEmitterInternalArray;
  17985. /**
  17986. * Starts the particle system and begins to emit
  17987. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17988. */
  17989. start(delay?: number): void;
  17990. /**
  17991. * Stops the particle system.
  17992. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  17993. */
  17994. stop(stopSubEmitters?: boolean): void;
  17995. /**
  17996. * Remove all active particles
  17997. */
  17998. reset(): void;
  17999. /**
  18000. * @hidden (for internal use only)
  18001. */
  18002. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18003. /**
  18004. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18005. * Its lifetime will start back at 0.
  18006. */
  18007. recycleParticle: (particle: Particle) => void;
  18008. private _stopSubEmitters;
  18009. private _createParticle;
  18010. private _removeFromRoot;
  18011. private _emitFromParticle;
  18012. private _update;
  18013. /** @hidden */
  18014. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18015. /** @hidden */
  18016. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18017. /** @hidden */
  18018. private _getEffect;
  18019. /**
  18020. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18021. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18022. */
  18023. animate(preWarmOnly?: boolean): void;
  18024. private _appendParticleVertices;
  18025. /**
  18026. * Rebuilds the particle system.
  18027. */
  18028. rebuild(): void;
  18029. /**
  18030. * Is this system ready to be used/rendered
  18031. * @return true if the system is ready
  18032. */
  18033. isReady(): boolean;
  18034. private _render;
  18035. /**
  18036. * Renders the particle system in its current state.
  18037. * @returns the current number of particles
  18038. */
  18039. render(): number;
  18040. /**
  18041. * Disposes the particle system and free the associated resources
  18042. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18043. */
  18044. dispose(disposeTexture?: boolean): void;
  18045. /**
  18046. * Clones the particle system.
  18047. * @param name The name of the cloned object
  18048. * @param newEmitter The new emitter to use
  18049. * @returns the cloned particle system
  18050. */
  18051. clone(name: string, newEmitter: any): ParticleSystem;
  18052. /**
  18053. * Serializes the particle system to a JSON object.
  18054. * @returns the JSON object
  18055. */
  18056. serialize(): any;
  18057. /** @hidden */
  18058. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18059. /** @hidden */
  18060. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18061. /**
  18062. * Parses a JSON object to create a particle system.
  18063. * @param parsedParticleSystem The JSON object to parse
  18064. * @param scene The scene to create the particle system in
  18065. * @param rootUrl The root url to use to load external dependencies like texture
  18066. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18067. * @returns the Parsed particle system
  18068. */
  18069. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18070. }
  18071. }
  18072. declare module "babylonjs/Particles/particle" {
  18073. import { Nullable } from "babylonjs/types";
  18074. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18075. import { Color4 } from "babylonjs/Maths/math.color";
  18076. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18077. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18078. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18079. /**
  18080. * A particle represents one of the element emitted by a particle system.
  18081. * This is mainly define by its coordinates, direction, velocity and age.
  18082. */
  18083. export class Particle {
  18084. /**
  18085. * The particle system the particle belongs to.
  18086. */
  18087. particleSystem: ParticleSystem;
  18088. private static _Count;
  18089. /**
  18090. * Unique ID of the particle
  18091. */
  18092. id: number;
  18093. /**
  18094. * The world position of the particle in the scene.
  18095. */
  18096. position: Vector3;
  18097. /**
  18098. * The world direction of the particle in the scene.
  18099. */
  18100. direction: Vector3;
  18101. /**
  18102. * The color of the particle.
  18103. */
  18104. color: Color4;
  18105. /**
  18106. * The color change of the particle per step.
  18107. */
  18108. colorStep: Color4;
  18109. /**
  18110. * Defines how long will the life of the particle be.
  18111. */
  18112. lifeTime: number;
  18113. /**
  18114. * The current age of the particle.
  18115. */
  18116. age: number;
  18117. /**
  18118. * The current size of the particle.
  18119. */
  18120. size: number;
  18121. /**
  18122. * The current scale of the particle.
  18123. */
  18124. scale: Vector2;
  18125. /**
  18126. * The current angle of the particle.
  18127. */
  18128. angle: number;
  18129. /**
  18130. * Defines how fast is the angle changing.
  18131. */
  18132. angularSpeed: number;
  18133. /**
  18134. * Defines the cell index used by the particle to be rendered from a sprite.
  18135. */
  18136. cellIndex: number;
  18137. /**
  18138. * The information required to support color remapping
  18139. */
  18140. remapData: Vector4;
  18141. /** @hidden */
  18142. _randomCellOffset?: number;
  18143. /** @hidden */
  18144. _initialDirection: Nullable<Vector3>;
  18145. /** @hidden */
  18146. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18147. /** @hidden */
  18148. _initialStartSpriteCellID: number;
  18149. /** @hidden */
  18150. _initialEndSpriteCellID: number;
  18151. /** @hidden */
  18152. _currentColorGradient: Nullable<ColorGradient>;
  18153. /** @hidden */
  18154. _currentColor1: Color4;
  18155. /** @hidden */
  18156. _currentColor2: Color4;
  18157. /** @hidden */
  18158. _currentSizeGradient: Nullable<FactorGradient>;
  18159. /** @hidden */
  18160. _currentSize1: number;
  18161. /** @hidden */
  18162. _currentSize2: number;
  18163. /** @hidden */
  18164. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18165. /** @hidden */
  18166. _currentAngularSpeed1: number;
  18167. /** @hidden */
  18168. _currentAngularSpeed2: number;
  18169. /** @hidden */
  18170. _currentVelocityGradient: Nullable<FactorGradient>;
  18171. /** @hidden */
  18172. _currentVelocity1: number;
  18173. /** @hidden */
  18174. _currentVelocity2: number;
  18175. /** @hidden */
  18176. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18177. /** @hidden */
  18178. _currentLimitVelocity1: number;
  18179. /** @hidden */
  18180. _currentLimitVelocity2: number;
  18181. /** @hidden */
  18182. _currentDragGradient: Nullable<FactorGradient>;
  18183. /** @hidden */
  18184. _currentDrag1: number;
  18185. /** @hidden */
  18186. _currentDrag2: number;
  18187. /** @hidden */
  18188. _randomNoiseCoordinates1: Vector3;
  18189. /** @hidden */
  18190. _randomNoiseCoordinates2: Vector3;
  18191. /**
  18192. * Creates a new instance Particle
  18193. * @param particleSystem the particle system the particle belongs to
  18194. */
  18195. constructor(
  18196. /**
  18197. * The particle system the particle belongs to.
  18198. */
  18199. particleSystem: ParticleSystem);
  18200. private updateCellInfoFromSystem;
  18201. /**
  18202. * Defines how the sprite cell index is updated for the particle
  18203. */
  18204. updateCellIndex(): void;
  18205. /** @hidden */
  18206. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18207. /** @hidden */
  18208. _inheritParticleInfoToSubEmitters(): void;
  18209. /** @hidden */
  18210. _reset(): void;
  18211. /**
  18212. * Copy the properties of particle to another one.
  18213. * @param other the particle to copy the information to.
  18214. */
  18215. copyTo(other: Particle): void;
  18216. }
  18217. }
  18218. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18219. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18220. import { Effect } from "babylonjs/Materials/effect";
  18221. import { Particle } from "babylonjs/Particles/particle";
  18222. /**
  18223. * Particle emitter represents a volume emitting particles.
  18224. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18225. */
  18226. export interface IParticleEmitterType {
  18227. /**
  18228. * Called by the particle System when the direction is computed for the created particle.
  18229. * @param worldMatrix is the world matrix of the particle system
  18230. * @param directionToUpdate is the direction vector to update with the result
  18231. * @param particle is the particle we are computed the direction for
  18232. */
  18233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18234. /**
  18235. * Called by the particle System when the position is computed for the created particle.
  18236. * @param worldMatrix is the world matrix of the particle system
  18237. * @param positionToUpdate is the position vector to update with the result
  18238. * @param particle is the particle we are computed the position for
  18239. */
  18240. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18241. /**
  18242. * Clones the current emitter and returns a copy of it
  18243. * @returns the new emitter
  18244. */
  18245. clone(): IParticleEmitterType;
  18246. /**
  18247. * Called by the GPUParticleSystem to setup the update shader
  18248. * @param effect defines the update shader
  18249. */
  18250. applyToShader(effect: Effect): void;
  18251. /**
  18252. * Returns a string to use to update the GPU particles update shader
  18253. * @returns the effect defines string
  18254. */
  18255. getEffectDefines(): string;
  18256. /**
  18257. * Returns a string representing the class name
  18258. * @returns a string containing the class name
  18259. */
  18260. getClassName(): string;
  18261. /**
  18262. * Serializes the particle system to a JSON object.
  18263. * @returns the JSON object
  18264. */
  18265. serialize(): any;
  18266. /**
  18267. * Parse properties from a JSON object
  18268. * @param serializationObject defines the JSON object
  18269. */
  18270. parse(serializationObject: any): void;
  18271. }
  18272. }
  18273. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18274. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18275. import { Effect } from "babylonjs/Materials/effect";
  18276. import { Particle } from "babylonjs/Particles/particle";
  18277. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18278. /**
  18279. * Particle emitter emitting particles from the inside of a box.
  18280. * It emits the particles randomly between 2 given directions.
  18281. */
  18282. export class BoxParticleEmitter implements IParticleEmitterType {
  18283. /**
  18284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18285. */
  18286. direction1: Vector3;
  18287. /**
  18288. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18289. */
  18290. direction2: Vector3;
  18291. /**
  18292. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18293. */
  18294. minEmitBox: Vector3;
  18295. /**
  18296. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18297. */
  18298. maxEmitBox: Vector3;
  18299. /**
  18300. * Creates a new instance BoxParticleEmitter
  18301. */
  18302. constructor();
  18303. /**
  18304. * Called by the particle System when the direction is computed for the created particle.
  18305. * @param worldMatrix is the world matrix of the particle system
  18306. * @param directionToUpdate is the direction vector to update with the result
  18307. * @param particle is the particle we are computed the direction for
  18308. */
  18309. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18310. /**
  18311. * Called by the particle System when the position is computed for the created particle.
  18312. * @param worldMatrix is the world matrix of the particle system
  18313. * @param positionToUpdate is the position vector to update with the result
  18314. * @param particle is the particle we are computed the position for
  18315. */
  18316. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18317. /**
  18318. * Clones the current emitter and returns a copy of it
  18319. * @returns the new emitter
  18320. */
  18321. clone(): BoxParticleEmitter;
  18322. /**
  18323. * Called by the GPUParticleSystem to setup the update shader
  18324. * @param effect defines the update shader
  18325. */
  18326. applyToShader(effect: Effect): void;
  18327. /**
  18328. * Returns a string to use to update the GPU particles update shader
  18329. * @returns a string containng the defines string
  18330. */
  18331. getEffectDefines(): string;
  18332. /**
  18333. * Returns the string "BoxParticleEmitter"
  18334. * @returns a string containing the class name
  18335. */
  18336. getClassName(): string;
  18337. /**
  18338. * Serializes the particle system to a JSON object.
  18339. * @returns the JSON object
  18340. */
  18341. serialize(): any;
  18342. /**
  18343. * Parse properties from a JSON object
  18344. * @param serializationObject defines the JSON object
  18345. */
  18346. parse(serializationObject: any): void;
  18347. }
  18348. }
  18349. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18350. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18351. import { Effect } from "babylonjs/Materials/effect";
  18352. import { Particle } from "babylonjs/Particles/particle";
  18353. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18354. /**
  18355. * Particle emitter emitting particles from the inside of a cone.
  18356. * It emits the particles alongside the cone volume from the base to the particle.
  18357. * The emission direction might be randomized.
  18358. */
  18359. export class ConeParticleEmitter implements IParticleEmitterType {
  18360. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18361. directionRandomizer: number;
  18362. private _radius;
  18363. private _angle;
  18364. private _height;
  18365. /**
  18366. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18367. */
  18368. radiusRange: number;
  18369. /**
  18370. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18371. */
  18372. heightRange: number;
  18373. /**
  18374. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18375. */
  18376. emitFromSpawnPointOnly: boolean;
  18377. /**
  18378. * Gets or sets the radius of the emission cone
  18379. */
  18380. radius: number;
  18381. /**
  18382. * Gets or sets the angle of the emission cone
  18383. */
  18384. angle: number;
  18385. private _buildHeight;
  18386. /**
  18387. * Creates a new instance ConeParticleEmitter
  18388. * @param radius the radius of the emission cone (1 by default)
  18389. * @param angle the cone base angle (PI by default)
  18390. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18391. */
  18392. constructor(radius?: number, angle?: number,
  18393. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18394. directionRandomizer?: number);
  18395. /**
  18396. * Called by the particle System when the direction is computed for the created particle.
  18397. * @param worldMatrix is the world matrix of the particle system
  18398. * @param directionToUpdate is the direction vector to update with the result
  18399. * @param particle is the particle we are computed the direction for
  18400. */
  18401. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18402. /**
  18403. * Called by the particle System when the position is computed for the created particle.
  18404. * @param worldMatrix is the world matrix of the particle system
  18405. * @param positionToUpdate is the position vector to update with the result
  18406. * @param particle is the particle we are computed the position for
  18407. */
  18408. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18409. /**
  18410. * Clones the current emitter and returns a copy of it
  18411. * @returns the new emitter
  18412. */
  18413. clone(): ConeParticleEmitter;
  18414. /**
  18415. * Called by the GPUParticleSystem to setup the update shader
  18416. * @param effect defines the update shader
  18417. */
  18418. applyToShader(effect: Effect): void;
  18419. /**
  18420. * Returns a string to use to update the GPU particles update shader
  18421. * @returns a string containng the defines string
  18422. */
  18423. getEffectDefines(): string;
  18424. /**
  18425. * Returns the string "ConeParticleEmitter"
  18426. * @returns a string containing the class name
  18427. */
  18428. getClassName(): string;
  18429. /**
  18430. * Serializes the particle system to a JSON object.
  18431. * @returns the JSON object
  18432. */
  18433. serialize(): any;
  18434. /**
  18435. * Parse properties from a JSON object
  18436. * @param serializationObject defines the JSON object
  18437. */
  18438. parse(serializationObject: any): void;
  18439. }
  18440. }
  18441. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18442. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18443. import { Effect } from "babylonjs/Materials/effect";
  18444. import { Particle } from "babylonjs/Particles/particle";
  18445. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18446. /**
  18447. * Particle emitter emitting particles from the inside of a cylinder.
  18448. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18449. */
  18450. export class CylinderParticleEmitter implements IParticleEmitterType {
  18451. /**
  18452. * The radius of the emission cylinder.
  18453. */
  18454. radius: number;
  18455. /**
  18456. * The height of the emission cylinder.
  18457. */
  18458. height: number;
  18459. /**
  18460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18461. */
  18462. radiusRange: number;
  18463. /**
  18464. * How much to randomize the particle direction [0-1].
  18465. */
  18466. directionRandomizer: number;
  18467. /**
  18468. * Creates a new instance CylinderParticleEmitter
  18469. * @param radius the radius of the emission cylinder (1 by default)
  18470. * @param height the height of the emission cylinder (1 by default)
  18471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18472. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18473. */
  18474. constructor(
  18475. /**
  18476. * The radius of the emission cylinder.
  18477. */
  18478. radius?: number,
  18479. /**
  18480. * The height of the emission cylinder.
  18481. */
  18482. height?: number,
  18483. /**
  18484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18485. */
  18486. radiusRange?: number,
  18487. /**
  18488. * How much to randomize the particle direction [0-1].
  18489. */
  18490. directionRandomizer?: number);
  18491. /**
  18492. * Called by the particle System when the direction is computed for the created particle.
  18493. * @param worldMatrix is the world matrix of the particle system
  18494. * @param directionToUpdate is the direction vector to update with the result
  18495. * @param particle is the particle we are computed the direction for
  18496. */
  18497. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18498. /**
  18499. * Called by the particle System when the position is computed for the created particle.
  18500. * @param worldMatrix is the world matrix of the particle system
  18501. * @param positionToUpdate is the position vector to update with the result
  18502. * @param particle is the particle we are computed the position for
  18503. */
  18504. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18505. /**
  18506. * Clones the current emitter and returns a copy of it
  18507. * @returns the new emitter
  18508. */
  18509. clone(): CylinderParticleEmitter;
  18510. /**
  18511. * Called by the GPUParticleSystem to setup the update shader
  18512. * @param effect defines the update shader
  18513. */
  18514. applyToShader(effect: Effect): void;
  18515. /**
  18516. * Returns a string to use to update the GPU particles update shader
  18517. * @returns a string containng the defines string
  18518. */
  18519. getEffectDefines(): string;
  18520. /**
  18521. * Returns the string "CylinderParticleEmitter"
  18522. * @returns a string containing the class name
  18523. */
  18524. getClassName(): string;
  18525. /**
  18526. * Serializes the particle system to a JSON object.
  18527. * @returns the JSON object
  18528. */
  18529. serialize(): any;
  18530. /**
  18531. * Parse properties from a JSON object
  18532. * @param serializationObject defines the JSON object
  18533. */
  18534. parse(serializationObject: any): void;
  18535. }
  18536. /**
  18537. * Particle emitter emitting particles from the inside of a cylinder.
  18538. * It emits the particles randomly between two vectors.
  18539. */
  18540. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18541. /**
  18542. * The min limit of the emission direction.
  18543. */
  18544. direction1: Vector3;
  18545. /**
  18546. * The max limit of the emission direction.
  18547. */
  18548. direction2: Vector3;
  18549. /**
  18550. * Creates a new instance CylinderDirectedParticleEmitter
  18551. * @param radius the radius of the emission cylinder (1 by default)
  18552. * @param height the height of the emission cylinder (1 by default)
  18553. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18554. * @param direction1 the min limit of the emission direction (up vector by default)
  18555. * @param direction2 the max limit of the emission direction (up vector by default)
  18556. */
  18557. constructor(radius?: number, height?: number, radiusRange?: number,
  18558. /**
  18559. * The min limit of the emission direction.
  18560. */
  18561. direction1?: Vector3,
  18562. /**
  18563. * The max limit of the emission direction.
  18564. */
  18565. direction2?: Vector3);
  18566. /**
  18567. * Called by the particle System when the direction is computed for the created particle.
  18568. * @param worldMatrix is the world matrix of the particle system
  18569. * @param directionToUpdate is the direction vector to update with the result
  18570. * @param particle is the particle we are computed the direction for
  18571. */
  18572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18573. /**
  18574. * Clones the current emitter and returns a copy of it
  18575. * @returns the new emitter
  18576. */
  18577. clone(): CylinderDirectedParticleEmitter;
  18578. /**
  18579. * Called by the GPUParticleSystem to setup the update shader
  18580. * @param effect defines the update shader
  18581. */
  18582. applyToShader(effect: Effect): void;
  18583. /**
  18584. * Returns a string to use to update the GPU particles update shader
  18585. * @returns a string containng the defines string
  18586. */
  18587. getEffectDefines(): string;
  18588. /**
  18589. * Returns the string "CylinderDirectedParticleEmitter"
  18590. * @returns a string containing the class name
  18591. */
  18592. getClassName(): string;
  18593. /**
  18594. * Serializes the particle system to a JSON object.
  18595. * @returns the JSON object
  18596. */
  18597. serialize(): any;
  18598. /**
  18599. * Parse properties from a JSON object
  18600. * @param serializationObject defines the JSON object
  18601. */
  18602. parse(serializationObject: any): void;
  18603. }
  18604. }
  18605. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18606. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18607. import { Effect } from "babylonjs/Materials/effect";
  18608. import { Particle } from "babylonjs/Particles/particle";
  18609. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18610. /**
  18611. * Particle emitter emitting particles from the inside of a hemisphere.
  18612. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18613. */
  18614. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18615. /**
  18616. * The radius of the emission hemisphere.
  18617. */
  18618. radius: number;
  18619. /**
  18620. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18621. */
  18622. radiusRange: number;
  18623. /**
  18624. * How much to randomize the particle direction [0-1].
  18625. */
  18626. directionRandomizer: number;
  18627. /**
  18628. * Creates a new instance HemisphericParticleEmitter
  18629. * @param radius the radius of the emission hemisphere (1 by default)
  18630. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18631. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18632. */
  18633. constructor(
  18634. /**
  18635. * The radius of the emission hemisphere.
  18636. */
  18637. radius?: number,
  18638. /**
  18639. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18640. */
  18641. radiusRange?: number,
  18642. /**
  18643. * How much to randomize the particle direction [0-1].
  18644. */
  18645. directionRandomizer?: number);
  18646. /**
  18647. * Called by the particle System when the direction is computed for the created particle.
  18648. * @param worldMatrix is the world matrix of the particle system
  18649. * @param directionToUpdate is the direction vector to update with the result
  18650. * @param particle is the particle we are computed the direction for
  18651. */
  18652. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18653. /**
  18654. * Called by the particle System when the position is computed for the created particle.
  18655. * @param worldMatrix is the world matrix of the particle system
  18656. * @param positionToUpdate is the position vector to update with the result
  18657. * @param particle is the particle we are computed the position for
  18658. */
  18659. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18660. /**
  18661. * Clones the current emitter and returns a copy of it
  18662. * @returns the new emitter
  18663. */
  18664. clone(): HemisphericParticleEmitter;
  18665. /**
  18666. * Called by the GPUParticleSystem to setup the update shader
  18667. * @param effect defines the update shader
  18668. */
  18669. applyToShader(effect: Effect): void;
  18670. /**
  18671. * Returns a string to use to update the GPU particles update shader
  18672. * @returns a string containng the defines string
  18673. */
  18674. getEffectDefines(): string;
  18675. /**
  18676. * Returns the string "HemisphericParticleEmitter"
  18677. * @returns a string containing the class name
  18678. */
  18679. getClassName(): string;
  18680. /**
  18681. * Serializes the particle system to a JSON object.
  18682. * @returns the JSON object
  18683. */
  18684. serialize(): any;
  18685. /**
  18686. * Parse properties from a JSON object
  18687. * @param serializationObject defines the JSON object
  18688. */
  18689. parse(serializationObject: any): void;
  18690. }
  18691. }
  18692. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18693. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18694. import { Effect } from "babylonjs/Materials/effect";
  18695. import { Particle } from "babylonjs/Particles/particle";
  18696. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18697. /**
  18698. * Particle emitter emitting particles from a point.
  18699. * It emits the particles randomly between 2 given directions.
  18700. */
  18701. export class PointParticleEmitter implements IParticleEmitterType {
  18702. /**
  18703. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18704. */
  18705. direction1: Vector3;
  18706. /**
  18707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18708. */
  18709. direction2: Vector3;
  18710. /**
  18711. * Creates a new instance PointParticleEmitter
  18712. */
  18713. constructor();
  18714. /**
  18715. * Called by the particle System when the direction is computed for the created particle.
  18716. * @param worldMatrix is the world matrix of the particle system
  18717. * @param directionToUpdate is the direction vector to update with the result
  18718. * @param particle is the particle we are computed the direction for
  18719. */
  18720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18721. /**
  18722. * Called by the particle System when the position is computed for the created particle.
  18723. * @param worldMatrix is the world matrix of the particle system
  18724. * @param positionToUpdate is the position vector to update with the result
  18725. * @param particle is the particle we are computed the position for
  18726. */
  18727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18728. /**
  18729. * Clones the current emitter and returns a copy of it
  18730. * @returns the new emitter
  18731. */
  18732. clone(): PointParticleEmitter;
  18733. /**
  18734. * Called by the GPUParticleSystem to setup the update shader
  18735. * @param effect defines the update shader
  18736. */
  18737. applyToShader(effect: Effect): void;
  18738. /**
  18739. * Returns a string to use to update the GPU particles update shader
  18740. * @returns a string containng the defines string
  18741. */
  18742. getEffectDefines(): string;
  18743. /**
  18744. * Returns the string "PointParticleEmitter"
  18745. * @returns a string containing the class name
  18746. */
  18747. getClassName(): string;
  18748. /**
  18749. * Serializes the particle system to a JSON object.
  18750. * @returns the JSON object
  18751. */
  18752. serialize(): any;
  18753. /**
  18754. * Parse properties from a JSON object
  18755. * @param serializationObject defines the JSON object
  18756. */
  18757. parse(serializationObject: any): void;
  18758. }
  18759. }
  18760. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18761. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18762. import { Effect } from "babylonjs/Materials/effect";
  18763. import { Particle } from "babylonjs/Particles/particle";
  18764. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18765. /**
  18766. * Particle emitter emitting particles from the inside of a sphere.
  18767. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18768. */
  18769. export class SphereParticleEmitter implements IParticleEmitterType {
  18770. /**
  18771. * The radius of the emission sphere.
  18772. */
  18773. radius: number;
  18774. /**
  18775. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18776. */
  18777. radiusRange: number;
  18778. /**
  18779. * How much to randomize the particle direction [0-1].
  18780. */
  18781. directionRandomizer: number;
  18782. /**
  18783. * Creates a new instance SphereParticleEmitter
  18784. * @param radius the radius of the emission sphere (1 by default)
  18785. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18786. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18787. */
  18788. constructor(
  18789. /**
  18790. * The radius of the emission sphere.
  18791. */
  18792. radius?: number,
  18793. /**
  18794. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18795. */
  18796. radiusRange?: number,
  18797. /**
  18798. * How much to randomize the particle direction [0-1].
  18799. */
  18800. directionRandomizer?: number);
  18801. /**
  18802. * Called by the particle System when the direction is computed for the created particle.
  18803. * @param worldMatrix is the world matrix of the particle system
  18804. * @param directionToUpdate is the direction vector to update with the result
  18805. * @param particle is the particle we are computed the direction for
  18806. */
  18807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18808. /**
  18809. * Called by the particle System when the position is computed for the created particle.
  18810. * @param worldMatrix is the world matrix of the particle system
  18811. * @param positionToUpdate is the position vector to update with the result
  18812. * @param particle is the particle we are computed the position for
  18813. */
  18814. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18815. /**
  18816. * Clones the current emitter and returns a copy of it
  18817. * @returns the new emitter
  18818. */
  18819. clone(): SphereParticleEmitter;
  18820. /**
  18821. * Called by the GPUParticleSystem to setup the update shader
  18822. * @param effect defines the update shader
  18823. */
  18824. applyToShader(effect: Effect): void;
  18825. /**
  18826. * Returns a string to use to update the GPU particles update shader
  18827. * @returns a string containng the defines string
  18828. */
  18829. getEffectDefines(): string;
  18830. /**
  18831. * Returns the string "SphereParticleEmitter"
  18832. * @returns a string containing the class name
  18833. */
  18834. getClassName(): string;
  18835. /**
  18836. * Serializes the particle system to a JSON object.
  18837. * @returns the JSON object
  18838. */
  18839. serialize(): any;
  18840. /**
  18841. * Parse properties from a JSON object
  18842. * @param serializationObject defines the JSON object
  18843. */
  18844. parse(serializationObject: any): void;
  18845. }
  18846. /**
  18847. * Particle emitter emitting particles from the inside of a sphere.
  18848. * It emits the particles randomly between two vectors.
  18849. */
  18850. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18851. /**
  18852. * The min limit of the emission direction.
  18853. */
  18854. direction1: Vector3;
  18855. /**
  18856. * The max limit of the emission direction.
  18857. */
  18858. direction2: Vector3;
  18859. /**
  18860. * Creates a new instance SphereDirectedParticleEmitter
  18861. * @param radius the radius of the emission sphere (1 by default)
  18862. * @param direction1 the min limit of the emission direction (up vector by default)
  18863. * @param direction2 the max limit of the emission direction (up vector by default)
  18864. */
  18865. constructor(radius?: number,
  18866. /**
  18867. * The min limit of the emission direction.
  18868. */
  18869. direction1?: Vector3,
  18870. /**
  18871. * The max limit of the emission direction.
  18872. */
  18873. direction2?: Vector3);
  18874. /**
  18875. * Called by the particle System when the direction is computed for the created particle.
  18876. * @param worldMatrix is the world matrix of the particle system
  18877. * @param directionToUpdate is the direction vector to update with the result
  18878. * @param particle is the particle we are computed the direction for
  18879. */
  18880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18881. /**
  18882. * Clones the current emitter and returns a copy of it
  18883. * @returns the new emitter
  18884. */
  18885. clone(): SphereDirectedParticleEmitter;
  18886. /**
  18887. * Called by the GPUParticleSystem to setup the update shader
  18888. * @param effect defines the update shader
  18889. */
  18890. applyToShader(effect: Effect): void;
  18891. /**
  18892. * Returns a string to use to update the GPU particles update shader
  18893. * @returns a string containng the defines string
  18894. */
  18895. getEffectDefines(): string;
  18896. /**
  18897. * Returns the string "SphereDirectedParticleEmitter"
  18898. * @returns a string containing the class name
  18899. */
  18900. getClassName(): string;
  18901. /**
  18902. * Serializes the particle system to a JSON object.
  18903. * @returns the JSON object
  18904. */
  18905. serialize(): any;
  18906. /**
  18907. * Parse properties from a JSON object
  18908. * @param serializationObject defines the JSON object
  18909. */
  18910. parse(serializationObject: any): void;
  18911. }
  18912. }
  18913. declare module "babylonjs/Particles/EmitterTypes/index" {
  18914. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18915. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18916. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18917. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18918. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18919. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18920. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18921. }
  18922. declare module "babylonjs/Particles/IParticleSystem" {
  18923. import { Nullable } from "babylonjs/types";
  18924. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18925. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18928. import { Texture } from "babylonjs/Materials/Textures/texture";
  18929. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18930. import { Scene } from "babylonjs/scene";
  18931. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18932. import { Animation } from "babylonjs/Animations/animation";
  18933. /**
  18934. * Interface representing a particle system in Babylon.js.
  18935. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18936. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18937. */
  18938. export interface IParticleSystem {
  18939. /**
  18940. * List of animations used by the particle system.
  18941. */
  18942. animations: Animation[];
  18943. /**
  18944. * The id of the Particle system.
  18945. */
  18946. id: string;
  18947. /**
  18948. * The name of the Particle system.
  18949. */
  18950. name: string;
  18951. /**
  18952. * The emitter represents the Mesh or position we are attaching the particle system to.
  18953. */
  18954. emitter: Nullable<AbstractMesh | Vector3>;
  18955. /**
  18956. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18957. */
  18958. isBillboardBased: boolean;
  18959. /**
  18960. * The rendering group used by the Particle system to chose when to render.
  18961. */
  18962. renderingGroupId: number;
  18963. /**
  18964. * The layer mask we are rendering the particles through.
  18965. */
  18966. layerMask: number;
  18967. /**
  18968. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18969. */
  18970. updateSpeed: number;
  18971. /**
  18972. * The amount of time the particle system is running (depends of the overall update speed).
  18973. */
  18974. targetStopDuration: number;
  18975. /**
  18976. * The texture used to render each particle. (this can be a spritesheet)
  18977. */
  18978. particleTexture: Nullable<Texture>;
  18979. /**
  18980. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18981. */
  18982. blendMode: number;
  18983. /**
  18984. * Minimum life time of emitting particles.
  18985. */
  18986. minLifeTime: number;
  18987. /**
  18988. * Maximum life time of emitting particles.
  18989. */
  18990. maxLifeTime: number;
  18991. /**
  18992. * Minimum Size of emitting particles.
  18993. */
  18994. minSize: number;
  18995. /**
  18996. * Maximum Size of emitting particles.
  18997. */
  18998. maxSize: number;
  18999. /**
  19000. * Minimum scale of emitting particles on X axis.
  19001. */
  19002. minScaleX: number;
  19003. /**
  19004. * Maximum scale of emitting particles on X axis.
  19005. */
  19006. maxScaleX: number;
  19007. /**
  19008. * Minimum scale of emitting particles on Y axis.
  19009. */
  19010. minScaleY: number;
  19011. /**
  19012. * Maximum scale of emitting particles on Y axis.
  19013. */
  19014. maxScaleY: number;
  19015. /**
  19016. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19017. */
  19018. color1: Color4;
  19019. /**
  19020. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19021. */
  19022. color2: Color4;
  19023. /**
  19024. * Color the particle will have at the end of its lifetime.
  19025. */
  19026. colorDead: Color4;
  19027. /**
  19028. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19029. */
  19030. emitRate: number;
  19031. /**
  19032. * You can use gravity if you want to give an orientation to your particles.
  19033. */
  19034. gravity: Vector3;
  19035. /**
  19036. * Minimum power of emitting particles.
  19037. */
  19038. minEmitPower: number;
  19039. /**
  19040. * Maximum power of emitting particles.
  19041. */
  19042. maxEmitPower: number;
  19043. /**
  19044. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19045. */
  19046. minAngularSpeed: number;
  19047. /**
  19048. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19049. */
  19050. maxAngularSpeed: number;
  19051. /**
  19052. * Gets or sets the minimal initial rotation in radians.
  19053. */
  19054. minInitialRotation: number;
  19055. /**
  19056. * Gets or sets the maximal initial rotation in radians.
  19057. */
  19058. maxInitialRotation: number;
  19059. /**
  19060. * The particle emitter type defines the emitter used by the particle system.
  19061. * It can be for example box, sphere, or cone...
  19062. */
  19063. particleEmitterType: Nullable<IParticleEmitterType>;
  19064. /**
  19065. * Defines the delay in milliseconds before starting the system (0 by default)
  19066. */
  19067. startDelay: number;
  19068. /**
  19069. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  19070. */
  19071. preWarmCycles: number;
  19072. /**
  19073. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19074. */
  19075. preWarmStepOffset: number;
  19076. /**
  19077. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  19078. */
  19079. spriteCellChangeSpeed: number;
  19080. /**
  19081. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19082. */
  19083. startSpriteCellID: number;
  19084. /**
  19085. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19086. */
  19087. endSpriteCellID: number;
  19088. /**
  19089. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19090. */
  19091. spriteCellWidth: number;
  19092. /**
  19093. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19094. */
  19095. spriteCellHeight: number;
  19096. /**
  19097. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19098. */
  19099. spriteRandomStartCell: boolean;
  19100. /**
  19101. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19102. */
  19103. isAnimationSheetEnabled: boolean;
  19104. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19105. translationPivot: Vector2;
  19106. /**
  19107. * Gets or sets a texture used to add random noise to particle positions
  19108. */
  19109. noiseTexture: Nullable<BaseTexture>;
  19110. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19111. noiseStrength: Vector3;
  19112. /**
  19113. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19114. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19115. */
  19116. billboardMode: number;
  19117. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19118. limitVelocityDamping: number;
  19119. /**
  19120. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19121. */
  19122. beginAnimationOnStart: boolean;
  19123. /**
  19124. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19125. */
  19126. beginAnimationFrom: number;
  19127. /**
  19128. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19129. */
  19130. beginAnimationTo: number;
  19131. /**
  19132. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19133. */
  19134. beginAnimationLoop: boolean;
  19135. /**
  19136. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19137. */
  19138. disposeOnStop: boolean;
  19139. /**
  19140. * Gets the maximum number of particles active at the same time.
  19141. * @returns The max number of active particles.
  19142. */
  19143. getCapacity(): number;
  19144. /**
  19145. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19146. * @returns True if it has been started, otherwise false.
  19147. */
  19148. isStarted(): boolean;
  19149. /**
  19150. * Animates the particle system for this frame.
  19151. */
  19152. animate(): void;
  19153. /**
  19154. * Renders the particle system in its current state.
  19155. * @returns the current number of particles
  19156. */
  19157. render(): number;
  19158. /**
  19159. * Dispose the particle system and frees its associated resources.
  19160. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19161. */
  19162. dispose(disposeTexture?: boolean): void;
  19163. /**
  19164. * Clones the particle system.
  19165. * @param name The name of the cloned object
  19166. * @param newEmitter The new emitter to use
  19167. * @returns the cloned particle system
  19168. */
  19169. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19170. /**
  19171. * Serializes the particle system to a JSON object.
  19172. * @returns the JSON object
  19173. */
  19174. serialize(): any;
  19175. /**
  19176. * Rebuild the particle system
  19177. */
  19178. rebuild(): void;
  19179. /**
  19180. * Starts the particle system and begins to emit
  19181. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19182. */
  19183. start(delay?: number): void;
  19184. /**
  19185. * Stops the particle system.
  19186. */
  19187. stop(): void;
  19188. /**
  19189. * Remove all active particles
  19190. */
  19191. reset(): void;
  19192. /**
  19193. * Is this system ready to be used/rendered
  19194. * @return true if the system is ready
  19195. */
  19196. isReady(): boolean;
  19197. /**
  19198. * Adds a new color gradient
  19199. * @param gradient defines the gradient to use (between 0 and 1)
  19200. * @param color1 defines the color to affect to the specified gradient
  19201. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19202. * @returns the current particle system
  19203. */
  19204. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19205. /**
  19206. * Remove a specific color gradient
  19207. * @param gradient defines the gradient to remove
  19208. * @returns the current particle system
  19209. */
  19210. removeColorGradient(gradient: number): IParticleSystem;
  19211. /**
  19212. * Adds a new size gradient
  19213. * @param gradient defines the gradient to use (between 0 and 1)
  19214. * @param factor defines the size factor to affect to the specified gradient
  19215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19216. * @returns the current particle system
  19217. */
  19218. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19219. /**
  19220. * Remove a specific size gradient
  19221. * @param gradient defines the gradient to remove
  19222. * @returns the current particle system
  19223. */
  19224. removeSizeGradient(gradient: number): IParticleSystem;
  19225. /**
  19226. * Gets the current list of color gradients.
  19227. * You must use addColorGradient and removeColorGradient to udpate this list
  19228. * @returns the list of color gradients
  19229. */
  19230. getColorGradients(): Nullable<Array<ColorGradient>>;
  19231. /**
  19232. * Gets the current list of size gradients.
  19233. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19234. * @returns the list of size gradients
  19235. */
  19236. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19237. /**
  19238. * Gets the current list of angular speed gradients.
  19239. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19240. * @returns the list of angular speed gradients
  19241. */
  19242. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19243. /**
  19244. * Adds a new angular speed gradient
  19245. * @param gradient defines the gradient to use (between 0 and 1)
  19246. * @param factor defines the angular speed to affect to the specified gradient
  19247. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19248. * @returns the current particle system
  19249. */
  19250. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19251. /**
  19252. * Remove a specific angular speed gradient
  19253. * @param gradient defines the gradient to remove
  19254. * @returns the current particle system
  19255. */
  19256. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19257. /**
  19258. * Gets the current list of velocity gradients.
  19259. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19260. * @returns the list of velocity gradients
  19261. */
  19262. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19263. /**
  19264. * Adds a new velocity gradient
  19265. * @param gradient defines the gradient to use (between 0 and 1)
  19266. * @param factor defines the velocity to affect to the specified gradient
  19267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19268. * @returns the current particle system
  19269. */
  19270. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19271. /**
  19272. * Remove a specific velocity gradient
  19273. * @param gradient defines the gradient to remove
  19274. * @returns the current particle system
  19275. */
  19276. removeVelocityGradient(gradient: number): IParticleSystem;
  19277. /**
  19278. * Gets the current list of limit velocity gradients.
  19279. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19280. * @returns the list of limit velocity gradients
  19281. */
  19282. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19283. /**
  19284. * Adds a new limit velocity gradient
  19285. * @param gradient defines the gradient to use (between 0 and 1)
  19286. * @param factor defines the limit velocity to affect to the specified gradient
  19287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19288. * @returns the current particle system
  19289. */
  19290. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19291. /**
  19292. * Remove a specific limit velocity gradient
  19293. * @param gradient defines the gradient to remove
  19294. * @returns the current particle system
  19295. */
  19296. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19297. /**
  19298. * Adds a new drag gradient
  19299. * @param gradient defines the gradient to use (between 0 and 1)
  19300. * @param factor defines the drag to affect to the specified gradient
  19301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19302. * @returns the current particle system
  19303. */
  19304. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19305. /**
  19306. * Remove a specific drag gradient
  19307. * @param gradient defines the gradient to remove
  19308. * @returns the current particle system
  19309. */
  19310. removeDragGradient(gradient: number): IParticleSystem;
  19311. /**
  19312. * Gets the current list of drag gradients.
  19313. * You must use addDragGradient and removeDragGradient to udpate this list
  19314. * @returns the list of drag gradients
  19315. */
  19316. getDragGradients(): Nullable<Array<FactorGradient>>;
  19317. /**
  19318. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19319. * @param gradient defines the gradient to use (between 0 and 1)
  19320. * @param factor defines the emit rate to affect to the specified gradient
  19321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19322. * @returns the current particle system
  19323. */
  19324. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19325. /**
  19326. * Remove a specific emit rate gradient
  19327. * @param gradient defines the gradient to remove
  19328. * @returns the current particle system
  19329. */
  19330. removeEmitRateGradient(gradient: number): IParticleSystem;
  19331. /**
  19332. * Gets the current list of emit rate gradients.
  19333. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19334. * @returns the list of emit rate gradients
  19335. */
  19336. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19337. /**
  19338. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19339. * @param gradient defines the gradient to use (between 0 and 1)
  19340. * @param factor defines the start size to affect to the specified gradient
  19341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19342. * @returns the current particle system
  19343. */
  19344. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19345. /**
  19346. * Remove a specific start size gradient
  19347. * @param gradient defines the gradient to remove
  19348. * @returns the current particle system
  19349. */
  19350. removeStartSizeGradient(gradient: number): IParticleSystem;
  19351. /**
  19352. * Gets the current list of start size gradients.
  19353. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19354. * @returns the list of start size gradients
  19355. */
  19356. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19357. /**
  19358. * Adds a new life time gradient
  19359. * @param gradient defines the gradient to use (between 0 and 1)
  19360. * @param factor defines the life time factor to affect to the specified gradient
  19361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19362. * @returns the current particle system
  19363. */
  19364. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19365. /**
  19366. * Remove a specific life time gradient
  19367. * @param gradient defines the gradient to remove
  19368. * @returns the current particle system
  19369. */
  19370. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19371. /**
  19372. * Gets the current list of life time gradients.
  19373. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19374. * @returns the list of life time gradients
  19375. */
  19376. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19377. /**
  19378. * Gets the current list of color gradients.
  19379. * You must use addColorGradient and removeColorGradient to udpate this list
  19380. * @returns the list of color gradients
  19381. */
  19382. getColorGradients(): Nullable<Array<ColorGradient>>;
  19383. /**
  19384. * Adds a new ramp gradient used to remap particle colors
  19385. * @param gradient defines the gradient to use (between 0 and 1)
  19386. * @param color defines the color to affect to the specified gradient
  19387. * @returns the current particle system
  19388. */
  19389. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19390. /**
  19391. * Gets the current list of ramp gradients.
  19392. * You must use addRampGradient and removeRampGradient to udpate this list
  19393. * @returns the list of ramp gradients
  19394. */
  19395. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19396. /** Gets or sets a boolean indicating that ramp gradients must be used
  19397. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19398. */
  19399. useRampGradients: boolean;
  19400. /**
  19401. * Adds a new color remap gradient
  19402. * @param gradient defines the gradient to use (between 0 and 1)
  19403. * @param min defines the color remap minimal range
  19404. * @param max defines the color remap maximal range
  19405. * @returns the current particle system
  19406. */
  19407. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19408. /**
  19409. * Gets the current list of color remap gradients.
  19410. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19411. * @returns the list of color remap gradients
  19412. */
  19413. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19414. /**
  19415. * Adds a new alpha remap gradient
  19416. * @param gradient defines the gradient to use (between 0 and 1)
  19417. * @param min defines the alpha remap minimal range
  19418. * @param max defines the alpha remap maximal range
  19419. * @returns the current particle system
  19420. */
  19421. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19422. /**
  19423. * Gets the current list of alpha remap gradients.
  19424. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19425. * @returns the list of alpha remap gradients
  19426. */
  19427. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19428. /**
  19429. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19432. * @returns the emitter
  19433. */
  19434. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19435. /**
  19436. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19437. * @param radius The radius of the hemisphere to emit from
  19438. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19439. * @returns the emitter
  19440. */
  19441. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19442. /**
  19443. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19444. * @param radius The radius of the sphere to emit from
  19445. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19446. * @returns the emitter
  19447. */
  19448. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19449. /**
  19450. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19451. * @param radius The radius of the sphere to emit from
  19452. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19453. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19454. * @returns the emitter
  19455. */
  19456. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19457. /**
  19458. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19459. * @param radius The radius of the emission cylinder
  19460. * @param height The height of the emission cylinder
  19461. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19462. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19463. * @returns the emitter
  19464. */
  19465. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19466. /**
  19467. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19468. * @param radius The radius of the cylinder to emit from
  19469. * @param height The height of the emission cylinder
  19470. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19471. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19472. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19473. * @returns the emitter
  19474. */
  19475. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19476. /**
  19477. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19478. * @param radius The radius of the cone to emit from
  19479. * @param angle The base angle of the cone
  19480. * @returns the emitter
  19481. */
  19482. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19483. /**
  19484. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19487. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19488. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19489. * @returns the emitter
  19490. */
  19491. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19492. /**
  19493. * Get hosting scene
  19494. * @returns the scene
  19495. */
  19496. getScene(): Scene;
  19497. }
  19498. }
  19499. declare module "babylonjs/Meshes/instancedMesh" {
  19500. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19501. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19502. import { Camera } from "babylonjs/Cameras/camera";
  19503. import { Node } from "babylonjs/node";
  19504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19505. import { Mesh } from "babylonjs/Meshes/mesh";
  19506. import { Material } from "babylonjs/Materials/material";
  19507. import { Skeleton } from "babylonjs/Bones/skeleton";
  19508. import { Light } from "babylonjs/Lights/light";
  19509. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19510. /**
  19511. * Creates an instance based on a source mesh.
  19512. */
  19513. export class InstancedMesh extends AbstractMesh {
  19514. private _sourceMesh;
  19515. private _currentLOD;
  19516. /** @hidden */
  19517. _indexInSourceMeshInstanceArray: number;
  19518. constructor(name: string, source: Mesh);
  19519. /**
  19520. * Returns the string "InstancedMesh".
  19521. */
  19522. getClassName(): string;
  19523. /** Gets the list of lights affecting that mesh */
  19524. readonly lightSources: Light[];
  19525. _resyncLightSources(): void;
  19526. _resyncLightSource(light: Light): void;
  19527. _removeLightSource(light: Light, dispose: boolean): void;
  19528. /**
  19529. * If the source mesh receives shadows
  19530. */
  19531. readonly receiveShadows: boolean;
  19532. /**
  19533. * The material of the source mesh
  19534. */
  19535. readonly material: Nullable<Material>;
  19536. /**
  19537. * Visibility of the source mesh
  19538. */
  19539. readonly visibility: number;
  19540. /**
  19541. * Skeleton of the source mesh
  19542. */
  19543. readonly skeleton: Nullable<Skeleton>;
  19544. /**
  19545. * Rendering ground id of the source mesh
  19546. */
  19547. renderingGroupId: number;
  19548. /**
  19549. * Returns the total number of vertices (integer).
  19550. */
  19551. getTotalVertices(): number;
  19552. /**
  19553. * Returns a positive integer : the total number of indices in this mesh geometry.
  19554. * @returns the numner of indices or zero if the mesh has no geometry.
  19555. */
  19556. getTotalIndices(): number;
  19557. /**
  19558. * The source mesh of the instance
  19559. */
  19560. readonly sourceMesh: Mesh;
  19561. /**
  19562. * Is this node ready to be used/rendered
  19563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19564. * @return {boolean} is it ready
  19565. */
  19566. isReady(completeCheck?: boolean): boolean;
  19567. /**
  19568. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19569. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19570. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  19571. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19572. */
  19573. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19574. /**
  19575. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19576. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19577. * The `data` are either a numeric array either a Float32Array.
  19578. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19579. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  19580. * Note that a new underlying VertexBuffer object is created each call.
  19581. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19582. *
  19583. * Possible `kind` values :
  19584. * - VertexBuffer.PositionKind
  19585. * - VertexBuffer.UVKind
  19586. * - VertexBuffer.UV2Kind
  19587. * - VertexBuffer.UV3Kind
  19588. * - VertexBuffer.UV4Kind
  19589. * - VertexBuffer.UV5Kind
  19590. * - VertexBuffer.UV6Kind
  19591. * - VertexBuffer.ColorKind
  19592. * - VertexBuffer.MatricesIndicesKind
  19593. * - VertexBuffer.MatricesIndicesExtraKind
  19594. * - VertexBuffer.MatricesWeightsKind
  19595. * - VertexBuffer.MatricesWeightsExtraKind
  19596. *
  19597. * Returns the Mesh.
  19598. */
  19599. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19600. /**
  19601. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19602. * If the mesh has no geometry, it is simply returned as it is.
  19603. * The `data` are either a numeric array either a Float32Array.
  19604. * No new underlying VertexBuffer object is created.
  19605. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19606. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19607. *
  19608. * Possible `kind` values :
  19609. * - VertexBuffer.PositionKind
  19610. * - VertexBuffer.UVKind
  19611. * - VertexBuffer.UV2Kind
  19612. * - VertexBuffer.UV3Kind
  19613. * - VertexBuffer.UV4Kind
  19614. * - VertexBuffer.UV5Kind
  19615. * - VertexBuffer.UV6Kind
  19616. * - VertexBuffer.ColorKind
  19617. * - VertexBuffer.MatricesIndicesKind
  19618. * - VertexBuffer.MatricesIndicesExtraKind
  19619. * - VertexBuffer.MatricesWeightsKind
  19620. * - VertexBuffer.MatricesWeightsExtraKind
  19621. *
  19622. * Returns the Mesh.
  19623. */
  19624. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19625. /**
  19626. * Sets the mesh indices.
  19627. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19628. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19629. * This method creates a new index buffer each call.
  19630. * Returns the Mesh.
  19631. */
  19632. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19633. /**
  19634. * Boolean : True if the mesh owns the requested kind of data.
  19635. */
  19636. isVerticesDataPresent(kind: string): boolean;
  19637. /**
  19638. * Returns an array of indices (IndicesArray).
  19639. */
  19640. getIndices(): Nullable<IndicesArray>;
  19641. readonly _positions: Nullable<Vector3[]>;
  19642. /**
  19643. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19644. * This means the mesh underlying bounding box and sphere are recomputed.
  19645. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19646. * @returns the current mesh
  19647. */
  19648. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19649. /** @hidden */
  19650. _preActivate(): InstancedMesh;
  19651. /** @hidden */
  19652. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19653. /** @hidden */
  19654. _postActivate(): void;
  19655. getWorldMatrix(): Matrix;
  19656. readonly isAnInstance: boolean;
  19657. /**
  19658. * Returns the current associated LOD AbstractMesh.
  19659. */
  19660. getLOD(camera: Camera): AbstractMesh;
  19661. /** @hidden */
  19662. _syncSubMeshes(): InstancedMesh;
  19663. /** @hidden */
  19664. _generatePointsArray(): boolean;
  19665. /**
  19666. * Creates a new InstancedMesh from the current mesh.
  19667. * - name (string) : the cloned mesh name
  19668. * - newParent (optional Node) : the optional Node to parent the clone to.
  19669. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19670. *
  19671. * Returns the clone.
  19672. */
  19673. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19674. /**
  19675. * Disposes the InstancedMesh.
  19676. * Returns nothing.
  19677. */
  19678. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19679. }
  19680. module "babylonjs/Meshes/mesh" {
  19681. interface Mesh {
  19682. /**
  19683. * Register a custom buffer that will be instanced
  19684. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19685. * @param kind defines the buffer kind
  19686. * @param stride defines the stride in floats
  19687. */
  19688. registerInstancedBuffer(kind: string, stride: number): void;
  19689. /** @hidden */
  19690. _userInstancedBuffersStorage: {
  19691. data: {
  19692. [key: string]: Float32Array;
  19693. };
  19694. sizes: {
  19695. [key: string]: number;
  19696. };
  19697. vertexBuffers: {
  19698. [key: string]: Nullable<VertexBuffer>;
  19699. };
  19700. strides: {
  19701. [key: string]: number;
  19702. };
  19703. };
  19704. }
  19705. }
  19706. module "babylonjs/Meshes/abstractMesh" {
  19707. interface AbstractMesh {
  19708. /**
  19709. * Object used to store instanced buffers defined by user
  19710. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19711. */
  19712. instancedBuffers: {
  19713. [key: string]: any;
  19714. };
  19715. }
  19716. }
  19717. }
  19718. declare module "babylonjs/Materials/shaderMaterial" {
  19719. import { Scene } from "babylonjs/scene";
  19720. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19722. import { Mesh } from "babylonjs/Meshes/mesh";
  19723. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19725. import { Texture } from "babylonjs/Materials/Textures/texture";
  19726. import { Material } from "babylonjs/Materials/material";
  19727. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19728. /**
  19729. * Defines the options associated with the creation of a shader material.
  19730. */
  19731. export interface IShaderMaterialOptions {
  19732. /**
  19733. * Does the material work in alpha blend mode
  19734. */
  19735. needAlphaBlending: boolean;
  19736. /**
  19737. * Does the material work in alpha test mode
  19738. */
  19739. needAlphaTesting: boolean;
  19740. /**
  19741. * The list of attribute names used in the shader
  19742. */
  19743. attributes: string[];
  19744. /**
  19745. * The list of unifrom names used in the shader
  19746. */
  19747. uniforms: string[];
  19748. /**
  19749. * The list of UBO names used in the shader
  19750. */
  19751. uniformBuffers: string[];
  19752. /**
  19753. * The list of sampler names used in the shader
  19754. */
  19755. samplers: string[];
  19756. /**
  19757. * The list of defines used in the shader
  19758. */
  19759. defines: string[];
  19760. }
  19761. /**
  19762. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19763. *
  19764. * This returned material effects how the mesh will look based on the code in the shaders.
  19765. *
  19766. * @see http://doc.babylonjs.com/how_to/shader_material
  19767. */
  19768. export class ShaderMaterial extends Material {
  19769. private _shaderPath;
  19770. private _options;
  19771. private _textures;
  19772. private _textureArrays;
  19773. private _floats;
  19774. private _ints;
  19775. private _floatsArrays;
  19776. private _colors3;
  19777. private _colors3Arrays;
  19778. private _colors4;
  19779. private _colors4Arrays;
  19780. private _vectors2;
  19781. private _vectors3;
  19782. private _vectors4;
  19783. private _matrices;
  19784. private _matrixArrays;
  19785. private _matrices3x3;
  19786. private _matrices2x2;
  19787. private _vectors2Arrays;
  19788. private _vectors3Arrays;
  19789. private _vectors4Arrays;
  19790. private _cachedWorldViewMatrix;
  19791. private _cachedWorldViewProjectionMatrix;
  19792. private _renderId;
  19793. private _multiview;
  19794. /**
  19795. * Instantiate a new shader material.
  19796. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19797. * This returned material effects how the mesh will look based on the code in the shaders.
  19798. * @see http://doc.babylonjs.com/how_to/shader_material
  19799. * @param name Define the name of the material in the scene
  19800. * @param scene Define the scene the material belongs to
  19801. * @param shaderPath Defines the route to the shader code in one of three ways:
  19802. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19803. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19804. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19805. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19806. * @param options Define the options used to create the shader
  19807. */
  19808. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19809. /**
  19810. * Gets the shader path used to define the shader code
  19811. * It can be modified to trigger a new compilation
  19812. */
  19813. /**
  19814. * Sets the shader path used to define the shader code
  19815. * It can be modified to trigger a new compilation
  19816. */
  19817. shaderPath: any;
  19818. /**
  19819. * Gets the options used to compile the shader.
  19820. * They can be modified to trigger a new compilation
  19821. */
  19822. readonly options: IShaderMaterialOptions;
  19823. /**
  19824. * Gets the current class name of the material e.g. "ShaderMaterial"
  19825. * Mainly use in serialization.
  19826. * @returns the class name
  19827. */
  19828. getClassName(): string;
  19829. /**
  19830. * Specifies if the material will require alpha blending
  19831. * @returns a boolean specifying if alpha blending is needed
  19832. */
  19833. needAlphaBlending(): boolean;
  19834. /**
  19835. * Specifies if this material should be rendered in alpha test mode
  19836. * @returns a boolean specifying if an alpha test is needed.
  19837. */
  19838. needAlphaTesting(): boolean;
  19839. private _checkUniform;
  19840. /**
  19841. * Set a texture in the shader.
  19842. * @param name Define the name of the uniform samplers as defined in the shader
  19843. * @param texture Define the texture to bind to this sampler
  19844. * @return the material itself allowing "fluent" like uniform updates
  19845. */
  19846. setTexture(name: string, texture: Texture): ShaderMaterial;
  19847. /**
  19848. * Set a texture array in the shader.
  19849. * @param name Define the name of the uniform sampler array as defined in the shader
  19850. * @param textures Define the list of textures to bind to this sampler
  19851. * @return the material itself allowing "fluent" like uniform updates
  19852. */
  19853. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19854. /**
  19855. * Set a float in the shader.
  19856. * @param name Define the name of the uniform as defined in the shader
  19857. * @param value Define the value to give to the uniform
  19858. * @return the material itself allowing "fluent" like uniform updates
  19859. */
  19860. setFloat(name: string, value: number): ShaderMaterial;
  19861. /**
  19862. * Set a int in the shader.
  19863. * @param name Define the name of the uniform as defined in the shader
  19864. * @param value Define the value to give to the uniform
  19865. * @return the material itself allowing "fluent" like uniform updates
  19866. */
  19867. setInt(name: string, value: number): ShaderMaterial;
  19868. /**
  19869. * Set an array of floats in the shader.
  19870. * @param name Define the name of the uniform as defined in the shader
  19871. * @param value Define the value to give to the uniform
  19872. * @return the material itself allowing "fluent" like uniform updates
  19873. */
  19874. setFloats(name: string, value: number[]): ShaderMaterial;
  19875. /**
  19876. * Set a vec3 in the shader from a Color3.
  19877. * @param name Define the name of the uniform as defined in the shader
  19878. * @param value Define the value to give to the uniform
  19879. * @return the material itself allowing "fluent" like uniform updates
  19880. */
  19881. setColor3(name: string, value: Color3): ShaderMaterial;
  19882. /**
  19883. * Set a vec3 array in the shader from a Color3 array.
  19884. * @param name Define the name of the uniform as defined in the shader
  19885. * @param value Define the value to give to the uniform
  19886. * @return the material itself allowing "fluent" like uniform updates
  19887. */
  19888. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19889. /**
  19890. * Set a vec4 in the shader from a Color4.
  19891. * @param name Define the name of the uniform as defined in the shader
  19892. * @param value Define the value to give to the uniform
  19893. * @return the material itself allowing "fluent" like uniform updates
  19894. */
  19895. setColor4(name: string, value: Color4): ShaderMaterial;
  19896. /**
  19897. * Set a vec4 array in the shader from a Color4 array.
  19898. * @param name Define the name of the uniform as defined in the shader
  19899. * @param value Define the value to give to the uniform
  19900. * @return the material itself allowing "fluent" like uniform updates
  19901. */
  19902. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19903. /**
  19904. * Set a vec2 in the shader from a Vector2.
  19905. * @param name Define the name of the uniform as defined in the shader
  19906. * @param value Define the value to give to the uniform
  19907. * @return the material itself allowing "fluent" like uniform updates
  19908. */
  19909. setVector2(name: string, value: Vector2): ShaderMaterial;
  19910. /**
  19911. * Set a vec3 in the shader from a Vector3.
  19912. * @param name Define the name of the uniform as defined in the shader
  19913. * @param value Define the value to give to the uniform
  19914. * @return the material itself allowing "fluent" like uniform updates
  19915. */
  19916. setVector3(name: string, value: Vector3): ShaderMaterial;
  19917. /**
  19918. * Set a vec4 in the shader from a Vector4.
  19919. * @param name Define the name of the uniform as defined in the shader
  19920. * @param value Define the value to give to the uniform
  19921. * @return the material itself allowing "fluent" like uniform updates
  19922. */
  19923. setVector4(name: string, value: Vector4): ShaderMaterial;
  19924. /**
  19925. * Set a mat4 in the shader from a Matrix.
  19926. * @param name Define the name of the uniform as defined in the shader
  19927. * @param value Define the value to give to the uniform
  19928. * @return the material itself allowing "fluent" like uniform updates
  19929. */
  19930. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19931. /**
  19932. * Set a float32Array in the shader from a matrix array.
  19933. * @param name Define the name of the uniform as defined in the shader
  19934. * @param value Define the value to give to the uniform
  19935. * @return the material itself allowing "fluent" like uniform updates
  19936. */
  19937. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19938. /**
  19939. * Set a mat3 in the shader from a Float32Array.
  19940. * @param name Define the name of the uniform as defined in the shader
  19941. * @param value Define the value to give to the uniform
  19942. * @return the material itself allowing "fluent" like uniform updates
  19943. */
  19944. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19945. /**
  19946. * Set a mat2 in the shader from a Float32Array.
  19947. * @param name Define the name of the uniform as defined in the shader
  19948. * @param value Define the value to give to the uniform
  19949. * @return the material itself allowing "fluent" like uniform updates
  19950. */
  19951. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19952. /**
  19953. * Set a vec2 array in the shader from a number array.
  19954. * @param name Define the name of the uniform as defined in the shader
  19955. * @param value Define the value to give to the uniform
  19956. * @return the material itself allowing "fluent" like uniform updates
  19957. */
  19958. setArray2(name: string, value: number[]): ShaderMaterial;
  19959. /**
  19960. * Set a vec3 array in the shader from a number array.
  19961. * @param name Define the name of the uniform as defined in the shader
  19962. * @param value Define the value to give to the uniform
  19963. * @return the material itself allowing "fluent" like uniform updates
  19964. */
  19965. setArray3(name: string, value: number[]): ShaderMaterial;
  19966. /**
  19967. * Set a vec4 array in the shader from a number array.
  19968. * @param name Define the name of the uniform as defined in the shader
  19969. * @param value Define the value to give to the uniform
  19970. * @return the material itself allowing "fluent" like uniform updates
  19971. */
  19972. setArray4(name: string, value: number[]): ShaderMaterial;
  19973. private _checkCache;
  19974. /**
  19975. * Specifies that the submesh is ready to be used
  19976. * @param mesh defines the mesh to check
  19977. * @param subMesh defines which submesh to check
  19978. * @param useInstances specifies that instances should be used
  19979. * @returns a boolean indicating that the submesh is ready or not
  19980. */
  19981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19982. /**
  19983. * Checks if the material is ready to render the requested mesh
  19984. * @param mesh Define the mesh to render
  19985. * @param useInstances Define whether or not the material is used with instances
  19986. * @returns true if ready, otherwise false
  19987. */
  19988. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19989. /**
  19990. * Binds the world matrix to the material
  19991. * @param world defines the world transformation matrix
  19992. */
  19993. bindOnlyWorldMatrix(world: Matrix): void;
  19994. /**
  19995. * Binds the material to the mesh
  19996. * @param world defines the world transformation matrix
  19997. * @param mesh defines the mesh to bind the material to
  19998. */
  19999. bind(world: Matrix, mesh?: Mesh): void;
  20000. /**
  20001. * Gets the active textures from the material
  20002. * @returns an array of textures
  20003. */
  20004. getActiveTextures(): BaseTexture[];
  20005. /**
  20006. * Specifies if the material uses a texture
  20007. * @param texture defines the texture to check against the material
  20008. * @returns a boolean specifying if the material uses the texture
  20009. */
  20010. hasTexture(texture: BaseTexture): boolean;
  20011. /**
  20012. * Makes a duplicate of the material, and gives it a new name
  20013. * @param name defines the new name for the duplicated material
  20014. * @returns the cloned material
  20015. */
  20016. clone(name: string): ShaderMaterial;
  20017. /**
  20018. * Disposes the material
  20019. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20020. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20021. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20022. */
  20023. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20024. /**
  20025. * Serializes this material in a JSON representation
  20026. * @returns the serialized material object
  20027. */
  20028. serialize(): any;
  20029. /**
  20030. * Creates a shader material from parsed shader material data
  20031. * @param source defines the JSON represnetation of the material
  20032. * @param scene defines the hosting scene
  20033. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20034. * @returns a new material
  20035. */
  20036. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20037. }
  20038. }
  20039. declare module "babylonjs/Shaders/color.fragment" {
  20040. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20041. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20042. /** @hidden */
  20043. export var colorPixelShader: {
  20044. name: string;
  20045. shader: string;
  20046. };
  20047. }
  20048. declare module "babylonjs/Shaders/color.vertex" {
  20049. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20050. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20051. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20052. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20053. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20054. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20055. /** @hidden */
  20056. export var colorVertexShader: {
  20057. name: string;
  20058. shader: string;
  20059. };
  20060. }
  20061. declare module "babylonjs/Meshes/linesMesh" {
  20062. import { Nullable } from "babylonjs/types";
  20063. import { Scene } from "babylonjs/scene";
  20064. import { Color3 } from "babylonjs/Maths/math.color";
  20065. import { Node } from "babylonjs/node";
  20066. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20067. import { Mesh } from "babylonjs/Meshes/mesh";
  20068. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20069. import { Effect } from "babylonjs/Materials/effect";
  20070. import { Material } from "babylonjs/Materials/material";
  20071. import "babylonjs/Shaders/color.fragment";
  20072. import "babylonjs/Shaders/color.vertex";
  20073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20074. /**
  20075. * Line mesh
  20076. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20077. */
  20078. export class LinesMesh extends Mesh {
  20079. /**
  20080. * If vertex color should be applied to the mesh
  20081. */
  20082. readonly useVertexColor?: boolean | undefined;
  20083. /**
  20084. * If vertex alpha should be applied to the mesh
  20085. */
  20086. readonly useVertexAlpha?: boolean | undefined;
  20087. /**
  20088. * Color of the line (Default: White)
  20089. */
  20090. color: Color3;
  20091. /**
  20092. * Alpha of the line (Default: 1)
  20093. */
  20094. alpha: number;
  20095. /**
  20096. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20097. * This margin is expressed in world space coordinates, so its value may vary.
  20098. * Default value is 0.1
  20099. */
  20100. intersectionThreshold: number;
  20101. private _colorShader;
  20102. private color4;
  20103. /**
  20104. * Creates a new LinesMesh
  20105. * @param name defines the name
  20106. * @param scene defines the hosting scene
  20107. * @param parent defines the parent mesh if any
  20108. * @param source defines the optional source LinesMesh used to clone data from
  20109. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20110. * When false, achieved by calling a clone(), also passing False.
  20111. * This will make creation of children, recursive.
  20112. * @param useVertexColor defines if this LinesMesh supports vertex color
  20113. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20114. */
  20115. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20116. /**
  20117. * If vertex color should be applied to the mesh
  20118. */
  20119. useVertexColor?: boolean | undefined,
  20120. /**
  20121. * If vertex alpha should be applied to the mesh
  20122. */
  20123. useVertexAlpha?: boolean | undefined);
  20124. private _addClipPlaneDefine;
  20125. private _removeClipPlaneDefine;
  20126. isReady(): boolean;
  20127. /**
  20128. * Returns the string "LineMesh"
  20129. */
  20130. getClassName(): string;
  20131. /**
  20132. * @hidden
  20133. */
  20134. /**
  20135. * @hidden
  20136. */
  20137. material: Material;
  20138. /**
  20139. * @hidden
  20140. */
  20141. readonly checkCollisions: boolean;
  20142. /** @hidden */
  20143. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20144. /** @hidden */
  20145. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20146. /**
  20147. * Disposes of the line mesh
  20148. * @param doNotRecurse If children should be disposed
  20149. */
  20150. dispose(doNotRecurse?: boolean): void;
  20151. /**
  20152. * Returns a new LineMesh object cloned from the current one.
  20153. */
  20154. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20155. /**
  20156. * Creates a new InstancedLinesMesh object from the mesh model.
  20157. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20158. * @param name defines the name of the new instance
  20159. * @returns a new InstancedLinesMesh
  20160. */
  20161. createInstance(name: string): InstancedLinesMesh;
  20162. }
  20163. /**
  20164. * Creates an instance based on a source LinesMesh
  20165. */
  20166. export class InstancedLinesMesh extends InstancedMesh {
  20167. /**
  20168. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20169. * This margin is expressed in world space coordinates, so its value may vary.
  20170. * Initilized with the intersectionThreshold value of the source LinesMesh
  20171. */
  20172. intersectionThreshold: number;
  20173. constructor(name: string, source: LinesMesh);
  20174. /**
  20175. * Returns the string "InstancedLinesMesh".
  20176. */
  20177. getClassName(): string;
  20178. }
  20179. }
  20180. declare module "babylonjs/Shaders/line.fragment" {
  20181. /** @hidden */
  20182. export var linePixelShader: {
  20183. name: string;
  20184. shader: string;
  20185. };
  20186. }
  20187. declare module "babylonjs/Shaders/line.vertex" {
  20188. /** @hidden */
  20189. export var lineVertexShader: {
  20190. name: string;
  20191. shader: string;
  20192. };
  20193. }
  20194. declare module "babylonjs/Rendering/edgesRenderer" {
  20195. import { Nullable } from "babylonjs/types";
  20196. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20198. import { Vector3 } from "babylonjs/Maths/math.vector";
  20199. import { IDisposable } from "babylonjs/scene";
  20200. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20201. import "babylonjs/Shaders/line.fragment";
  20202. import "babylonjs/Shaders/line.vertex";
  20203. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20204. module "babylonjs/Meshes/abstractMesh" {
  20205. interface AbstractMesh {
  20206. /**
  20207. * Gets the edgesRenderer associated with the mesh
  20208. */
  20209. edgesRenderer: Nullable<EdgesRenderer>;
  20210. }
  20211. }
  20212. module "babylonjs/Meshes/linesMesh" {
  20213. interface LinesMesh {
  20214. /**
  20215. * Enables the edge rendering mode on the mesh.
  20216. * This mode makes the mesh edges visible
  20217. * @param epsilon defines the maximal distance between two angles to detect a face
  20218. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20219. * @returns the currentAbstractMesh
  20220. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20221. */
  20222. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20223. }
  20224. }
  20225. module "babylonjs/Meshes/linesMesh" {
  20226. interface InstancedLinesMesh {
  20227. /**
  20228. * Enables the edge rendering mode on the mesh.
  20229. * This mode makes the mesh edges visible
  20230. * @param epsilon defines the maximal distance between two angles to detect a face
  20231. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20232. * @returns the current InstancedLinesMesh
  20233. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20234. */
  20235. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20236. }
  20237. }
  20238. /**
  20239. * Defines the minimum contract an Edges renderer should follow.
  20240. */
  20241. export interface IEdgesRenderer extends IDisposable {
  20242. /**
  20243. * Gets or sets a boolean indicating if the edgesRenderer is active
  20244. */
  20245. isEnabled: boolean;
  20246. /**
  20247. * Renders the edges of the attached mesh,
  20248. */
  20249. render(): void;
  20250. /**
  20251. * Checks wether or not the edges renderer is ready to render.
  20252. * @return true if ready, otherwise false.
  20253. */
  20254. isReady(): boolean;
  20255. }
  20256. /**
  20257. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20258. */
  20259. export class EdgesRenderer implements IEdgesRenderer {
  20260. /**
  20261. * Define the size of the edges with an orthographic camera
  20262. */
  20263. edgesWidthScalerForOrthographic: number;
  20264. /**
  20265. * Define the size of the edges with a perspective camera
  20266. */
  20267. edgesWidthScalerForPerspective: number;
  20268. protected _source: AbstractMesh;
  20269. protected _linesPositions: number[];
  20270. protected _linesNormals: number[];
  20271. protected _linesIndices: number[];
  20272. protected _epsilon: number;
  20273. protected _indicesCount: number;
  20274. protected _lineShader: ShaderMaterial;
  20275. protected _ib: DataBuffer;
  20276. protected _buffers: {
  20277. [key: string]: Nullable<VertexBuffer>;
  20278. };
  20279. protected _checkVerticesInsteadOfIndices: boolean;
  20280. private _meshRebuildObserver;
  20281. private _meshDisposeObserver;
  20282. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20283. isEnabled: boolean;
  20284. /**
  20285. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20286. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20287. * @param source Mesh used to create edges
  20288. * @param epsilon sum of angles in adjacency to check for edge
  20289. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20290. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20291. */
  20292. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20293. protected _prepareRessources(): void;
  20294. /** @hidden */
  20295. _rebuild(): void;
  20296. /**
  20297. * Releases the required resources for the edges renderer
  20298. */
  20299. dispose(): void;
  20300. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20301. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20302. /**
  20303. * Checks if the pair of p0 and p1 is en edge
  20304. * @param faceIndex
  20305. * @param edge
  20306. * @param faceNormals
  20307. * @param p0
  20308. * @param p1
  20309. * @private
  20310. */
  20311. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20312. /**
  20313. * push line into the position, normal and index buffer
  20314. * @protected
  20315. */
  20316. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20317. /**
  20318. * Generates lines edges from adjacencjes
  20319. * @private
  20320. */
  20321. _generateEdgesLines(): void;
  20322. /**
  20323. * Checks wether or not the edges renderer is ready to render.
  20324. * @return true if ready, otherwise false.
  20325. */
  20326. isReady(): boolean;
  20327. /**
  20328. * Renders the edges of the attached mesh,
  20329. */
  20330. render(): void;
  20331. }
  20332. /**
  20333. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20334. */
  20335. export class LineEdgesRenderer extends EdgesRenderer {
  20336. /**
  20337. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20338. * @param source LineMesh used to generate edges
  20339. * @param epsilon not important (specified angle for edge detection)
  20340. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20341. */
  20342. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20343. /**
  20344. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20345. */
  20346. _generateEdgesLines(): void;
  20347. }
  20348. }
  20349. declare module "babylonjs/Rendering/renderingGroup" {
  20350. import { SmartArray } from "babylonjs/Misc/smartArray";
  20351. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20353. import { Nullable } from "babylonjs/types";
  20354. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20355. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20356. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20357. import { Material } from "babylonjs/Materials/material";
  20358. import { Scene } from "babylonjs/scene";
  20359. /**
  20360. * This represents the object necessary to create a rendering group.
  20361. * This is exclusively used and created by the rendering manager.
  20362. * To modify the behavior, you use the available helpers in your scene or meshes.
  20363. * @hidden
  20364. */
  20365. export class RenderingGroup {
  20366. index: number;
  20367. private static _zeroVector;
  20368. private _scene;
  20369. private _opaqueSubMeshes;
  20370. private _transparentSubMeshes;
  20371. private _alphaTestSubMeshes;
  20372. private _depthOnlySubMeshes;
  20373. private _particleSystems;
  20374. private _spriteManagers;
  20375. private _opaqueSortCompareFn;
  20376. private _alphaTestSortCompareFn;
  20377. private _transparentSortCompareFn;
  20378. private _renderOpaque;
  20379. private _renderAlphaTest;
  20380. private _renderTransparent;
  20381. /** @hidden */
  20382. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20383. onBeforeTransparentRendering: () => void;
  20384. /**
  20385. * Set the opaque sort comparison function.
  20386. * If null the sub meshes will be render in the order they were created
  20387. */
  20388. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20389. /**
  20390. * Set the alpha test sort comparison function.
  20391. * If null the sub meshes will be render in the order they were created
  20392. */
  20393. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20394. /**
  20395. * Set the transparent sort comparison function.
  20396. * If null the sub meshes will be render in the order they were created
  20397. */
  20398. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20399. /**
  20400. * Creates a new rendering group.
  20401. * @param index The rendering group index
  20402. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20403. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20404. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20405. */
  20406. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20407. /**
  20408. * Render all the sub meshes contained in the group.
  20409. * @param customRenderFunction Used to override the default render behaviour of the group.
  20410. * @returns true if rendered some submeshes.
  20411. */
  20412. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20413. /**
  20414. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20415. * @param subMeshes The submeshes to render
  20416. */
  20417. private renderOpaqueSorted;
  20418. /**
  20419. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20420. * @param subMeshes The submeshes to render
  20421. */
  20422. private renderAlphaTestSorted;
  20423. /**
  20424. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20425. * @param subMeshes The submeshes to render
  20426. */
  20427. private renderTransparentSorted;
  20428. /**
  20429. * Renders the submeshes in a specified order.
  20430. * @param subMeshes The submeshes to sort before render
  20431. * @param sortCompareFn The comparison function use to sort
  20432. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20433. * @param transparent Specifies to activate blending if true
  20434. */
  20435. private static renderSorted;
  20436. /**
  20437. * Renders the submeshes in the order they were dispatched (no sort applied).
  20438. * @param subMeshes The submeshes to render
  20439. */
  20440. private static renderUnsorted;
  20441. /**
  20442. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20443. * are rendered back to front if in the same alpha index.
  20444. *
  20445. * @param a The first submesh
  20446. * @param b The second submesh
  20447. * @returns The result of the comparison
  20448. */
  20449. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20450. /**
  20451. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20452. * are rendered back to front.
  20453. *
  20454. * @param a The first submesh
  20455. * @param b The second submesh
  20456. * @returns The result of the comparison
  20457. */
  20458. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20459. /**
  20460. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20461. * are rendered front to back (prevent overdraw).
  20462. *
  20463. * @param a The first submesh
  20464. * @param b The second submesh
  20465. * @returns The result of the comparison
  20466. */
  20467. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20468. /**
  20469. * Resets the different lists of submeshes to prepare a new frame.
  20470. */
  20471. prepare(): void;
  20472. dispose(): void;
  20473. /**
  20474. * Inserts the submesh in its correct queue depending on its material.
  20475. * @param subMesh The submesh to dispatch
  20476. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20477. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20478. */
  20479. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20480. dispatchSprites(spriteManager: ISpriteManager): void;
  20481. dispatchParticles(particleSystem: IParticleSystem): void;
  20482. private _renderParticles;
  20483. private _renderSprites;
  20484. }
  20485. }
  20486. declare module "babylonjs/Rendering/renderingManager" {
  20487. import { Nullable } from "babylonjs/types";
  20488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20489. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20490. import { SmartArray } from "babylonjs/Misc/smartArray";
  20491. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20492. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20493. import { Material } from "babylonjs/Materials/material";
  20494. import { Scene } from "babylonjs/scene";
  20495. import { Camera } from "babylonjs/Cameras/camera";
  20496. /**
  20497. * Interface describing the different options available in the rendering manager
  20498. * regarding Auto Clear between groups.
  20499. */
  20500. export interface IRenderingManagerAutoClearSetup {
  20501. /**
  20502. * Defines whether or not autoclear is enable.
  20503. */
  20504. autoClear: boolean;
  20505. /**
  20506. * Defines whether or not to autoclear the depth buffer.
  20507. */
  20508. depth: boolean;
  20509. /**
  20510. * Defines whether or not to autoclear the stencil buffer.
  20511. */
  20512. stencil: boolean;
  20513. }
  20514. /**
  20515. * This class is used by the onRenderingGroupObservable
  20516. */
  20517. export class RenderingGroupInfo {
  20518. /**
  20519. * The Scene that being rendered
  20520. */
  20521. scene: Scene;
  20522. /**
  20523. * The camera currently used for the rendering pass
  20524. */
  20525. camera: Nullable<Camera>;
  20526. /**
  20527. * The ID of the renderingGroup being processed
  20528. */
  20529. renderingGroupId: number;
  20530. }
  20531. /**
  20532. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20533. * It is enable to manage the different groups as well as the different necessary sort functions.
  20534. * This should not be used directly aside of the few static configurations
  20535. */
  20536. export class RenderingManager {
  20537. /**
  20538. * The max id used for rendering groups (not included)
  20539. */
  20540. static MAX_RENDERINGGROUPS: number;
  20541. /**
  20542. * The min id used for rendering groups (included)
  20543. */
  20544. static MIN_RENDERINGGROUPS: number;
  20545. /**
  20546. * Used to globally prevent autoclearing scenes.
  20547. */
  20548. static AUTOCLEAR: boolean;
  20549. /**
  20550. * @hidden
  20551. */
  20552. _useSceneAutoClearSetup: boolean;
  20553. private _scene;
  20554. private _renderingGroups;
  20555. private _depthStencilBufferAlreadyCleaned;
  20556. private _autoClearDepthStencil;
  20557. private _customOpaqueSortCompareFn;
  20558. private _customAlphaTestSortCompareFn;
  20559. private _customTransparentSortCompareFn;
  20560. private _renderingGroupInfo;
  20561. /**
  20562. * Instantiates a new rendering group for a particular scene
  20563. * @param scene Defines the scene the groups belongs to
  20564. */
  20565. constructor(scene: Scene);
  20566. private _clearDepthStencilBuffer;
  20567. /**
  20568. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20569. * @hidden
  20570. */
  20571. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20572. /**
  20573. * Resets the different information of the group to prepare a new frame
  20574. * @hidden
  20575. */
  20576. reset(): void;
  20577. /**
  20578. * Dispose and release the group and its associated resources.
  20579. * @hidden
  20580. */
  20581. dispose(): void;
  20582. /**
  20583. * Clear the info related to rendering groups preventing retention points during dispose.
  20584. */
  20585. freeRenderingGroups(): void;
  20586. private _prepareRenderingGroup;
  20587. /**
  20588. * Add a sprite manager to the rendering manager in order to render it this frame.
  20589. * @param spriteManager Define the sprite manager to render
  20590. */
  20591. dispatchSprites(spriteManager: ISpriteManager): void;
  20592. /**
  20593. * Add a particle system to the rendering manager in order to render it this frame.
  20594. * @param particleSystem Define the particle system to render
  20595. */
  20596. dispatchParticles(particleSystem: IParticleSystem): void;
  20597. /**
  20598. * Add a submesh to the manager in order to render it this frame
  20599. * @param subMesh The submesh to dispatch
  20600. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20601. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20602. */
  20603. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20604. /**
  20605. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20606. * This allowed control for front to back rendering or reversly depending of the special needs.
  20607. *
  20608. * @param renderingGroupId The rendering group id corresponding to its index
  20609. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20610. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20611. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20612. */
  20613. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20614. /**
  20615. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20616. *
  20617. * @param renderingGroupId The rendering group id corresponding to its index
  20618. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20619. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20620. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20621. */
  20622. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20623. /**
  20624. * Gets the current auto clear configuration for one rendering group of the rendering
  20625. * manager.
  20626. * @param index the rendering group index to get the information for
  20627. * @returns The auto clear setup for the requested rendering group
  20628. */
  20629. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20630. }
  20631. }
  20632. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20633. import { Observable } from "babylonjs/Misc/observable";
  20634. import { SmartArray } from "babylonjs/Misc/smartArray";
  20635. import { Nullable } from "babylonjs/types";
  20636. import { Camera } from "babylonjs/Cameras/camera";
  20637. import { Scene } from "babylonjs/scene";
  20638. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20639. import { Color4 } from "babylonjs/Maths/math.color";
  20640. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20643. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20644. import { Texture } from "babylonjs/Materials/Textures/texture";
  20645. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20646. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20647. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20648. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20649. import { Engine } from "babylonjs/Engines/engine";
  20650. /**
  20651. * This Helps creating a texture that will be created from a camera in your scene.
  20652. * It is basically a dynamic texture that could be used to create special effects for instance.
  20653. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20654. */
  20655. export class RenderTargetTexture extends Texture {
  20656. isCube: boolean;
  20657. /**
  20658. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20659. */
  20660. static readonly REFRESHRATE_RENDER_ONCE: number;
  20661. /**
  20662. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20663. */
  20664. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20665. /**
  20666. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20667. * the central point of your effect and can save a lot of performances.
  20668. */
  20669. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20670. /**
  20671. * Use this predicate to dynamically define the list of mesh you want to render.
  20672. * If set, the renderList property will be overwritten.
  20673. */
  20674. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20675. private _renderList;
  20676. /**
  20677. * Use this list to define the list of mesh you want to render.
  20678. */
  20679. renderList: Nullable<Array<AbstractMesh>>;
  20680. private _hookArray;
  20681. /**
  20682. * Define if particles should be rendered in your texture.
  20683. */
  20684. renderParticles: boolean;
  20685. /**
  20686. * Define if sprites should be rendered in your texture.
  20687. */
  20688. renderSprites: boolean;
  20689. /**
  20690. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20691. */
  20692. coordinatesMode: number;
  20693. /**
  20694. * Define the camera used to render the texture.
  20695. */
  20696. activeCamera: Nullable<Camera>;
  20697. /**
  20698. * Override the render function of the texture with your own one.
  20699. */
  20700. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20701. /**
  20702. * Define if camera post processes should be use while rendering the texture.
  20703. */
  20704. useCameraPostProcesses: boolean;
  20705. /**
  20706. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20707. */
  20708. ignoreCameraViewport: boolean;
  20709. private _postProcessManager;
  20710. private _postProcesses;
  20711. private _resizeObserver;
  20712. /**
  20713. * An event triggered when the texture is unbind.
  20714. */
  20715. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20716. /**
  20717. * An event triggered when the texture is unbind.
  20718. */
  20719. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20720. private _onAfterUnbindObserver;
  20721. /**
  20722. * Set a after unbind callback in the texture.
  20723. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20724. */
  20725. onAfterUnbind: () => void;
  20726. /**
  20727. * An event triggered before rendering the texture
  20728. */
  20729. onBeforeRenderObservable: Observable<number>;
  20730. private _onBeforeRenderObserver;
  20731. /**
  20732. * Set a before render callback in the texture.
  20733. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20734. */
  20735. onBeforeRender: (faceIndex: number) => void;
  20736. /**
  20737. * An event triggered after rendering the texture
  20738. */
  20739. onAfterRenderObservable: Observable<number>;
  20740. private _onAfterRenderObserver;
  20741. /**
  20742. * Set a after render callback in the texture.
  20743. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20744. */
  20745. onAfterRender: (faceIndex: number) => void;
  20746. /**
  20747. * An event triggered after the texture clear
  20748. */
  20749. onClearObservable: Observable<Engine>;
  20750. private _onClearObserver;
  20751. /**
  20752. * Set a clear callback in the texture.
  20753. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20754. */
  20755. onClear: (Engine: Engine) => void;
  20756. /**
  20757. * An event triggered when the texture is resized.
  20758. */
  20759. onResizeObservable: Observable<RenderTargetTexture>;
  20760. /**
  20761. * Define the clear color of the Render Target if it should be different from the scene.
  20762. */
  20763. clearColor: Color4;
  20764. protected _size: number | {
  20765. width: number;
  20766. height: number;
  20767. };
  20768. protected _initialSizeParameter: number | {
  20769. width: number;
  20770. height: number;
  20771. } | {
  20772. ratio: number;
  20773. };
  20774. protected _sizeRatio: Nullable<number>;
  20775. /** @hidden */
  20776. _generateMipMaps: boolean;
  20777. protected _renderingManager: RenderingManager;
  20778. /** @hidden */
  20779. _waitingRenderList: string[];
  20780. protected _doNotChangeAspectRatio: boolean;
  20781. protected _currentRefreshId: number;
  20782. protected _refreshRate: number;
  20783. protected _textureMatrix: Matrix;
  20784. protected _samples: number;
  20785. protected _renderTargetOptions: RenderTargetCreationOptions;
  20786. /**
  20787. * Gets render target creation options that were used.
  20788. */
  20789. readonly renderTargetOptions: RenderTargetCreationOptions;
  20790. protected _engine: Engine;
  20791. protected _onRatioRescale(): void;
  20792. /**
  20793. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20794. * It must define where the camera used to render the texture is set
  20795. */
  20796. boundingBoxPosition: Vector3;
  20797. private _boundingBoxSize;
  20798. /**
  20799. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20800. * When defined, the cubemap will switch to local mode
  20801. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20802. * @example https://www.babylonjs-playground.com/#RNASML
  20803. */
  20804. boundingBoxSize: Vector3;
  20805. /**
  20806. * In case the RTT has been created with a depth texture, get the associated
  20807. * depth texture.
  20808. * Otherwise, return null.
  20809. */
  20810. depthStencilTexture: Nullable<InternalTexture>;
  20811. /**
  20812. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20813. * or used a shadow, depth texture...
  20814. * @param name The friendly name of the texture
  20815. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20816. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20817. * @param generateMipMaps True if mip maps need to be generated after render.
  20818. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20819. * @param type The type of the buffer in the RTT (int, half float, float...)
  20820. * @param isCube True if a cube texture needs to be created
  20821. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20822. * @param generateDepthBuffer True to generate a depth buffer
  20823. * @param generateStencilBuffer True to generate a stencil buffer
  20824. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20825. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20826. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20827. */
  20828. constructor(name: string, size: number | {
  20829. width: number;
  20830. height: number;
  20831. } | {
  20832. ratio: number;
  20833. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20834. /**
  20835. * Creates a depth stencil texture.
  20836. * This is only available in WebGL 2 or with the depth texture extension available.
  20837. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20838. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20839. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20840. */
  20841. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20842. private _processSizeParameter;
  20843. /**
  20844. * Define the number of samples to use in case of MSAA.
  20845. * It defaults to one meaning no MSAA has been enabled.
  20846. */
  20847. samples: number;
  20848. /**
  20849. * Resets the refresh counter of the texture and start bak from scratch.
  20850. * Could be useful to regenerate the texture if it is setup to render only once.
  20851. */
  20852. resetRefreshCounter(): void;
  20853. /**
  20854. * Define the refresh rate of the texture or the rendering frequency.
  20855. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20856. */
  20857. refreshRate: number;
  20858. /**
  20859. * Adds a post process to the render target rendering passes.
  20860. * @param postProcess define the post process to add
  20861. */
  20862. addPostProcess(postProcess: PostProcess): void;
  20863. /**
  20864. * Clear all the post processes attached to the render target
  20865. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20866. */
  20867. clearPostProcesses(dispose?: boolean): void;
  20868. /**
  20869. * Remove one of the post process from the list of attached post processes to the texture
  20870. * @param postProcess define the post process to remove from the list
  20871. */
  20872. removePostProcess(postProcess: PostProcess): void;
  20873. /** @hidden */
  20874. _shouldRender(): boolean;
  20875. /**
  20876. * Gets the actual render size of the texture.
  20877. * @returns the width of the render size
  20878. */
  20879. getRenderSize(): number;
  20880. /**
  20881. * Gets the actual render width of the texture.
  20882. * @returns the width of the render size
  20883. */
  20884. getRenderWidth(): number;
  20885. /**
  20886. * Gets the actual render height of the texture.
  20887. * @returns the height of the render size
  20888. */
  20889. getRenderHeight(): number;
  20890. /**
  20891. * Get if the texture can be rescaled or not.
  20892. */
  20893. readonly canRescale: boolean;
  20894. /**
  20895. * Resize the texture using a ratio.
  20896. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20897. */
  20898. scale(ratio: number): void;
  20899. /**
  20900. * Get the texture reflection matrix used to rotate/transform the reflection.
  20901. * @returns the reflection matrix
  20902. */
  20903. getReflectionTextureMatrix(): Matrix;
  20904. /**
  20905. * Resize the texture to a new desired size.
  20906. * Be carrefull as it will recreate all the data in the new texture.
  20907. * @param size Define the new size. It can be:
  20908. * - a number for squared texture,
  20909. * - an object containing { width: number, height: number }
  20910. * - or an object containing a ratio { ratio: number }
  20911. */
  20912. resize(size: number | {
  20913. width: number;
  20914. height: number;
  20915. } | {
  20916. ratio: number;
  20917. }): void;
  20918. /**
  20919. * Renders all the objects from the render list into the texture.
  20920. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20921. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20922. */
  20923. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20924. private _bestReflectionRenderTargetDimension;
  20925. /**
  20926. * @hidden
  20927. * @param faceIndex face index to bind to if this is a cubetexture
  20928. */
  20929. _bindFrameBuffer(faceIndex?: number): void;
  20930. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20931. private renderToTarget;
  20932. /**
  20933. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20934. * This allowed control for front to back rendering or reversly depending of the special needs.
  20935. *
  20936. * @param renderingGroupId The rendering group id corresponding to its index
  20937. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20938. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20939. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20940. */
  20941. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20942. /**
  20943. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20944. *
  20945. * @param renderingGroupId The rendering group id corresponding to its index
  20946. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20947. */
  20948. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20949. /**
  20950. * Clones the texture.
  20951. * @returns the cloned texture
  20952. */
  20953. clone(): RenderTargetTexture;
  20954. /**
  20955. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20956. * @returns The JSON representation of the texture
  20957. */
  20958. serialize(): any;
  20959. /**
  20960. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20961. */
  20962. disposeFramebufferObjects(): void;
  20963. /**
  20964. * Dispose the texture and release its associated resources.
  20965. */
  20966. dispose(): void;
  20967. /** @hidden */
  20968. _rebuild(): void;
  20969. /**
  20970. * Clear the info related to rendering groups preventing retention point in material dispose.
  20971. */
  20972. freeRenderingGroups(): void;
  20973. /**
  20974. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20975. * @returns the view count
  20976. */
  20977. getViewCount(): number;
  20978. }
  20979. }
  20980. declare module "babylonjs/Materials/material" {
  20981. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20982. import { SmartArray } from "babylonjs/Misc/smartArray";
  20983. import { Observable } from "babylonjs/Misc/observable";
  20984. import { Nullable } from "babylonjs/types";
  20985. import { Scene } from "babylonjs/scene";
  20986. import { Matrix } from "babylonjs/Maths/math.vector";
  20987. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20989. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20990. import { Effect } from "babylonjs/Materials/effect";
  20991. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20992. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20993. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20994. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20995. import { Mesh } from "babylonjs/Meshes/mesh";
  20996. import { Animation } from "babylonjs/Animations/animation";
  20997. /**
  20998. * Options for compiling materials.
  20999. */
  21000. export interface IMaterialCompilationOptions {
  21001. /**
  21002. * Defines whether clip planes are enabled.
  21003. */
  21004. clipPlane: boolean;
  21005. /**
  21006. * Defines whether instances are enabled.
  21007. */
  21008. useInstances: boolean;
  21009. }
  21010. /**
  21011. * Base class for the main features of a material in Babylon.js
  21012. */
  21013. export class Material implements IAnimatable {
  21014. /**
  21015. * Returns the triangle fill mode
  21016. */
  21017. static readonly TriangleFillMode: number;
  21018. /**
  21019. * Returns the wireframe mode
  21020. */
  21021. static readonly WireFrameFillMode: number;
  21022. /**
  21023. * Returns the point fill mode
  21024. */
  21025. static readonly PointFillMode: number;
  21026. /**
  21027. * Returns the point list draw mode
  21028. */
  21029. static readonly PointListDrawMode: number;
  21030. /**
  21031. * Returns the line list draw mode
  21032. */
  21033. static readonly LineListDrawMode: number;
  21034. /**
  21035. * Returns the line loop draw mode
  21036. */
  21037. static readonly LineLoopDrawMode: number;
  21038. /**
  21039. * Returns the line strip draw mode
  21040. */
  21041. static readonly LineStripDrawMode: number;
  21042. /**
  21043. * Returns the triangle strip draw mode
  21044. */
  21045. static readonly TriangleStripDrawMode: number;
  21046. /**
  21047. * Returns the triangle fan draw mode
  21048. */
  21049. static readonly TriangleFanDrawMode: number;
  21050. /**
  21051. * Stores the clock-wise side orientation
  21052. */
  21053. static readonly ClockWiseSideOrientation: number;
  21054. /**
  21055. * Stores the counter clock-wise side orientation
  21056. */
  21057. static readonly CounterClockWiseSideOrientation: number;
  21058. /**
  21059. * The dirty texture flag value
  21060. */
  21061. static readonly TextureDirtyFlag: number;
  21062. /**
  21063. * The dirty light flag value
  21064. */
  21065. static readonly LightDirtyFlag: number;
  21066. /**
  21067. * The dirty fresnel flag value
  21068. */
  21069. static readonly FresnelDirtyFlag: number;
  21070. /**
  21071. * The dirty attribute flag value
  21072. */
  21073. static readonly AttributesDirtyFlag: number;
  21074. /**
  21075. * The dirty misc flag value
  21076. */
  21077. static readonly MiscDirtyFlag: number;
  21078. /**
  21079. * The all dirty flag value
  21080. */
  21081. static readonly AllDirtyFlag: number;
  21082. /**
  21083. * The ID of the material
  21084. */
  21085. id: string;
  21086. /**
  21087. * Gets or sets the unique id of the material
  21088. */
  21089. uniqueId: number;
  21090. /**
  21091. * The name of the material
  21092. */
  21093. name: string;
  21094. /**
  21095. * Gets or sets user defined metadata
  21096. */
  21097. metadata: any;
  21098. /**
  21099. * For internal use only. Please do not use.
  21100. */
  21101. reservedDataStore: any;
  21102. /**
  21103. * Specifies if the ready state should be checked on each call
  21104. */
  21105. checkReadyOnEveryCall: boolean;
  21106. /**
  21107. * Specifies if the ready state should be checked once
  21108. */
  21109. checkReadyOnlyOnce: boolean;
  21110. /**
  21111. * The state of the material
  21112. */
  21113. state: string;
  21114. /**
  21115. * The alpha value of the material
  21116. */
  21117. protected _alpha: number;
  21118. /**
  21119. * List of inspectable custom properties (used by the Inspector)
  21120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21121. */
  21122. inspectableCustomProperties: IInspectable[];
  21123. /**
  21124. * Sets the alpha value of the material
  21125. */
  21126. /**
  21127. * Gets the alpha value of the material
  21128. */
  21129. alpha: number;
  21130. /**
  21131. * Specifies if back face culling is enabled
  21132. */
  21133. protected _backFaceCulling: boolean;
  21134. /**
  21135. * Sets the back-face culling state
  21136. */
  21137. /**
  21138. * Gets the back-face culling state
  21139. */
  21140. backFaceCulling: boolean;
  21141. /**
  21142. * Stores the value for side orientation
  21143. */
  21144. sideOrientation: number;
  21145. /**
  21146. * Callback triggered when the material is compiled
  21147. */
  21148. onCompiled: Nullable<(effect: Effect) => void>;
  21149. /**
  21150. * Callback triggered when an error occurs
  21151. */
  21152. onError: Nullable<(effect: Effect, errors: string) => void>;
  21153. /**
  21154. * Callback triggered to get the render target textures
  21155. */
  21156. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21157. /**
  21158. * Gets a boolean indicating that current material needs to register RTT
  21159. */
  21160. readonly hasRenderTargetTextures: boolean;
  21161. /**
  21162. * Specifies if the material should be serialized
  21163. */
  21164. doNotSerialize: boolean;
  21165. /**
  21166. * @hidden
  21167. */
  21168. _storeEffectOnSubMeshes: boolean;
  21169. /**
  21170. * Stores the animations for the material
  21171. */
  21172. animations: Nullable<Array<Animation>>;
  21173. /**
  21174. * An event triggered when the material is disposed
  21175. */
  21176. onDisposeObservable: Observable<Material>;
  21177. /**
  21178. * An observer which watches for dispose events
  21179. */
  21180. private _onDisposeObserver;
  21181. private _onUnBindObservable;
  21182. /**
  21183. * Called during a dispose event
  21184. */
  21185. onDispose: () => void;
  21186. private _onBindObservable;
  21187. /**
  21188. * An event triggered when the material is bound
  21189. */
  21190. readonly onBindObservable: Observable<AbstractMesh>;
  21191. /**
  21192. * An observer which watches for bind events
  21193. */
  21194. private _onBindObserver;
  21195. /**
  21196. * Called during a bind event
  21197. */
  21198. onBind: (Mesh: AbstractMesh) => void;
  21199. /**
  21200. * An event triggered when the material is unbound
  21201. */
  21202. readonly onUnBindObservable: Observable<Material>;
  21203. /**
  21204. * Stores the value of the alpha mode
  21205. */
  21206. private _alphaMode;
  21207. /**
  21208. * Sets the value of the alpha mode.
  21209. *
  21210. * | Value | Type | Description |
  21211. * | --- | --- | --- |
  21212. * | 0 | ALPHA_DISABLE | |
  21213. * | 1 | ALPHA_ADD | |
  21214. * | 2 | ALPHA_COMBINE | |
  21215. * | 3 | ALPHA_SUBTRACT | |
  21216. * | 4 | ALPHA_MULTIPLY | |
  21217. * | 5 | ALPHA_MAXIMIZED | |
  21218. * | 6 | ALPHA_ONEONE | |
  21219. * | 7 | ALPHA_PREMULTIPLIED | |
  21220. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21221. * | 9 | ALPHA_INTERPOLATE | |
  21222. * | 10 | ALPHA_SCREENMODE | |
  21223. *
  21224. */
  21225. /**
  21226. * Gets the value of the alpha mode
  21227. */
  21228. alphaMode: number;
  21229. /**
  21230. * Stores the state of the need depth pre-pass value
  21231. */
  21232. private _needDepthPrePass;
  21233. /**
  21234. * Sets the need depth pre-pass value
  21235. */
  21236. /**
  21237. * Gets the depth pre-pass value
  21238. */
  21239. needDepthPrePass: boolean;
  21240. /**
  21241. * Specifies if depth writing should be disabled
  21242. */
  21243. disableDepthWrite: boolean;
  21244. /**
  21245. * Specifies if depth writing should be forced
  21246. */
  21247. forceDepthWrite: boolean;
  21248. /**
  21249. * Specifies the depth function that should be used. 0 means the default engine function
  21250. */
  21251. depthFunction: number;
  21252. /**
  21253. * Specifies if there should be a separate pass for culling
  21254. */
  21255. separateCullingPass: boolean;
  21256. /**
  21257. * Stores the state specifing if fog should be enabled
  21258. */
  21259. private _fogEnabled;
  21260. /**
  21261. * Sets the state for enabling fog
  21262. */
  21263. /**
  21264. * Gets the value of the fog enabled state
  21265. */
  21266. fogEnabled: boolean;
  21267. /**
  21268. * Stores the size of points
  21269. */
  21270. pointSize: number;
  21271. /**
  21272. * Stores the z offset value
  21273. */
  21274. zOffset: number;
  21275. /**
  21276. * Gets a value specifying if wireframe mode is enabled
  21277. */
  21278. /**
  21279. * Sets the state of wireframe mode
  21280. */
  21281. wireframe: boolean;
  21282. /**
  21283. * Gets the value specifying if point clouds are enabled
  21284. */
  21285. /**
  21286. * Sets the state of point cloud mode
  21287. */
  21288. pointsCloud: boolean;
  21289. /**
  21290. * Gets the material fill mode
  21291. */
  21292. /**
  21293. * Sets the material fill mode
  21294. */
  21295. fillMode: number;
  21296. /**
  21297. * @hidden
  21298. * Stores the effects for the material
  21299. */
  21300. _effect: Nullable<Effect>;
  21301. /**
  21302. * @hidden
  21303. * Specifies if the material was previously ready
  21304. */
  21305. _wasPreviouslyReady: boolean;
  21306. /**
  21307. * Specifies if uniform buffers should be used
  21308. */
  21309. private _useUBO;
  21310. /**
  21311. * Stores a reference to the scene
  21312. */
  21313. private _scene;
  21314. /**
  21315. * Stores the fill mode state
  21316. */
  21317. private _fillMode;
  21318. /**
  21319. * Specifies if the depth write state should be cached
  21320. */
  21321. private _cachedDepthWriteState;
  21322. /**
  21323. * Specifies if the depth function state should be cached
  21324. */
  21325. private _cachedDepthFunctionState;
  21326. /**
  21327. * Stores the uniform buffer
  21328. */
  21329. protected _uniformBuffer: UniformBuffer;
  21330. /** @hidden */
  21331. _indexInSceneMaterialArray: number;
  21332. /** @hidden */
  21333. meshMap: Nullable<{
  21334. [id: string]: AbstractMesh | undefined;
  21335. }>;
  21336. /**
  21337. * Creates a material instance
  21338. * @param name defines the name of the material
  21339. * @param scene defines the scene to reference
  21340. * @param doNotAdd specifies if the material should be added to the scene
  21341. */
  21342. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21343. /**
  21344. * Returns a string representation of the current material
  21345. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21346. * @returns a string with material information
  21347. */
  21348. toString(fullDetails?: boolean): string;
  21349. /**
  21350. * Gets the class name of the material
  21351. * @returns a string with the class name of the material
  21352. */
  21353. getClassName(): string;
  21354. /**
  21355. * Specifies if updates for the material been locked
  21356. */
  21357. readonly isFrozen: boolean;
  21358. /**
  21359. * Locks updates for the material
  21360. */
  21361. freeze(): void;
  21362. /**
  21363. * Unlocks updates for the material
  21364. */
  21365. unfreeze(): void;
  21366. /**
  21367. * Specifies if the material is ready to be used
  21368. * @param mesh defines the mesh to check
  21369. * @param useInstances specifies if instances should be used
  21370. * @returns a boolean indicating if the material is ready to be used
  21371. */
  21372. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21373. /**
  21374. * Specifies that the submesh is ready to be used
  21375. * @param mesh defines the mesh to check
  21376. * @param subMesh defines which submesh to check
  21377. * @param useInstances specifies that instances should be used
  21378. * @returns a boolean indicating that the submesh is ready or not
  21379. */
  21380. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21381. /**
  21382. * Returns the material effect
  21383. * @returns the effect associated with the material
  21384. */
  21385. getEffect(): Nullable<Effect>;
  21386. /**
  21387. * Returns the current scene
  21388. * @returns a Scene
  21389. */
  21390. getScene(): Scene;
  21391. /**
  21392. * Specifies if the material will require alpha blending
  21393. * @returns a boolean specifying if alpha blending is needed
  21394. */
  21395. needAlphaBlending(): boolean;
  21396. /**
  21397. * Specifies if the mesh will require alpha blending
  21398. * @param mesh defines the mesh to check
  21399. * @returns a boolean specifying if alpha blending is needed for the mesh
  21400. */
  21401. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21402. /**
  21403. * Specifies if this material should be rendered in alpha test mode
  21404. * @returns a boolean specifying if an alpha test is needed.
  21405. */
  21406. needAlphaTesting(): boolean;
  21407. /**
  21408. * Gets the texture used for the alpha test
  21409. * @returns the texture to use for alpha testing
  21410. */
  21411. getAlphaTestTexture(): Nullable<BaseTexture>;
  21412. /**
  21413. * Marks the material to indicate that it needs to be re-calculated
  21414. */
  21415. markDirty(): void;
  21416. /** @hidden */
  21417. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21418. /**
  21419. * Binds the material to the mesh
  21420. * @param world defines the world transformation matrix
  21421. * @param mesh defines the mesh to bind the material to
  21422. */
  21423. bind(world: Matrix, mesh?: Mesh): void;
  21424. /**
  21425. * Binds the submesh to the material
  21426. * @param world defines the world transformation matrix
  21427. * @param mesh defines the mesh containing the submesh
  21428. * @param subMesh defines the submesh to bind the material to
  21429. */
  21430. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21431. /**
  21432. * Binds the world matrix to the material
  21433. * @param world defines the world transformation matrix
  21434. */
  21435. bindOnlyWorldMatrix(world: Matrix): void;
  21436. /**
  21437. * Binds the scene's uniform buffer to the effect.
  21438. * @param effect defines the effect to bind to the scene uniform buffer
  21439. * @param sceneUbo defines the uniform buffer storing scene data
  21440. */
  21441. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21442. /**
  21443. * Binds the view matrix to the effect
  21444. * @param effect defines the effect to bind the view matrix to
  21445. */
  21446. bindView(effect: Effect): void;
  21447. /**
  21448. * Binds the view projection matrix to the effect
  21449. * @param effect defines the effect to bind the view projection matrix to
  21450. */
  21451. bindViewProjection(effect: Effect): void;
  21452. /**
  21453. * Specifies if material alpha testing should be turned on for the mesh
  21454. * @param mesh defines the mesh to check
  21455. */
  21456. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21457. /**
  21458. * Processes to execute after binding the material to a mesh
  21459. * @param mesh defines the rendered mesh
  21460. */
  21461. protected _afterBind(mesh?: Mesh): void;
  21462. /**
  21463. * Unbinds the material from the mesh
  21464. */
  21465. unbind(): void;
  21466. /**
  21467. * Gets the active textures from the material
  21468. * @returns an array of textures
  21469. */
  21470. getActiveTextures(): BaseTexture[];
  21471. /**
  21472. * Specifies if the material uses a texture
  21473. * @param texture defines the texture to check against the material
  21474. * @returns a boolean specifying if the material uses the texture
  21475. */
  21476. hasTexture(texture: BaseTexture): boolean;
  21477. /**
  21478. * Makes a duplicate of the material, and gives it a new name
  21479. * @param name defines the new name for the duplicated material
  21480. * @returns the cloned material
  21481. */
  21482. clone(name: string): Nullable<Material>;
  21483. /**
  21484. * Gets the meshes bound to the material
  21485. * @returns an array of meshes bound to the material
  21486. */
  21487. getBindedMeshes(): AbstractMesh[];
  21488. /**
  21489. * Force shader compilation
  21490. * @param mesh defines the mesh associated with this material
  21491. * @param onCompiled defines a function to execute once the material is compiled
  21492. * @param options defines the options to configure the compilation
  21493. * @param onError defines a function to execute if the material fails compiling
  21494. */
  21495. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21496. /**
  21497. * Force shader compilation
  21498. * @param mesh defines the mesh that will use this material
  21499. * @param options defines additional options for compiling the shaders
  21500. * @returns a promise that resolves when the compilation completes
  21501. */
  21502. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21503. private static readonly _AllDirtyCallBack;
  21504. private static readonly _ImageProcessingDirtyCallBack;
  21505. private static readonly _TextureDirtyCallBack;
  21506. private static readonly _FresnelDirtyCallBack;
  21507. private static readonly _MiscDirtyCallBack;
  21508. private static readonly _LightsDirtyCallBack;
  21509. private static readonly _AttributeDirtyCallBack;
  21510. private static _FresnelAndMiscDirtyCallBack;
  21511. private static _TextureAndMiscDirtyCallBack;
  21512. private static readonly _DirtyCallbackArray;
  21513. private static readonly _RunDirtyCallBacks;
  21514. /**
  21515. * Marks a define in the material to indicate that it needs to be re-computed
  21516. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21517. */
  21518. markAsDirty(flag: number): void;
  21519. /**
  21520. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21521. * @param func defines a function which checks material defines against the submeshes
  21522. */
  21523. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21524. /**
  21525. * Indicates that we need to re-calculated for all submeshes
  21526. */
  21527. protected _markAllSubMeshesAsAllDirty(): void;
  21528. /**
  21529. * Indicates that image processing needs to be re-calculated for all submeshes
  21530. */
  21531. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21532. /**
  21533. * Indicates that textures need to be re-calculated for all submeshes
  21534. */
  21535. protected _markAllSubMeshesAsTexturesDirty(): void;
  21536. /**
  21537. * Indicates that fresnel needs to be re-calculated for all submeshes
  21538. */
  21539. protected _markAllSubMeshesAsFresnelDirty(): void;
  21540. /**
  21541. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21542. */
  21543. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21544. /**
  21545. * Indicates that lights need to be re-calculated for all submeshes
  21546. */
  21547. protected _markAllSubMeshesAsLightsDirty(): void;
  21548. /**
  21549. * Indicates that attributes need to be re-calculated for all submeshes
  21550. */
  21551. protected _markAllSubMeshesAsAttributesDirty(): void;
  21552. /**
  21553. * Indicates that misc needs to be re-calculated for all submeshes
  21554. */
  21555. protected _markAllSubMeshesAsMiscDirty(): void;
  21556. /**
  21557. * Indicates that textures and misc need to be re-calculated for all submeshes
  21558. */
  21559. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21560. /**
  21561. * Disposes the material
  21562. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21563. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21564. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21565. */
  21566. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21567. /** @hidden */
  21568. private releaseVertexArrayObject;
  21569. /**
  21570. * Serializes this material
  21571. * @returns the serialized material object
  21572. */
  21573. serialize(): any;
  21574. /**
  21575. * Creates a material from parsed material data
  21576. * @param parsedMaterial defines parsed material data
  21577. * @param scene defines the hosting scene
  21578. * @param rootUrl defines the root URL to use to load textures
  21579. * @returns a new material
  21580. */
  21581. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21582. }
  21583. }
  21584. declare module "babylonjs/Materials/multiMaterial" {
  21585. import { Nullable } from "babylonjs/types";
  21586. import { Scene } from "babylonjs/scene";
  21587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21588. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21590. import { Material } from "babylonjs/Materials/material";
  21591. /**
  21592. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21593. * separate meshes. This can be use to improve performances.
  21594. * @see http://doc.babylonjs.com/how_to/multi_materials
  21595. */
  21596. export class MultiMaterial extends Material {
  21597. private _subMaterials;
  21598. /**
  21599. * Gets or Sets the list of Materials used within the multi material.
  21600. * They need to be ordered according to the submeshes order in the associated mesh
  21601. */
  21602. subMaterials: Nullable<Material>[];
  21603. /**
  21604. * Function used to align with Node.getChildren()
  21605. * @returns the list of Materials used within the multi material
  21606. */
  21607. getChildren(): Nullable<Material>[];
  21608. /**
  21609. * Instantiates a new Multi Material
  21610. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21611. * separate meshes. This can be use to improve performances.
  21612. * @see http://doc.babylonjs.com/how_to/multi_materials
  21613. * @param name Define the name in the scene
  21614. * @param scene Define the scene the material belongs to
  21615. */
  21616. constructor(name: string, scene: Scene);
  21617. private _hookArray;
  21618. /**
  21619. * Get one of the submaterial by its index in the submaterials array
  21620. * @param index The index to look the sub material at
  21621. * @returns The Material if the index has been defined
  21622. */
  21623. getSubMaterial(index: number): Nullable<Material>;
  21624. /**
  21625. * Get the list of active textures for the whole sub materials list.
  21626. * @returns All the textures that will be used during the rendering
  21627. */
  21628. getActiveTextures(): BaseTexture[];
  21629. /**
  21630. * Gets the current class name of the material e.g. "MultiMaterial"
  21631. * Mainly use in serialization.
  21632. * @returns the class name
  21633. */
  21634. getClassName(): string;
  21635. /**
  21636. * Checks if the material is ready to render the requested sub mesh
  21637. * @param mesh Define the mesh the submesh belongs to
  21638. * @param subMesh Define the sub mesh to look readyness for
  21639. * @param useInstances Define whether or not the material is used with instances
  21640. * @returns true if ready, otherwise false
  21641. */
  21642. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21643. /**
  21644. * Clones the current material and its related sub materials
  21645. * @param name Define the name of the newly cloned material
  21646. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21647. * @returns the cloned material
  21648. */
  21649. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21650. /**
  21651. * Serializes the materials into a JSON representation.
  21652. * @returns the JSON representation
  21653. */
  21654. serialize(): any;
  21655. /**
  21656. * Dispose the material and release its associated resources
  21657. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21658. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21659. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21660. */
  21661. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21662. /**
  21663. * Creates a MultiMaterial from parsed MultiMaterial data.
  21664. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21665. * @param scene defines the hosting scene
  21666. * @returns a new MultiMaterial
  21667. */
  21668. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21669. }
  21670. }
  21671. declare module "babylonjs/Meshes/subMesh" {
  21672. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21673. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21674. import { Engine } from "babylonjs/Engines/engine";
  21675. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21676. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21677. import { Effect } from "babylonjs/Materials/effect";
  21678. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21679. import { Plane } from "babylonjs/Maths/math.plane";
  21680. import { Collider } from "babylonjs/Collisions/collider";
  21681. import { Material } from "babylonjs/Materials/material";
  21682. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21684. import { Mesh } from "babylonjs/Meshes/mesh";
  21685. import { Ray } from "babylonjs/Culling/ray";
  21686. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21687. /**
  21688. * Base class for submeshes
  21689. */
  21690. export class BaseSubMesh {
  21691. /** @hidden */
  21692. _materialDefines: Nullable<MaterialDefines>;
  21693. /** @hidden */
  21694. _materialEffect: Nullable<Effect>;
  21695. /**
  21696. * Gets associated effect
  21697. */
  21698. readonly effect: Nullable<Effect>;
  21699. /**
  21700. * Sets associated effect (effect used to render this submesh)
  21701. * @param effect defines the effect to associate with
  21702. * @param defines defines the set of defines used to compile this effect
  21703. */
  21704. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21705. }
  21706. /**
  21707. * Defines a subdivision inside a mesh
  21708. */
  21709. export class SubMesh extends BaseSubMesh implements ICullable {
  21710. /** the material index to use */
  21711. materialIndex: number;
  21712. /** vertex index start */
  21713. verticesStart: number;
  21714. /** vertices count */
  21715. verticesCount: number;
  21716. /** index start */
  21717. indexStart: number;
  21718. /** indices count */
  21719. indexCount: number;
  21720. /** @hidden */
  21721. _linesIndexCount: number;
  21722. private _mesh;
  21723. private _renderingMesh;
  21724. private _boundingInfo;
  21725. private _linesIndexBuffer;
  21726. /** @hidden */
  21727. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21728. /** @hidden */
  21729. _trianglePlanes: Plane[];
  21730. /** @hidden */
  21731. _lastColliderTransformMatrix: Nullable<Matrix>;
  21732. /** @hidden */
  21733. _renderId: number;
  21734. /** @hidden */
  21735. _alphaIndex: number;
  21736. /** @hidden */
  21737. _distanceToCamera: number;
  21738. /** @hidden */
  21739. _id: number;
  21740. private _currentMaterial;
  21741. /**
  21742. * Add a new submesh to a mesh
  21743. * @param materialIndex defines the material index to use
  21744. * @param verticesStart defines vertex index start
  21745. * @param verticesCount defines vertices count
  21746. * @param indexStart defines index start
  21747. * @param indexCount defines indices count
  21748. * @param mesh defines the parent mesh
  21749. * @param renderingMesh defines an optional rendering mesh
  21750. * @param createBoundingBox defines if bounding box should be created for this submesh
  21751. * @returns the new submesh
  21752. */
  21753. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21754. /**
  21755. * Creates a new submesh
  21756. * @param materialIndex defines the material index to use
  21757. * @param verticesStart defines vertex index start
  21758. * @param verticesCount defines vertices count
  21759. * @param indexStart defines index start
  21760. * @param indexCount defines indices count
  21761. * @param mesh defines the parent mesh
  21762. * @param renderingMesh defines an optional rendering mesh
  21763. * @param createBoundingBox defines if bounding box should be created for this submesh
  21764. */
  21765. constructor(
  21766. /** the material index to use */
  21767. materialIndex: number,
  21768. /** vertex index start */
  21769. verticesStart: number,
  21770. /** vertices count */
  21771. verticesCount: number,
  21772. /** index start */
  21773. indexStart: number,
  21774. /** indices count */
  21775. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21776. /**
  21777. * Returns true if this submesh covers the entire parent mesh
  21778. * @ignorenaming
  21779. */
  21780. readonly IsGlobal: boolean;
  21781. /**
  21782. * Returns the submesh BoudingInfo object
  21783. * @returns current bounding info (or mesh's one if the submesh is global)
  21784. */
  21785. getBoundingInfo(): BoundingInfo;
  21786. /**
  21787. * Sets the submesh BoundingInfo
  21788. * @param boundingInfo defines the new bounding info to use
  21789. * @returns the SubMesh
  21790. */
  21791. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21792. /**
  21793. * Returns the mesh of the current submesh
  21794. * @return the parent mesh
  21795. */
  21796. getMesh(): AbstractMesh;
  21797. /**
  21798. * Returns the rendering mesh of the submesh
  21799. * @returns the rendering mesh (could be different from parent mesh)
  21800. */
  21801. getRenderingMesh(): Mesh;
  21802. /**
  21803. * Returns the submesh material
  21804. * @returns null or the current material
  21805. */
  21806. getMaterial(): Nullable<Material>;
  21807. /**
  21808. * Sets a new updated BoundingInfo object to the submesh
  21809. * @param data defines an optional position array to use to determine the bounding info
  21810. * @returns the SubMesh
  21811. */
  21812. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21813. /** @hidden */
  21814. _checkCollision(collider: Collider): boolean;
  21815. /**
  21816. * Updates the submesh BoundingInfo
  21817. * @param world defines the world matrix to use to update the bounding info
  21818. * @returns the submesh
  21819. */
  21820. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21821. /**
  21822. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21823. * @param frustumPlanes defines the frustum planes
  21824. * @returns true if the submesh is intersecting with the frustum
  21825. */
  21826. isInFrustum(frustumPlanes: Plane[]): boolean;
  21827. /**
  21828. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21829. * @param frustumPlanes defines the frustum planes
  21830. * @returns true if the submesh is inside the frustum
  21831. */
  21832. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21833. /**
  21834. * Renders the submesh
  21835. * @param enableAlphaMode defines if alpha needs to be used
  21836. * @returns the submesh
  21837. */
  21838. render(enableAlphaMode: boolean): SubMesh;
  21839. /**
  21840. * @hidden
  21841. */
  21842. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21843. /**
  21844. * Checks if the submesh intersects with a ray
  21845. * @param ray defines the ray to test
  21846. * @returns true is the passed ray intersects the submesh bounding box
  21847. */
  21848. canIntersects(ray: Ray): boolean;
  21849. /**
  21850. * Intersects current submesh with a ray
  21851. * @param ray defines the ray to test
  21852. * @param positions defines mesh's positions array
  21853. * @param indices defines mesh's indices array
  21854. * @param fastCheck defines if only bounding info should be used
  21855. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21856. * @returns intersection info or null if no intersection
  21857. */
  21858. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21859. /** @hidden */
  21860. private _intersectLines;
  21861. /** @hidden */
  21862. private _intersectUnIndexedLines;
  21863. /** @hidden */
  21864. private _intersectTriangles;
  21865. /** @hidden */
  21866. private _intersectUnIndexedTriangles;
  21867. /** @hidden */
  21868. _rebuild(): void;
  21869. /**
  21870. * Creates a new submesh from the passed mesh
  21871. * @param newMesh defines the new hosting mesh
  21872. * @param newRenderingMesh defines an optional rendering mesh
  21873. * @returns the new submesh
  21874. */
  21875. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21876. /**
  21877. * Release associated resources
  21878. */
  21879. dispose(): void;
  21880. /**
  21881. * Gets the class name
  21882. * @returns the string "SubMesh".
  21883. */
  21884. getClassName(): string;
  21885. /**
  21886. * Creates a new submesh from indices data
  21887. * @param materialIndex the index of the main mesh material
  21888. * @param startIndex the index where to start the copy in the mesh indices array
  21889. * @param indexCount the number of indices to copy then from the startIndex
  21890. * @param mesh the main mesh to create the submesh from
  21891. * @param renderingMesh the optional rendering mesh
  21892. * @returns a new submesh
  21893. */
  21894. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21895. }
  21896. }
  21897. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21898. /**
  21899. * Class used to represent data loading progression
  21900. */
  21901. export class SceneLoaderFlags {
  21902. private static _ForceFullSceneLoadingForIncremental;
  21903. private static _ShowLoadingScreen;
  21904. private static _CleanBoneMatrixWeights;
  21905. private static _loggingLevel;
  21906. /**
  21907. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21908. */
  21909. static ForceFullSceneLoadingForIncremental: boolean;
  21910. /**
  21911. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21912. */
  21913. static ShowLoadingScreen: boolean;
  21914. /**
  21915. * Defines the current logging level (while loading the scene)
  21916. * @ignorenaming
  21917. */
  21918. static loggingLevel: number;
  21919. /**
  21920. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21921. */
  21922. static CleanBoneMatrixWeights: boolean;
  21923. }
  21924. }
  21925. declare module "babylonjs/Meshes/geometry" {
  21926. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21927. import { Scene } from "babylonjs/scene";
  21928. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21929. import { Engine } from "babylonjs/Engines/engine";
  21930. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21931. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21932. import { Effect } from "babylonjs/Materials/effect";
  21933. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21934. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21935. import { Mesh } from "babylonjs/Meshes/mesh";
  21936. /**
  21937. * Class used to store geometry data (vertex buffers + index buffer)
  21938. */
  21939. export class Geometry implements IGetSetVerticesData {
  21940. /**
  21941. * Gets or sets the ID of the geometry
  21942. */
  21943. id: string;
  21944. /**
  21945. * Gets or sets the unique ID of the geometry
  21946. */
  21947. uniqueId: number;
  21948. /**
  21949. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21950. */
  21951. delayLoadState: number;
  21952. /**
  21953. * Gets the file containing the data to load when running in delay load state
  21954. */
  21955. delayLoadingFile: Nullable<string>;
  21956. /**
  21957. * Callback called when the geometry is updated
  21958. */
  21959. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21960. private _scene;
  21961. private _engine;
  21962. private _meshes;
  21963. private _totalVertices;
  21964. /** @hidden */
  21965. _indices: IndicesArray;
  21966. /** @hidden */
  21967. _vertexBuffers: {
  21968. [key: string]: VertexBuffer;
  21969. };
  21970. private _isDisposed;
  21971. private _extend;
  21972. private _boundingBias;
  21973. /** @hidden */
  21974. _delayInfo: Array<string>;
  21975. private _indexBuffer;
  21976. private _indexBufferIsUpdatable;
  21977. /** @hidden */
  21978. _boundingInfo: Nullable<BoundingInfo>;
  21979. /** @hidden */
  21980. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21981. /** @hidden */
  21982. _softwareSkinningFrameId: number;
  21983. private _vertexArrayObjects;
  21984. private _updatable;
  21985. /** @hidden */
  21986. _positions: Nullable<Vector3[]>;
  21987. /**
  21988. * 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
  21989. */
  21990. /**
  21991. * 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
  21992. */
  21993. boundingBias: Vector2;
  21994. /**
  21995. * Static function used to attach a new empty geometry to a mesh
  21996. * @param mesh defines the mesh to attach the geometry to
  21997. * @returns the new Geometry
  21998. */
  21999. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22000. /**
  22001. * Creates a new geometry
  22002. * @param id defines the unique ID
  22003. * @param scene defines the hosting scene
  22004. * @param vertexData defines the VertexData used to get geometry data
  22005. * @param updatable defines if geometry must be updatable (false by default)
  22006. * @param mesh defines the mesh that will be associated with the geometry
  22007. */
  22008. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22009. /**
  22010. * Gets the current extend of the geometry
  22011. */
  22012. readonly extend: {
  22013. minimum: Vector3;
  22014. maximum: Vector3;
  22015. };
  22016. /**
  22017. * Gets the hosting scene
  22018. * @returns the hosting Scene
  22019. */
  22020. getScene(): Scene;
  22021. /**
  22022. * Gets the hosting engine
  22023. * @returns the hosting Engine
  22024. */
  22025. getEngine(): Engine;
  22026. /**
  22027. * Defines if the geometry is ready to use
  22028. * @returns true if the geometry is ready to be used
  22029. */
  22030. isReady(): boolean;
  22031. /**
  22032. * Gets a value indicating that the geometry should not be serialized
  22033. */
  22034. readonly doNotSerialize: boolean;
  22035. /** @hidden */
  22036. _rebuild(): void;
  22037. /**
  22038. * Affects all geometry data in one call
  22039. * @param vertexData defines the geometry data
  22040. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22041. */
  22042. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22043. /**
  22044. * Set specific vertex data
  22045. * @param kind defines the data kind (Position, normal, etc...)
  22046. * @param data defines the vertex data to use
  22047. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22048. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22049. */
  22050. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22051. /**
  22052. * Removes a specific vertex data
  22053. * @param kind defines the data kind (Position, normal, etc...)
  22054. */
  22055. removeVerticesData(kind: string): void;
  22056. /**
  22057. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22058. * @param buffer defines the vertex buffer to use
  22059. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22060. */
  22061. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22062. /**
  22063. * Update a specific vertex buffer
  22064. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22065. * It will do nothing if the buffer is not updatable
  22066. * @param kind defines the data kind (Position, normal, etc...)
  22067. * @param data defines the data to use
  22068. * @param offset defines the offset in the target buffer where to store the data
  22069. * @param useBytes set to true if the offset is in bytes
  22070. */
  22071. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22072. /**
  22073. * Update a specific vertex buffer
  22074. * This function will create a new buffer if the current one is not updatable
  22075. * @param kind defines the data kind (Position, normal, etc...)
  22076. * @param data defines the data to use
  22077. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22078. */
  22079. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22080. private _updateBoundingInfo;
  22081. /** @hidden */
  22082. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22083. /**
  22084. * Gets total number of vertices
  22085. * @returns the total number of vertices
  22086. */
  22087. getTotalVertices(): number;
  22088. /**
  22089. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22090. * @param kind defines the data kind (Position, normal, etc...)
  22091. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22092. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22093. * @returns a float array containing vertex data
  22094. */
  22095. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22096. /**
  22097. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22098. * @param kind defines the data kind (Position, normal, etc...)
  22099. * @returns true if the vertex buffer with the specified kind is updatable
  22100. */
  22101. isVertexBufferUpdatable(kind: string): boolean;
  22102. /**
  22103. * Gets a specific vertex buffer
  22104. * @param kind defines the data kind (Position, normal, etc...)
  22105. * @returns a VertexBuffer
  22106. */
  22107. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22108. /**
  22109. * Returns all vertex buffers
  22110. * @return an object holding all vertex buffers indexed by kind
  22111. */
  22112. getVertexBuffers(): Nullable<{
  22113. [key: string]: VertexBuffer;
  22114. }>;
  22115. /**
  22116. * Gets a boolean indicating if specific vertex buffer is present
  22117. * @param kind defines the data kind (Position, normal, etc...)
  22118. * @returns true if data is present
  22119. */
  22120. isVerticesDataPresent(kind: string): boolean;
  22121. /**
  22122. * Gets a list of all attached data kinds (Position, normal, etc...)
  22123. * @returns a list of string containing all kinds
  22124. */
  22125. getVerticesDataKinds(): string[];
  22126. /**
  22127. * Update index buffer
  22128. * @param indices defines the indices to store in the index buffer
  22129. * @param offset defines the offset in the target buffer where to store the data
  22130. * @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)
  22131. */
  22132. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22133. /**
  22134. * Creates a new index buffer
  22135. * @param indices defines the indices to store in the index buffer
  22136. * @param totalVertices defines the total number of vertices (could be null)
  22137. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22138. */
  22139. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22140. /**
  22141. * Return the total number of indices
  22142. * @returns the total number of indices
  22143. */
  22144. getTotalIndices(): number;
  22145. /**
  22146. * Gets the index buffer array
  22147. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22148. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22149. * @returns the index buffer array
  22150. */
  22151. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22152. /**
  22153. * Gets the index buffer
  22154. * @return the index buffer
  22155. */
  22156. getIndexBuffer(): Nullable<DataBuffer>;
  22157. /** @hidden */
  22158. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22159. /**
  22160. * Release the associated resources for a specific mesh
  22161. * @param mesh defines the source mesh
  22162. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22163. */
  22164. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22165. /**
  22166. * Apply current geometry to a given mesh
  22167. * @param mesh defines the mesh to apply geometry to
  22168. */
  22169. applyToMesh(mesh: Mesh): void;
  22170. private _updateExtend;
  22171. private _applyToMesh;
  22172. private notifyUpdate;
  22173. /**
  22174. * Load the geometry if it was flagged as delay loaded
  22175. * @param scene defines the hosting scene
  22176. * @param onLoaded defines a callback called when the geometry is loaded
  22177. */
  22178. load(scene: Scene, onLoaded?: () => void): void;
  22179. private _queueLoad;
  22180. /**
  22181. * Invert the geometry to move from a right handed system to a left handed one.
  22182. */
  22183. toLeftHanded(): void;
  22184. /** @hidden */
  22185. _resetPointsArrayCache(): void;
  22186. /** @hidden */
  22187. _generatePointsArray(): boolean;
  22188. /**
  22189. * Gets a value indicating if the geometry is disposed
  22190. * @returns true if the geometry was disposed
  22191. */
  22192. isDisposed(): boolean;
  22193. private _disposeVertexArrayObjects;
  22194. /**
  22195. * Free all associated resources
  22196. */
  22197. dispose(): void;
  22198. /**
  22199. * Clone the current geometry into a new geometry
  22200. * @param id defines the unique ID of the new geometry
  22201. * @returns a new geometry object
  22202. */
  22203. copy(id: string): Geometry;
  22204. /**
  22205. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22206. * @return a JSON representation of the current geometry data (without the vertices data)
  22207. */
  22208. serialize(): any;
  22209. private toNumberArray;
  22210. /**
  22211. * Serialize all vertices data into a JSON oject
  22212. * @returns a JSON representation of the current geometry data
  22213. */
  22214. serializeVerticeData(): any;
  22215. /**
  22216. * Extracts a clone of a mesh geometry
  22217. * @param mesh defines the source mesh
  22218. * @param id defines the unique ID of the new geometry object
  22219. * @returns the new geometry object
  22220. */
  22221. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22222. /**
  22223. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22224. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22225. * Be aware Math.random() could cause collisions, but:
  22226. * "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"
  22227. * @returns a string containing a new GUID
  22228. */
  22229. static RandomId(): string;
  22230. /** @hidden */
  22231. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22232. private static _CleanMatricesWeights;
  22233. /**
  22234. * Create a new geometry from persisted data (Using .babylon file format)
  22235. * @param parsedVertexData defines the persisted data
  22236. * @param scene defines the hosting scene
  22237. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22238. * @returns the new geometry object
  22239. */
  22240. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22241. }
  22242. }
  22243. declare module "babylonjs/Meshes/mesh.vertexData" {
  22244. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22245. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22246. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22247. import { Geometry } from "babylonjs/Meshes/geometry";
  22248. import { Mesh } from "babylonjs/Meshes/mesh";
  22249. /**
  22250. * Define an interface for all classes that will get and set the data on vertices
  22251. */
  22252. export interface IGetSetVerticesData {
  22253. /**
  22254. * Gets a boolean indicating if specific vertex data is present
  22255. * @param kind defines the vertex data kind to use
  22256. * @returns true is data kind is present
  22257. */
  22258. isVerticesDataPresent(kind: string): boolean;
  22259. /**
  22260. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22261. * @param kind defines the data kind (Position, normal, etc...)
  22262. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22263. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22264. * @returns a float array containing vertex data
  22265. */
  22266. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22267. /**
  22268. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22269. * @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.
  22270. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22271. * @returns the indices array or an empty array if the mesh has no geometry
  22272. */
  22273. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22274. /**
  22275. * Set specific vertex data
  22276. * @param kind defines the data kind (Position, normal, etc...)
  22277. * @param data defines the vertex data to use
  22278. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22279. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22280. */
  22281. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22282. /**
  22283. * Update a specific associated vertex buffer
  22284. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22285. * - VertexBuffer.PositionKind
  22286. * - VertexBuffer.UVKind
  22287. * - VertexBuffer.UV2Kind
  22288. * - VertexBuffer.UV3Kind
  22289. * - VertexBuffer.UV4Kind
  22290. * - VertexBuffer.UV5Kind
  22291. * - VertexBuffer.UV6Kind
  22292. * - VertexBuffer.ColorKind
  22293. * - VertexBuffer.MatricesIndicesKind
  22294. * - VertexBuffer.MatricesIndicesExtraKind
  22295. * - VertexBuffer.MatricesWeightsKind
  22296. * - VertexBuffer.MatricesWeightsExtraKind
  22297. * @param data defines the data source
  22298. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22299. * @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)
  22300. */
  22301. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22302. /**
  22303. * Creates a new index buffer
  22304. * @param indices defines the indices to store in the index buffer
  22305. * @param totalVertices defines the total number of vertices (could be null)
  22306. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22307. */
  22308. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22309. }
  22310. /**
  22311. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22312. */
  22313. export class VertexData {
  22314. /**
  22315. * Mesh side orientation : usually the external or front surface
  22316. */
  22317. static readonly FRONTSIDE: number;
  22318. /**
  22319. * Mesh side orientation : usually the internal or back surface
  22320. */
  22321. static readonly BACKSIDE: number;
  22322. /**
  22323. * Mesh side orientation : both internal and external or front and back surfaces
  22324. */
  22325. static readonly DOUBLESIDE: number;
  22326. /**
  22327. * Mesh side orientation : by default, `FRONTSIDE`
  22328. */
  22329. static readonly DEFAULTSIDE: number;
  22330. /**
  22331. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22332. */
  22333. positions: Nullable<FloatArray>;
  22334. /**
  22335. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22336. */
  22337. normals: Nullable<FloatArray>;
  22338. /**
  22339. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22340. */
  22341. tangents: Nullable<FloatArray>;
  22342. /**
  22343. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22344. */
  22345. uvs: Nullable<FloatArray>;
  22346. /**
  22347. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22348. */
  22349. uvs2: Nullable<FloatArray>;
  22350. /**
  22351. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22352. */
  22353. uvs3: Nullable<FloatArray>;
  22354. /**
  22355. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22356. */
  22357. uvs4: Nullable<FloatArray>;
  22358. /**
  22359. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22360. */
  22361. uvs5: Nullable<FloatArray>;
  22362. /**
  22363. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22364. */
  22365. uvs6: Nullable<FloatArray>;
  22366. /**
  22367. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22368. */
  22369. colors: Nullable<FloatArray>;
  22370. /**
  22371. * 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).
  22372. */
  22373. matricesIndices: Nullable<FloatArray>;
  22374. /**
  22375. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22376. */
  22377. matricesWeights: Nullable<FloatArray>;
  22378. /**
  22379. * An array extending the number of possible indices
  22380. */
  22381. matricesIndicesExtra: Nullable<FloatArray>;
  22382. /**
  22383. * An array extending the number of possible weights when the number of indices is extended
  22384. */
  22385. matricesWeightsExtra: Nullable<FloatArray>;
  22386. /**
  22387. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22388. */
  22389. indices: Nullable<IndicesArray>;
  22390. /**
  22391. * Uses the passed data array to set the set the values for the specified kind of data
  22392. * @param data a linear array of floating numbers
  22393. * @param kind the type of data that is being set, eg positions, colors etc
  22394. */
  22395. set(data: FloatArray, kind: string): void;
  22396. /**
  22397. * Associates the vertexData to the passed Mesh.
  22398. * Sets it as updatable or not (default `false`)
  22399. * @param mesh the mesh the vertexData is applied to
  22400. * @param updatable when used and having the value true allows new data to update the vertexData
  22401. * @returns the VertexData
  22402. */
  22403. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22404. /**
  22405. * Associates the vertexData to the passed Geometry.
  22406. * Sets it as updatable or not (default `false`)
  22407. * @param geometry the geometry the vertexData is applied to
  22408. * @param updatable when used and having the value true allows new data to update the vertexData
  22409. * @returns VertexData
  22410. */
  22411. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22412. /**
  22413. * Updates the associated mesh
  22414. * @param mesh the mesh to be updated
  22415. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22416. * @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
  22417. * @returns VertexData
  22418. */
  22419. updateMesh(mesh: Mesh): VertexData;
  22420. /**
  22421. * Updates the associated geometry
  22422. * @param geometry the geometry to be updated
  22423. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22424. * @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
  22425. * @returns VertexData.
  22426. */
  22427. updateGeometry(geometry: Geometry): VertexData;
  22428. private _applyTo;
  22429. private _update;
  22430. /**
  22431. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22432. * @param matrix the transforming matrix
  22433. * @returns the VertexData
  22434. */
  22435. transform(matrix: Matrix): VertexData;
  22436. /**
  22437. * Merges the passed VertexData into the current one
  22438. * @param other the VertexData to be merged into the current one
  22439. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22440. * @returns the modified VertexData
  22441. */
  22442. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22443. private _mergeElement;
  22444. private _validate;
  22445. /**
  22446. * Serializes the VertexData
  22447. * @returns a serialized object
  22448. */
  22449. serialize(): any;
  22450. /**
  22451. * Extracts the vertexData from a mesh
  22452. * @param mesh the mesh from which to extract the VertexData
  22453. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22454. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22455. * @returns the object VertexData associated to the passed mesh
  22456. */
  22457. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22458. /**
  22459. * Extracts the vertexData from the geometry
  22460. * @param geometry the geometry from which to extract the VertexData
  22461. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22462. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22463. * @returns the object VertexData associated to the passed mesh
  22464. */
  22465. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22466. private static _ExtractFrom;
  22467. /**
  22468. * Creates the VertexData for a Ribbon
  22469. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22470. * * pathArray array of paths, each of which an array of successive Vector3
  22471. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22472. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22473. * * 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
  22474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22475. * * 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)
  22476. * * 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)
  22477. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22478. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22479. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22480. * @returns the VertexData of the ribbon
  22481. */
  22482. static CreateRibbon(options: {
  22483. pathArray: Vector3[][];
  22484. closeArray?: boolean;
  22485. closePath?: boolean;
  22486. offset?: number;
  22487. sideOrientation?: number;
  22488. frontUVs?: Vector4;
  22489. backUVs?: Vector4;
  22490. invertUV?: boolean;
  22491. uvs?: Vector2[];
  22492. colors?: Color4[];
  22493. }): VertexData;
  22494. /**
  22495. * Creates the VertexData for a box
  22496. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22497. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22498. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22499. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22500. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22501. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22502. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22504. * * 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)
  22505. * * 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)
  22506. * @returns the VertexData of the box
  22507. */
  22508. static CreateBox(options: {
  22509. size?: number;
  22510. width?: number;
  22511. height?: number;
  22512. depth?: number;
  22513. faceUV?: Vector4[];
  22514. faceColors?: Color4[];
  22515. sideOrientation?: number;
  22516. frontUVs?: Vector4;
  22517. backUVs?: Vector4;
  22518. }): VertexData;
  22519. /**
  22520. * Creates the VertexData for a tiled box
  22521. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22522. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22523. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22524. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22526. * @returns the VertexData of the box
  22527. */
  22528. static CreateTiledBox(options: {
  22529. pattern?: number;
  22530. width?: number;
  22531. height?: number;
  22532. depth?: number;
  22533. tileSize?: number;
  22534. tileWidth?: number;
  22535. tileHeight?: number;
  22536. alignHorizontal?: number;
  22537. alignVertical?: number;
  22538. faceUV?: Vector4[];
  22539. faceColors?: Color4[];
  22540. sideOrientation?: number;
  22541. }): VertexData;
  22542. /**
  22543. * Creates the VertexData for a tiled plane
  22544. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22545. * * pattern a limited pattern arrangement depending on the number
  22546. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22547. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22548. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22550. * * 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)
  22551. * * 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)
  22552. * @returns the VertexData of the tiled plane
  22553. */
  22554. static CreateTiledPlane(options: {
  22555. pattern?: number;
  22556. tileSize?: number;
  22557. tileWidth?: number;
  22558. tileHeight?: number;
  22559. size?: number;
  22560. width?: number;
  22561. height?: number;
  22562. alignHorizontal?: number;
  22563. alignVertical?: number;
  22564. sideOrientation?: number;
  22565. frontUVs?: Vector4;
  22566. backUVs?: Vector4;
  22567. }): VertexData;
  22568. /**
  22569. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22570. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22571. * * segments sets the number of horizontal strips optional, default 32
  22572. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22573. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22574. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22575. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22576. * * 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
  22577. * * 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
  22578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22579. * * 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)
  22580. * * 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)
  22581. * @returns the VertexData of the ellipsoid
  22582. */
  22583. static CreateSphere(options: {
  22584. segments?: number;
  22585. diameter?: number;
  22586. diameterX?: number;
  22587. diameterY?: number;
  22588. diameterZ?: number;
  22589. arc?: number;
  22590. slice?: number;
  22591. sideOrientation?: number;
  22592. frontUVs?: Vector4;
  22593. backUVs?: Vector4;
  22594. }): VertexData;
  22595. /**
  22596. * Creates the VertexData for a cylinder, cone or prism
  22597. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22598. * * height sets the height (y direction) of the cylinder, optional, default 2
  22599. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22600. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22601. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22602. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22603. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22604. * * 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
  22605. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22606. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22607. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22608. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22609. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22610. * * 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)
  22611. * * 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)
  22612. * @returns the VertexData of the cylinder, cone or prism
  22613. */
  22614. static CreateCylinder(options: {
  22615. height?: number;
  22616. diameterTop?: number;
  22617. diameterBottom?: number;
  22618. diameter?: number;
  22619. tessellation?: number;
  22620. subdivisions?: number;
  22621. arc?: number;
  22622. faceColors?: Color4[];
  22623. faceUV?: Vector4[];
  22624. hasRings?: boolean;
  22625. enclose?: boolean;
  22626. sideOrientation?: number;
  22627. frontUVs?: Vector4;
  22628. backUVs?: Vector4;
  22629. }): VertexData;
  22630. /**
  22631. * Creates the VertexData for a torus
  22632. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22633. * * diameter the diameter of the torus, optional default 1
  22634. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22635. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22636. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22637. * * 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)
  22638. * * 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)
  22639. * @returns the VertexData of the torus
  22640. */
  22641. static CreateTorus(options: {
  22642. diameter?: number;
  22643. thickness?: number;
  22644. tessellation?: number;
  22645. sideOrientation?: number;
  22646. frontUVs?: Vector4;
  22647. backUVs?: Vector4;
  22648. }): VertexData;
  22649. /**
  22650. * Creates the VertexData of the LineSystem
  22651. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22652. * - lines an array of lines, each line being an array of successive Vector3
  22653. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22654. * @returns the VertexData of the LineSystem
  22655. */
  22656. static CreateLineSystem(options: {
  22657. lines: Vector3[][];
  22658. colors?: Nullable<Color4[][]>;
  22659. }): VertexData;
  22660. /**
  22661. * Create the VertexData for a DashedLines
  22662. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22663. * - points an array successive Vector3
  22664. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22665. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22666. * - dashNb the intended total number of dashes, optional, default 200
  22667. * @returns the VertexData for the DashedLines
  22668. */
  22669. static CreateDashedLines(options: {
  22670. points: Vector3[];
  22671. dashSize?: number;
  22672. gapSize?: number;
  22673. dashNb?: number;
  22674. }): VertexData;
  22675. /**
  22676. * Creates the VertexData for a Ground
  22677. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22678. * - width the width (x direction) of the ground, optional, default 1
  22679. * - height the height (z direction) of the ground, optional, default 1
  22680. * - subdivisions the number of subdivisions per side, optional, default 1
  22681. * @returns the VertexData of the Ground
  22682. */
  22683. static CreateGround(options: {
  22684. width?: number;
  22685. height?: number;
  22686. subdivisions?: number;
  22687. subdivisionsX?: number;
  22688. subdivisionsY?: number;
  22689. }): VertexData;
  22690. /**
  22691. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22692. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22693. * * xmin the ground minimum X coordinate, optional, default -1
  22694. * * zmin the ground minimum Z coordinate, optional, default -1
  22695. * * xmax the ground maximum X coordinate, optional, default 1
  22696. * * zmax the ground maximum Z coordinate, optional, default 1
  22697. * * 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}
  22698. * * 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}
  22699. * @returns the VertexData of the TiledGround
  22700. */
  22701. static CreateTiledGround(options: {
  22702. xmin: number;
  22703. zmin: number;
  22704. xmax: number;
  22705. zmax: number;
  22706. subdivisions?: {
  22707. w: number;
  22708. h: number;
  22709. };
  22710. precision?: {
  22711. w: number;
  22712. h: number;
  22713. };
  22714. }): VertexData;
  22715. /**
  22716. * Creates the VertexData of the Ground designed from a heightmap
  22717. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22718. * * width the width (x direction) of the ground
  22719. * * height the height (z direction) of the ground
  22720. * * subdivisions the number of subdivisions per side
  22721. * * minHeight the minimum altitude on the ground, optional, default 0
  22722. * * maxHeight the maximum altitude on the ground, optional default 1
  22723. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22724. * * buffer the array holding the image color data
  22725. * * bufferWidth the width of image
  22726. * * bufferHeight the height of image
  22727. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22728. * @returns the VertexData of the Ground designed from a heightmap
  22729. */
  22730. static CreateGroundFromHeightMap(options: {
  22731. width: number;
  22732. height: number;
  22733. subdivisions: number;
  22734. minHeight: number;
  22735. maxHeight: number;
  22736. colorFilter: Color3;
  22737. buffer: Uint8Array;
  22738. bufferWidth: number;
  22739. bufferHeight: number;
  22740. alphaFilter: number;
  22741. }): VertexData;
  22742. /**
  22743. * Creates the VertexData for a Plane
  22744. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22745. * * size sets the width and height of the plane to the value of size, optional default 1
  22746. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22747. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22749. * * 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)
  22750. * * 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)
  22751. * @returns the VertexData of the box
  22752. */
  22753. static CreatePlane(options: {
  22754. size?: number;
  22755. width?: number;
  22756. height?: number;
  22757. sideOrientation?: number;
  22758. frontUVs?: Vector4;
  22759. backUVs?: Vector4;
  22760. }): VertexData;
  22761. /**
  22762. * Creates the VertexData of the Disc or regular Polygon
  22763. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22764. * * radius the radius of the disc, optional default 0.5
  22765. * * tessellation the number of polygon sides, optional, default 64
  22766. * * 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
  22767. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22768. * * 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)
  22769. * * 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)
  22770. * @returns the VertexData of the box
  22771. */
  22772. static CreateDisc(options: {
  22773. radius?: number;
  22774. tessellation?: number;
  22775. arc?: number;
  22776. sideOrientation?: number;
  22777. frontUVs?: Vector4;
  22778. backUVs?: Vector4;
  22779. }): VertexData;
  22780. /**
  22781. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22782. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22783. * @param polygon a mesh built from polygonTriangulation.build()
  22784. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22785. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22786. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22787. * @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)
  22788. * @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)
  22789. * @returns the VertexData of the Polygon
  22790. */
  22791. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22792. /**
  22793. * Creates the VertexData of the IcoSphere
  22794. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22795. * * radius the radius of the IcoSphere, optional default 1
  22796. * * radiusX allows stretching in the x direction, optional, default radius
  22797. * * radiusY allows stretching in the y direction, optional, default radius
  22798. * * radiusZ allows stretching in the z direction, optional, default radius
  22799. * * flat when true creates a flat shaded mesh, optional, default true
  22800. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22801. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22802. * * 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)
  22803. * * 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)
  22804. * @returns the VertexData of the IcoSphere
  22805. */
  22806. static CreateIcoSphere(options: {
  22807. radius?: number;
  22808. radiusX?: number;
  22809. radiusY?: number;
  22810. radiusZ?: number;
  22811. flat?: boolean;
  22812. subdivisions?: number;
  22813. sideOrientation?: number;
  22814. frontUVs?: Vector4;
  22815. backUVs?: Vector4;
  22816. }): VertexData;
  22817. /**
  22818. * Creates the VertexData for a Polyhedron
  22819. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22820. * * type provided types are:
  22821. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22822. * * 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)
  22823. * * size the size of the IcoSphere, optional default 1
  22824. * * sizeX allows stretching in the x direction, optional, default size
  22825. * * sizeY allows stretching in the y direction, optional, default size
  22826. * * sizeZ allows stretching in the z direction, optional, default size
  22827. * * 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
  22828. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22829. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22830. * * flat when true creates a flat shaded mesh, optional, default true
  22831. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22832. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22833. * * 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)
  22834. * * 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)
  22835. * @returns the VertexData of the Polyhedron
  22836. */
  22837. static CreatePolyhedron(options: {
  22838. type?: number;
  22839. size?: number;
  22840. sizeX?: number;
  22841. sizeY?: number;
  22842. sizeZ?: number;
  22843. custom?: any;
  22844. faceUV?: Vector4[];
  22845. faceColors?: Color4[];
  22846. flat?: boolean;
  22847. sideOrientation?: number;
  22848. frontUVs?: Vector4;
  22849. backUVs?: Vector4;
  22850. }): VertexData;
  22851. /**
  22852. * Creates the VertexData for a TorusKnot
  22853. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22854. * * radius the radius of the torus knot, optional, default 2
  22855. * * tube the thickness of the tube, optional, default 0.5
  22856. * * radialSegments the number of sides on each tube segments, optional, default 32
  22857. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22858. * * p the number of windings around the z axis, optional, default 2
  22859. * * q the number of windings around the x axis, optional, default 3
  22860. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22861. * * 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)
  22862. * * 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)
  22863. * @returns the VertexData of the Torus Knot
  22864. */
  22865. static CreateTorusKnot(options: {
  22866. radius?: number;
  22867. tube?: number;
  22868. radialSegments?: number;
  22869. tubularSegments?: number;
  22870. p?: number;
  22871. q?: number;
  22872. sideOrientation?: number;
  22873. frontUVs?: Vector4;
  22874. backUVs?: Vector4;
  22875. }): VertexData;
  22876. /**
  22877. * Compute normals for given positions and indices
  22878. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22879. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22880. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22881. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22882. * * facetNormals : optional array of facet normals (vector3)
  22883. * * facetPositions : optional array of facet positions (vector3)
  22884. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22885. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22886. * * bInfo : optional bounding info, required for facetPartitioning computation
  22887. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22888. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22889. * * useRightHandedSystem: optional boolean to for right handed system computation
  22890. * * depthSort : optional boolean to enable the facet depth sort computation
  22891. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22892. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22893. */
  22894. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22895. facetNormals?: any;
  22896. facetPositions?: any;
  22897. facetPartitioning?: any;
  22898. ratio?: number;
  22899. bInfo?: any;
  22900. bbSize?: Vector3;
  22901. subDiv?: any;
  22902. useRightHandedSystem?: boolean;
  22903. depthSort?: boolean;
  22904. distanceTo?: Vector3;
  22905. depthSortedFacets?: any;
  22906. }): void;
  22907. /** @hidden */
  22908. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22909. /**
  22910. * Applies VertexData created from the imported parameters to the geometry
  22911. * @param parsedVertexData the parsed data from an imported file
  22912. * @param geometry the geometry to apply the VertexData to
  22913. */
  22914. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22915. }
  22916. }
  22917. declare module "babylonjs/Morph/morphTarget" {
  22918. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22919. import { Observable } from "babylonjs/Misc/observable";
  22920. import { Nullable, FloatArray } from "babylonjs/types";
  22921. import { Scene } from "babylonjs/scene";
  22922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22923. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22924. /**
  22925. * Defines a target to use with MorphTargetManager
  22926. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22927. */
  22928. export class MorphTarget implements IAnimatable {
  22929. /** defines the name of the target */
  22930. name: string;
  22931. /**
  22932. * Gets or sets the list of animations
  22933. */
  22934. animations: import("babylonjs/Animations/animation").Animation[];
  22935. private _scene;
  22936. private _positions;
  22937. private _normals;
  22938. private _tangents;
  22939. private _uvs;
  22940. private _influence;
  22941. private _uniqueId;
  22942. /**
  22943. * Observable raised when the influence changes
  22944. */
  22945. onInfluenceChanged: Observable<boolean>;
  22946. /** @hidden */
  22947. _onDataLayoutChanged: Observable<void>;
  22948. /**
  22949. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22950. */
  22951. influence: number;
  22952. /**
  22953. * Gets or sets the id of the morph Target
  22954. */
  22955. id: string;
  22956. private _animationPropertiesOverride;
  22957. /**
  22958. * Gets or sets the animation properties override
  22959. */
  22960. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22961. /**
  22962. * Creates a new MorphTarget
  22963. * @param name defines the name of the target
  22964. * @param influence defines the influence to use
  22965. * @param scene defines the scene the morphtarget belongs to
  22966. */
  22967. constructor(
  22968. /** defines the name of the target */
  22969. name: string, influence?: number, scene?: Nullable<Scene>);
  22970. /**
  22971. * Gets the unique ID of this manager
  22972. */
  22973. readonly uniqueId: number;
  22974. /**
  22975. * Gets a boolean defining if the target contains position data
  22976. */
  22977. readonly hasPositions: boolean;
  22978. /**
  22979. * Gets a boolean defining if the target contains normal data
  22980. */
  22981. readonly hasNormals: boolean;
  22982. /**
  22983. * Gets a boolean defining if the target contains tangent data
  22984. */
  22985. readonly hasTangents: boolean;
  22986. /**
  22987. * Gets a boolean defining if the target contains texture coordinates data
  22988. */
  22989. readonly hasUVs: boolean;
  22990. /**
  22991. * Affects position data to this target
  22992. * @param data defines the position data to use
  22993. */
  22994. setPositions(data: Nullable<FloatArray>): void;
  22995. /**
  22996. * Gets the position data stored in this target
  22997. * @returns a FloatArray containing the position data (or null if not present)
  22998. */
  22999. getPositions(): Nullable<FloatArray>;
  23000. /**
  23001. * Affects normal data to this target
  23002. * @param data defines the normal data to use
  23003. */
  23004. setNormals(data: Nullable<FloatArray>): void;
  23005. /**
  23006. * Gets the normal data stored in this target
  23007. * @returns a FloatArray containing the normal data (or null if not present)
  23008. */
  23009. getNormals(): Nullable<FloatArray>;
  23010. /**
  23011. * Affects tangent data to this target
  23012. * @param data defines the tangent data to use
  23013. */
  23014. setTangents(data: Nullable<FloatArray>): void;
  23015. /**
  23016. * Gets the tangent data stored in this target
  23017. * @returns a FloatArray containing the tangent data (or null if not present)
  23018. */
  23019. getTangents(): Nullable<FloatArray>;
  23020. /**
  23021. * Affects texture coordinates data to this target
  23022. * @param data defines the texture coordinates data to use
  23023. */
  23024. setUVs(data: Nullable<FloatArray>): void;
  23025. /**
  23026. * Gets the texture coordinates data stored in this target
  23027. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23028. */
  23029. getUVs(): Nullable<FloatArray>;
  23030. /**
  23031. * Clone the current target
  23032. * @returns a new MorphTarget
  23033. */
  23034. clone(): MorphTarget;
  23035. /**
  23036. * Serializes the current target into a Serialization object
  23037. * @returns the serialized object
  23038. */
  23039. serialize(): any;
  23040. /**
  23041. * Returns the string "MorphTarget"
  23042. * @returns "MorphTarget"
  23043. */
  23044. getClassName(): string;
  23045. /**
  23046. * Creates a new target from serialized data
  23047. * @param serializationObject defines the serialized data to use
  23048. * @returns a new MorphTarget
  23049. */
  23050. static Parse(serializationObject: any): MorphTarget;
  23051. /**
  23052. * Creates a MorphTarget from mesh data
  23053. * @param mesh defines the source mesh
  23054. * @param name defines the name to use for the new target
  23055. * @param influence defines the influence to attach to the target
  23056. * @returns a new MorphTarget
  23057. */
  23058. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23059. }
  23060. }
  23061. declare module "babylonjs/Morph/morphTargetManager" {
  23062. import { Nullable } from "babylonjs/types";
  23063. import { Scene } from "babylonjs/scene";
  23064. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23065. /**
  23066. * This class is used to deform meshes using morphing between different targets
  23067. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23068. */
  23069. export class MorphTargetManager {
  23070. private _targets;
  23071. private _targetInfluenceChangedObservers;
  23072. private _targetDataLayoutChangedObservers;
  23073. private _activeTargets;
  23074. private _scene;
  23075. private _influences;
  23076. private _supportsNormals;
  23077. private _supportsTangents;
  23078. private _supportsUVs;
  23079. private _vertexCount;
  23080. private _uniqueId;
  23081. private _tempInfluences;
  23082. /**
  23083. * Gets or sets a boolean indicating if normals must be morphed
  23084. */
  23085. enableNormalMorphing: boolean;
  23086. /**
  23087. * Gets or sets a boolean indicating if tangents must be morphed
  23088. */
  23089. enableTangentMorphing: boolean;
  23090. /**
  23091. * Gets or sets a boolean indicating if UV must be morphed
  23092. */
  23093. enableUVMorphing: boolean;
  23094. /**
  23095. * Creates a new MorphTargetManager
  23096. * @param scene defines the current scene
  23097. */
  23098. constructor(scene?: Nullable<Scene>);
  23099. /**
  23100. * Gets the unique ID of this manager
  23101. */
  23102. readonly uniqueId: number;
  23103. /**
  23104. * Gets the number of vertices handled by this manager
  23105. */
  23106. readonly vertexCount: number;
  23107. /**
  23108. * Gets a boolean indicating if this manager supports morphing of normals
  23109. */
  23110. readonly supportsNormals: boolean;
  23111. /**
  23112. * Gets a boolean indicating if this manager supports morphing of tangents
  23113. */
  23114. readonly supportsTangents: boolean;
  23115. /**
  23116. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23117. */
  23118. readonly supportsUVs: boolean;
  23119. /**
  23120. * Gets the number of targets stored in this manager
  23121. */
  23122. readonly numTargets: number;
  23123. /**
  23124. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23125. */
  23126. readonly numInfluencers: number;
  23127. /**
  23128. * Gets the list of influences (one per target)
  23129. */
  23130. readonly influences: Float32Array;
  23131. /**
  23132. * Gets the active target at specified index. An active target is a target with an influence > 0
  23133. * @param index defines the index to check
  23134. * @returns the requested target
  23135. */
  23136. getActiveTarget(index: number): MorphTarget;
  23137. /**
  23138. * Gets the target at specified index
  23139. * @param index defines the index to check
  23140. * @returns the requested target
  23141. */
  23142. getTarget(index: number): MorphTarget;
  23143. /**
  23144. * Add a new target to this manager
  23145. * @param target defines the target to add
  23146. */
  23147. addTarget(target: MorphTarget): void;
  23148. /**
  23149. * Removes a target from the manager
  23150. * @param target defines the target to remove
  23151. */
  23152. removeTarget(target: MorphTarget): void;
  23153. /**
  23154. * Clone the current manager
  23155. * @returns a new MorphTargetManager
  23156. */
  23157. clone(): MorphTargetManager;
  23158. /**
  23159. * Serializes the current manager into a Serialization object
  23160. * @returns the serialized object
  23161. */
  23162. serialize(): any;
  23163. private _syncActiveTargets;
  23164. /**
  23165. * Syncrhonize the targets with all the meshes using this morph target manager
  23166. */
  23167. synchronize(): void;
  23168. /**
  23169. * Creates a new MorphTargetManager from serialized data
  23170. * @param serializationObject defines the serialized data
  23171. * @param scene defines the hosting scene
  23172. * @returns the new MorphTargetManager
  23173. */
  23174. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23175. }
  23176. }
  23177. declare module "babylonjs/Meshes/meshLODLevel" {
  23178. import { Mesh } from "babylonjs/Meshes/mesh";
  23179. import { Nullable } from "babylonjs/types";
  23180. /**
  23181. * Class used to represent a specific level of detail of a mesh
  23182. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23183. */
  23184. export class MeshLODLevel {
  23185. /** Defines the distance where this level should start being displayed */
  23186. distance: number;
  23187. /** Defines the mesh to use to render this level */
  23188. mesh: Nullable<Mesh>;
  23189. /**
  23190. * Creates a new LOD level
  23191. * @param distance defines the distance where this level should star being displayed
  23192. * @param mesh defines the mesh to use to render this level
  23193. */
  23194. constructor(
  23195. /** Defines the distance where this level should start being displayed */
  23196. distance: number,
  23197. /** Defines the mesh to use to render this level */
  23198. mesh: Nullable<Mesh>);
  23199. }
  23200. }
  23201. declare module "babylonjs/Meshes/groundMesh" {
  23202. import { Scene } from "babylonjs/scene";
  23203. import { Vector3 } from "babylonjs/Maths/math.vector";
  23204. import { Mesh } from "babylonjs/Meshes/mesh";
  23205. /**
  23206. * Mesh representing the gorund
  23207. */
  23208. export class GroundMesh extends Mesh {
  23209. /** If octree should be generated */
  23210. generateOctree: boolean;
  23211. private _heightQuads;
  23212. /** @hidden */
  23213. _subdivisionsX: number;
  23214. /** @hidden */
  23215. _subdivisionsY: number;
  23216. /** @hidden */
  23217. _width: number;
  23218. /** @hidden */
  23219. _height: number;
  23220. /** @hidden */
  23221. _minX: number;
  23222. /** @hidden */
  23223. _maxX: number;
  23224. /** @hidden */
  23225. _minZ: number;
  23226. /** @hidden */
  23227. _maxZ: number;
  23228. constructor(name: string, scene: Scene);
  23229. /**
  23230. * "GroundMesh"
  23231. * @returns "GroundMesh"
  23232. */
  23233. getClassName(): string;
  23234. /**
  23235. * The minimum of x and y subdivisions
  23236. */
  23237. readonly subdivisions: number;
  23238. /**
  23239. * X subdivisions
  23240. */
  23241. readonly subdivisionsX: number;
  23242. /**
  23243. * Y subdivisions
  23244. */
  23245. readonly subdivisionsY: number;
  23246. /**
  23247. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23248. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23249. * @param chunksCount the number of subdivisions for x and y
  23250. * @param octreeBlocksSize (Default: 32)
  23251. */
  23252. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23253. /**
  23254. * Returns a height (y) value in the Worl system :
  23255. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23256. * @param x x coordinate
  23257. * @param z z coordinate
  23258. * @returns the ground y position if (x, z) are outside the ground surface.
  23259. */
  23260. getHeightAtCoordinates(x: number, z: number): number;
  23261. /**
  23262. * Returns a normalized vector (Vector3) orthogonal to the ground
  23263. * at the ground coordinates (x, z) expressed in the World system.
  23264. * @param x x coordinate
  23265. * @param z z coordinate
  23266. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23267. */
  23268. getNormalAtCoordinates(x: number, z: number): Vector3;
  23269. /**
  23270. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23271. * at the ground coordinates (x, z) expressed in the World system.
  23272. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23273. * @param x x coordinate
  23274. * @param z z coordinate
  23275. * @param ref vector to store the result
  23276. * @returns the GroundMesh.
  23277. */
  23278. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23279. /**
  23280. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23281. * if the ground has been updated.
  23282. * This can be used in the render loop.
  23283. * @returns the GroundMesh.
  23284. */
  23285. updateCoordinateHeights(): GroundMesh;
  23286. private _getFacetAt;
  23287. private _initHeightQuads;
  23288. private _computeHeightQuads;
  23289. /**
  23290. * Serializes this ground mesh
  23291. * @param serializationObject object to write serialization to
  23292. */
  23293. serialize(serializationObject: any): void;
  23294. /**
  23295. * Parses a serialized ground mesh
  23296. * @param parsedMesh the serialized mesh
  23297. * @param scene the scene to create the ground mesh in
  23298. * @returns the created ground mesh
  23299. */
  23300. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23301. }
  23302. }
  23303. declare module "babylonjs/Physics/physicsJoint" {
  23304. import { Vector3 } from "babylonjs/Maths/math.vector";
  23305. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23306. /**
  23307. * Interface for Physics-Joint data
  23308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23309. */
  23310. export interface PhysicsJointData {
  23311. /**
  23312. * The main pivot of the joint
  23313. */
  23314. mainPivot?: Vector3;
  23315. /**
  23316. * The connected pivot of the joint
  23317. */
  23318. connectedPivot?: Vector3;
  23319. /**
  23320. * The main axis of the joint
  23321. */
  23322. mainAxis?: Vector3;
  23323. /**
  23324. * The connected axis of the joint
  23325. */
  23326. connectedAxis?: Vector3;
  23327. /**
  23328. * The collision of the joint
  23329. */
  23330. collision?: boolean;
  23331. /**
  23332. * Native Oimo/Cannon/Energy data
  23333. */
  23334. nativeParams?: any;
  23335. }
  23336. /**
  23337. * This is a holder class for the physics joint created by the physics plugin
  23338. * It holds a set of functions to control the underlying joint
  23339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23340. */
  23341. export class PhysicsJoint {
  23342. /**
  23343. * The type of the physics joint
  23344. */
  23345. type: number;
  23346. /**
  23347. * The data for the physics joint
  23348. */
  23349. jointData: PhysicsJointData;
  23350. private _physicsJoint;
  23351. protected _physicsPlugin: IPhysicsEnginePlugin;
  23352. /**
  23353. * Initializes the physics joint
  23354. * @param type The type of the physics joint
  23355. * @param jointData The data for the physics joint
  23356. */
  23357. constructor(
  23358. /**
  23359. * The type of the physics joint
  23360. */
  23361. type: number,
  23362. /**
  23363. * The data for the physics joint
  23364. */
  23365. jointData: PhysicsJointData);
  23366. /**
  23367. * Gets the physics joint
  23368. */
  23369. /**
  23370. * Sets the physics joint
  23371. */
  23372. physicsJoint: any;
  23373. /**
  23374. * Sets the physics plugin
  23375. */
  23376. physicsPlugin: IPhysicsEnginePlugin;
  23377. /**
  23378. * Execute a function that is physics-plugin specific.
  23379. * @param {Function} func the function that will be executed.
  23380. * It accepts two parameters: the physics world and the physics joint
  23381. */
  23382. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23383. /**
  23384. * Distance-Joint type
  23385. */
  23386. static DistanceJoint: number;
  23387. /**
  23388. * Hinge-Joint type
  23389. */
  23390. static HingeJoint: number;
  23391. /**
  23392. * Ball-and-Socket joint type
  23393. */
  23394. static BallAndSocketJoint: number;
  23395. /**
  23396. * Wheel-Joint type
  23397. */
  23398. static WheelJoint: number;
  23399. /**
  23400. * Slider-Joint type
  23401. */
  23402. static SliderJoint: number;
  23403. /**
  23404. * Prismatic-Joint type
  23405. */
  23406. static PrismaticJoint: number;
  23407. /**
  23408. * Universal-Joint type
  23409. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23410. */
  23411. static UniversalJoint: number;
  23412. /**
  23413. * Hinge-Joint 2 type
  23414. */
  23415. static Hinge2Joint: number;
  23416. /**
  23417. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23418. */
  23419. static PointToPointJoint: number;
  23420. /**
  23421. * Spring-Joint type
  23422. */
  23423. static SpringJoint: number;
  23424. /**
  23425. * Lock-Joint type
  23426. */
  23427. static LockJoint: number;
  23428. }
  23429. /**
  23430. * A class representing a physics distance joint
  23431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23432. */
  23433. export class DistanceJoint extends PhysicsJoint {
  23434. /**
  23435. *
  23436. * @param jointData The data for the Distance-Joint
  23437. */
  23438. constructor(jointData: DistanceJointData);
  23439. /**
  23440. * Update the predefined distance.
  23441. * @param maxDistance The maximum preferred distance
  23442. * @param minDistance The minimum preferred distance
  23443. */
  23444. updateDistance(maxDistance: number, minDistance?: number): void;
  23445. }
  23446. /**
  23447. * Represents a Motor-Enabled Joint
  23448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23449. */
  23450. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23451. /**
  23452. * Initializes the Motor-Enabled Joint
  23453. * @param type The type of the joint
  23454. * @param jointData The physica joint data for the joint
  23455. */
  23456. constructor(type: number, jointData: PhysicsJointData);
  23457. /**
  23458. * Set the motor values.
  23459. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23460. * @param force the force to apply
  23461. * @param maxForce max force for this motor.
  23462. */
  23463. setMotor(force?: number, maxForce?: number): void;
  23464. /**
  23465. * Set the motor's limits.
  23466. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23467. * @param upperLimit The upper limit of the motor
  23468. * @param lowerLimit The lower limit of the motor
  23469. */
  23470. setLimit(upperLimit: number, lowerLimit?: number): void;
  23471. }
  23472. /**
  23473. * This class represents a single physics Hinge-Joint
  23474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23475. */
  23476. export class HingeJoint extends MotorEnabledJoint {
  23477. /**
  23478. * Initializes the Hinge-Joint
  23479. * @param jointData The joint data for the Hinge-Joint
  23480. */
  23481. constructor(jointData: PhysicsJointData);
  23482. /**
  23483. * Set the motor values.
  23484. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23485. * @param {number} force the force to apply
  23486. * @param {number} maxForce max force for this motor.
  23487. */
  23488. setMotor(force?: number, maxForce?: number): void;
  23489. /**
  23490. * Set the motor's limits.
  23491. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23492. * @param upperLimit The upper limit of the motor
  23493. * @param lowerLimit The lower limit of the motor
  23494. */
  23495. setLimit(upperLimit: number, lowerLimit?: number): void;
  23496. }
  23497. /**
  23498. * This class represents a dual hinge physics joint (same as wheel joint)
  23499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23500. */
  23501. export class Hinge2Joint extends MotorEnabledJoint {
  23502. /**
  23503. * Initializes the Hinge2-Joint
  23504. * @param jointData The joint data for the Hinge2-Joint
  23505. */
  23506. constructor(jointData: PhysicsJointData);
  23507. /**
  23508. * Set the motor values.
  23509. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23510. * @param {number} targetSpeed the speed the motor is to reach
  23511. * @param {number} maxForce max force for this motor.
  23512. * @param {motorIndex} the motor's index, 0 or 1.
  23513. */
  23514. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23515. /**
  23516. * Set the motor limits.
  23517. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23518. * @param {number} upperLimit the upper limit
  23519. * @param {number} lowerLimit lower limit
  23520. * @param {motorIndex} the motor's index, 0 or 1.
  23521. */
  23522. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23523. }
  23524. /**
  23525. * Interface for a motor enabled joint
  23526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23527. */
  23528. export interface IMotorEnabledJoint {
  23529. /**
  23530. * Physics joint
  23531. */
  23532. physicsJoint: any;
  23533. /**
  23534. * Sets the motor of the motor-enabled joint
  23535. * @param force The force of the motor
  23536. * @param maxForce The maximum force of the motor
  23537. * @param motorIndex The index of the motor
  23538. */
  23539. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23540. /**
  23541. * Sets the limit of the motor
  23542. * @param upperLimit The upper limit of the motor
  23543. * @param lowerLimit The lower limit of the motor
  23544. * @param motorIndex The index of the motor
  23545. */
  23546. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23547. }
  23548. /**
  23549. * Joint data for a Distance-Joint
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface DistanceJointData extends PhysicsJointData {
  23553. /**
  23554. * Max distance the 2 joint objects can be apart
  23555. */
  23556. maxDistance: number;
  23557. }
  23558. /**
  23559. * Joint data from a spring joint
  23560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23561. */
  23562. export interface SpringJointData extends PhysicsJointData {
  23563. /**
  23564. * Length of the spring
  23565. */
  23566. length: number;
  23567. /**
  23568. * Stiffness of the spring
  23569. */
  23570. stiffness: number;
  23571. /**
  23572. * Damping of the spring
  23573. */
  23574. damping: number;
  23575. /** this callback will be called when applying the force to the impostors. */
  23576. forceApplicationCallback: () => void;
  23577. }
  23578. }
  23579. declare module "babylonjs/Physics/physicsRaycastResult" {
  23580. import { Vector3 } from "babylonjs/Maths/math.vector";
  23581. /**
  23582. * Holds the data for the raycast result
  23583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23584. */
  23585. export class PhysicsRaycastResult {
  23586. private _hasHit;
  23587. private _hitDistance;
  23588. private _hitNormalWorld;
  23589. private _hitPointWorld;
  23590. private _rayFromWorld;
  23591. private _rayToWorld;
  23592. /**
  23593. * Gets if there was a hit
  23594. */
  23595. readonly hasHit: boolean;
  23596. /**
  23597. * Gets the distance from the hit
  23598. */
  23599. readonly hitDistance: number;
  23600. /**
  23601. * Gets the hit normal/direction in the world
  23602. */
  23603. readonly hitNormalWorld: Vector3;
  23604. /**
  23605. * Gets the hit point in the world
  23606. */
  23607. readonly hitPointWorld: Vector3;
  23608. /**
  23609. * Gets the ray "start point" of the ray in the world
  23610. */
  23611. readonly rayFromWorld: Vector3;
  23612. /**
  23613. * Gets the ray "end point" of the ray in the world
  23614. */
  23615. readonly rayToWorld: Vector3;
  23616. /**
  23617. * Sets the hit data (normal & point in world space)
  23618. * @param hitNormalWorld defines the normal in world space
  23619. * @param hitPointWorld defines the point in world space
  23620. */
  23621. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23622. /**
  23623. * Sets the distance from the start point to the hit point
  23624. * @param distance
  23625. */
  23626. setHitDistance(distance: number): void;
  23627. /**
  23628. * Calculates the distance manually
  23629. */
  23630. calculateHitDistance(): void;
  23631. /**
  23632. * Resets all the values to default
  23633. * @param from The from point on world space
  23634. * @param to The to point on world space
  23635. */
  23636. reset(from?: Vector3, to?: Vector3): void;
  23637. }
  23638. /**
  23639. * Interface for the size containing width and height
  23640. */
  23641. interface IXYZ {
  23642. /**
  23643. * X
  23644. */
  23645. x: number;
  23646. /**
  23647. * Y
  23648. */
  23649. y: number;
  23650. /**
  23651. * Z
  23652. */
  23653. z: number;
  23654. }
  23655. }
  23656. declare module "babylonjs/Physics/IPhysicsEngine" {
  23657. import { Nullable } from "babylonjs/types";
  23658. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23660. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23661. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23662. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23663. /**
  23664. * Interface used to describe a physics joint
  23665. */
  23666. export interface PhysicsImpostorJoint {
  23667. /** Defines the main impostor to which the joint is linked */
  23668. mainImpostor: PhysicsImpostor;
  23669. /** Defines the impostor that is connected to the main impostor using this joint */
  23670. connectedImpostor: PhysicsImpostor;
  23671. /** Defines the joint itself */
  23672. joint: PhysicsJoint;
  23673. }
  23674. /** @hidden */
  23675. export interface IPhysicsEnginePlugin {
  23676. world: any;
  23677. name: string;
  23678. setGravity(gravity: Vector3): void;
  23679. setTimeStep(timeStep: number): void;
  23680. getTimeStep(): number;
  23681. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23682. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23683. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23684. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23685. removePhysicsBody(impostor: PhysicsImpostor): void;
  23686. generateJoint(joint: PhysicsImpostorJoint): void;
  23687. removeJoint(joint: PhysicsImpostorJoint): void;
  23688. isSupported(): boolean;
  23689. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23690. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23691. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23692. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23693. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23694. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23695. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23696. getBodyMass(impostor: PhysicsImpostor): number;
  23697. getBodyFriction(impostor: PhysicsImpostor): number;
  23698. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23699. getBodyRestitution(impostor: PhysicsImpostor): number;
  23700. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23701. getBodyPressure?(impostor: PhysicsImpostor): number;
  23702. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23703. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23704. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23705. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23706. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23707. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23708. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23709. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23710. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23711. sleepBody(impostor: PhysicsImpostor): void;
  23712. wakeUpBody(impostor: PhysicsImpostor): void;
  23713. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23714. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23715. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23716. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23717. getRadius(impostor: PhysicsImpostor): number;
  23718. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23719. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23720. dispose(): void;
  23721. }
  23722. /**
  23723. * Interface used to define a physics engine
  23724. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23725. */
  23726. export interface IPhysicsEngine {
  23727. /**
  23728. * Gets the gravity vector used by the simulation
  23729. */
  23730. gravity: Vector3;
  23731. /**
  23732. * Sets the gravity vector used by the simulation
  23733. * @param gravity defines the gravity vector to use
  23734. */
  23735. setGravity(gravity: Vector3): void;
  23736. /**
  23737. * Set the time step of the physics engine.
  23738. * Default is 1/60.
  23739. * To slow it down, enter 1/600 for example.
  23740. * To speed it up, 1/30
  23741. * @param newTimeStep the new timestep to apply to this world.
  23742. */
  23743. setTimeStep(newTimeStep: number): void;
  23744. /**
  23745. * Get the time step of the physics engine.
  23746. * @returns the current time step
  23747. */
  23748. getTimeStep(): number;
  23749. /**
  23750. * Release all resources
  23751. */
  23752. dispose(): void;
  23753. /**
  23754. * Gets the name of the current physics plugin
  23755. * @returns the name of the plugin
  23756. */
  23757. getPhysicsPluginName(): string;
  23758. /**
  23759. * Adding a new impostor for the impostor tracking.
  23760. * This will be done by the impostor itself.
  23761. * @param impostor the impostor to add
  23762. */
  23763. addImpostor(impostor: PhysicsImpostor): void;
  23764. /**
  23765. * Remove an impostor from the engine.
  23766. * This impostor and its mesh will not longer be updated by the physics engine.
  23767. * @param impostor the impostor to remove
  23768. */
  23769. removeImpostor(impostor: PhysicsImpostor): void;
  23770. /**
  23771. * Add a joint to the physics engine
  23772. * @param mainImpostor defines the main impostor to which the joint is added.
  23773. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23774. * @param joint defines the joint that will connect both impostors.
  23775. */
  23776. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23777. /**
  23778. * Removes a joint from the simulation
  23779. * @param mainImpostor defines the impostor used with the joint
  23780. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23781. * @param joint defines the joint to remove
  23782. */
  23783. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23784. /**
  23785. * Gets the current plugin used to run the simulation
  23786. * @returns current plugin
  23787. */
  23788. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23789. /**
  23790. * Gets the list of physic impostors
  23791. * @returns an array of PhysicsImpostor
  23792. */
  23793. getImpostors(): Array<PhysicsImpostor>;
  23794. /**
  23795. * Gets the impostor for a physics enabled object
  23796. * @param object defines the object impersonated by the impostor
  23797. * @returns the PhysicsImpostor or null if not found
  23798. */
  23799. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23800. /**
  23801. * Gets the impostor for a physics body object
  23802. * @param body defines physics body used by the impostor
  23803. * @returns the PhysicsImpostor or null if not found
  23804. */
  23805. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23806. /**
  23807. * Does a raycast in the physics world
  23808. * @param from when should the ray start?
  23809. * @param to when should the ray end?
  23810. * @returns PhysicsRaycastResult
  23811. */
  23812. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23813. /**
  23814. * Called by the scene. No need to call it.
  23815. * @param delta defines the timespam between frames
  23816. */
  23817. _step(delta: number): void;
  23818. }
  23819. }
  23820. declare module "babylonjs/Physics/physicsImpostor" {
  23821. import { Nullable, IndicesArray } from "babylonjs/types";
  23822. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23825. import { Scene } from "babylonjs/scene";
  23826. import { Bone } from "babylonjs/Bones/bone";
  23827. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23828. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23829. import { Space } from "babylonjs/Maths/math.axis";
  23830. /**
  23831. * The interface for the physics imposter parameters
  23832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23833. */
  23834. export interface PhysicsImpostorParameters {
  23835. /**
  23836. * The mass of the physics imposter
  23837. */
  23838. mass: number;
  23839. /**
  23840. * The friction of the physics imposter
  23841. */
  23842. friction?: number;
  23843. /**
  23844. * The coefficient of restitution of the physics imposter
  23845. */
  23846. restitution?: number;
  23847. /**
  23848. * The native options of the physics imposter
  23849. */
  23850. nativeOptions?: any;
  23851. /**
  23852. * Specifies if the parent should be ignored
  23853. */
  23854. ignoreParent?: boolean;
  23855. /**
  23856. * Specifies if bi-directional transformations should be disabled
  23857. */
  23858. disableBidirectionalTransformation?: boolean;
  23859. /**
  23860. * The pressure inside the physics imposter, soft object only
  23861. */
  23862. pressure?: number;
  23863. /**
  23864. * The stiffness the physics imposter, soft object only
  23865. */
  23866. stiffness?: number;
  23867. /**
  23868. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23869. */
  23870. velocityIterations?: number;
  23871. /**
  23872. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23873. */
  23874. positionIterations?: number;
  23875. /**
  23876. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23877. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23878. * Add to fix multiple points
  23879. */
  23880. fixedPoints?: number;
  23881. /**
  23882. * The collision margin around a soft object
  23883. */
  23884. margin?: number;
  23885. /**
  23886. * The collision margin around a soft object
  23887. */
  23888. damping?: number;
  23889. /**
  23890. * The path for a rope based on an extrusion
  23891. */
  23892. path?: any;
  23893. /**
  23894. * The shape of an extrusion used for a rope based on an extrusion
  23895. */
  23896. shape?: any;
  23897. }
  23898. /**
  23899. * Interface for a physics-enabled object
  23900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23901. */
  23902. export interface IPhysicsEnabledObject {
  23903. /**
  23904. * The position of the physics-enabled object
  23905. */
  23906. position: Vector3;
  23907. /**
  23908. * The rotation of the physics-enabled object
  23909. */
  23910. rotationQuaternion: Nullable<Quaternion>;
  23911. /**
  23912. * The scale of the physics-enabled object
  23913. */
  23914. scaling: Vector3;
  23915. /**
  23916. * The rotation of the physics-enabled object
  23917. */
  23918. rotation?: Vector3;
  23919. /**
  23920. * The parent of the physics-enabled object
  23921. */
  23922. parent?: any;
  23923. /**
  23924. * The bounding info of the physics-enabled object
  23925. * @returns The bounding info of the physics-enabled object
  23926. */
  23927. getBoundingInfo(): BoundingInfo;
  23928. /**
  23929. * Computes the world matrix
  23930. * @param force Specifies if the world matrix should be computed by force
  23931. * @returns A world matrix
  23932. */
  23933. computeWorldMatrix(force: boolean): Matrix;
  23934. /**
  23935. * Gets the world matrix
  23936. * @returns A world matrix
  23937. */
  23938. getWorldMatrix?(): Matrix;
  23939. /**
  23940. * Gets the child meshes
  23941. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23942. * @returns An array of abstract meshes
  23943. */
  23944. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23945. /**
  23946. * Gets the vertex data
  23947. * @param kind The type of vertex data
  23948. * @returns A nullable array of numbers, or a float32 array
  23949. */
  23950. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23951. /**
  23952. * Gets the indices from the mesh
  23953. * @returns A nullable array of index arrays
  23954. */
  23955. getIndices?(): Nullable<IndicesArray>;
  23956. /**
  23957. * Gets the scene from the mesh
  23958. * @returns the indices array or null
  23959. */
  23960. getScene?(): Scene;
  23961. /**
  23962. * Gets the absolute position from the mesh
  23963. * @returns the absolute position
  23964. */
  23965. getAbsolutePosition(): Vector3;
  23966. /**
  23967. * Gets the absolute pivot point from the mesh
  23968. * @returns the absolute pivot point
  23969. */
  23970. getAbsolutePivotPoint(): Vector3;
  23971. /**
  23972. * Rotates the mesh
  23973. * @param axis The axis of rotation
  23974. * @param amount The amount of rotation
  23975. * @param space The space of the rotation
  23976. * @returns The rotation transform node
  23977. */
  23978. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23979. /**
  23980. * Translates the mesh
  23981. * @param axis The axis of translation
  23982. * @param distance The distance of translation
  23983. * @param space The space of the translation
  23984. * @returns The transform node
  23985. */
  23986. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23987. /**
  23988. * Sets the absolute position of the mesh
  23989. * @param absolutePosition The absolute position of the mesh
  23990. * @returns The transform node
  23991. */
  23992. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23993. /**
  23994. * Gets the class name of the mesh
  23995. * @returns The class name
  23996. */
  23997. getClassName(): string;
  23998. }
  23999. /**
  24000. * Represents a physics imposter
  24001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24002. */
  24003. export class PhysicsImpostor {
  24004. /**
  24005. * The physics-enabled object used as the physics imposter
  24006. */
  24007. object: IPhysicsEnabledObject;
  24008. /**
  24009. * The type of the physics imposter
  24010. */
  24011. type: number;
  24012. private _options;
  24013. private _scene?;
  24014. /**
  24015. * The default object size of the imposter
  24016. */
  24017. static DEFAULT_OBJECT_SIZE: Vector3;
  24018. /**
  24019. * The identity quaternion of the imposter
  24020. */
  24021. static IDENTITY_QUATERNION: Quaternion;
  24022. /** @hidden */
  24023. _pluginData: any;
  24024. private _physicsEngine;
  24025. private _physicsBody;
  24026. private _bodyUpdateRequired;
  24027. private _onBeforePhysicsStepCallbacks;
  24028. private _onAfterPhysicsStepCallbacks;
  24029. /** @hidden */
  24030. _onPhysicsCollideCallbacks: Array<{
  24031. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24032. otherImpostors: Array<PhysicsImpostor>;
  24033. }>;
  24034. private _deltaPosition;
  24035. private _deltaRotation;
  24036. private _deltaRotationConjugated;
  24037. /** @hidden */
  24038. _isFromLine: boolean;
  24039. private _parent;
  24040. private _isDisposed;
  24041. private static _tmpVecs;
  24042. private static _tmpQuat;
  24043. /**
  24044. * Specifies if the physics imposter is disposed
  24045. */
  24046. readonly isDisposed: boolean;
  24047. /**
  24048. * Gets the mass of the physics imposter
  24049. */
  24050. mass: number;
  24051. /**
  24052. * Gets the coefficient of friction
  24053. */
  24054. /**
  24055. * Sets the coefficient of friction
  24056. */
  24057. friction: number;
  24058. /**
  24059. * Gets the coefficient of restitution
  24060. */
  24061. /**
  24062. * Sets the coefficient of restitution
  24063. */
  24064. restitution: number;
  24065. /**
  24066. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24067. */
  24068. /**
  24069. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24070. */
  24071. pressure: number;
  24072. /**
  24073. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24074. */
  24075. /**
  24076. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24077. */
  24078. stiffness: number;
  24079. /**
  24080. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24081. */
  24082. /**
  24083. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24084. */
  24085. velocityIterations: number;
  24086. /**
  24087. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24088. */
  24089. /**
  24090. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24091. */
  24092. positionIterations: number;
  24093. /**
  24094. * The unique id of the physics imposter
  24095. * set by the physics engine when adding this impostor to the array
  24096. */
  24097. uniqueId: number;
  24098. /**
  24099. * @hidden
  24100. */
  24101. soft: boolean;
  24102. /**
  24103. * @hidden
  24104. */
  24105. segments: number;
  24106. private _joints;
  24107. /**
  24108. * Initializes the physics imposter
  24109. * @param object The physics-enabled object used as the physics imposter
  24110. * @param type The type of the physics imposter
  24111. * @param _options The options for the physics imposter
  24112. * @param _scene The Babylon scene
  24113. */
  24114. constructor(
  24115. /**
  24116. * The physics-enabled object used as the physics imposter
  24117. */
  24118. object: IPhysicsEnabledObject,
  24119. /**
  24120. * The type of the physics imposter
  24121. */
  24122. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24123. /**
  24124. * This function will completly initialize this impostor.
  24125. * It will create a new body - but only if this mesh has no parent.
  24126. * If it has, this impostor will not be used other than to define the impostor
  24127. * of the child mesh.
  24128. * @hidden
  24129. */
  24130. _init(): void;
  24131. private _getPhysicsParent;
  24132. /**
  24133. * Should a new body be generated.
  24134. * @returns boolean specifying if body initialization is required
  24135. */
  24136. isBodyInitRequired(): boolean;
  24137. /**
  24138. * Sets the updated scaling
  24139. * @param updated Specifies if the scaling is updated
  24140. */
  24141. setScalingUpdated(): void;
  24142. /**
  24143. * Force a regeneration of this or the parent's impostor's body.
  24144. * Use under cautious - This will remove all joints already implemented.
  24145. */
  24146. forceUpdate(): void;
  24147. /**
  24148. * Gets the body that holds this impostor. Either its own, or its parent.
  24149. */
  24150. /**
  24151. * Set the physics body. Used mainly by the physics engine/plugin
  24152. */
  24153. physicsBody: any;
  24154. /**
  24155. * Get the parent of the physics imposter
  24156. * @returns Physics imposter or null
  24157. */
  24158. /**
  24159. * Sets the parent of the physics imposter
  24160. */
  24161. parent: Nullable<PhysicsImpostor>;
  24162. /**
  24163. * Resets the update flags
  24164. */
  24165. resetUpdateFlags(): void;
  24166. /**
  24167. * Gets the object extend size
  24168. * @returns the object extend size
  24169. */
  24170. getObjectExtendSize(): Vector3;
  24171. /**
  24172. * Gets the object center
  24173. * @returns The object center
  24174. */
  24175. getObjectCenter(): Vector3;
  24176. /**
  24177. * Get a specific parametes from the options parameter
  24178. * @param paramName The object parameter name
  24179. * @returns The object parameter
  24180. */
  24181. getParam(paramName: string): any;
  24182. /**
  24183. * Sets a specific parameter in the options given to the physics plugin
  24184. * @param paramName The parameter name
  24185. * @param value The value of the parameter
  24186. */
  24187. setParam(paramName: string, value: number): void;
  24188. /**
  24189. * Specifically change the body's mass option. Won't recreate the physics body object
  24190. * @param mass The mass of the physics imposter
  24191. */
  24192. setMass(mass: number): void;
  24193. /**
  24194. * Gets the linear velocity
  24195. * @returns linear velocity or null
  24196. */
  24197. getLinearVelocity(): Nullable<Vector3>;
  24198. /**
  24199. * Sets the linear velocity
  24200. * @param velocity linear velocity or null
  24201. */
  24202. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24203. /**
  24204. * Gets the angular velocity
  24205. * @returns angular velocity or null
  24206. */
  24207. getAngularVelocity(): Nullable<Vector3>;
  24208. /**
  24209. * Sets the angular velocity
  24210. * @param velocity The velocity or null
  24211. */
  24212. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24213. /**
  24214. * Execute a function with the physics plugin native code
  24215. * Provide a function the will have two variables - the world object and the physics body object
  24216. * @param func The function to execute with the physics plugin native code
  24217. */
  24218. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24219. /**
  24220. * Register a function that will be executed before the physics world is stepping forward
  24221. * @param func The function to execute before the physics world is stepped forward
  24222. */
  24223. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24224. /**
  24225. * Unregister a function that will be executed before the physics world is stepping forward
  24226. * @param func The function to execute before the physics world is stepped forward
  24227. */
  24228. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24229. /**
  24230. * Register a function that will be executed after the physics step
  24231. * @param func The function to execute after physics step
  24232. */
  24233. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24234. /**
  24235. * Unregisters a function that will be executed after the physics step
  24236. * @param func The function to execute after physics step
  24237. */
  24238. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24239. /**
  24240. * register a function that will be executed when this impostor collides against a different body
  24241. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24242. * @param func Callback that is executed on collision
  24243. */
  24244. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24245. /**
  24246. * Unregisters the physics imposter on contact
  24247. * @param collideAgainst The physics object to collide against
  24248. * @param func Callback to execute on collision
  24249. */
  24250. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24251. private _tmpQuat;
  24252. private _tmpQuat2;
  24253. /**
  24254. * Get the parent rotation
  24255. * @returns The parent rotation
  24256. */
  24257. getParentsRotation(): Quaternion;
  24258. /**
  24259. * this function is executed by the physics engine.
  24260. */
  24261. beforeStep: () => void;
  24262. /**
  24263. * this function is executed by the physics engine
  24264. */
  24265. afterStep: () => void;
  24266. /**
  24267. * Legacy collision detection event support
  24268. */
  24269. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24270. /**
  24271. * event and body object due to cannon's event-based architecture.
  24272. */
  24273. onCollide: (e: {
  24274. body: any;
  24275. }) => void;
  24276. /**
  24277. * Apply a force
  24278. * @param force The force to apply
  24279. * @param contactPoint The contact point for the force
  24280. * @returns The physics imposter
  24281. */
  24282. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24283. /**
  24284. * Apply an impulse
  24285. * @param force The impulse force
  24286. * @param contactPoint The contact point for the impulse force
  24287. * @returns The physics imposter
  24288. */
  24289. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24290. /**
  24291. * A help function to create a joint
  24292. * @param otherImpostor A physics imposter used to create a joint
  24293. * @param jointType The type of joint
  24294. * @param jointData The data for the joint
  24295. * @returns The physics imposter
  24296. */
  24297. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24298. /**
  24299. * Add a joint to this impostor with a different impostor
  24300. * @param otherImpostor A physics imposter used to add a joint
  24301. * @param joint The joint to add
  24302. * @returns The physics imposter
  24303. */
  24304. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24305. /**
  24306. * Add an anchor to a cloth impostor
  24307. * @param otherImpostor rigid impostor to anchor to
  24308. * @param width ratio across width from 0 to 1
  24309. * @param height ratio up height from 0 to 1
  24310. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24311. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24312. * @returns impostor the soft imposter
  24313. */
  24314. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24315. /**
  24316. * Add a hook to a rope impostor
  24317. * @param otherImpostor rigid impostor to anchor to
  24318. * @param length ratio across rope from 0 to 1
  24319. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24320. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24321. * @returns impostor the rope imposter
  24322. */
  24323. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24324. /**
  24325. * Will keep this body still, in a sleep mode.
  24326. * @returns the physics imposter
  24327. */
  24328. sleep(): PhysicsImpostor;
  24329. /**
  24330. * Wake the body up.
  24331. * @returns The physics imposter
  24332. */
  24333. wakeUp(): PhysicsImpostor;
  24334. /**
  24335. * Clones the physics imposter
  24336. * @param newObject The physics imposter clones to this physics-enabled object
  24337. * @returns A nullable physics imposter
  24338. */
  24339. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24340. /**
  24341. * Disposes the physics imposter
  24342. */
  24343. dispose(): void;
  24344. /**
  24345. * Sets the delta position
  24346. * @param position The delta position amount
  24347. */
  24348. setDeltaPosition(position: Vector3): void;
  24349. /**
  24350. * Sets the delta rotation
  24351. * @param rotation The delta rotation amount
  24352. */
  24353. setDeltaRotation(rotation: Quaternion): void;
  24354. /**
  24355. * Gets the box size of the physics imposter and stores the result in the input parameter
  24356. * @param result Stores the box size
  24357. * @returns The physics imposter
  24358. */
  24359. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24360. /**
  24361. * Gets the radius of the physics imposter
  24362. * @returns Radius of the physics imposter
  24363. */
  24364. getRadius(): number;
  24365. /**
  24366. * Sync a bone with this impostor
  24367. * @param bone The bone to sync to the impostor.
  24368. * @param boneMesh The mesh that the bone is influencing.
  24369. * @param jointPivot The pivot of the joint / bone in local space.
  24370. * @param distToJoint Optional distance from the impostor to the joint.
  24371. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24372. */
  24373. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24374. /**
  24375. * Sync impostor to a bone
  24376. * @param bone The bone that the impostor will be synced to.
  24377. * @param boneMesh The mesh that the bone is influencing.
  24378. * @param jointPivot The pivot of the joint / bone in local space.
  24379. * @param distToJoint Optional distance from the impostor to the joint.
  24380. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24381. * @param boneAxis Optional vector3 axis the bone is aligned with
  24382. */
  24383. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24384. /**
  24385. * No-Imposter type
  24386. */
  24387. static NoImpostor: number;
  24388. /**
  24389. * Sphere-Imposter type
  24390. */
  24391. static SphereImpostor: number;
  24392. /**
  24393. * Box-Imposter type
  24394. */
  24395. static BoxImpostor: number;
  24396. /**
  24397. * Plane-Imposter type
  24398. */
  24399. static PlaneImpostor: number;
  24400. /**
  24401. * Mesh-imposter type
  24402. */
  24403. static MeshImpostor: number;
  24404. /**
  24405. * Capsule-Impostor type (Ammo.js plugin only)
  24406. */
  24407. static CapsuleImpostor: number;
  24408. /**
  24409. * Cylinder-Imposter type
  24410. */
  24411. static CylinderImpostor: number;
  24412. /**
  24413. * Particle-Imposter type
  24414. */
  24415. static ParticleImpostor: number;
  24416. /**
  24417. * Heightmap-Imposter type
  24418. */
  24419. static HeightmapImpostor: number;
  24420. /**
  24421. * ConvexHull-Impostor type (Ammo.js plugin only)
  24422. */
  24423. static ConvexHullImpostor: number;
  24424. /**
  24425. * Rope-Imposter type
  24426. */
  24427. static RopeImpostor: number;
  24428. /**
  24429. * Cloth-Imposter type
  24430. */
  24431. static ClothImpostor: number;
  24432. /**
  24433. * Softbody-Imposter type
  24434. */
  24435. static SoftbodyImpostor: number;
  24436. }
  24437. }
  24438. declare module "babylonjs/Meshes/mesh" {
  24439. import { Observable } from "babylonjs/Misc/observable";
  24440. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24441. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24442. import { Camera } from "babylonjs/Cameras/camera";
  24443. import { Scene } from "babylonjs/scene";
  24444. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24445. import { Color4 } from "babylonjs/Maths/math.color";
  24446. import { Engine } from "babylonjs/Engines/engine";
  24447. import { Node } from "babylonjs/node";
  24448. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24449. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24450. import { Buffer } from "babylonjs/Meshes/buffer";
  24451. import { Geometry } from "babylonjs/Meshes/geometry";
  24452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24454. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24455. import { Effect } from "babylonjs/Materials/effect";
  24456. import { Material } from "babylonjs/Materials/material";
  24457. import { Skeleton } from "babylonjs/Bones/skeleton";
  24458. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24459. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24460. import { Path3D } from "babylonjs/Maths/math.path";
  24461. import { Plane } from "babylonjs/Maths/math.plane";
  24462. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24463. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24464. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24465. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24466. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24467. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24468. /**
  24469. * @hidden
  24470. **/
  24471. export class _CreationDataStorage {
  24472. closePath?: boolean;
  24473. closeArray?: boolean;
  24474. idx: number[];
  24475. dashSize: number;
  24476. gapSize: number;
  24477. path3D: Path3D;
  24478. pathArray: Vector3[][];
  24479. arc: number;
  24480. radius: number;
  24481. cap: number;
  24482. tessellation: number;
  24483. }
  24484. /**
  24485. * @hidden
  24486. **/
  24487. class _InstanceDataStorage {
  24488. visibleInstances: any;
  24489. batchCache: _InstancesBatch;
  24490. instancesBufferSize: number;
  24491. instancesBuffer: Nullable<Buffer>;
  24492. instancesData: Float32Array;
  24493. overridenInstanceCount: number;
  24494. isFrozen: boolean;
  24495. previousBatch: Nullable<_InstancesBatch>;
  24496. hardwareInstancedRendering: boolean;
  24497. sideOrientation: number;
  24498. manualUpdate: boolean;
  24499. }
  24500. /**
  24501. * @hidden
  24502. **/
  24503. export class _InstancesBatch {
  24504. mustReturn: boolean;
  24505. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24506. renderSelf: boolean[];
  24507. hardwareInstancedRendering: boolean[];
  24508. }
  24509. /**
  24510. * Class used to represent renderable models
  24511. */
  24512. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24513. /**
  24514. * Mesh side orientation : usually the external or front surface
  24515. */
  24516. static readonly FRONTSIDE: number;
  24517. /**
  24518. * Mesh side orientation : usually the internal or back surface
  24519. */
  24520. static readonly BACKSIDE: number;
  24521. /**
  24522. * Mesh side orientation : both internal and external or front and back surfaces
  24523. */
  24524. static readonly DOUBLESIDE: number;
  24525. /**
  24526. * Mesh side orientation : by default, `FRONTSIDE`
  24527. */
  24528. static readonly DEFAULTSIDE: number;
  24529. /**
  24530. * Mesh cap setting : no cap
  24531. */
  24532. static readonly NO_CAP: number;
  24533. /**
  24534. * Mesh cap setting : one cap at the beginning of the mesh
  24535. */
  24536. static readonly CAP_START: number;
  24537. /**
  24538. * Mesh cap setting : one cap at the end of the mesh
  24539. */
  24540. static readonly CAP_END: number;
  24541. /**
  24542. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24543. */
  24544. static readonly CAP_ALL: number;
  24545. /**
  24546. * Mesh pattern setting : no flip or rotate
  24547. */
  24548. static readonly NO_FLIP: number;
  24549. /**
  24550. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24551. */
  24552. static readonly FLIP_TILE: number;
  24553. /**
  24554. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24555. */
  24556. static readonly ROTATE_TILE: number;
  24557. /**
  24558. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24559. */
  24560. static readonly FLIP_ROW: number;
  24561. /**
  24562. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24563. */
  24564. static readonly ROTATE_ROW: number;
  24565. /**
  24566. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24567. */
  24568. static readonly FLIP_N_ROTATE_TILE: number;
  24569. /**
  24570. * Mesh pattern setting : rotate pattern and rotate
  24571. */
  24572. static readonly FLIP_N_ROTATE_ROW: number;
  24573. /**
  24574. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24575. */
  24576. static readonly CENTER: number;
  24577. /**
  24578. * Mesh tile positioning : part tiles on left
  24579. */
  24580. static readonly LEFT: number;
  24581. /**
  24582. * Mesh tile positioning : part tiles on right
  24583. */
  24584. static readonly RIGHT: number;
  24585. /**
  24586. * Mesh tile positioning : part tiles on top
  24587. */
  24588. static readonly TOP: number;
  24589. /**
  24590. * Mesh tile positioning : part tiles on bottom
  24591. */
  24592. static readonly BOTTOM: number;
  24593. /**
  24594. * Gets the default side orientation.
  24595. * @param orientation the orientation to value to attempt to get
  24596. * @returns the default orientation
  24597. * @hidden
  24598. */
  24599. static _GetDefaultSideOrientation(orientation?: number): number;
  24600. private _internalMeshDataInfo;
  24601. /**
  24602. * An event triggered before rendering the mesh
  24603. */
  24604. readonly onBeforeRenderObservable: Observable<Mesh>;
  24605. /**
  24606. * An event triggered before binding the mesh
  24607. */
  24608. readonly onBeforeBindObservable: Observable<Mesh>;
  24609. /**
  24610. * An event triggered after rendering the mesh
  24611. */
  24612. readonly onAfterRenderObservable: Observable<Mesh>;
  24613. /**
  24614. * An event triggered before drawing the mesh
  24615. */
  24616. readonly onBeforeDrawObservable: Observable<Mesh>;
  24617. private _onBeforeDrawObserver;
  24618. /**
  24619. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24620. */
  24621. onBeforeDraw: () => void;
  24622. readonly hasInstances: boolean;
  24623. /**
  24624. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24625. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24626. */
  24627. delayLoadState: number;
  24628. /**
  24629. * Gets the list of instances created from this mesh
  24630. * it is not supposed to be modified manually.
  24631. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24632. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24633. */
  24634. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24635. /**
  24636. * Gets the file containing delay loading data for this mesh
  24637. */
  24638. delayLoadingFile: string;
  24639. /** @hidden */
  24640. _binaryInfo: any;
  24641. /**
  24642. * User defined function used to change how LOD level selection is done
  24643. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24644. */
  24645. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24646. /**
  24647. * Gets or sets the morph target manager
  24648. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24649. */
  24650. morphTargetManager: Nullable<MorphTargetManager>;
  24651. /** @hidden */
  24652. _creationDataStorage: Nullable<_CreationDataStorage>;
  24653. /** @hidden */
  24654. _geometry: Nullable<Geometry>;
  24655. /** @hidden */
  24656. _delayInfo: Array<string>;
  24657. /** @hidden */
  24658. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24659. /** @hidden */
  24660. _instanceDataStorage: _InstanceDataStorage;
  24661. private _effectiveMaterial;
  24662. /** @hidden */
  24663. _shouldGenerateFlatShading: boolean;
  24664. /** @hidden */
  24665. _originalBuilderSideOrientation: number;
  24666. /**
  24667. * Use this property to change the original side orientation defined at construction time
  24668. */
  24669. overrideMaterialSideOrientation: Nullable<number>;
  24670. /**
  24671. * Gets the source mesh (the one used to clone this one from)
  24672. */
  24673. readonly source: Nullable<Mesh>;
  24674. /**
  24675. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24676. */
  24677. isUnIndexed: boolean;
  24678. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24679. readonly worldMatrixInstancedBuffer: Float32Array;
  24680. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24681. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24682. /**
  24683. * @constructor
  24684. * @param name The value used by scene.getMeshByName() to do a lookup.
  24685. * @param scene The scene to add this mesh to.
  24686. * @param parent The parent of this mesh, if it has one
  24687. * @param source An optional Mesh from which geometry is shared, cloned.
  24688. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24689. * When false, achieved by calling a clone(), also passing False.
  24690. * This will make creation of children, recursive.
  24691. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24692. */
  24693. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24694. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24695. doNotInstantiate: boolean;
  24696. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24697. /**
  24698. * Gets the class name
  24699. * @returns the string "Mesh".
  24700. */
  24701. getClassName(): string;
  24702. /** @hidden */
  24703. readonly _isMesh: boolean;
  24704. /**
  24705. * Returns a description of this mesh
  24706. * @param fullDetails define if full details about this mesh must be used
  24707. * @returns a descriptive string representing this mesh
  24708. */
  24709. toString(fullDetails?: boolean): string;
  24710. /** @hidden */
  24711. _unBindEffect(): void;
  24712. /**
  24713. * Gets a boolean indicating if this mesh has LOD
  24714. */
  24715. readonly hasLODLevels: boolean;
  24716. /**
  24717. * Gets the list of MeshLODLevel associated with the current mesh
  24718. * @returns an array of MeshLODLevel
  24719. */
  24720. getLODLevels(): MeshLODLevel[];
  24721. private _sortLODLevels;
  24722. /**
  24723. * Add a mesh as LOD level triggered at the given distance.
  24724. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24725. * @param distance The distance from the center of the object to show this level
  24726. * @param mesh The mesh to be added as LOD level (can be null)
  24727. * @return This mesh (for chaining)
  24728. */
  24729. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24730. /**
  24731. * Returns the LOD level mesh at the passed distance or null if not found.
  24732. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24733. * @param distance The distance from the center of the object to show this level
  24734. * @returns a Mesh or `null`
  24735. */
  24736. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24737. /**
  24738. * Remove a mesh from the LOD array
  24739. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24740. * @param mesh defines the mesh to be removed
  24741. * @return This mesh (for chaining)
  24742. */
  24743. removeLODLevel(mesh: Mesh): Mesh;
  24744. /**
  24745. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24746. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24747. * @param camera defines the camera to use to compute distance
  24748. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24749. * @return This mesh (for chaining)
  24750. */
  24751. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24752. /**
  24753. * Gets the mesh internal Geometry object
  24754. */
  24755. readonly geometry: Nullable<Geometry>;
  24756. /**
  24757. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24758. * @returns the total number of vertices
  24759. */
  24760. getTotalVertices(): number;
  24761. /**
  24762. * Returns the content of an associated vertex buffer
  24763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24764. * - VertexBuffer.PositionKind
  24765. * - VertexBuffer.UVKind
  24766. * - VertexBuffer.UV2Kind
  24767. * - VertexBuffer.UV3Kind
  24768. * - VertexBuffer.UV4Kind
  24769. * - VertexBuffer.UV5Kind
  24770. * - VertexBuffer.UV6Kind
  24771. * - VertexBuffer.ColorKind
  24772. * - VertexBuffer.MatricesIndicesKind
  24773. * - VertexBuffer.MatricesIndicesExtraKind
  24774. * - VertexBuffer.MatricesWeightsKind
  24775. * - VertexBuffer.MatricesWeightsExtraKind
  24776. * @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
  24777. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24778. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24779. */
  24780. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24781. /**
  24782. * Returns the mesh VertexBuffer object from the requested `kind`
  24783. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24784. * - VertexBuffer.PositionKind
  24785. * - VertexBuffer.NormalKind
  24786. * - VertexBuffer.UVKind
  24787. * - VertexBuffer.UV2Kind
  24788. * - VertexBuffer.UV3Kind
  24789. * - VertexBuffer.UV4Kind
  24790. * - VertexBuffer.UV5Kind
  24791. * - VertexBuffer.UV6Kind
  24792. * - VertexBuffer.ColorKind
  24793. * - VertexBuffer.MatricesIndicesKind
  24794. * - VertexBuffer.MatricesIndicesExtraKind
  24795. * - VertexBuffer.MatricesWeightsKind
  24796. * - VertexBuffer.MatricesWeightsExtraKind
  24797. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24798. */
  24799. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24800. /**
  24801. * Tests if a specific vertex buffer is associated with this mesh
  24802. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24803. * - VertexBuffer.PositionKind
  24804. * - VertexBuffer.NormalKind
  24805. * - VertexBuffer.UVKind
  24806. * - VertexBuffer.UV2Kind
  24807. * - VertexBuffer.UV3Kind
  24808. * - VertexBuffer.UV4Kind
  24809. * - VertexBuffer.UV5Kind
  24810. * - VertexBuffer.UV6Kind
  24811. * - VertexBuffer.ColorKind
  24812. * - VertexBuffer.MatricesIndicesKind
  24813. * - VertexBuffer.MatricesIndicesExtraKind
  24814. * - VertexBuffer.MatricesWeightsKind
  24815. * - VertexBuffer.MatricesWeightsExtraKind
  24816. * @returns a boolean
  24817. */
  24818. isVerticesDataPresent(kind: string): boolean;
  24819. /**
  24820. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24821. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24822. * - VertexBuffer.PositionKind
  24823. * - VertexBuffer.UVKind
  24824. * - VertexBuffer.UV2Kind
  24825. * - VertexBuffer.UV3Kind
  24826. * - VertexBuffer.UV4Kind
  24827. * - VertexBuffer.UV5Kind
  24828. * - VertexBuffer.UV6Kind
  24829. * - VertexBuffer.ColorKind
  24830. * - VertexBuffer.MatricesIndicesKind
  24831. * - VertexBuffer.MatricesIndicesExtraKind
  24832. * - VertexBuffer.MatricesWeightsKind
  24833. * - VertexBuffer.MatricesWeightsExtraKind
  24834. * @returns a boolean
  24835. */
  24836. isVertexBufferUpdatable(kind: string): boolean;
  24837. /**
  24838. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24839. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24840. * - VertexBuffer.PositionKind
  24841. * - VertexBuffer.NormalKind
  24842. * - VertexBuffer.UVKind
  24843. * - VertexBuffer.UV2Kind
  24844. * - VertexBuffer.UV3Kind
  24845. * - VertexBuffer.UV4Kind
  24846. * - VertexBuffer.UV5Kind
  24847. * - VertexBuffer.UV6Kind
  24848. * - VertexBuffer.ColorKind
  24849. * - VertexBuffer.MatricesIndicesKind
  24850. * - VertexBuffer.MatricesIndicesExtraKind
  24851. * - VertexBuffer.MatricesWeightsKind
  24852. * - VertexBuffer.MatricesWeightsExtraKind
  24853. * @returns an array of strings
  24854. */
  24855. getVerticesDataKinds(): string[];
  24856. /**
  24857. * Returns a positive integer : the total number of indices in this mesh geometry.
  24858. * @returns the numner of indices or zero if the mesh has no geometry.
  24859. */
  24860. getTotalIndices(): number;
  24861. /**
  24862. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24863. * @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.
  24864. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24865. * @returns the indices array or an empty array if the mesh has no geometry
  24866. */
  24867. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24868. readonly isBlocked: boolean;
  24869. /**
  24870. * Determine if the current mesh is ready to be rendered
  24871. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24872. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24873. * @returns true if all associated assets are ready (material, textures, shaders)
  24874. */
  24875. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24876. /**
  24877. * 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.
  24878. */
  24879. readonly areNormalsFrozen: boolean;
  24880. /**
  24881. * 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.
  24882. * @returns the current mesh
  24883. */
  24884. freezeNormals(): Mesh;
  24885. /**
  24886. * 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
  24887. * @returns the current mesh
  24888. */
  24889. unfreezeNormals(): Mesh;
  24890. /**
  24891. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24892. */
  24893. overridenInstanceCount: number;
  24894. /** @hidden */
  24895. _preActivate(): Mesh;
  24896. /** @hidden */
  24897. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24898. /** @hidden */
  24899. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24900. /**
  24901. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24902. * This means the mesh underlying bounding box and sphere are recomputed.
  24903. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24904. * @returns the current mesh
  24905. */
  24906. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24907. /** @hidden */
  24908. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24909. /**
  24910. * This function will subdivide the mesh into multiple submeshes
  24911. * @param count defines the expected number of submeshes
  24912. */
  24913. subdivide(count: number): void;
  24914. /**
  24915. * Copy a FloatArray into a specific associated vertex buffer
  24916. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24917. * - VertexBuffer.PositionKind
  24918. * - VertexBuffer.UVKind
  24919. * - VertexBuffer.UV2Kind
  24920. * - VertexBuffer.UV3Kind
  24921. * - VertexBuffer.UV4Kind
  24922. * - VertexBuffer.UV5Kind
  24923. * - VertexBuffer.UV6Kind
  24924. * - VertexBuffer.ColorKind
  24925. * - VertexBuffer.MatricesIndicesKind
  24926. * - VertexBuffer.MatricesIndicesExtraKind
  24927. * - VertexBuffer.MatricesWeightsKind
  24928. * - VertexBuffer.MatricesWeightsExtraKind
  24929. * @param data defines the data source
  24930. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24931. * @param stride defines the data stride size (can be null)
  24932. * @returns the current mesh
  24933. */
  24934. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24935. /**
  24936. * Delete a vertex buffer associated with this mesh
  24937. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24938. * - VertexBuffer.PositionKind
  24939. * - VertexBuffer.UVKind
  24940. * - VertexBuffer.UV2Kind
  24941. * - VertexBuffer.UV3Kind
  24942. * - VertexBuffer.UV4Kind
  24943. * - VertexBuffer.UV5Kind
  24944. * - VertexBuffer.UV6Kind
  24945. * - VertexBuffer.ColorKind
  24946. * - VertexBuffer.MatricesIndicesKind
  24947. * - VertexBuffer.MatricesIndicesExtraKind
  24948. * - VertexBuffer.MatricesWeightsKind
  24949. * - VertexBuffer.MatricesWeightsExtraKind
  24950. */
  24951. removeVerticesData(kind: string): void;
  24952. /**
  24953. * Flags an associated vertex buffer as updatable
  24954. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24955. * - VertexBuffer.PositionKind
  24956. * - VertexBuffer.UVKind
  24957. * - VertexBuffer.UV2Kind
  24958. * - VertexBuffer.UV3Kind
  24959. * - VertexBuffer.UV4Kind
  24960. * - VertexBuffer.UV5Kind
  24961. * - VertexBuffer.UV6Kind
  24962. * - VertexBuffer.ColorKind
  24963. * - VertexBuffer.MatricesIndicesKind
  24964. * - VertexBuffer.MatricesIndicesExtraKind
  24965. * - VertexBuffer.MatricesWeightsKind
  24966. * - VertexBuffer.MatricesWeightsExtraKind
  24967. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24968. */
  24969. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24970. /**
  24971. * Sets the mesh global Vertex Buffer
  24972. * @param buffer defines the buffer to use
  24973. * @returns the current mesh
  24974. */
  24975. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24976. /**
  24977. * Update a specific associated vertex buffer
  24978. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24979. * - VertexBuffer.PositionKind
  24980. * - VertexBuffer.UVKind
  24981. * - VertexBuffer.UV2Kind
  24982. * - VertexBuffer.UV3Kind
  24983. * - VertexBuffer.UV4Kind
  24984. * - VertexBuffer.UV5Kind
  24985. * - VertexBuffer.UV6Kind
  24986. * - VertexBuffer.ColorKind
  24987. * - VertexBuffer.MatricesIndicesKind
  24988. * - VertexBuffer.MatricesIndicesExtraKind
  24989. * - VertexBuffer.MatricesWeightsKind
  24990. * - VertexBuffer.MatricesWeightsExtraKind
  24991. * @param data defines the data source
  24992. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24993. * @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)
  24994. * @returns the current mesh
  24995. */
  24996. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24997. /**
  24998. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24999. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25000. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25001. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25002. * @returns the current mesh
  25003. */
  25004. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25005. /**
  25006. * Creates a un-shared specific occurence of the geometry for the mesh.
  25007. * @returns the current mesh
  25008. */
  25009. makeGeometryUnique(): Mesh;
  25010. /**
  25011. * Set the index buffer of this mesh
  25012. * @param indices defines the source data
  25013. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25014. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25015. * @returns the current mesh
  25016. */
  25017. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25018. /**
  25019. * Update the current index buffer
  25020. * @param indices defines the source data
  25021. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25022. * @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)
  25023. * @returns the current mesh
  25024. */
  25025. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25026. /**
  25027. * Invert the geometry to move from a right handed system to a left handed one.
  25028. * @returns the current mesh
  25029. */
  25030. toLeftHanded(): Mesh;
  25031. /** @hidden */
  25032. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25033. /** @hidden */
  25034. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25035. /**
  25036. * Registers for this mesh a javascript function called just before the rendering process
  25037. * @param func defines the function to call before rendering this mesh
  25038. * @returns the current mesh
  25039. */
  25040. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25041. /**
  25042. * Disposes a previously registered javascript function called before the rendering
  25043. * @param func defines the function to remove
  25044. * @returns the current mesh
  25045. */
  25046. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25047. /**
  25048. * Registers for this mesh a javascript function called just after the rendering is complete
  25049. * @param func defines the function to call after rendering this mesh
  25050. * @returns the current mesh
  25051. */
  25052. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25053. /**
  25054. * Disposes a previously registered javascript function called after the rendering.
  25055. * @param func defines the function to remove
  25056. * @returns the current mesh
  25057. */
  25058. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25059. /** @hidden */
  25060. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25061. /** @hidden */
  25062. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25063. /** @hidden */
  25064. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25065. /** @hidden */
  25066. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25067. /** @hidden */
  25068. _rebuild(): void;
  25069. /** @hidden */
  25070. _freeze(): void;
  25071. /** @hidden */
  25072. _unFreeze(): void;
  25073. /**
  25074. * 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
  25075. * @param subMesh defines the subMesh to render
  25076. * @param enableAlphaMode defines if alpha mode can be changed
  25077. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25078. * @returns the current mesh
  25079. */
  25080. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25081. private _onBeforeDraw;
  25082. /**
  25083. * Renormalize the mesh and patch it up if there are no weights
  25084. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25085. * However in the case of zero weights then we set just a single influence to 1.
  25086. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25087. */
  25088. cleanMatrixWeights(): void;
  25089. private normalizeSkinFourWeights;
  25090. private normalizeSkinWeightsAndExtra;
  25091. /**
  25092. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25093. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25094. * the user know there was an issue with importing the mesh
  25095. * @returns a validation object with skinned, valid and report string
  25096. */
  25097. validateSkinning(): {
  25098. skinned: boolean;
  25099. valid: boolean;
  25100. report: string;
  25101. };
  25102. /** @hidden */
  25103. _checkDelayState(): Mesh;
  25104. private _queueLoad;
  25105. /**
  25106. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25107. * A mesh is in the frustum if its bounding box intersects the frustum
  25108. * @param frustumPlanes defines the frustum to test
  25109. * @returns true if the mesh is in the frustum planes
  25110. */
  25111. isInFrustum(frustumPlanes: Plane[]): boolean;
  25112. /**
  25113. * Sets the mesh material by the material or multiMaterial `id` property
  25114. * @param id is a string identifying the material or the multiMaterial
  25115. * @returns the current mesh
  25116. */
  25117. setMaterialByID(id: string): Mesh;
  25118. /**
  25119. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25120. * @returns an array of IAnimatable
  25121. */
  25122. getAnimatables(): IAnimatable[];
  25123. /**
  25124. * Modifies the mesh geometry according to the passed transformation matrix.
  25125. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25126. * The mesh normals are modified using the same transformation.
  25127. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25128. * @param transform defines the transform matrix to use
  25129. * @see http://doc.babylonjs.com/resources/baking_transformations
  25130. * @returns the current mesh
  25131. */
  25132. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25133. /**
  25134. * Modifies the mesh geometry according to its own current World Matrix.
  25135. * The mesh World Matrix is then reset.
  25136. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25137. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25138. * @see http://doc.babylonjs.com/resources/baking_transformations
  25139. * @returns the current mesh
  25140. */
  25141. bakeCurrentTransformIntoVertices(): Mesh;
  25142. /** @hidden */
  25143. readonly _positions: Nullable<Vector3[]>;
  25144. /** @hidden */
  25145. _resetPointsArrayCache(): Mesh;
  25146. /** @hidden */
  25147. _generatePointsArray(): boolean;
  25148. /**
  25149. * Returns a new Mesh object generated from the current mesh properties.
  25150. * This method must not get confused with createInstance()
  25151. * @param name is a string, the name given to the new mesh
  25152. * @param newParent can be any Node object (default `null`)
  25153. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25154. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25155. * @returns a new mesh
  25156. */
  25157. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25158. /**
  25159. * Releases resources associated with this mesh.
  25160. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25161. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25162. */
  25163. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25164. /** @hidden */
  25165. _disposeInstanceSpecificData(): void;
  25166. /**
  25167. * Modifies the mesh geometry according to a displacement map.
  25168. * 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.
  25169. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25170. * @param url is a string, the URL from the image file is to be downloaded.
  25171. * @param minHeight is the lower limit of the displacement.
  25172. * @param maxHeight is the upper limit of the displacement.
  25173. * @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.
  25174. * @param uvOffset is an optional vector2 used to offset UV.
  25175. * @param uvScale is an optional vector2 used to scale UV.
  25176. * @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.
  25177. * @returns the Mesh.
  25178. */
  25179. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25180. /**
  25181. * Modifies the mesh geometry according to a displacementMap buffer.
  25182. * 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.
  25183. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25184. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25185. * @param heightMapWidth is the width of the buffer image.
  25186. * @param heightMapHeight is the height of the buffer image.
  25187. * @param minHeight is the lower limit of the displacement.
  25188. * @param maxHeight is the upper limit of the displacement.
  25189. * @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.
  25190. * @param uvOffset is an optional vector2 used to offset UV.
  25191. * @param uvScale is an optional vector2 used to scale UV.
  25192. * @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.
  25193. * @returns the Mesh.
  25194. */
  25195. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25196. /**
  25197. * Modify the mesh to get a flat shading rendering.
  25198. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25199. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25200. * @returns current mesh
  25201. */
  25202. convertToFlatShadedMesh(): Mesh;
  25203. /**
  25204. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25205. * In other words, more vertices, no more indices and a single bigger VBO.
  25206. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25207. * @returns current mesh
  25208. */
  25209. convertToUnIndexedMesh(): Mesh;
  25210. /**
  25211. * Inverses facet orientations.
  25212. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25213. * @param flipNormals will also inverts the normals
  25214. * @returns current mesh
  25215. */
  25216. flipFaces(flipNormals?: boolean): Mesh;
  25217. /**
  25218. * Increase the number of facets and hence vertices in a mesh
  25219. * Vertex normals are interpolated from existing vertex normals
  25220. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25221. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25222. */
  25223. increaseVertices(numberPerEdge: number): void;
  25224. /**
  25225. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25226. * This will undo any application of covertToFlatShadedMesh
  25227. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25228. */
  25229. forceSharedVertices(): void;
  25230. /** @hidden */
  25231. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25232. /** @hidden */
  25233. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25234. /**
  25235. * Creates a new InstancedMesh object from the mesh model.
  25236. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25237. * @param name defines the name of the new instance
  25238. * @returns a new InstancedMesh
  25239. */
  25240. createInstance(name: string): InstancedMesh;
  25241. /**
  25242. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25243. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25244. * @returns the current mesh
  25245. */
  25246. synchronizeInstances(): Mesh;
  25247. /**
  25248. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25249. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25250. * This should be used together with the simplification to avoid disappearing triangles.
  25251. * @param successCallback an optional success callback to be called after the optimization finished.
  25252. * @returns the current mesh
  25253. */
  25254. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25255. /**
  25256. * Serialize current mesh
  25257. * @param serializationObject defines the object which will receive the serialization data
  25258. */
  25259. serialize(serializationObject: any): void;
  25260. /** @hidden */
  25261. _syncGeometryWithMorphTargetManager(): void;
  25262. /** @hidden */
  25263. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25264. /**
  25265. * Returns a new Mesh object parsed from the source provided.
  25266. * @param parsedMesh is the source
  25267. * @param scene defines the hosting scene
  25268. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25269. * @returns a new Mesh
  25270. */
  25271. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25272. /**
  25273. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25274. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25275. * @param name defines the name of the mesh to create
  25276. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25277. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25278. * @param closePath creates a seam between the first and the last points of each path of the path array
  25279. * @param offset is taken in account only if the `pathArray` is containing a single path
  25280. * @param scene defines the hosting scene
  25281. * @param updatable defines if the mesh must be flagged as updatable
  25282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25283. * @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)
  25284. * @returns a new Mesh
  25285. */
  25286. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25287. /**
  25288. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25289. * @param name defines the name of the mesh to create
  25290. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25291. * @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
  25292. * @param scene defines the hosting scene
  25293. * @param updatable defines if the mesh must be flagged as updatable
  25294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25295. * @returns a new Mesh
  25296. */
  25297. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25298. /**
  25299. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25300. * @param name defines the name of the mesh to create
  25301. * @param size sets the size (float) of each box side (default 1)
  25302. * @param scene defines the hosting scene
  25303. * @param updatable defines if the mesh must be flagged as updatable
  25304. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25305. * @returns a new Mesh
  25306. */
  25307. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25308. /**
  25309. * Creates a sphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25312. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25313. * @param scene defines the hosting scene
  25314. * @param updatable defines if the mesh must be flagged as updatable
  25315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25316. * @returns a new Mesh
  25317. */
  25318. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25319. /**
  25320. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25321. * @param name defines the name of the mesh to create
  25322. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25323. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25324. * @param scene defines the hosting scene
  25325. * @returns a new Mesh
  25326. */
  25327. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25328. /**
  25329. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25330. * @param name defines the name of the mesh to create
  25331. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25332. * @param diameterTop set the top cap diameter (floats, default 1)
  25333. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25334. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25335. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25336. * @param scene defines the hosting scene
  25337. * @param updatable defines if the mesh must be flagged as updatable
  25338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25339. * @returns a new Mesh
  25340. */
  25341. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25342. /**
  25343. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25344. * @param name defines the name of the mesh to create
  25345. * @param diameter sets the diameter size (float) of the torus (default 1)
  25346. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25347. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25348. * @param scene defines the hosting scene
  25349. * @param updatable defines if the mesh must be flagged as updatable
  25350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25351. * @returns a new Mesh
  25352. */
  25353. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25354. /**
  25355. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25356. * @param name defines the name of the mesh to create
  25357. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25358. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25359. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25360. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25361. * @param p the number of windings on X axis (positive integers, default 2)
  25362. * @param q the number of windings on Y axis (positive integers, default 3)
  25363. * @param scene defines the hosting scene
  25364. * @param updatable defines if the mesh must be flagged as updatable
  25365. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25366. * @returns a new Mesh
  25367. */
  25368. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25369. /**
  25370. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25371. * @param name defines the name of the mesh to create
  25372. * @param points is an array successive Vector3
  25373. * @param scene defines the hosting scene
  25374. * @param updatable defines if the mesh must be flagged as updatable
  25375. * @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).
  25376. * @returns a new Mesh
  25377. */
  25378. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25379. /**
  25380. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25381. * @param name defines the name of the mesh to create
  25382. * @param points is an array successive Vector3
  25383. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25384. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25385. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25386. * @param scene defines the hosting scene
  25387. * @param updatable defines if the mesh must be flagged as updatable
  25388. * @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)
  25389. * @returns a new Mesh
  25390. */
  25391. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25392. /**
  25393. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25394. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25395. * 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.
  25396. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25397. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25398. * Remember you can only change the shape positions, not their number when updating a polygon.
  25399. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25400. * @param name defines the name of the mesh to create
  25401. * @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
  25402. * @param scene defines the hosting scene
  25403. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25404. * @param updatable defines if the mesh must be flagged as updatable
  25405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25406. * @param earcutInjection can be used to inject your own earcut reference
  25407. * @returns a new Mesh
  25408. */
  25409. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25410. /**
  25411. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25412. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25413. * @param name defines the name of the mesh to create
  25414. * @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
  25415. * @param depth defines the height of extrusion
  25416. * @param scene defines the hosting scene
  25417. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25418. * @param updatable defines if the mesh must be flagged as updatable
  25419. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25420. * @param earcutInjection can be used to inject your own earcut reference
  25421. * @returns a new Mesh
  25422. */
  25423. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25424. /**
  25425. * Creates an extruded shape mesh.
  25426. * 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
  25427. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25428. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25429. * @param name defines the name of the mesh to create
  25430. * @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
  25431. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25432. * @param scale is the value to scale the shape
  25433. * @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
  25434. * @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
  25435. * @param scene defines the hosting scene
  25436. * @param updatable defines if the mesh must be flagged as updatable
  25437. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25438. * @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)
  25439. * @returns a new Mesh
  25440. */
  25441. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25442. /**
  25443. * Creates an custom extruded shape mesh.
  25444. * The custom extrusion is a parametric shape.
  25445. * It has no predefined shape. Its final shape will depend on the input parameters.
  25446. * Please consider using the same method from the MeshBuilder class instead
  25447. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25448. * @param name defines the name of the mesh to create
  25449. * @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
  25450. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25451. * @param scaleFunction is a custom Javascript function called on each path point
  25452. * @param rotationFunction is a custom Javascript function called on each path point
  25453. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25454. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25455. * @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
  25456. * @param scene defines the hosting scene
  25457. * @param updatable defines if the mesh must be flagged as updatable
  25458. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25459. * @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)
  25460. * @returns a new Mesh
  25461. */
  25462. 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;
  25463. /**
  25464. * Creates lathe mesh.
  25465. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25466. * Please consider using the same method from the MeshBuilder class instead
  25467. * @param name defines the name of the mesh to create
  25468. * @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
  25469. * @param radius is the radius value of the lathe
  25470. * @param tessellation is the side number of the lathe.
  25471. * @param scene defines the hosting scene
  25472. * @param updatable defines if the mesh must be flagged as updatable
  25473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25474. * @returns a new Mesh
  25475. */
  25476. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25477. /**
  25478. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25479. * @param name defines the name of the mesh to create
  25480. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25481. * @param scene defines the hosting scene
  25482. * @param updatable defines if the mesh must be flagged as updatable
  25483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25484. * @returns a new Mesh
  25485. */
  25486. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25487. /**
  25488. * Creates a ground mesh.
  25489. * Please consider using the same method from the MeshBuilder class instead
  25490. * @param name defines the name of the mesh to create
  25491. * @param width set the width of the ground
  25492. * @param height set the height of the ground
  25493. * @param subdivisions sets the number of subdivisions per side
  25494. * @param scene defines the hosting scene
  25495. * @param updatable defines if the mesh must be flagged as updatable
  25496. * @returns a new Mesh
  25497. */
  25498. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25499. /**
  25500. * Creates a tiled ground mesh.
  25501. * Please consider using the same method from the MeshBuilder class instead
  25502. * @param name defines the name of the mesh to create
  25503. * @param xmin set the ground minimum X coordinate
  25504. * @param zmin set the ground minimum Y coordinate
  25505. * @param xmax set the ground maximum X coordinate
  25506. * @param zmax set the ground maximum Z coordinate
  25507. * @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
  25508. * @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
  25509. * @param scene defines the hosting scene
  25510. * @param updatable defines if the mesh must be flagged as updatable
  25511. * @returns a new Mesh
  25512. */
  25513. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25514. w: number;
  25515. h: number;
  25516. }, precision: {
  25517. w: number;
  25518. h: number;
  25519. }, scene: Scene, updatable?: boolean): Mesh;
  25520. /**
  25521. * Creates a ground mesh from a height map.
  25522. * Please consider using the same method from the MeshBuilder class instead
  25523. * @see http://doc.babylonjs.com/babylon101/height_map
  25524. * @param name defines the name of the mesh to create
  25525. * @param url sets the URL of the height map image resource
  25526. * @param width set the ground width size
  25527. * @param height set the ground height size
  25528. * @param subdivisions sets the number of subdivision per side
  25529. * @param minHeight is the minimum altitude on the ground
  25530. * @param maxHeight is the maximum altitude on the ground
  25531. * @param scene defines the hosting scene
  25532. * @param updatable defines if the mesh must be flagged as updatable
  25533. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25534. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25535. * @returns a new Mesh
  25536. */
  25537. 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;
  25538. /**
  25539. * Creates a tube mesh.
  25540. * The tube is a parametric shape.
  25541. * It has no predefined shape. Its final shape will depend on the input parameters.
  25542. * Please consider using the same method from the MeshBuilder class instead
  25543. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25544. * @param name defines the name of the mesh to create
  25545. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25546. * @param radius sets the tube radius size
  25547. * @param tessellation is the number of sides on the tubular surface
  25548. * @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
  25549. * @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
  25550. * @param scene defines the hosting scene
  25551. * @param updatable defines if the mesh must be flagged as updatable
  25552. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25553. * @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)
  25554. * @returns a new Mesh
  25555. */
  25556. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25557. (i: number, distance: number): number;
  25558. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25559. /**
  25560. * Creates a polyhedron mesh.
  25561. * Please consider using the same method from the MeshBuilder class instead.
  25562. * * 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
  25563. * * The parameter `size` (positive float, default 1) sets the polygon size
  25564. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25565. * * 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`
  25566. * * 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
  25567. * * 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)`)
  25568. * * 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
  25569. * * 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
  25570. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25571. * * If you create a double-sided mesh, you can choose what parts of 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
  25572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25573. * @param name defines the name of the mesh to create
  25574. * @param options defines the options used to create the mesh
  25575. * @param scene defines the hosting scene
  25576. * @returns a new Mesh
  25577. */
  25578. static CreatePolyhedron(name: string, options: {
  25579. type?: number;
  25580. size?: number;
  25581. sizeX?: number;
  25582. sizeY?: number;
  25583. sizeZ?: number;
  25584. custom?: any;
  25585. faceUV?: Vector4[];
  25586. faceColors?: Color4[];
  25587. updatable?: boolean;
  25588. sideOrientation?: number;
  25589. }, scene: Scene): Mesh;
  25590. /**
  25591. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25592. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25593. * * 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`)
  25594. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25595. * * 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
  25596. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25597. * * If you create a double-sided mesh, you can choose what parts of 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
  25598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25599. * @param name defines the name of the mesh
  25600. * @param options defines the options used to create the mesh
  25601. * @param scene defines the hosting scene
  25602. * @returns a new Mesh
  25603. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25604. */
  25605. static CreateIcoSphere(name: string, options: {
  25606. radius?: number;
  25607. flat?: boolean;
  25608. subdivisions?: number;
  25609. sideOrientation?: number;
  25610. updatable?: boolean;
  25611. }, scene: Scene): Mesh;
  25612. /**
  25613. * Creates a decal mesh.
  25614. * Please consider using the same method from the MeshBuilder class instead.
  25615. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25616. * @param name defines the name of the mesh
  25617. * @param sourceMesh defines the mesh receiving the decal
  25618. * @param position sets the position of the decal in world coordinates
  25619. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25620. * @param size sets the decal scaling
  25621. * @param angle sets the angle to rotate the decal
  25622. * @returns a new Mesh
  25623. */
  25624. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25625. /**
  25626. * Prepare internal position array for software CPU skinning
  25627. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25628. */
  25629. setPositionsForCPUSkinning(): Float32Array;
  25630. /**
  25631. * Prepare internal normal array for software CPU skinning
  25632. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25633. */
  25634. setNormalsForCPUSkinning(): Float32Array;
  25635. /**
  25636. * Updates the vertex buffer by applying transformation from the bones
  25637. * @param skeleton defines the skeleton to apply to current mesh
  25638. * @returns the current mesh
  25639. */
  25640. applySkeleton(skeleton: Skeleton): Mesh;
  25641. /**
  25642. * 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
  25643. * @param meshes defines the list of meshes to scan
  25644. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25645. */
  25646. static MinMax(meshes: AbstractMesh[]): {
  25647. min: Vector3;
  25648. max: Vector3;
  25649. };
  25650. /**
  25651. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25652. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25653. * @returns a vector3
  25654. */
  25655. static Center(meshesOrMinMaxVector: {
  25656. min: Vector3;
  25657. max: Vector3;
  25658. } | AbstractMesh[]): Vector3;
  25659. /**
  25660. * Merge the array of meshes into a single mesh for performance reasons.
  25661. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25662. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25663. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25664. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25665. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25666. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25667. * @returns a new mesh
  25668. */
  25669. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25670. /** @hidden */
  25671. addInstance(instance: InstancedMesh): void;
  25672. /** @hidden */
  25673. removeInstance(instance: InstancedMesh): void;
  25674. }
  25675. }
  25676. declare module "babylonjs/Cameras/camera" {
  25677. import { SmartArray } from "babylonjs/Misc/smartArray";
  25678. import { Observable } from "babylonjs/Misc/observable";
  25679. import { Nullable } from "babylonjs/types";
  25680. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25681. import { Scene } from "babylonjs/scene";
  25682. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25683. import { Node } from "babylonjs/node";
  25684. import { Mesh } from "babylonjs/Meshes/mesh";
  25685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25686. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25687. import { Viewport } from "babylonjs/Maths/math.viewport";
  25688. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25689. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25690. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25691. import { Ray } from "babylonjs/Culling/ray";
  25692. /**
  25693. * This is the base class of all the camera used in the application.
  25694. * @see http://doc.babylonjs.com/features/cameras
  25695. */
  25696. export class Camera extends Node {
  25697. /** @hidden */
  25698. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25699. /**
  25700. * This is the default projection mode used by the cameras.
  25701. * It helps recreating a feeling of perspective and better appreciate depth.
  25702. * This is the best way to simulate real life cameras.
  25703. */
  25704. static readonly PERSPECTIVE_CAMERA: number;
  25705. /**
  25706. * This helps creating camera with an orthographic mode.
  25707. * 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.
  25708. */
  25709. static readonly ORTHOGRAPHIC_CAMERA: number;
  25710. /**
  25711. * This is the default FOV mode for perspective cameras.
  25712. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25713. */
  25714. static readonly FOVMODE_VERTICAL_FIXED: number;
  25715. /**
  25716. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25717. */
  25718. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25719. /**
  25720. * This specifies ther is no need for a camera rig.
  25721. * Basically only one eye is rendered corresponding to the camera.
  25722. */
  25723. static readonly RIG_MODE_NONE: number;
  25724. /**
  25725. * Simulates a camera Rig with one blue eye and one red eye.
  25726. * This can be use with 3d blue and red glasses.
  25727. */
  25728. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25729. /**
  25730. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25731. */
  25732. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25733. /**
  25734. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25735. */
  25736. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25737. /**
  25738. * Defines that both eyes of the camera will be rendered over under each other.
  25739. */
  25740. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25741. /**
  25742. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25743. */
  25744. static readonly RIG_MODE_VR: number;
  25745. /**
  25746. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25747. */
  25748. static readonly RIG_MODE_WEBVR: number;
  25749. /**
  25750. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25751. */
  25752. static readonly RIG_MODE_CUSTOM: number;
  25753. /**
  25754. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25755. */
  25756. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25757. /**
  25758. * Define the input manager associated with the camera.
  25759. */
  25760. inputs: CameraInputsManager<Camera>;
  25761. /** @hidden */
  25762. _position: Vector3;
  25763. /**
  25764. * Define the current local position of the camera in the scene
  25765. */
  25766. position: Vector3;
  25767. /**
  25768. * The vector the camera should consider as up.
  25769. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25770. */
  25771. upVector: Vector3;
  25772. /**
  25773. * Define the current limit on the left side for an orthographic camera
  25774. * In scene unit
  25775. */
  25776. orthoLeft: Nullable<number>;
  25777. /**
  25778. * Define the current limit on the right side for an orthographic camera
  25779. * In scene unit
  25780. */
  25781. orthoRight: Nullable<number>;
  25782. /**
  25783. * Define the current limit on the bottom side for an orthographic camera
  25784. * In scene unit
  25785. */
  25786. orthoBottom: Nullable<number>;
  25787. /**
  25788. * Define the current limit on the top side for an orthographic camera
  25789. * In scene unit
  25790. */
  25791. orthoTop: Nullable<number>;
  25792. /**
  25793. * Field Of View is set in Radians. (default is 0.8)
  25794. */
  25795. fov: number;
  25796. /**
  25797. * Define the minimum distance the camera can see from.
  25798. * This is important to note that the depth buffer are not infinite and the closer it starts
  25799. * the more your scene might encounter depth fighting issue.
  25800. */
  25801. minZ: number;
  25802. /**
  25803. * Define the maximum distance the camera can see to.
  25804. * This is important to note that the depth buffer are not infinite and the further it end
  25805. * the more your scene might encounter depth fighting issue.
  25806. */
  25807. maxZ: number;
  25808. /**
  25809. * Define the default inertia of the camera.
  25810. * This helps giving a smooth feeling to the camera movement.
  25811. */
  25812. inertia: number;
  25813. /**
  25814. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25815. */
  25816. mode: number;
  25817. /**
  25818. * Define wether the camera is intermediate.
  25819. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25820. */
  25821. isIntermediate: boolean;
  25822. /**
  25823. * Define the viewport of the camera.
  25824. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25825. */
  25826. viewport: Viewport;
  25827. /**
  25828. * Restricts the camera to viewing objects with the same layerMask.
  25829. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25830. */
  25831. layerMask: number;
  25832. /**
  25833. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25834. */
  25835. fovMode: number;
  25836. /**
  25837. * Rig mode of the camera.
  25838. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25839. * This is normally controlled byt the camera themselves as internal use.
  25840. */
  25841. cameraRigMode: number;
  25842. /**
  25843. * Defines the distance between both "eyes" in case of a RIG
  25844. */
  25845. interaxialDistance: number;
  25846. /**
  25847. * Defines if stereoscopic rendering is done side by side or over under.
  25848. */
  25849. isStereoscopicSideBySide: boolean;
  25850. /**
  25851. * 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
  25852. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25853. * else in the scene. (Eg. security camera)
  25854. *
  25855. * 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)
  25856. */
  25857. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25858. /**
  25859. * When set, the camera will render to this render target instead of the default canvas
  25860. *
  25861. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25862. */
  25863. outputRenderTarget: Nullable<RenderTargetTexture>;
  25864. /**
  25865. * Observable triggered when the camera view matrix has changed.
  25866. */
  25867. onViewMatrixChangedObservable: Observable<Camera>;
  25868. /**
  25869. * Observable triggered when the camera Projection matrix has changed.
  25870. */
  25871. onProjectionMatrixChangedObservable: Observable<Camera>;
  25872. /**
  25873. * Observable triggered when the inputs have been processed.
  25874. */
  25875. onAfterCheckInputsObservable: Observable<Camera>;
  25876. /**
  25877. * Observable triggered when reset has been called and applied to the camera.
  25878. */
  25879. onRestoreStateObservable: Observable<Camera>;
  25880. /** @hidden */
  25881. _cameraRigParams: any;
  25882. /** @hidden */
  25883. _rigCameras: Camera[];
  25884. /** @hidden */
  25885. _rigPostProcess: Nullable<PostProcess>;
  25886. protected _webvrViewMatrix: Matrix;
  25887. /** @hidden */
  25888. _skipRendering: boolean;
  25889. /** @hidden */
  25890. _projectionMatrix: Matrix;
  25891. /** @hidden */
  25892. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25893. /** @hidden */
  25894. _activeMeshes: SmartArray<AbstractMesh>;
  25895. protected _globalPosition: Vector3;
  25896. /** @hidden */
  25897. _computedViewMatrix: Matrix;
  25898. private _doNotComputeProjectionMatrix;
  25899. private _transformMatrix;
  25900. private _frustumPlanes;
  25901. private _refreshFrustumPlanes;
  25902. private _storedFov;
  25903. private _stateStored;
  25904. /**
  25905. * Instantiates a new camera object.
  25906. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25907. * @see http://doc.babylonjs.com/features/cameras
  25908. * @param name Defines the name of the camera in the scene
  25909. * @param position Defines the position of the camera
  25910. * @param scene Defines the scene the camera belongs too
  25911. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25912. */
  25913. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25914. /**
  25915. * Store current camera state (fov, position, etc..)
  25916. * @returns the camera
  25917. */
  25918. storeState(): Camera;
  25919. /**
  25920. * Restores the camera state values if it has been stored. You must call storeState() first
  25921. */
  25922. protected _restoreStateValues(): boolean;
  25923. /**
  25924. * Restored camera state. You must call storeState() first.
  25925. * @returns true if restored and false otherwise
  25926. */
  25927. restoreState(): boolean;
  25928. /**
  25929. * Gets the class name of the camera.
  25930. * @returns the class name
  25931. */
  25932. getClassName(): string;
  25933. /** @hidden */
  25934. readonly _isCamera: boolean;
  25935. /**
  25936. * Gets a string representation of the camera useful for debug purpose.
  25937. * @param fullDetails Defines that a more verboe level of logging is required
  25938. * @returns the string representation
  25939. */
  25940. toString(fullDetails?: boolean): string;
  25941. /**
  25942. * Gets the current world space position of the camera.
  25943. */
  25944. readonly globalPosition: Vector3;
  25945. /**
  25946. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25947. * @returns the active meshe list
  25948. */
  25949. getActiveMeshes(): SmartArray<AbstractMesh>;
  25950. /**
  25951. * Check wether a mesh is part of the current active mesh list of the camera
  25952. * @param mesh Defines the mesh to check
  25953. * @returns true if active, false otherwise
  25954. */
  25955. isActiveMesh(mesh: Mesh): boolean;
  25956. /**
  25957. * Is this camera ready to be used/rendered
  25958. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25959. * @return true if the camera is ready
  25960. */
  25961. isReady(completeCheck?: boolean): boolean;
  25962. /** @hidden */
  25963. _initCache(): void;
  25964. /** @hidden */
  25965. _updateCache(ignoreParentClass?: boolean): void;
  25966. /** @hidden */
  25967. _isSynchronized(): boolean;
  25968. /** @hidden */
  25969. _isSynchronizedViewMatrix(): boolean;
  25970. /** @hidden */
  25971. _isSynchronizedProjectionMatrix(): boolean;
  25972. /**
  25973. * Attach the input controls to a specific dom element to get the input from.
  25974. * @param element Defines the element the controls should be listened from
  25975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25976. */
  25977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25978. /**
  25979. * Detach the current controls from the specified dom element.
  25980. * @param element Defines the element to stop listening the inputs from
  25981. */
  25982. detachControl(element: HTMLElement): void;
  25983. /**
  25984. * Update the camera state according to the different inputs gathered during the frame.
  25985. */
  25986. update(): void;
  25987. /** @hidden */
  25988. _checkInputs(): void;
  25989. /** @hidden */
  25990. readonly rigCameras: Camera[];
  25991. /**
  25992. * Gets the post process used by the rig cameras
  25993. */
  25994. readonly rigPostProcess: Nullable<PostProcess>;
  25995. /**
  25996. * Internal, gets the first post proces.
  25997. * @returns the first post process to be run on this camera.
  25998. */
  25999. _getFirstPostProcess(): Nullable<PostProcess>;
  26000. private _cascadePostProcessesToRigCams;
  26001. /**
  26002. * Attach a post process to the camera.
  26003. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26004. * @param postProcess The post process to attach to the camera
  26005. * @param insertAt The position of the post process in case several of them are in use in the scene
  26006. * @returns the position the post process has been inserted at
  26007. */
  26008. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26009. /**
  26010. * Detach a post process to the camera.
  26011. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26012. * @param postProcess The post process to detach from the camera
  26013. */
  26014. detachPostProcess(postProcess: PostProcess): void;
  26015. /**
  26016. * Gets the current world matrix of the camera
  26017. */
  26018. getWorldMatrix(): Matrix;
  26019. /** @hidden */
  26020. _getViewMatrix(): Matrix;
  26021. /**
  26022. * Gets the current view matrix of the camera.
  26023. * @param force forces the camera to recompute the matrix without looking at the cached state
  26024. * @returns the view matrix
  26025. */
  26026. getViewMatrix(force?: boolean): Matrix;
  26027. /**
  26028. * Freeze the projection matrix.
  26029. * It will prevent the cache check of the camera projection compute and can speed up perf
  26030. * if no parameter of the camera are meant to change
  26031. * @param projection Defines manually a projection if necessary
  26032. */
  26033. freezeProjectionMatrix(projection?: Matrix): void;
  26034. /**
  26035. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26036. */
  26037. unfreezeProjectionMatrix(): void;
  26038. /**
  26039. * Gets the current projection matrix of the camera.
  26040. * @param force forces the camera to recompute the matrix without looking at the cached state
  26041. * @returns the projection matrix
  26042. */
  26043. getProjectionMatrix(force?: boolean): Matrix;
  26044. /**
  26045. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26046. * @returns a Matrix
  26047. */
  26048. getTransformationMatrix(): Matrix;
  26049. private _updateFrustumPlanes;
  26050. /**
  26051. * Checks if a cullable object (mesh...) is in the camera frustum
  26052. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26053. * @param target The object to check
  26054. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26055. * @returns true if the object is in frustum otherwise false
  26056. */
  26057. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26058. /**
  26059. * Checks if a cullable object (mesh...) is in the camera frustum
  26060. * Unlike isInFrustum this cheks the full bounding box
  26061. * @param target The object to check
  26062. * @returns true if the object is in frustum otherwise false
  26063. */
  26064. isCompletelyInFrustum(target: ICullable): boolean;
  26065. /**
  26066. * Gets a ray in the forward direction from the camera.
  26067. * @param length Defines the length of the ray to create
  26068. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26069. * @param origin Defines the start point of the ray which defaults to the camera position
  26070. * @returns the forward ray
  26071. */
  26072. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26073. /**
  26074. * Releases resources associated with this node.
  26075. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26076. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26077. */
  26078. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26079. /** @hidden */
  26080. _isLeftCamera: boolean;
  26081. /**
  26082. * Gets the left camera of a rig setup in case of Rigged Camera
  26083. */
  26084. readonly isLeftCamera: boolean;
  26085. /** @hidden */
  26086. _isRightCamera: boolean;
  26087. /**
  26088. * Gets the right camera of a rig setup in case of Rigged Camera
  26089. */
  26090. readonly isRightCamera: boolean;
  26091. /**
  26092. * Gets the left camera of a rig setup in case of Rigged Camera
  26093. */
  26094. readonly leftCamera: Nullable<FreeCamera>;
  26095. /**
  26096. * Gets the right camera of a rig setup in case of Rigged Camera
  26097. */
  26098. readonly rightCamera: Nullable<FreeCamera>;
  26099. /**
  26100. * Gets the left camera target of a rig setup in case of Rigged Camera
  26101. * @returns the target position
  26102. */
  26103. getLeftTarget(): Nullable<Vector3>;
  26104. /**
  26105. * Gets the right camera target of a rig setup in case of Rigged Camera
  26106. * @returns the target position
  26107. */
  26108. getRightTarget(): Nullable<Vector3>;
  26109. /**
  26110. * @hidden
  26111. */
  26112. setCameraRigMode(mode: number, rigParams: any): void;
  26113. /** @hidden */
  26114. static _setStereoscopicRigMode(camera: Camera): void;
  26115. /** @hidden */
  26116. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26117. /** @hidden */
  26118. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26119. /** @hidden */
  26120. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26121. /** @hidden */
  26122. _getVRProjectionMatrix(): Matrix;
  26123. protected _updateCameraRotationMatrix(): void;
  26124. protected _updateWebVRCameraRotationMatrix(): void;
  26125. /**
  26126. * This function MUST be overwritten by the different WebVR cameras available.
  26127. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26128. * @hidden
  26129. */
  26130. _getWebVRProjectionMatrix(): Matrix;
  26131. /**
  26132. * This function MUST be overwritten by the different WebVR cameras available.
  26133. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26134. * @hidden
  26135. */
  26136. _getWebVRViewMatrix(): Matrix;
  26137. /** @hidden */
  26138. setCameraRigParameter(name: string, value: any): void;
  26139. /**
  26140. * needs to be overridden by children so sub has required properties to be copied
  26141. * @hidden
  26142. */
  26143. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26144. /**
  26145. * May need to be overridden by children
  26146. * @hidden
  26147. */
  26148. _updateRigCameras(): void;
  26149. /** @hidden */
  26150. _setupInputs(): void;
  26151. /**
  26152. * Serialiaze the camera setup to a json represention
  26153. * @returns the JSON representation
  26154. */
  26155. serialize(): any;
  26156. /**
  26157. * Clones the current camera.
  26158. * @param name The cloned camera name
  26159. * @returns the cloned camera
  26160. */
  26161. clone(name: string): Camera;
  26162. /**
  26163. * Gets the direction of the camera relative to a given local axis.
  26164. * @param localAxis Defines the reference axis to provide a relative direction.
  26165. * @return the direction
  26166. */
  26167. getDirection(localAxis: Vector3): Vector3;
  26168. /**
  26169. * Returns the current camera absolute rotation
  26170. */
  26171. readonly absoluteRotation: Quaternion;
  26172. /**
  26173. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26174. * @param localAxis Defines the reference axis to provide a relative direction.
  26175. * @param result Defines the vector to store the result in
  26176. */
  26177. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26178. /**
  26179. * Gets a camera constructor for a given camera type
  26180. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26181. * @param name The name of the camera the result will be able to instantiate
  26182. * @param scene The scene the result will construct the camera in
  26183. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26184. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26185. * @returns a factory method to construc the camera
  26186. */
  26187. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26188. /**
  26189. * Compute the world matrix of the camera.
  26190. * @returns the camera world matrix
  26191. */
  26192. computeWorldMatrix(): Matrix;
  26193. /**
  26194. * Parse a JSON and creates the camera from the parsed information
  26195. * @param parsedCamera The JSON to parse
  26196. * @param scene The scene to instantiate the camera in
  26197. * @returns the newly constructed camera
  26198. */
  26199. static Parse(parsedCamera: any, scene: Scene): Camera;
  26200. }
  26201. }
  26202. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26203. import { Nullable } from "babylonjs/types";
  26204. import { Scene } from "babylonjs/scene";
  26205. import { Vector4 } from "babylonjs/Maths/math.vector";
  26206. import { Mesh } from "babylonjs/Meshes/mesh";
  26207. /**
  26208. * Class containing static functions to help procedurally build meshes
  26209. */
  26210. export class DiscBuilder {
  26211. /**
  26212. * Creates a plane polygonal mesh. By default, this is a disc
  26213. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26214. * * 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
  26215. * * 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
  26216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26219. * @param name defines the name of the mesh
  26220. * @param options defines the options used to create the mesh
  26221. * @param scene defines the hosting scene
  26222. * @returns the plane polygonal mesh
  26223. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26224. */
  26225. static CreateDisc(name: string, options: {
  26226. radius?: number;
  26227. tessellation?: number;
  26228. arc?: number;
  26229. updatable?: boolean;
  26230. sideOrientation?: number;
  26231. frontUVs?: Vector4;
  26232. backUVs?: Vector4;
  26233. }, scene?: Nullable<Scene>): Mesh;
  26234. }
  26235. }
  26236. declare module "babylonjs/Particles/solidParticleSystem" {
  26237. import { Nullable } from "babylonjs/types";
  26238. import { Vector3 } from "babylonjs/Maths/math.vector";
  26239. import { Mesh } from "babylonjs/Meshes/mesh";
  26240. import { Scene, IDisposable } from "babylonjs/scene";
  26241. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26242. /**
  26243. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26244. *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.
  26245. * The SPS is also a particle system. It provides some methods to manage the particles.
  26246. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26247. *
  26248. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26249. */
  26250. export class SolidParticleSystem implements IDisposable {
  26251. /**
  26252. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26253. * Example : var p = SPS.particles[i];
  26254. */
  26255. particles: SolidParticle[];
  26256. /**
  26257. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26258. */
  26259. nbParticles: number;
  26260. /**
  26261. * If the particles must ever face the camera (default false). Useful for planar particles.
  26262. */
  26263. billboard: boolean;
  26264. /**
  26265. * Recompute normals when adding a shape
  26266. */
  26267. recomputeNormals: boolean;
  26268. /**
  26269. * This a counter ofr your own usage. It's not set by any SPS functions.
  26270. */
  26271. counter: number;
  26272. /**
  26273. * The SPS name. This name is also given to the underlying mesh.
  26274. */
  26275. name: string;
  26276. /**
  26277. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26278. */
  26279. mesh: Mesh;
  26280. /**
  26281. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26282. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26283. */
  26284. vars: any;
  26285. /**
  26286. * This array is populated when the SPS is set as 'pickable'.
  26287. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26288. * Each element of this array is an object `{idx: int, faceId: int}`.
  26289. * `idx` is the picked particle index in the `SPS.particles` array
  26290. * `faceId` is the picked face index counted within this particle.
  26291. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26292. */
  26293. pickedParticles: {
  26294. idx: number;
  26295. faceId: number;
  26296. }[];
  26297. /**
  26298. * This array is populated when `enableDepthSort` is set to true.
  26299. * Each element of this array is an instance of the class DepthSortedParticle.
  26300. */
  26301. depthSortedParticles: DepthSortedParticle[];
  26302. /**
  26303. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26304. * @hidden
  26305. */
  26306. _bSphereOnly: boolean;
  26307. /**
  26308. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26309. * @hidden
  26310. */
  26311. _bSphereRadiusFactor: number;
  26312. private _scene;
  26313. private _positions;
  26314. private _indices;
  26315. private _normals;
  26316. private _colors;
  26317. private _uvs;
  26318. private _indices32;
  26319. private _positions32;
  26320. private _normals32;
  26321. private _fixedNormal32;
  26322. private _colors32;
  26323. private _uvs32;
  26324. private _index;
  26325. private _updatable;
  26326. private _pickable;
  26327. private _isVisibilityBoxLocked;
  26328. private _alwaysVisible;
  26329. private _depthSort;
  26330. private _expandable;
  26331. private _shapeCounter;
  26332. private _copy;
  26333. private _color;
  26334. private _computeParticleColor;
  26335. private _computeParticleTexture;
  26336. private _computeParticleRotation;
  26337. private _computeParticleVertex;
  26338. private _computeBoundingBox;
  26339. private _depthSortParticles;
  26340. private _camera;
  26341. private _mustUnrotateFixedNormals;
  26342. private _particlesIntersect;
  26343. private _needs32Bits;
  26344. private _isNotBuilt;
  26345. private _lastParticleId;
  26346. private _idxOfId;
  26347. private _multimaterialEnabled;
  26348. private _indicesByMaterial;
  26349. private _materialIndexes;
  26350. private _depthSortFunction;
  26351. private _materialSortFunction;
  26352. /**
  26353. * Creates a SPS (Solid Particle System) object.
  26354. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26355. * @param scene (Scene) is the scene in which the SPS is added.
  26356. * @param options defines the options of the sps e.g.
  26357. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26358. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26359. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26360. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26361. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26362. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26363. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26364. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26365. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26366. */
  26367. constructor(name: string, scene: Scene, options?: {
  26368. updatable?: boolean;
  26369. isPickable?: boolean;
  26370. enableDepthSort?: boolean;
  26371. particleIntersection?: boolean;
  26372. boundingSphereOnly?: boolean;
  26373. bSphereRadiusFactor?: number;
  26374. expandable?: boolean;
  26375. enableMultiMaterial?: boolean;
  26376. });
  26377. /**
  26378. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26379. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26380. * @returns the created mesh
  26381. */
  26382. buildMesh(): Mesh;
  26383. /**
  26384. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26385. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26386. * Thus the particles generated from `digest()` have their property `position` set yet.
  26387. * @param mesh ( Mesh ) is the mesh to be digested
  26388. * @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
  26389. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26390. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26391. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26392. * @returns the current SPS
  26393. */
  26394. digest(mesh: Mesh, options?: {
  26395. facetNb?: number;
  26396. number?: number;
  26397. delta?: number;
  26398. storage?: [];
  26399. }): SolidParticleSystem;
  26400. /**
  26401. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26402. * @hidden
  26403. */
  26404. private _unrotateFixedNormals;
  26405. /**
  26406. * Resets the temporary working copy particle
  26407. * @hidden
  26408. */
  26409. private _resetCopy;
  26410. /**
  26411. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26412. * @param p the current index in the positions array to be updated
  26413. * @param ind the current index in the indices array
  26414. * @param shape a Vector3 array, the shape geometry
  26415. * @param positions the positions array to be updated
  26416. * @param meshInd the shape indices array
  26417. * @param indices the indices array to be updated
  26418. * @param meshUV the shape uv array
  26419. * @param uvs the uv array to be updated
  26420. * @param meshCol the shape color array
  26421. * @param colors the color array to be updated
  26422. * @param meshNor the shape normals array
  26423. * @param normals the normals array to be updated
  26424. * @param idx the particle index
  26425. * @param idxInShape the particle index in its shape
  26426. * @param options the addShape() method passed options
  26427. * @hidden
  26428. */
  26429. private _meshBuilder;
  26430. /**
  26431. * Returns a shape Vector3 array from positions float array
  26432. * @param positions float array
  26433. * @returns a vector3 array
  26434. * @hidden
  26435. */
  26436. private _posToShape;
  26437. /**
  26438. * Returns a shapeUV array from a float uvs (array deep copy)
  26439. * @param uvs as a float array
  26440. * @returns a shapeUV array
  26441. * @hidden
  26442. */
  26443. private _uvsToShapeUV;
  26444. /**
  26445. * Adds a new particle object in the particles array
  26446. * @param idx particle index in particles array
  26447. * @param id particle id
  26448. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26449. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26450. * @param model particle ModelShape object
  26451. * @param shapeId model shape identifier
  26452. * @param idxInShape index of the particle in the current model
  26453. * @param bInfo model bounding info object
  26454. * @param storage target storage array, if any
  26455. * @hidden
  26456. */
  26457. private _addParticle;
  26458. /**
  26459. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26460. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26461. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26462. * @param nb (positive integer) the number of particles to be created from this model
  26463. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26464. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26465. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26466. * @returns the number of shapes in the system
  26467. */
  26468. addShape(mesh: Mesh, nb: number, options?: {
  26469. positionFunction?: any;
  26470. vertexFunction?: any;
  26471. storage?: [];
  26472. }): number;
  26473. /**
  26474. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26475. * @hidden
  26476. */
  26477. private _rebuildParticle;
  26478. /**
  26479. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26480. * @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.
  26481. * @returns the SPS.
  26482. */
  26483. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26484. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26485. * Returns an array with the removed particles.
  26486. * 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.
  26487. * The SPS can't be empty so at least one particle needs to remain in place.
  26488. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26489. * @param start index of the first particle to remove
  26490. * @param end index of the last particle to remove (included)
  26491. * @returns an array populated with the removed particles
  26492. */
  26493. removeParticles(start: number, end: number): SolidParticle[];
  26494. /**
  26495. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26496. * @param solidParticleArray an array populated with Solid Particles objects
  26497. * @returns the SPS
  26498. */
  26499. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26500. /**
  26501. * Creates a new particle and modifies the SPS mesh geometry :
  26502. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26503. * - calls _addParticle() to populate the particle array
  26504. * factorized code from addShape() and insertParticlesFromArray()
  26505. * @param idx particle index in the particles array
  26506. * @param i particle index in its shape
  26507. * @param modelShape particle ModelShape object
  26508. * @param shape shape vertex array
  26509. * @param meshInd shape indices array
  26510. * @param meshUV shape uv array
  26511. * @param meshCol shape color array
  26512. * @param meshNor shape normals array
  26513. * @param bbInfo shape bounding info
  26514. * @param storage target particle storage
  26515. * @options addShape() passed options
  26516. * @hidden
  26517. */
  26518. private _insertNewParticle;
  26519. /**
  26520. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26521. * This method calls `updateParticle()` for each particle of the SPS.
  26522. * For an animated SPS, it is usually called within the render loop.
  26523. * 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.
  26524. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26525. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26526. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26527. * @returns the SPS.
  26528. */
  26529. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26530. /**
  26531. * Disposes the SPS.
  26532. */
  26533. dispose(): void;
  26534. /**
  26535. * Returns a SolidParticle object from its identifier : particle.id
  26536. * @param id (integer) the particle Id
  26537. * @returns the searched particle or null if not found in the SPS.
  26538. */
  26539. getParticleById(id: number): Nullable<SolidParticle>;
  26540. /**
  26541. * Returns a new array populated with the particles having the passed shapeId.
  26542. * @param shapeId (integer) the shape identifier
  26543. * @returns a new solid particle array
  26544. */
  26545. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26546. /**
  26547. * Populates the passed array "ref" with the particles having the passed shapeId.
  26548. * @param shapeId the shape identifier
  26549. * @returns the SPS
  26550. * @param ref
  26551. */
  26552. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26553. /**
  26554. * Computes the required SubMeshes according the materials assigned to the particles.
  26555. * @returns the solid particle system.
  26556. * Does nothing if called before the SPS mesh is built.
  26557. */
  26558. computeSubMeshes(): SolidParticleSystem;
  26559. /**
  26560. * Sorts the solid particles by material when MultiMaterial is enabled.
  26561. * Updates the indices32 array.
  26562. * Updates the indicesByMaterial array.
  26563. * Updates the mesh indices array.
  26564. * @returns the SPS
  26565. * @hidden
  26566. */
  26567. private _sortParticlesByMaterial;
  26568. /**
  26569. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26570. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26571. * @returns the SPS.
  26572. */
  26573. refreshVisibleSize(): SolidParticleSystem;
  26574. /**
  26575. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26576. * @param size the size (float) of the visibility box
  26577. * note : this doesn't lock the SPS mesh bounding box.
  26578. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26579. */
  26580. setVisibilityBox(size: number): void;
  26581. /**
  26582. * Gets whether the SPS as always visible or not
  26583. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26584. */
  26585. /**
  26586. * Sets the SPS as always visible or not
  26587. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26588. */
  26589. isAlwaysVisible: boolean;
  26590. /**
  26591. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26592. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26593. */
  26594. /**
  26595. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26596. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26597. */
  26598. isVisibilityBoxLocked: boolean;
  26599. /**
  26600. * Tells to `setParticles()` to compute the particle rotations or not.
  26601. * Default value : true. The SPS is faster when it's set to false.
  26602. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26603. */
  26604. /**
  26605. * Gets if `setParticles()` computes the particle rotations or not.
  26606. * Default value : true. The SPS is faster when it's set to false.
  26607. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26608. */
  26609. computeParticleRotation: boolean;
  26610. /**
  26611. * Tells to `setParticles()` to compute the particle colors or not.
  26612. * Default value : true. The SPS is faster when it's set to false.
  26613. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26614. */
  26615. /**
  26616. * Gets if `setParticles()` computes the particle colors or not.
  26617. * Default value : true. The SPS is faster when it's set to false.
  26618. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26619. */
  26620. computeParticleColor: boolean;
  26621. /**
  26622. * Gets if `setParticles()` computes the particle textures or not.
  26623. * Default value : true. The SPS is faster when it's set to false.
  26624. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26625. */
  26626. computeParticleTexture: boolean;
  26627. /**
  26628. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26629. * Default value : false. The SPS is faster when it's set to false.
  26630. * Note : the particle custom vertex positions aren't stored values.
  26631. */
  26632. /**
  26633. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26634. * Default value : false. The SPS is faster when it's set to false.
  26635. * Note : the particle custom vertex positions aren't stored values.
  26636. */
  26637. computeParticleVertex: boolean;
  26638. /**
  26639. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26640. */
  26641. /**
  26642. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26643. */
  26644. computeBoundingBox: boolean;
  26645. /**
  26646. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26647. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26648. * Default : `true`
  26649. */
  26650. /**
  26651. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26652. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26653. * Default : `true`
  26654. */
  26655. depthSortParticles: boolean;
  26656. /**
  26657. * Gets if the SPS is created as expandable at construction time.
  26658. * Default : `false`
  26659. */
  26660. readonly expandable: boolean;
  26661. /**
  26662. * Gets if the SPS supports the Multi Materials
  26663. */
  26664. readonly multimaterialEnabled: boolean;
  26665. /**
  26666. * This function does nothing. It may be overwritten to set all the particle first values.
  26667. * The SPS doesn't call this function, you may have to call it by your own.
  26668. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26669. */
  26670. initParticles(): void;
  26671. /**
  26672. * This function does nothing. It may be overwritten to recycle a particle.
  26673. * The SPS doesn't call this function, you may have to call it by your own.
  26674. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26675. * @param particle The particle to recycle
  26676. * @returns the recycled particle
  26677. */
  26678. recycleParticle(particle: SolidParticle): SolidParticle;
  26679. /**
  26680. * Updates a particle : this function should be overwritten by the user.
  26681. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26682. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26683. * @example : just set a particle position or velocity and recycle conditions
  26684. * @param particle The particle to update
  26685. * @returns the updated particle
  26686. */
  26687. updateParticle(particle: SolidParticle): SolidParticle;
  26688. /**
  26689. * Updates a vertex of a particle : it can be overwritten by the user.
  26690. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26691. * @param particle the current particle
  26692. * @param vertex the current index of the current particle
  26693. * @param pt the index of the current vertex in the particle shape
  26694. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26695. * @example : just set a vertex particle position
  26696. * @returns the updated vertex
  26697. */
  26698. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26699. /**
  26700. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26701. * This does nothing and may be overwritten by the user.
  26702. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26703. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26704. * @param update the boolean update value actually passed to setParticles()
  26705. */
  26706. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26707. /**
  26708. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26709. * This will be passed three parameters.
  26710. * This does nothing and may be overwritten by the user.
  26711. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26712. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26713. * @param update the boolean update value actually passed to setParticles()
  26714. */
  26715. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26716. }
  26717. }
  26718. declare module "babylonjs/Particles/solidParticle" {
  26719. import { Nullable } from "babylonjs/types";
  26720. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26721. import { Color4 } from "babylonjs/Maths/math.color";
  26722. import { Mesh } from "babylonjs/Meshes/mesh";
  26723. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26724. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26725. import { Plane } from "babylonjs/Maths/math.plane";
  26726. /**
  26727. * Represents one particle of a solid particle system.
  26728. */
  26729. export class SolidParticle {
  26730. /**
  26731. * particle global index
  26732. */
  26733. idx: number;
  26734. /**
  26735. * particle identifier
  26736. */
  26737. id: number;
  26738. /**
  26739. * The color of the particle
  26740. */
  26741. color: Nullable<Color4>;
  26742. /**
  26743. * The world space position of the particle.
  26744. */
  26745. position: Vector3;
  26746. /**
  26747. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26748. */
  26749. rotation: Vector3;
  26750. /**
  26751. * The world space rotation quaternion of the particle.
  26752. */
  26753. rotationQuaternion: Nullable<Quaternion>;
  26754. /**
  26755. * The scaling of the particle.
  26756. */
  26757. scaling: Vector3;
  26758. /**
  26759. * The uvs of the particle.
  26760. */
  26761. uvs: Vector4;
  26762. /**
  26763. * The current speed of the particle.
  26764. */
  26765. velocity: Vector3;
  26766. /**
  26767. * The pivot point in the particle local space.
  26768. */
  26769. pivot: Vector3;
  26770. /**
  26771. * Must the particle be translated from its pivot point in its local space ?
  26772. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26773. * Default : false
  26774. */
  26775. translateFromPivot: boolean;
  26776. /**
  26777. * Is the particle active or not ?
  26778. */
  26779. alive: boolean;
  26780. /**
  26781. * Is the particle visible or not ?
  26782. */
  26783. isVisible: boolean;
  26784. /**
  26785. * Index of this particle in the global "positions" array (Internal use)
  26786. * @hidden
  26787. */
  26788. _pos: number;
  26789. /**
  26790. * @hidden Index of this particle in the global "indices" array (Internal use)
  26791. */
  26792. _ind: number;
  26793. /**
  26794. * @hidden ModelShape of this particle (Internal use)
  26795. */
  26796. _model: ModelShape;
  26797. /**
  26798. * ModelShape id of this particle
  26799. */
  26800. shapeId: number;
  26801. /**
  26802. * Index of the particle in its shape id
  26803. */
  26804. idxInShape: number;
  26805. /**
  26806. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26807. */
  26808. _modelBoundingInfo: BoundingInfo;
  26809. /**
  26810. * @hidden Particle BoundingInfo object (Internal use)
  26811. */
  26812. _boundingInfo: BoundingInfo;
  26813. /**
  26814. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26815. */
  26816. _sps: SolidParticleSystem;
  26817. /**
  26818. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26819. */
  26820. _stillInvisible: boolean;
  26821. /**
  26822. * @hidden Last computed particle rotation matrix
  26823. */
  26824. _rotationMatrix: number[];
  26825. /**
  26826. * Parent particle Id, if any.
  26827. * Default null.
  26828. */
  26829. parentId: Nullable<number>;
  26830. /**
  26831. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  26832. */
  26833. materialIndex: Nullable<number>;
  26834. /**
  26835. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26836. * The possible values are :
  26837. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26838. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26839. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26840. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26841. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26842. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26843. * */
  26844. cullingStrategy: number;
  26845. /**
  26846. * @hidden Internal global position in the SPS.
  26847. */
  26848. _globalPosition: Vector3;
  26849. /**
  26850. * Creates a Solid Particle object.
  26851. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26852. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26853. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26854. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26855. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26856. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26857. * @param shapeId (integer) is the model shape identifier in the SPS.
  26858. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26859. * @param sps defines the sps it is associated to
  26860. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26861. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  26862. */
  26863. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  26864. /**
  26865. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26866. * @param target the particle target
  26867. * @returns the current particle
  26868. */
  26869. copyToRef(target: SolidParticle): SolidParticle;
  26870. /**
  26871. * Legacy support, changed scale to scaling
  26872. */
  26873. /**
  26874. * Legacy support, changed scale to scaling
  26875. */
  26876. scale: Vector3;
  26877. /**
  26878. * Legacy support, changed quaternion to rotationQuaternion
  26879. */
  26880. /**
  26881. * Legacy support, changed quaternion to rotationQuaternion
  26882. */
  26883. quaternion: Nullable<Quaternion>;
  26884. /**
  26885. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26886. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26887. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26888. * @returns true if it intersects
  26889. */
  26890. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26891. /**
  26892. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26893. * A particle is in the frustum if its bounding box intersects the frustum
  26894. * @param frustumPlanes defines the frustum to test
  26895. * @returns true if the particle is in the frustum planes
  26896. */
  26897. isInFrustum(frustumPlanes: Plane[]): boolean;
  26898. /**
  26899. * get the rotation matrix of the particle
  26900. * @hidden
  26901. */
  26902. getRotationMatrix(m: Matrix): void;
  26903. }
  26904. /**
  26905. * Represents the shape of the model used by one particle of a solid particle system.
  26906. * SPS internal tool, don't use it manually.
  26907. */
  26908. export class ModelShape {
  26909. /**
  26910. * The shape id
  26911. * @hidden
  26912. */
  26913. shapeID: number;
  26914. /**
  26915. * flat array of model positions (internal use)
  26916. * @hidden
  26917. */
  26918. _shape: Vector3[];
  26919. /**
  26920. * flat array of model UVs (internal use)
  26921. * @hidden
  26922. */
  26923. _shapeUV: number[];
  26924. /**
  26925. * color array of the model
  26926. * @hidden
  26927. */
  26928. _shapeColors: number[];
  26929. /**
  26930. * indices array of the model
  26931. * @hidden
  26932. */
  26933. _indices: number[];
  26934. /**
  26935. * normals array of the model
  26936. * @hidden
  26937. */
  26938. _normals: number[];
  26939. /**
  26940. * length of the shape in the model indices array (internal use)
  26941. * @hidden
  26942. */
  26943. _indicesLength: number;
  26944. /**
  26945. * Custom position function (internal use)
  26946. * @hidden
  26947. */
  26948. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26949. /**
  26950. * Custom vertex function (internal use)
  26951. * @hidden
  26952. */
  26953. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26954. /**
  26955. * 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.
  26956. * SPS internal tool, don't use it manually.
  26957. * @hidden
  26958. */
  26959. 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>);
  26960. }
  26961. /**
  26962. * Represents a Depth Sorted Particle in the solid particle system.
  26963. * @hidden
  26964. */
  26965. export class DepthSortedParticle {
  26966. /**
  26967. * Index of the particle in the "indices" array
  26968. */
  26969. ind: number;
  26970. /**
  26971. * Length of the particle shape in the "indices" array
  26972. */
  26973. indicesLength: number;
  26974. /**
  26975. * Squared distance from the particle to the camera
  26976. */
  26977. sqDistance: number;
  26978. /**
  26979. * Material index when used with MultiMaterials
  26980. */
  26981. materialIndex: number;
  26982. /**
  26983. * Creates a new sorted particle
  26984. * @param materialIndex
  26985. */
  26986. constructor(ind: number, indLength: number, materialIndex: number);
  26987. }
  26988. }
  26989. declare module "babylonjs/Collisions/meshCollisionData" {
  26990. import { Collider } from "babylonjs/Collisions/collider";
  26991. import { Vector3 } from "babylonjs/Maths/math.vector";
  26992. import { Nullable } from "babylonjs/types";
  26993. import { Observer } from "babylonjs/Misc/observable";
  26994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26995. /**
  26996. * @hidden
  26997. */
  26998. export class _MeshCollisionData {
  26999. _checkCollisions: boolean;
  27000. _collisionMask: number;
  27001. _collisionGroup: number;
  27002. _collider: Nullable<Collider>;
  27003. _oldPositionForCollisions: Vector3;
  27004. _diffPositionForCollisions: Vector3;
  27005. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27006. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27007. }
  27008. }
  27009. declare module "babylonjs/Meshes/abstractMesh" {
  27010. import { Observable } from "babylonjs/Misc/observable";
  27011. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  27012. import { Camera } from "babylonjs/Cameras/camera";
  27013. import { Scene, IDisposable } from "babylonjs/scene";
  27014. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  27015. import { Node } from "babylonjs/node";
  27016. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  27017. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27019. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  27020. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27021. import { Material } from "babylonjs/Materials/material";
  27022. import { Light } from "babylonjs/Lights/light";
  27023. import { Skeleton } from "babylonjs/Bones/skeleton";
  27024. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  27025. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  27026. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27027. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  27028. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  27029. import { Plane } from "babylonjs/Maths/math.plane";
  27030. import { Ray } from "babylonjs/Culling/ray";
  27031. import { Collider } from "babylonjs/Collisions/collider";
  27032. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  27033. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  27034. /** @hidden */
  27035. class _FacetDataStorage {
  27036. facetPositions: Vector3[];
  27037. facetNormals: Vector3[];
  27038. facetPartitioning: number[][];
  27039. facetNb: number;
  27040. partitioningSubdivisions: number;
  27041. partitioningBBoxRatio: number;
  27042. facetDataEnabled: boolean;
  27043. facetParameters: any;
  27044. bbSize: Vector3;
  27045. subDiv: {
  27046. max: number;
  27047. X: number;
  27048. Y: number;
  27049. Z: number;
  27050. };
  27051. facetDepthSort: boolean;
  27052. facetDepthSortEnabled: boolean;
  27053. depthSortedIndices: IndicesArray;
  27054. depthSortedFacets: {
  27055. ind: number;
  27056. sqDistance: number;
  27057. }[];
  27058. facetDepthSortFunction: (f1: {
  27059. ind: number;
  27060. sqDistance: number;
  27061. }, f2: {
  27062. ind: number;
  27063. sqDistance: number;
  27064. }) => number;
  27065. facetDepthSortFrom: Vector3;
  27066. facetDepthSortOrigin: Vector3;
  27067. invertedMatrix: Matrix;
  27068. }
  27069. /**
  27070. * @hidden
  27071. **/
  27072. class _InternalAbstractMeshDataInfo {
  27073. _hasVertexAlpha: boolean;
  27074. _useVertexColors: boolean;
  27075. _numBoneInfluencers: number;
  27076. _applyFog: boolean;
  27077. _receiveShadows: boolean;
  27078. _facetData: _FacetDataStorage;
  27079. _visibility: number;
  27080. _skeleton: Nullable<Skeleton>;
  27081. _layerMask: number;
  27082. _computeBonesUsingShaders: boolean;
  27083. _isActive: boolean;
  27084. _onlyForInstances: boolean;
  27085. _isActiveIntermediate: boolean;
  27086. _onlyForInstancesIntermediate: boolean;
  27087. _actAsRegularMesh: boolean;
  27088. }
  27089. /**
  27090. * Class used to store all common mesh properties
  27091. */
  27092. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27093. /** No occlusion */
  27094. static OCCLUSION_TYPE_NONE: number;
  27095. /** Occlusion set to optimisitic */
  27096. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27097. /** Occlusion set to strict */
  27098. static OCCLUSION_TYPE_STRICT: number;
  27099. /** Use an accurante occlusion algorithm */
  27100. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27101. /** Use a conservative occlusion algorithm */
  27102. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27103. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27104. * Test order :
  27105. * Is the bounding sphere outside the frustum ?
  27106. * If not, are the bounding box vertices outside the frustum ?
  27107. * It not, then the cullable object is in the frustum.
  27108. */
  27109. static readonly CULLINGSTRATEGY_STANDARD: number;
  27110. /** Culling strategy : Bounding Sphere Only.
  27111. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27112. * It's also less accurate than the standard because some not visible objects can still be selected.
  27113. * Test : is the bounding sphere outside the frustum ?
  27114. * If not, then the cullable object is in the frustum.
  27115. */
  27116. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27117. /** Culling strategy : Optimistic Inclusion.
  27118. * This in an inclusion test first, then the standard exclusion test.
  27119. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27120. * 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.
  27121. * Anyway, it's as accurate as the standard strategy.
  27122. * Test :
  27123. * Is the cullable object bounding sphere center in the frustum ?
  27124. * If not, apply the default culling strategy.
  27125. */
  27126. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27127. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27128. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27129. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27130. * 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.
  27131. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27132. * Test :
  27133. * Is the cullable object bounding sphere center in the frustum ?
  27134. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27135. */
  27136. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27137. /**
  27138. * No billboard
  27139. */
  27140. static readonly BILLBOARDMODE_NONE: number;
  27141. /** Billboard on X axis */
  27142. static readonly BILLBOARDMODE_X: number;
  27143. /** Billboard on Y axis */
  27144. static readonly BILLBOARDMODE_Y: number;
  27145. /** Billboard on Z axis */
  27146. static readonly BILLBOARDMODE_Z: number;
  27147. /** Billboard on all axes */
  27148. static readonly BILLBOARDMODE_ALL: number;
  27149. /** Billboard on using position instead of orientation */
  27150. static readonly BILLBOARDMODE_USE_POSITION: number;
  27151. /** @hidden */
  27152. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27153. /**
  27154. * The culling strategy to use to check whether the mesh must be rendered or not.
  27155. * This value can be changed at any time and will be used on the next render mesh selection.
  27156. * The possible values are :
  27157. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27158. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27159. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27160. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27161. * Please read each static variable documentation to get details about the culling process.
  27162. * */
  27163. cullingStrategy: number;
  27164. /**
  27165. * Gets the number of facets in the mesh
  27166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27167. */
  27168. readonly facetNb: number;
  27169. /**
  27170. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27172. */
  27173. partitioningSubdivisions: number;
  27174. /**
  27175. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27176. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27178. */
  27179. partitioningBBoxRatio: number;
  27180. /**
  27181. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27182. * Works only for updatable meshes.
  27183. * Doesn't work with multi-materials
  27184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27185. */
  27186. mustDepthSortFacets: boolean;
  27187. /**
  27188. * The location (Vector3) where the facet depth sort must be computed from.
  27189. * By default, the active camera position.
  27190. * Used only when facet depth sort is enabled
  27191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27192. */
  27193. facetDepthSortFrom: Vector3;
  27194. /**
  27195. * gets a boolean indicating if facetData is enabled
  27196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27197. */
  27198. readonly isFacetDataEnabled: boolean;
  27199. /** @hidden */
  27200. _updateNonUniformScalingState(value: boolean): boolean;
  27201. /**
  27202. * An event triggered when this mesh collides with another one
  27203. */
  27204. onCollideObservable: Observable<AbstractMesh>;
  27205. /** Set a function to call when this mesh collides with another one */
  27206. onCollide: () => void;
  27207. /**
  27208. * An event triggered when the collision's position changes
  27209. */
  27210. onCollisionPositionChangeObservable: Observable<Vector3>;
  27211. /** Set a function to call when the collision's position changes */
  27212. onCollisionPositionChange: () => void;
  27213. /**
  27214. * An event triggered when material is changed
  27215. */
  27216. onMaterialChangedObservable: Observable<AbstractMesh>;
  27217. /**
  27218. * Gets or sets the orientation for POV movement & rotation
  27219. */
  27220. definedFacingForward: boolean;
  27221. /** @hidden */
  27222. _occlusionQuery: Nullable<WebGLQuery>;
  27223. /** @hidden */
  27224. _renderingGroup: Nullable<RenderingGroup>;
  27225. /**
  27226. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27227. */
  27228. /**
  27229. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27230. */
  27231. visibility: number;
  27232. /** Gets or sets the alpha index used to sort transparent meshes
  27233. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27234. */
  27235. alphaIndex: number;
  27236. /**
  27237. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27238. */
  27239. isVisible: boolean;
  27240. /**
  27241. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27242. */
  27243. isPickable: boolean;
  27244. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27245. showSubMeshesBoundingBox: boolean;
  27246. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27247. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27248. */
  27249. isBlocker: boolean;
  27250. /**
  27251. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27252. */
  27253. enablePointerMoveEvents: boolean;
  27254. /**
  27255. * Specifies the rendering group id for this mesh (0 by default)
  27256. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27257. */
  27258. renderingGroupId: number;
  27259. private _material;
  27260. /** Gets or sets current material */
  27261. material: Nullable<Material>;
  27262. /**
  27263. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27264. * @see http://doc.babylonjs.com/babylon101/shadows
  27265. */
  27266. receiveShadows: boolean;
  27267. /** Defines color to use when rendering outline */
  27268. outlineColor: Color3;
  27269. /** Define width to use when rendering outline */
  27270. outlineWidth: number;
  27271. /** Defines color to use when rendering overlay */
  27272. overlayColor: Color3;
  27273. /** Defines alpha to use when rendering overlay */
  27274. overlayAlpha: number;
  27275. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27276. hasVertexAlpha: boolean;
  27277. /** 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) */
  27278. useVertexColors: boolean;
  27279. /**
  27280. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27281. */
  27282. computeBonesUsingShaders: boolean;
  27283. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27284. numBoneInfluencers: number;
  27285. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27286. applyFog: boolean;
  27287. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27288. useOctreeForRenderingSelection: boolean;
  27289. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27290. useOctreeForPicking: boolean;
  27291. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27292. useOctreeForCollisions: boolean;
  27293. /**
  27294. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27295. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27296. */
  27297. layerMask: number;
  27298. /**
  27299. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27300. */
  27301. alwaysSelectAsActiveMesh: boolean;
  27302. /**
  27303. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27304. */
  27305. doNotSyncBoundingInfo: boolean;
  27306. /**
  27307. * Gets or sets the current action manager
  27308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27309. */
  27310. actionManager: Nullable<AbstractActionManager>;
  27311. private _meshCollisionData;
  27312. /**
  27313. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27315. */
  27316. ellipsoid: Vector3;
  27317. /**
  27318. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27319. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27320. */
  27321. ellipsoidOffset: Vector3;
  27322. /**
  27323. * Gets or sets a collision mask used to mask collisions (default is -1).
  27324. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27325. */
  27326. collisionMask: number;
  27327. /**
  27328. * Gets or sets the current collision group mask (-1 by default).
  27329. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27330. */
  27331. collisionGroup: number;
  27332. /**
  27333. * Defines edge width used when edgesRenderer is enabled
  27334. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27335. */
  27336. edgesWidth: number;
  27337. /**
  27338. * Defines edge color used when edgesRenderer is enabled
  27339. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27340. */
  27341. edgesColor: Color4;
  27342. /** @hidden */
  27343. _edgesRenderer: Nullable<IEdgesRenderer>;
  27344. /** @hidden */
  27345. _masterMesh: Nullable<AbstractMesh>;
  27346. /** @hidden */
  27347. _boundingInfo: Nullable<BoundingInfo>;
  27348. /** @hidden */
  27349. _renderId: number;
  27350. /**
  27351. * Gets or sets the list of subMeshes
  27352. * @see http://doc.babylonjs.com/how_to/multi_materials
  27353. */
  27354. subMeshes: SubMesh[];
  27355. /** @hidden */
  27356. _intersectionsInProgress: AbstractMesh[];
  27357. /** @hidden */
  27358. _unIndexed: boolean;
  27359. /** @hidden */
  27360. _lightSources: Light[];
  27361. /** Gets the list of lights affecting that mesh */
  27362. readonly lightSources: Light[];
  27363. /** @hidden */
  27364. readonly _positions: Nullable<Vector3[]>;
  27365. /** @hidden */
  27366. _waitingData: {
  27367. lods: Nullable<any>;
  27368. actions: Nullable<any>;
  27369. freezeWorldMatrix: Nullable<boolean>;
  27370. };
  27371. /** @hidden */
  27372. _bonesTransformMatrices: Nullable<Float32Array>;
  27373. /** @hidden */
  27374. _transformMatrixTexture: Nullable<RawTexture>;
  27375. /**
  27376. * Gets or sets a skeleton to apply skining transformations
  27377. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27378. */
  27379. skeleton: Nullable<Skeleton>;
  27380. /**
  27381. * An event triggered when the mesh is rebuilt.
  27382. */
  27383. onRebuildObservable: Observable<AbstractMesh>;
  27384. /**
  27385. * Creates a new AbstractMesh
  27386. * @param name defines the name of the mesh
  27387. * @param scene defines the hosting scene
  27388. */
  27389. constructor(name: string, scene?: Nullable<Scene>);
  27390. /**
  27391. * Returns the string "AbstractMesh"
  27392. * @returns "AbstractMesh"
  27393. */
  27394. getClassName(): string;
  27395. /**
  27396. * Gets a string representation of the current mesh
  27397. * @param fullDetails defines a boolean indicating if full details must be included
  27398. * @returns a string representation of the current mesh
  27399. */
  27400. toString(fullDetails?: boolean): string;
  27401. /**
  27402. * @hidden
  27403. */
  27404. protected _getEffectiveParent(): Nullable<Node>;
  27405. /** @hidden */
  27406. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27407. /** @hidden */
  27408. _rebuild(): void;
  27409. /** @hidden */
  27410. _resyncLightSources(): void;
  27411. /** @hidden */
  27412. _resyncLightSource(light: Light): void;
  27413. /** @hidden */
  27414. _unBindEffect(): void;
  27415. /** @hidden */
  27416. _removeLightSource(light: Light, dispose: boolean): void;
  27417. private _markSubMeshesAsDirty;
  27418. /** @hidden */
  27419. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27420. /** @hidden */
  27421. _markSubMeshesAsAttributesDirty(): void;
  27422. /** @hidden */
  27423. _markSubMeshesAsMiscDirty(): void;
  27424. /**
  27425. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27426. */
  27427. scaling: Vector3;
  27428. /**
  27429. * Returns true if the mesh is blocked. Implemented by child classes
  27430. */
  27431. readonly isBlocked: boolean;
  27432. /**
  27433. * Returns the mesh itself by default. Implemented by child classes
  27434. * @param camera defines the camera to use to pick the right LOD level
  27435. * @returns the currentAbstractMesh
  27436. */
  27437. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27438. /**
  27439. * Returns 0 by default. Implemented by child classes
  27440. * @returns an integer
  27441. */
  27442. getTotalVertices(): number;
  27443. /**
  27444. * Returns a positive integer : the total number of indices in this mesh geometry.
  27445. * @returns the numner of indices or zero if the mesh has no geometry.
  27446. */
  27447. getTotalIndices(): number;
  27448. /**
  27449. * Returns null by default. Implemented by child classes
  27450. * @returns null
  27451. */
  27452. getIndices(): Nullable<IndicesArray>;
  27453. /**
  27454. * Returns the array of the requested vertex data kind. Implemented by child classes
  27455. * @param kind defines the vertex data kind to use
  27456. * @returns null
  27457. */
  27458. getVerticesData(kind: string): Nullable<FloatArray>;
  27459. /**
  27460. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27461. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27462. * Note that a new underlying VertexBuffer object is created each call.
  27463. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27464. * @param kind defines vertex data kind:
  27465. * * VertexBuffer.PositionKind
  27466. * * VertexBuffer.UVKind
  27467. * * VertexBuffer.UV2Kind
  27468. * * VertexBuffer.UV3Kind
  27469. * * VertexBuffer.UV4Kind
  27470. * * VertexBuffer.UV5Kind
  27471. * * VertexBuffer.UV6Kind
  27472. * * VertexBuffer.ColorKind
  27473. * * VertexBuffer.MatricesIndicesKind
  27474. * * VertexBuffer.MatricesIndicesExtraKind
  27475. * * VertexBuffer.MatricesWeightsKind
  27476. * * VertexBuffer.MatricesWeightsExtraKind
  27477. * @param data defines the data source
  27478. * @param updatable defines if the data must be flagged as updatable (or static)
  27479. * @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
  27480. * @returns the current mesh
  27481. */
  27482. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27483. /**
  27484. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27485. * If the mesh has no geometry, it is simply returned as it is.
  27486. * @param kind defines vertex data kind:
  27487. * * VertexBuffer.PositionKind
  27488. * * VertexBuffer.UVKind
  27489. * * VertexBuffer.UV2Kind
  27490. * * VertexBuffer.UV3Kind
  27491. * * VertexBuffer.UV4Kind
  27492. * * VertexBuffer.UV5Kind
  27493. * * VertexBuffer.UV6Kind
  27494. * * VertexBuffer.ColorKind
  27495. * * VertexBuffer.MatricesIndicesKind
  27496. * * VertexBuffer.MatricesIndicesExtraKind
  27497. * * VertexBuffer.MatricesWeightsKind
  27498. * * VertexBuffer.MatricesWeightsExtraKind
  27499. * @param data defines the data source
  27500. * @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
  27501. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27502. * @returns the current mesh
  27503. */
  27504. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27505. /**
  27506. * Sets the mesh indices,
  27507. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27508. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27509. * @param totalVertices Defines the total number of vertices
  27510. * @returns the current mesh
  27511. */
  27512. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27513. /**
  27514. * Gets a boolean indicating if specific vertex data is present
  27515. * @param kind defines the vertex data kind to use
  27516. * @returns true is data kind is present
  27517. */
  27518. isVerticesDataPresent(kind: string): boolean;
  27519. /**
  27520. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27521. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27522. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27523. * @returns a BoundingInfo
  27524. */
  27525. getBoundingInfo(): BoundingInfo;
  27526. /**
  27527. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27528. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27529. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27530. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27531. * @returns the current mesh
  27532. */
  27533. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27534. /**
  27535. * Overwrite the current bounding info
  27536. * @param boundingInfo defines the new bounding info
  27537. * @returns the current mesh
  27538. */
  27539. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27540. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27541. readonly useBones: boolean;
  27542. /** @hidden */
  27543. _preActivate(): void;
  27544. /** @hidden */
  27545. _preActivateForIntermediateRendering(renderId: number): void;
  27546. /** @hidden */
  27547. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27548. /** @hidden */
  27549. _postActivate(): void;
  27550. /** @hidden */
  27551. _freeze(): void;
  27552. /** @hidden */
  27553. _unFreeze(): void;
  27554. /**
  27555. * Gets the current world matrix
  27556. * @returns a Matrix
  27557. */
  27558. getWorldMatrix(): Matrix;
  27559. /** @hidden */
  27560. _getWorldMatrixDeterminant(): number;
  27561. /**
  27562. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27563. */
  27564. readonly isAnInstance: boolean;
  27565. /**
  27566. * Gets a boolean indicating if this mesh has instances
  27567. */
  27568. readonly hasInstances: boolean;
  27569. /**
  27570. * Perform relative position change from the point of view of behind the front of the mesh.
  27571. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27572. * Supports definition of mesh facing forward or backward
  27573. * @param amountRight defines the distance on the right axis
  27574. * @param amountUp defines the distance on the up axis
  27575. * @param amountForward defines the distance on the forward axis
  27576. * @returns the current mesh
  27577. */
  27578. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27579. /**
  27580. * Calculate relative position change from the point of view of behind the front of the mesh.
  27581. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27582. * Supports definition of mesh facing forward or backward
  27583. * @param amountRight defines the distance on the right axis
  27584. * @param amountUp defines the distance on the up axis
  27585. * @param amountForward defines the distance on the forward axis
  27586. * @returns the new displacement vector
  27587. */
  27588. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27589. /**
  27590. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27591. * Supports definition of mesh facing forward or backward
  27592. * @param flipBack defines the flip
  27593. * @param twirlClockwise defines the twirl
  27594. * @param tiltRight defines the tilt
  27595. * @returns the current mesh
  27596. */
  27597. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27598. /**
  27599. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27600. * Supports definition of mesh facing forward or backward.
  27601. * @param flipBack defines the flip
  27602. * @param twirlClockwise defines the twirl
  27603. * @param tiltRight defines the tilt
  27604. * @returns the new rotation vector
  27605. */
  27606. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27607. /**
  27608. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27609. * This means the mesh underlying bounding box and sphere are recomputed.
  27610. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27611. * @returns the current mesh
  27612. */
  27613. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27614. /** @hidden */
  27615. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27616. /** @hidden */
  27617. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27618. /** @hidden */
  27619. _updateBoundingInfo(): AbstractMesh;
  27620. /** @hidden */
  27621. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27622. /** @hidden */
  27623. protected _afterComputeWorldMatrix(): void;
  27624. /** @hidden */
  27625. readonly _effectiveMesh: AbstractMesh;
  27626. /**
  27627. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27628. * A mesh is in the frustum if its bounding box intersects the frustum
  27629. * @param frustumPlanes defines the frustum to test
  27630. * @returns true if the mesh is in the frustum planes
  27631. */
  27632. isInFrustum(frustumPlanes: Plane[]): boolean;
  27633. /**
  27634. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27635. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27636. * @param frustumPlanes defines the frustum to test
  27637. * @returns true if the mesh is completely in the frustum planes
  27638. */
  27639. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27640. /**
  27641. * True if the mesh intersects another mesh or a SolidParticle object
  27642. * @param mesh defines a target mesh or SolidParticle to test
  27643. * @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)
  27644. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27645. * @returns true if there is an intersection
  27646. */
  27647. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27648. /**
  27649. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27650. * @param point defines the point to test
  27651. * @returns true if there is an intersection
  27652. */
  27653. intersectsPoint(point: Vector3): boolean;
  27654. /**
  27655. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27656. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27657. */
  27658. checkCollisions: boolean;
  27659. /**
  27660. * Gets Collider object used to compute collisions (not physics)
  27661. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27662. */
  27663. readonly collider: Nullable<Collider>;
  27664. /**
  27665. * Move the mesh using collision engine
  27666. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27667. * @param displacement defines the requested displacement vector
  27668. * @returns the current mesh
  27669. */
  27670. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27671. private _onCollisionPositionChange;
  27672. /** @hidden */
  27673. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27674. /** @hidden */
  27675. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27676. /** @hidden */
  27677. _checkCollision(collider: Collider): AbstractMesh;
  27678. /** @hidden */
  27679. _generatePointsArray(): boolean;
  27680. /**
  27681. * Checks if the passed Ray intersects with the mesh
  27682. * @param ray defines the ray to use
  27683. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27684. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27685. * @returns the picking info
  27686. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27687. */
  27688. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27689. /**
  27690. * Clones the current mesh
  27691. * @param name defines the mesh name
  27692. * @param newParent defines the new mesh parent
  27693. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27694. * @returns the new mesh
  27695. */
  27696. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27697. /**
  27698. * Disposes all the submeshes of the current meshnp
  27699. * @returns the current mesh
  27700. */
  27701. releaseSubMeshes(): AbstractMesh;
  27702. /**
  27703. * Releases resources associated with this abstract mesh.
  27704. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27705. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27706. */
  27707. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27708. /**
  27709. * Adds the passed mesh as a child to the current mesh
  27710. * @param mesh defines the child mesh
  27711. * @returns the current mesh
  27712. */
  27713. addChild(mesh: AbstractMesh): AbstractMesh;
  27714. /**
  27715. * Removes the passed mesh from the current mesh children list
  27716. * @param mesh defines the child mesh
  27717. * @returns the current mesh
  27718. */
  27719. removeChild(mesh: AbstractMesh): AbstractMesh;
  27720. /** @hidden */
  27721. private _initFacetData;
  27722. /**
  27723. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27724. * This method can be called within the render loop.
  27725. * 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
  27726. * @returns the current mesh
  27727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27728. */
  27729. updateFacetData(): AbstractMesh;
  27730. /**
  27731. * Returns the facetLocalNormals array.
  27732. * The normals are expressed in the mesh local spac
  27733. * @returns an array of Vector3
  27734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27735. */
  27736. getFacetLocalNormals(): Vector3[];
  27737. /**
  27738. * Returns the facetLocalPositions array.
  27739. * The facet positions are expressed in the mesh local space
  27740. * @returns an array of Vector3
  27741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27742. */
  27743. getFacetLocalPositions(): Vector3[];
  27744. /**
  27745. * Returns the facetLocalPartioning array
  27746. * @returns an array of array of numbers
  27747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27748. */
  27749. getFacetLocalPartitioning(): number[][];
  27750. /**
  27751. * Returns the i-th facet position in the world system.
  27752. * This method allocates a new Vector3 per call
  27753. * @param i defines the facet index
  27754. * @returns a new Vector3
  27755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27756. */
  27757. getFacetPosition(i: number): Vector3;
  27758. /**
  27759. * Sets the reference Vector3 with the i-th facet position in the world system
  27760. * @param i defines the facet index
  27761. * @param ref defines the target vector
  27762. * @returns the current mesh
  27763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27764. */
  27765. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27766. /**
  27767. * Returns the i-th facet normal in the world system.
  27768. * This method allocates a new Vector3 per call
  27769. * @param i defines the facet index
  27770. * @returns a new Vector3
  27771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27772. */
  27773. getFacetNormal(i: number): Vector3;
  27774. /**
  27775. * Sets the reference Vector3 with the i-th facet normal in the world system
  27776. * @param i defines the facet index
  27777. * @param ref defines the target vector
  27778. * @returns the current mesh
  27779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27780. */
  27781. getFacetNormalToRef(i: number, ref: Vector3): this;
  27782. /**
  27783. * 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)
  27784. * @param x defines x coordinate
  27785. * @param y defines y coordinate
  27786. * @param z defines z coordinate
  27787. * @returns the array of facet indexes
  27788. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27789. */
  27790. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27791. /**
  27792. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27793. * @param projected sets as the (x,y,z) world projection on the facet
  27794. * @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
  27795. * @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
  27796. * @param x defines x coordinate
  27797. * @param y defines y coordinate
  27798. * @param z defines z coordinate
  27799. * @returns the face index if found (or null instead)
  27800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27801. */
  27802. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27803. /**
  27804. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27805. * @param projected sets as the (x,y,z) local projection on the facet
  27806. * @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
  27807. * @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
  27808. * @param x defines x coordinate
  27809. * @param y defines y coordinate
  27810. * @param z defines z coordinate
  27811. * @returns the face index if found (or null instead)
  27812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27813. */
  27814. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27815. /**
  27816. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27817. * @returns the parameters
  27818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27819. */
  27820. getFacetDataParameters(): any;
  27821. /**
  27822. * Disables the feature FacetData and frees the related memory
  27823. * @returns the current mesh
  27824. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27825. */
  27826. disableFacetData(): AbstractMesh;
  27827. /**
  27828. * Updates the AbstractMesh indices array
  27829. * @param indices defines the data source
  27830. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27831. * @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)
  27832. * @returns the current mesh
  27833. */
  27834. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27835. /**
  27836. * Creates new normals data for the mesh
  27837. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27838. * @returns the current mesh
  27839. */
  27840. createNormals(updatable: boolean): AbstractMesh;
  27841. /**
  27842. * Align the mesh with a normal
  27843. * @param normal defines the normal to use
  27844. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27845. * @returns the current mesh
  27846. */
  27847. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27848. /** @hidden */
  27849. _checkOcclusionQuery(): boolean;
  27850. /**
  27851. * Disables the mesh edge rendering mode
  27852. * @returns the currentAbstractMesh
  27853. */
  27854. disableEdgesRendering(): AbstractMesh;
  27855. /**
  27856. * Enables the edge rendering mode on the mesh.
  27857. * This mode makes the mesh edges visible
  27858. * @param epsilon defines the maximal distance between two angles to detect a face
  27859. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27860. * @returns the currentAbstractMesh
  27861. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27862. */
  27863. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27864. }
  27865. }
  27866. declare module "babylonjs/Actions/actionEvent" {
  27867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27868. import { Nullable } from "babylonjs/types";
  27869. import { Sprite } from "babylonjs/Sprites/sprite";
  27870. import { Scene } from "babylonjs/scene";
  27871. import { Vector2 } from "babylonjs/Maths/math.vector";
  27872. /**
  27873. * Interface used to define ActionEvent
  27874. */
  27875. export interface IActionEvent {
  27876. /** The mesh or sprite that triggered the action */
  27877. source: any;
  27878. /** The X mouse cursor position at the time of the event */
  27879. pointerX: number;
  27880. /** The Y mouse cursor position at the time of the event */
  27881. pointerY: number;
  27882. /** The mesh that is currently pointed at (can be null) */
  27883. meshUnderPointer: Nullable<AbstractMesh>;
  27884. /** the original (browser) event that triggered the ActionEvent */
  27885. sourceEvent?: any;
  27886. /** additional data for the event */
  27887. additionalData?: any;
  27888. }
  27889. /**
  27890. * ActionEvent is the event being sent when an action is triggered.
  27891. */
  27892. export class ActionEvent implements IActionEvent {
  27893. /** The mesh or sprite that triggered the action */
  27894. source: any;
  27895. /** The X mouse cursor position at the time of the event */
  27896. pointerX: number;
  27897. /** The Y mouse cursor position at the time of the event */
  27898. pointerY: number;
  27899. /** The mesh that is currently pointed at (can be null) */
  27900. meshUnderPointer: Nullable<AbstractMesh>;
  27901. /** the original (browser) event that triggered the ActionEvent */
  27902. sourceEvent?: any;
  27903. /** additional data for the event */
  27904. additionalData?: any;
  27905. /**
  27906. * Creates a new ActionEvent
  27907. * @param source The mesh or sprite that triggered the action
  27908. * @param pointerX The X mouse cursor position at the time of the event
  27909. * @param pointerY The Y mouse cursor position at the time of the event
  27910. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27911. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27912. * @param additionalData additional data for the event
  27913. */
  27914. constructor(
  27915. /** The mesh or sprite that triggered the action */
  27916. source: any,
  27917. /** The X mouse cursor position at the time of the event */
  27918. pointerX: number,
  27919. /** The Y mouse cursor position at the time of the event */
  27920. pointerY: number,
  27921. /** The mesh that is currently pointed at (can be null) */
  27922. meshUnderPointer: Nullable<AbstractMesh>,
  27923. /** the original (browser) event that triggered the ActionEvent */
  27924. sourceEvent?: any,
  27925. /** additional data for the event */
  27926. additionalData?: any);
  27927. /**
  27928. * Helper function to auto-create an ActionEvent from a source mesh.
  27929. * @param source The source mesh that triggered the event
  27930. * @param evt The original (browser) event
  27931. * @param additionalData additional data for the event
  27932. * @returns the new ActionEvent
  27933. */
  27934. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27935. /**
  27936. * Helper function to auto-create an ActionEvent from a source sprite
  27937. * @param source The source sprite that triggered the event
  27938. * @param scene Scene associated with the sprite
  27939. * @param evt The original (browser) event
  27940. * @param additionalData additional data for the event
  27941. * @returns the new ActionEvent
  27942. */
  27943. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27944. /**
  27945. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27946. * @param scene the scene where the event occurred
  27947. * @param evt The original (browser) event
  27948. * @returns the new ActionEvent
  27949. */
  27950. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27951. /**
  27952. * Helper function to auto-create an ActionEvent from a primitive
  27953. * @param prim defines the target primitive
  27954. * @param pointerPos defines the pointer position
  27955. * @param evt The original (browser) event
  27956. * @param additionalData additional data for the event
  27957. * @returns the new ActionEvent
  27958. */
  27959. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27960. }
  27961. }
  27962. declare module "babylonjs/Actions/abstractActionManager" {
  27963. import { IDisposable } from "babylonjs/scene";
  27964. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27965. import { IAction } from "babylonjs/Actions/action";
  27966. import { Nullable } from "babylonjs/types";
  27967. /**
  27968. * Abstract class used to decouple action Manager from scene and meshes.
  27969. * Do not instantiate.
  27970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27971. */
  27972. export abstract class AbstractActionManager implements IDisposable {
  27973. /** Gets the list of active triggers */
  27974. static Triggers: {
  27975. [key: string]: number;
  27976. };
  27977. /** Gets the cursor to use when hovering items */
  27978. hoverCursor: string;
  27979. /** Gets the list of actions */
  27980. actions: IAction[];
  27981. /**
  27982. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27983. */
  27984. isRecursive: boolean;
  27985. /**
  27986. * Releases all associated resources
  27987. */
  27988. abstract dispose(): void;
  27989. /**
  27990. * Does this action manager has pointer triggers
  27991. */
  27992. abstract readonly hasPointerTriggers: boolean;
  27993. /**
  27994. * Does this action manager has pick triggers
  27995. */
  27996. abstract readonly hasPickTriggers: boolean;
  27997. /**
  27998. * Process a specific trigger
  27999. * @param trigger defines the trigger to process
  28000. * @param evt defines the event details to be processed
  28001. */
  28002. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28003. /**
  28004. * Does this action manager handles actions of any of the given triggers
  28005. * @param triggers defines the triggers to be tested
  28006. * @return a boolean indicating whether one (or more) of the triggers is handled
  28007. */
  28008. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28009. /**
  28010. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28011. * speed.
  28012. * @param triggerA defines the trigger to be tested
  28013. * @param triggerB defines the trigger to be tested
  28014. * @return a boolean indicating whether one (or more) of the triggers is handled
  28015. */
  28016. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28017. /**
  28018. * Does this action manager handles actions of a given trigger
  28019. * @param trigger defines the trigger to be tested
  28020. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28021. * @return whether the trigger is handled
  28022. */
  28023. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28024. /**
  28025. * Serialize this manager to a JSON object
  28026. * @param name defines the property name to store this manager
  28027. * @returns a JSON representation of this manager
  28028. */
  28029. abstract serialize(name: string): any;
  28030. /**
  28031. * Registers an action to this action manager
  28032. * @param action defines the action to be registered
  28033. * @return the action amended (prepared) after registration
  28034. */
  28035. abstract registerAction(action: IAction): Nullable<IAction>;
  28036. /**
  28037. * Unregisters an action to this action manager
  28038. * @param action defines the action to be unregistered
  28039. * @return a boolean indicating whether the action has been unregistered
  28040. */
  28041. abstract unregisterAction(action: IAction): Boolean;
  28042. /**
  28043. * Does exist one action manager with at least one trigger
  28044. **/
  28045. static readonly HasTriggers: boolean;
  28046. /**
  28047. * Does exist one action manager with at least one pick trigger
  28048. **/
  28049. static readonly HasPickTriggers: boolean;
  28050. /**
  28051. * Does exist one action manager that handles actions of a given trigger
  28052. * @param trigger defines the trigger to be tested
  28053. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28054. **/
  28055. static HasSpecificTrigger(trigger: number): boolean;
  28056. }
  28057. }
  28058. declare module "babylonjs/node" {
  28059. import { Scene } from "babylonjs/scene";
  28060. import { Nullable } from "babylonjs/types";
  28061. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28062. import { Engine } from "babylonjs/Engines/engine";
  28063. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  28064. import { Observable } from "babylonjs/Misc/observable";
  28065. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28066. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28067. import { Animatable } from "babylonjs/Animations/animatable";
  28068. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  28069. import { Animation } from "babylonjs/Animations/animation";
  28070. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28072. /**
  28073. * Defines how a node can be built from a string name.
  28074. */
  28075. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28076. /**
  28077. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28078. */
  28079. export class Node implements IBehaviorAware<Node> {
  28080. /** @hidden */
  28081. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  28082. private static _NodeConstructors;
  28083. /**
  28084. * Add a new node constructor
  28085. * @param type defines the type name of the node to construct
  28086. * @param constructorFunc defines the constructor function
  28087. */
  28088. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28089. /**
  28090. * Returns a node constructor based on type name
  28091. * @param type defines the type name
  28092. * @param name defines the new node name
  28093. * @param scene defines the hosting scene
  28094. * @param options defines optional options to transmit to constructors
  28095. * @returns the new constructor or null
  28096. */
  28097. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28098. /**
  28099. * Gets or sets the name of the node
  28100. */
  28101. name: string;
  28102. /**
  28103. * Gets or sets the id of the node
  28104. */
  28105. id: string;
  28106. /**
  28107. * Gets or sets the unique id of the node
  28108. */
  28109. uniqueId: number;
  28110. /**
  28111. * Gets or sets a string used to store user defined state for the node
  28112. */
  28113. state: string;
  28114. /**
  28115. * Gets or sets an object used to store user defined information for the node
  28116. */
  28117. metadata: any;
  28118. /**
  28119. * For internal use only. Please do not use.
  28120. */
  28121. reservedDataStore: any;
  28122. /**
  28123. * List of inspectable custom properties (used by the Inspector)
  28124. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28125. */
  28126. inspectableCustomProperties: IInspectable[];
  28127. private _doNotSerialize;
  28128. /**
  28129. * Gets or sets a boolean used to define if the node must be serialized
  28130. */
  28131. doNotSerialize: boolean;
  28132. /** @hidden */
  28133. _isDisposed: boolean;
  28134. /**
  28135. * Gets a list of Animations associated with the node
  28136. */
  28137. animations: import("babylonjs/Animations/animation").Animation[];
  28138. protected _ranges: {
  28139. [name: string]: Nullable<AnimationRange>;
  28140. };
  28141. /**
  28142. * Callback raised when the node is ready to be used
  28143. */
  28144. onReady: Nullable<(node: Node) => void>;
  28145. private _isEnabled;
  28146. private _isParentEnabled;
  28147. private _isReady;
  28148. /** @hidden */
  28149. _currentRenderId: number;
  28150. private _parentUpdateId;
  28151. /** @hidden */
  28152. _childUpdateId: number;
  28153. /** @hidden */
  28154. _waitingParentId: Nullable<string>;
  28155. /** @hidden */
  28156. _scene: Scene;
  28157. /** @hidden */
  28158. _cache: any;
  28159. private _parentNode;
  28160. private _children;
  28161. /** @hidden */
  28162. _worldMatrix: Matrix;
  28163. /** @hidden */
  28164. _worldMatrixDeterminant: number;
  28165. /** @hidden */
  28166. _worldMatrixDeterminantIsDirty: boolean;
  28167. /** @hidden */
  28168. private _sceneRootNodesIndex;
  28169. /**
  28170. * Gets a boolean indicating if the node has been disposed
  28171. * @returns true if the node was disposed
  28172. */
  28173. isDisposed(): boolean;
  28174. /**
  28175. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28176. * @see https://doc.babylonjs.com/how_to/parenting
  28177. */
  28178. parent: Nullable<Node>;
  28179. /** @hidden */
  28180. _addToSceneRootNodes(): void;
  28181. /** @hidden */
  28182. _removeFromSceneRootNodes(): void;
  28183. private _animationPropertiesOverride;
  28184. /**
  28185. * Gets or sets the animation properties override
  28186. */
  28187. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28188. /**
  28189. * Gets a string idenfifying the name of the class
  28190. * @returns "Node" string
  28191. */
  28192. getClassName(): string;
  28193. /** @hidden */
  28194. readonly _isNode: boolean;
  28195. /**
  28196. * An event triggered when the mesh is disposed
  28197. */
  28198. onDisposeObservable: Observable<Node>;
  28199. private _onDisposeObserver;
  28200. /**
  28201. * Sets a callback that will be raised when the node will be disposed
  28202. */
  28203. onDispose: () => void;
  28204. /**
  28205. * Creates a new Node
  28206. * @param name the name and id to be given to this node
  28207. * @param scene the scene this node will be added to
  28208. */
  28209. constructor(name: string, scene?: Nullable<Scene>);
  28210. /**
  28211. * Gets the scene of the node
  28212. * @returns a scene
  28213. */
  28214. getScene(): Scene;
  28215. /**
  28216. * Gets the engine of the node
  28217. * @returns a Engine
  28218. */
  28219. getEngine(): Engine;
  28220. private _behaviors;
  28221. /**
  28222. * Attach a behavior to the node
  28223. * @see http://doc.babylonjs.com/features/behaviour
  28224. * @param behavior defines the behavior to attach
  28225. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28226. * @returns the current Node
  28227. */
  28228. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28229. /**
  28230. * Remove an attached behavior
  28231. * @see http://doc.babylonjs.com/features/behaviour
  28232. * @param behavior defines the behavior to attach
  28233. * @returns the current Node
  28234. */
  28235. removeBehavior(behavior: Behavior<Node>): Node;
  28236. /**
  28237. * Gets the list of attached behaviors
  28238. * @see http://doc.babylonjs.com/features/behaviour
  28239. */
  28240. readonly behaviors: Behavior<Node>[];
  28241. /**
  28242. * Gets an attached behavior by name
  28243. * @param name defines the name of the behavior to look for
  28244. * @see http://doc.babylonjs.com/features/behaviour
  28245. * @returns null if behavior was not found else the requested behavior
  28246. */
  28247. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28248. /**
  28249. * Returns the latest update of the World matrix
  28250. * @returns a Matrix
  28251. */
  28252. getWorldMatrix(): Matrix;
  28253. /** @hidden */
  28254. _getWorldMatrixDeterminant(): number;
  28255. /**
  28256. * Returns directly the latest state of the mesh World matrix.
  28257. * A Matrix is returned.
  28258. */
  28259. readonly worldMatrixFromCache: Matrix;
  28260. /** @hidden */
  28261. _initCache(): void;
  28262. /** @hidden */
  28263. updateCache(force?: boolean): void;
  28264. /** @hidden */
  28265. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28266. /** @hidden */
  28267. _updateCache(ignoreParentClass?: boolean): void;
  28268. /** @hidden */
  28269. _isSynchronized(): boolean;
  28270. /** @hidden */
  28271. _markSyncedWithParent(): void;
  28272. /** @hidden */
  28273. isSynchronizedWithParent(): boolean;
  28274. /** @hidden */
  28275. isSynchronized(): boolean;
  28276. /**
  28277. * Is this node ready to be used/rendered
  28278. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28279. * @return true if the node is ready
  28280. */
  28281. isReady(completeCheck?: boolean): boolean;
  28282. /**
  28283. * Is this node enabled?
  28284. * 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
  28285. * @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
  28286. * @return whether this node (and its parent) is enabled
  28287. */
  28288. isEnabled(checkAncestors?: boolean): boolean;
  28289. /** @hidden */
  28290. protected _syncParentEnabledState(): void;
  28291. /**
  28292. * Set the enabled state of this node
  28293. * @param value defines the new enabled state
  28294. */
  28295. setEnabled(value: boolean): void;
  28296. /**
  28297. * Is this node a descendant of the given node?
  28298. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28299. * @param ancestor defines the parent node to inspect
  28300. * @returns a boolean indicating if this node is a descendant of the given node
  28301. */
  28302. isDescendantOf(ancestor: Node): boolean;
  28303. /** @hidden */
  28304. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28305. /**
  28306. * Will return all nodes that have this node as ascendant
  28307. * @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
  28308. * @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
  28309. * @return all children nodes of all types
  28310. */
  28311. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28312. /**
  28313. * Get all child-meshes of this node
  28314. * @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)
  28315. * @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
  28316. * @returns an array of AbstractMesh
  28317. */
  28318. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28319. /**
  28320. * Get all direct children of this node
  28321. * @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
  28322. * @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)
  28323. * @returns an array of Node
  28324. */
  28325. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28326. /** @hidden */
  28327. _setReady(state: boolean): void;
  28328. /**
  28329. * Get an animation by name
  28330. * @param name defines the name of the animation to look for
  28331. * @returns null if not found else the requested animation
  28332. */
  28333. getAnimationByName(name: string): Nullable<Animation>;
  28334. /**
  28335. * Creates an animation range for this node
  28336. * @param name defines the name of the range
  28337. * @param from defines the starting key
  28338. * @param to defines the end key
  28339. */
  28340. createAnimationRange(name: string, from: number, to: number): void;
  28341. /**
  28342. * Delete a specific animation range
  28343. * @param name defines the name of the range to delete
  28344. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28345. */
  28346. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28347. /**
  28348. * Get an animation range by name
  28349. * @param name defines the name of the animation range to look for
  28350. * @returns null if not found else the requested animation range
  28351. */
  28352. getAnimationRange(name: string): Nullable<AnimationRange>;
  28353. /**
  28354. * Gets the list of all animation ranges defined on this node
  28355. * @returns an array
  28356. */
  28357. getAnimationRanges(): Nullable<AnimationRange>[];
  28358. /**
  28359. * Will start the animation sequence
  28360. * @param name defines the range frames for animation sequence
  28361. * @param loop defines if the animation should loop (false by default)
  28362. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28363. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28364. * @returns the object created for this animation. If range does not exist, it will return null
  28365. */
  28366. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28367. /**
  28368. * Serialize animation ranges into a JSON compatible object
  28369. * @returns serialization object
  28370. */
  28371. serializeAnimationRanges(): any;
  28372. /**
  28373. * Computes the world matrix of the node
  28374. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28375. * @returns the world matrix
  28376. */
  28377. computeWorldMatrix(force?: boolean): Matrix;
  28378. /**
  28379. * Releases resources associated with this node.
  28380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28382. */
  28383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28384. /**
  28385. * Parse animation range data from a serialization object and store them into a given node
  28386. * @param node defines where to store the animation ranges
  28387. * @param parsedNode defines the serialization object to read data from
  28388. * @param scene defines the hosting scene
  28389. */
  28390. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28391. /**
  28392. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28393. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28394. * @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
  28395. * @returns the new bounding vectors
  28396. */
  28397. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28398. min: Vector3;
  28399. max: Vector3;
  28400. };
  28401. }
  28402. }
  28403. declare module "babylonjs/Animations/animation" {
  28404. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28405. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28406. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28407. import { Nullable } from "babylonjs/types";
  28408. import { Scene } from "babylonjs/scene";
  28409. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28410. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28411. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28412. import { Node } from "babylonjs/node";
  28413. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28414. import { Size } from "babylonjs/Maths/math.size";
  28415. import { Animatable } from "babylonjs/Animations/animatable";
  28416. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28417. /**
  28418. * @hidden
  28419. */
  28420. export class _IAnimationState {
  28421. key: number;
  28422. repeatCount: number;
  28423. workValue?: any;
  28424. loopMode?: number;
  28425. offsetValue?: any;
  28426. highLimitValue?: any;
  28427. }
  28428. /**
  28429. * Class used to store any kind of animation
  28430. */
  28431. export class Animation {
  28432. /**Name of the animation */
  28433. name: string;
  28434. /**Property to animate */
  28435. targetProperty: string;
  28436. /**The frames per second of the animation */
  28437. framePerSecond: number;
  28438. /**The data type of the animation */
  28439. dataType: number;
  28440. /**The loop mode of the animation */
  28441. loopMode?: number | undefined;
  28442. /**Specifies if blending should be enabled */
  28443. enableBlending?: boolean | undefined;
  28444. /**
  28445. * Use matrix interpolation instead of using direct key value when animating matrices
  28446. */
  28447. static AllowMatricesInterpolation: boolean;
  28448. /**
  28449. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28450. */
  28451. static AllowMatrixDecomposeForInterpolation: boolean;
  28452. /**
  28453. * Stores the key frames of the animation
  28454. */
  28455. private _keys;
  28456. /**
  28457. * Stores the easing function of the animation
  28458. */
  28459. private _easingFunction;
  28460. /**
  28461. * @hidden Internal use only
  28462. */
  28463. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28464. /**
  28465. * The set of event that will be linked to this animation
  28466. */
  28467. private _events;
  28468. /**
  28469. * Stores an array of target property paths
  28470. */
  28471. targetPropertyPath: string[];
  28472. /**
  28473. * Stores the blending speed of the animation
  28474. */
  28475. blendingSpeed: number;
  28476. /**
  28477. * Stores the animation ranges for the animation
  28478. */
  28479. private _ranges;
  28480. /**
  28481. * @hidden Internal use
  28482. */
  28483. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28484. /**
  28485. * Sets up an animation
  28486. * @param property The property to animate
  28487. * @param animationType The animation type to apply
  28488. * @param framePerSecond The frames per second of the animation
  28489. * @param easingFunction The easing function used in the animation
  28490. * @returns The created animation
  28491. */
  28492. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28493. /**
  28494. * Create and start an animation on a node
  28495. * @param name defines the name of the global animation that will be run on all nodes
  28496. * @param node defines the root node where the animation will take place
  28497. * @param targetProperty defines property to animate
  28498. * @param framePerSecond defines the number of frame per second yo use
  28499. * @param totalFrame defines the number of frames in total
  28500. * @param from defines the initial value
  28501. * @param to defines the final value
  28502. * @param loopMode defines which loop mode you want to use (off by default)
  28503. * @param easingFunction defines the easing function to use (linear by default)
  28504. * @param onAnimationEnd defines the callback to call when animation end
  28505. * @returns the animatable created for this animation
  28506. */
  28507. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28508. /**
  28509. * Create and start an animation on a node and its descendants
  28510. * @param name defines the name of the global animation that will be run on all nodes
  28511. * @param node defines the root node where the animation will take place
  28512. * @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
  28513. * @param targetProperty defines property to animate
  28514. * @param framePerSecond defines the number of frame per second to use
  28515. * @param totalFrame defines the number of frames in total
  28516. * @param from defines the initial value
  28517. * @param to defines the final value
  28518. * @param loopMode defines which loop mode you want to use (off by default)
  28519. * @param easingFunction defines the easing function to use (linear by default)
  28520. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28521. * @returns the list of animatables created for all nodes
  28522. * @example https://www.babylonjs-playground.com/#MH0VLI
  28523. */
  28524. 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[]>;
  28525. /**
  28526. * Creates a new animation, merges it with the existing animations and starts it
  28527. * @param name Name of the animation
  28528. * @param node Node which contains the scene that begins the animations
  28529. * @param targetProperty Specifies which property to animate
  28530. * @param framePerSecond The frames per second of the animation
  28531. * @param totalFrame The total number of frames
  28532. * @param from The frame at the beginning of the animation
  28533. * @param to The frame at the end of the animation
  28534. * @param loopMode Specifies the loop mode of the animation
  28535. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28536. * @param onAnimationEnd Callback to run once the animation is complete
  28537. * @returns Nullable animation
  28538. */
  28539. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28540. /**
  28541. * Transition property of an host to the target Value
  28542. * @param property The property to transition
  28543. * @param targetValue The target Value of the property
  28544. * @param host The object where the property to animate belongs
  28545. * @param scene Scene used to run the animation
  28546. * @param frameRate Framerate (in frame/s) to use
  28547. * @param transition The transition type we want to use
  28548. * @param duration The duration of the animation, in milliseconds
  28549. * @param onAnimationEnd Callback trigger at the end of the animation
  28550. * @returns Nullable animation
  28551. */
  28552. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28553. /**
  28554. * Return the array of runtime animations currently using this animation
  28555. */
  28556. readonly runtimeAnimations: RuntimeAnimation[];
  28557. /**
  28558. * Specifies if any of the runtime animations are currently running
  28559. */
  28560. readonly hasRunningRuntimeAnimations: boolean;
  28561. /**
  28562. * Initializes the animation
  28563. * @param name Name of the animation
  28564. * @param targetProperty Property to animate
  28565. * @param framePerSecond The frames per second of the animation
  28566. * @param dataType The data type of the animation
  28567. * @param loopMode The loop mode of the animation
  28568. * @param enableBlending Specifies if blending should be enabled
  28569. */
  28570. constructor(
  28571. /**Name of the animation */
  28572. name: string,
  28573. /**Property to animate */
  28574. targetProperty: string,
  28575. /**The frames per second of the animation */
  28576. framePerSecond: number,
  28577. /**The data type of the animation */
  28578. dataType: number,
  28579. /**The loop mode of the animation */
  28580. loopMode?: number | undefined,
  28581. /**Specifies if blending should be enabled */
  28582. enableBlending?: boolean | undefined);
  28583. /**
  28584. * Converts the animation to a string
  28585. * @param fullDetails support for multiple levels of logging within scene loading
  28586. * @returns String form of the animation
  28587. */
  28588. toString(fullDetails?: boolean): string;
  28589. /**
  28590. * Add an event to this animation
  28591. * @param event Event to add
  28592. */
  28593. addEvent(event: AnimationEvent): void;
  28594. /**
  28595. * Remove all events found at the given frame
  28596. * @param frame The frame to remove events from
  28597. */
  28598. removeEvents(frame: number): void;
  28599. /**
  28600. * Retrieves all the events from the animation
  28601. * @returns Events from the animation
  28602. */
  28603. getEvents(): AnimationEvent[];
  28604. /**
  28605. * Creates an animation range
  28606. * @param name Name of the animation range
  28607. * @param from Starting frame of the animation range
  28608. * @param to Ending frame of the animation
  28609. */
  28610. createRange(name: string, from: number, to: number): void;
  28611. /**
  28612. * Deletes an animation range by name
  28613. * @param name Name of the animation range to delete
  28614. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28615. */
  28616. deleteRange(name: string, deleteFrames?: boolean): void;
  28617. /**
  28618. * Gets the animation range by name, or null if not defined
  28619. * @param name Name of the animation range
  28620. * @returns Nullable animation range
  28621. */
  28622. getRange(name: string): Nullable<AnimationRange>;
  28623. /**
  28624. * Gets the key frames from the animation
  28625. * @returns The key frames of the animation
  28626. */
  28627. getKeys(): Array<IAnimationKey>;
  28628. /**
  28629. * Gets the highest frame rate of the animation
  28630. * @returns Highest frame rate of the animation
  28631. */
  28632. getHighestFrame(): number;
  28633. /**
  28634. * Gets the easing function of the animation
  28635. * @returns Easing function of the animation
  28636. */
  28637. getEasingFunction(): IEasingFunction;
  28638. /**
  28639. * Sets the easing function of the animation
  28640. * @param easingFunction A custom mathematical formula for animation
  28641. */
  28642. setEasingFunction(easingFunction: EasingFunction): void;
  28643. /**
  28644. * Interpolates a scalar linearly
  28645. * @param startValue Start value of the animation curve
  28646. * @param endValue End value of the animation curve
  28647. * @param gradient Scalar amount to interpolate
  28648. * @returns Interpolated scalar value
  28649. */
  28650. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28651. /**
  28652. * Interpolates a scalar cubically
  28653. * @param startValue Start value of the animation curve
  28654. * @param outTangent End tangent of the animation
  28655. * @param endValue End value of the animation curve
  28656. * @param inTangent Start tangent of the animation curve
  28657. * @param gradient Scalar amount to interpolate
  28658. * @returns Interpolated scalar value
  28659. */
  28660. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28661. /**
  28662. * Interpolates a quaternion using a spherical linear interpolation
  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 quaternion value
  28667. */
  28668. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28669. /**
  28670. * Interpolates a quaternion cubically
  28671. * @param startValue Start value of the animation curve
  28672. * @param outTangent End tangent of the animation curve
  28673. * @param endValue End value of the animation curve
  28674. * @param inTangent Start tangent of the animation curve
  28675. * @param gradient Scalar amount to interpolate
  28676. * @returns Interpolated quaternion value
  28677. */
  28678. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28679. /**
  28680. * Interpolates a Vector3 linearl
  28681. * @param startValue Start value of the animation curve
  28682. * @param endValue End value of the animation curve
  28683. * @param gradient Scalar amount to interpolate
  28684. * @returns Interpolated scalar value
  28685. */
  28686. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28687. /**
  28688. * Interpolates a Vector3 cubically
  28689. * @param startValue Start value of the animation curve
  28690. * @param outTangent End tangent of the animation
  28691. * @param endValue End value of the animation curve
  28692. * @param inTangent Start tangent of the animation curve
  28693. * @param gradient Scalar amount to interpolate
  28694. * @returns InterpolatedVector3 value
  28695. */
  28696. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28697. /**
  28698. * Interpolates a Vector2 linearly
  28699. * @param startValue Start value of the animation curve
  28700. * @param endValue End value of the animation curve
  28701. * @param gradient Scalar amount to interpolate
  28702. * @returns Interpolated Vector2 value
  28703. */
  28704. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28705. /**
  28706. * Interpolates a Vector2 cubically
  28707. * @param startValue Start value of the animation curve
  28708. * @param outTangent End tangent of the animation
  28709. * @param endValue End value of the animation curve
  28710. * @param inTangent Start tangent of the animation curve
  28711. * @param gradient Scalar amount to interpolate
  28712. * @returns Interpolated Vector2 value
  28713. */
  28714. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28715. /**
  28716. * Interpolates a size linearly
  28717. * @param startValue Start value of the animation curve
  28718. * @param endValue End value of the animation curve
  28719. * @param gradient Scalar amount to interpolate
  28720. * @returns Interpolated Size value
  28721. */
  28722. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28723. /**
  28724. * Interpolates a Color3 linearly
  28725. * @param startValue Start value of the animation curve
  28726. * @param endValue End value of the animation curve
  28727. * @param gradient Scalar amount to interpolate
  28728. * @returns Interpolated Color3 value
  28729. */
  28730. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28731. /**
  28732. * Interpolates a Color4 linearly
  28733. * @param startValue Start value of the animation curve
  28734. * @param endValue End value of the animation curve
  28735. * @param gradient Scalar amount to interpolate
  28736. * @returns Interpolated Color3 value
  28737. */
  28738. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28739. /**
  28740. * @hidden Internal use only
  28741. */
  28742. _getKeyValue(value: any): any;
  28743. /**
  28744. * @hidden Internal use only
  28745. */
  28746. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28747. /**
  28748. * Defines the function to use to interpolate matrices
  28749. * @param startValue defines the start matrix
  28750. * @param endValue defines the end matrix
  28751. * @param gradient defines the gradient between both matrices
  28752. * @param result defines an optional target matrix where to store the interpolation
  28753. * @returns the interpolated matrix
  28754. */
  28755. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28756. /**
  28757. * Makes a copy of the animation
  28758. * @returns Cloned animation
  28759. */
  28760. clone(): Animation;
  28761. /**
  28762. * Sets the key frames of the animation
  28763. * @param values The animation key frames to set
  28764. */
  28765. setKeys(values: Array<IAnimationKey>): void;
  28766. /**
  28767. * Serializes the animation to an object
  28768. * @returns Serialized object
  28769. */
  28770. serialize(): any;
  28771. /**
  28772. * Float animation type
  28773. */
  28774. static readonly ANIMATIONTYPE_FLOAT: number;
  28775. /**
  28776. * Vector3 animation type
  28777. */
  28778. static readonly ANIMATIONTYPE_VECTOR3: number;
  28779. /**
  28780. * Quaternion animation type
  28781. */
  28782. static readonly ANIMATIONTYPE_QUATERNION: number;
  28783. /**
  28784. * Matrix animation type
  28785. */
  28786. static readonly ANIMATIONTYPE_MATRIX: number;
  28787. /**
  28788. * Color3 animation type
  28789. */
  28790. static readonly ANIMATIONTYPE_COLOR3: number;
  28791. /**
  28792. * Color3 animation type
  28793. */
  28794. static readonly ANIMATIONTYPE_COLOR4: number;
  28795. /**
  28796. * Vector2 animation type
  28797. */
  28798. static readonly ANIMATIONTYPE_VECTOR2: number;
  28799. /**
  28800. * Size animation type
  28801. */
  28802. static readonly ANIMATIONTYPE_SIZE: number;
  28803. /**
  28804. * Relative Loop Mode
  28805. */
  28806. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28807. /**
  28808. * Cycle Loop Mode
  28809. */
  28810. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28811. /**
  28812. * Constant Loop Mode
  28813. */
  28814. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28815. /** @hidden */
  28816. static _UniversalLerp(left: any, right: any, amount: number): any;
  28817. /**
  28818. * Parses an animation object and creates an animation
  28819. * @param parsedAnimation Parsed animation object
  28820. * @returns Animation object
  28821. */
  28822. static Parse(parsedAnimation: any): Animation;
  28823. /**
  28824. * Appends the serialized animations from the source animations
  28825. * @param source Source containing the animations
  28826. * @param destination Target to store the animations
  28827. */
  28828. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28829. }
  28830. }
  28831. declare module "babylonjs/Animations/animatable.interface" {
  28832. import { Nullable } from "babylonjs/types";
  28833. import { Animation } from "babylonjs/Animations/animation";
  28834. /**
  28835. * Interface containing an array of animations
  28836. */
  28837. export interface IAnimatable {
  28838. /**
  28839. * Array of animations
  28840. */
  28841. animations: Nullable<Array<Animation>>;
  28842. }
  28843. }
  28844. declare module "babylonjs/Materials/fresnelParameters" {
  28845. import { Color3 } from "babylonjs/Maths/math.color";
  28846. /**
  28847. * This represents all the required information to add a fresnel effect on a material:
  28848. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28849. */
  28850. export class FresnelParameters {
  28851. private _isEnabled;
  28852. /**
  28853. * Define if the fresnel effect is enable or not.
  28854. */
  28855. isEnabled: boolean;
  28856. /**
  28857. * Define the color used on edges (grazing angle)
  28858. */
  28859. leftColor: Color3;
  28860. /**
  28861. * Define the color used on center
  28862. */
  28863. rightColor: Color3;
  28864. /**
  28865. * Define bias applied to computed fresnel term
  28866. */
  28867. bias: number;
  28868. /**
  28869. * Defined the power exponent applied to fresnel term
  28870. */
  28871. power: number;
  28872. /**
  28873. * Clones the current fresnel and its valuues
  28874. * @returns a clone fresnel configuration
  28875. */
  28876. clone(): FresnelParameters;
  28877. /**
  28878. * Serializes the current fresnel parameters to a JSON representation.
  28879. * @return the JSON serialization
  28880. */
  28881. serialize(): any;
  28882. /**
  28883. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28884. * @param parsedFresnelParameters Define the JSON representation
  28885. * @returns the parsed parameters
  28886. */
  28887. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28888. }
  28889. }
  28890. declare module "babylonjs/Misc/decorators" {
  28891. import { Nullable } from "babylonjs/types";
  28892. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28893. import { Scene } from "babylonjs/scene";
  28894. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28895. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28896. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28897. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28898. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28899. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28900. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28901. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28902. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28903. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28904. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28905. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28906. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28907. /**
  28908. * Decorator used to define property that can be serialized as reference to a camera
  28909. * @param sourceName defines the name of the property to decorate
  28910. */
  28911. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28912. /**
  28913. * Class used to help serialization objects
  28914. */
  28915. export class SerializationHelper {
  28916. /** @hidden */
  28917. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28918. /** @hidden */
  28919. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28920. /** @hidden */
  28921. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28922. /** @hidden */
  28923. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28924. /**
  28925. * Appends the serialized animations from the source animations
  28926. * @param source Source containing the animations
  28927. * @param destination Target to store the animations
  28928. */
  28929. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28930. /**
  28931. * Static function used to serialized a specific entity
  28932. * @param entity defines the entity to serialize
  28933. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28934. * @returns a JSON compatible object representing the serialization of the entity
  28935. */
  28936. static Serialize<T>(entity: T, serializationObject?: any): any;
  28937. /**
  28938. * Creates a new entity from a serialization data object
  28939. * @param creationFunction defines a function used to instanciated the new entity
  28940. * @param source defines the source serialization data
  28941. * @param scene defines the hosting scene
  28942. * @param rootUrl defines the root url for resources
  28943. * @returns a new entity
  28944. */
  28945. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28946. /**
  28947. * Clones an object
  28948. * @param creationFunction defines the function used to instanciate the new object
  28949. * @param source defines the source object
  28950. * @returns the cloned object
  28951. */
  28952. static Clone<T>(creationFunction: () => T, source: T): T;
  28953. /**
  28954. * Instanciates a new object based on a source one (some data will be shared between both object)
  28955. * @param creationFunction defines the function used to instanciate the new object
  28956. * @param source defines the source object
  28957. * @returns the new object
  28958. */
  28959. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28960. }
  28961. }
  28962. declare module "babylonjs/Misc/guid" {
  28963. /**
  28964. * Class used to manipulate GUIDs
  28965. */
  28966. export class GUID {
  28967. /**
  28968. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28969. * Be aware Math.random() could cause collisions, but:
  28970. * "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"
  28971. * @returns a pseudo random id
  28972. */
  28973. static RandomId(): string;
  28974. }
  28975. }
  28976. declare module "babylonjs/Materials/Textures/baseTexture" {
  28977. import { Observable } from "babylonjs/Misc/observable";
  28978. import { Nullable } from "babylonjs/types";
  28979. import { Scene } from "babylonjs/scene";
  28980. import { Matrix } from "babylonjs/Maths/math.vector";
  28981. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28982. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28983. import { ISize } from "babylonjs/Maths/math.size";
  28984. /**
  28985. * Base class of all the textures in babylon.
  28986. * It groups all the common properties the materials, post process, lights... might need
  28987. * in order to make a correct use of the texture.
  28988. */
  28989. export class BaseTexture implements IAnimatable {
  28990. /**
  28991. * Default anisotropic filtering level for the application.
  28992. * It is set to 4 as a good tradeoff between perf and quality.
  28993. */
  28994. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28995. /**
  28996. * Gets or sets the unique id of the texture
  28997. */
  28998. uniqueId: number;
  28999. /**
  29000. * Define the name of the texture.
  29001. */
  29002. name: string;
  29003. /**
  29004. * Gets or sets an object used to store user defined information.
  29005. */
  29006. metadata: any;
  29007. /**
  29008. * For internal use only. Please do not use.
  29009. */
  29010. reservedDataStore: any;
  29011. private _hasAlpha;
  29012. /**
  29013. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29014. */
  29015. hasAlpha: boolean;
  29016. /**
  29017. * Defines if the alpha value should be determined via the rgb values.
  29018. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29019. */
  29020. getAlphaFromRGB: boolean;
  29021. /**
  29022. * Intensity or strength of the texture.
  29023. * It is commonly used by materials to fine tune the intensity of the texture
  29024. */
  29025. level: number;
  29026. /**
  29027. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29028. * This is part of the texture as textures usually maps to one uv set.
  29029. */
  29030. coordinatesIndex: number;
  29031. private _coordinatesMode;
  29032. /**
  29033. * How a texture is mapped.
  29034. *
  29035. * | Value | Type | Description |
  29036. * | ----- | ----------------------------------- | ----------- |
  29037. * | 0 | EXPLICIT_MODE | |
  29038. * | 1 | SPHERICAL_MODE | |
  29039. * | 2 | PLANAR_MODE | |
  29040. * | 3 | CUBIC_MODE | |
  29041. * | 4 | PROJECTION_MODE | |
  29042. * | 5 | SKYBOX_MODE | |
  29043. * | 6 | INVCUBIC_MODE | |
  29044. * | 7 | EQUIRECTANGULAR_MODE | |
  29045. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29046. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29047. */
  29048. coordinatesMode: number;
  29049. /**
  29050. * | Value | Type | Description |
  29051. * | ----- | ------------------ | ----------- |
  29052. * | 0 | CLAMP_ADDRESSMODE | |
  29053. * | 1 | WRAP_ADDRESSMODE | |
  29054. * | 2 | MIRROR_ADDRESSMODE | |
  29055. */
  29056. wrapU: number;
  29057. /**
  29058. * | Value | Type | Description |
  29059. * | ----- | ------------------ | ----------- |
  29060. * | 0 | CLAMP_ADDRESSMODE | |
  29061. * | 1 | WRAP_ADDRESSMODE | |
  29062. * | 2 | MIRROR_ADDRESSMODE | |
  29063. */
  29064. wrapV: number;
  29065. /**
  29066. * | Value | Type | Description |
  29067. * | ----- | ------------------ | ----------- |
  29068. * | 0 | CLAMP_ADDRESSMODE | |
  29069. * | 1 | WRAP_ADDRESSMODE | |
  29070. * | 2 | MIRROR_ADDRESSMODE | |
  29071. */
  29072. wrapR: number;
  29073. /**
  29074. * With compliant hardware and browser (supporting anisotropic filtering)
  29075. * this defines the level of anisotropic filtering in the texture.
  29076. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29077. */
  29078. anisotropicFilteringLevel: number;
  29079. /**
  29080. * Define if the texture is a cube texture or if false a 2d texture.
  29081. */
  29082. isCube: boolean;
  29083. /**
  29084. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29085. */
  29086. is3D: boolean;
  29087. /**
  29088. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29089. */
  29090. is2DArray: boolean;
  29091. /**
  29092. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29093. * HDR texture are usually stored in linear space.
  29094. * This only impacts the PBR and Background materials
  29095. */
  29096. gammaSpace: boolean;
  29097. /**
  29098. * Gets or sets whether or not the texture contains RGBD data.
  29099. */
  29100. isRGBD: boolean;
  29101. /**
  29102. * Is Z inverted in the texture (useful in a cube texture).
  29103. */
  29104. invertZ: boolean;
  29105. /**
  29106. * Are mip maps generated for this texture or not.
  29107. */
  29108. readonly noMipmap: boolean;
  29109. /**
  29110. * @hidden
  29111. */
  29112. lodLevelInAlpha: boolean;
  29113. /**
  29114. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29115. */
  29116. lodGenerationOffset: number;
  29117. /**
  29118. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29119. */
  29120. lodGenerationScale: number;
  29121. /**
  29122. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29123. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29124. * average roughness values.
  29125. */
  29126. linearSpecularLOD: boolean;
  29127. /**
  29128. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29129. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29130. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29131. */
  29132. irradianceTexture: Nullable<BaseTexture>;
  29133. /**
  29134. * Define if the texture is a render target.
  29135. */
  29136. isRenderTarget: boolean;
  29137. /**
  29138. * Define the unique id of the texture in the scene.
  29139. */
  29140. readonly uid: string;
  29141. /**
  29142. * Return a string representation of the texture.
  29143. * @returns the texture as a string
  29144. */
  29145. toString(): string;
  29146. /**
  29147. * Get the class name of the texture.
  29148. * @returns "BaseTexture"
  29149. */
  29150. getClassName(): string;
  29151. /**
  29152. * Define the list of animation attached to the texture.
  29153. */
  29154. animations: import("babylonjs/Animations/animation").Animation[];
  29155. /**
  29156. * An event triggered when the texture is disposed.
  29157. */
  29158. onDisposeObservable: Observable<BaseTexture>;
  29159. private _onDisposeObserver;
  29160. /**
  29161. * Callback triggered when the texture has been disposed.
  29162. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29163. */
  29164. onDispose: () => void;
  29165. /**
  29166. * Define the current state of the loading sequence when in delayed load mode.
  29167. */
  29168. delayLoadState: number;
  29169. private _scene;
  29170. /** @hidden */
  29171. _texture: Nullable<InternalTexture>;
  29172. private _uid;
  29173. /**
  29174. * Define if the texture is preventinga material to render or not.
  29175. * If not and the texture is not ready, the engine will use a default black texture instead.
  29176. */
  29177. readonly isBlocking: boolean;
  29178. /**
  29179. * Instantiates a new BaseTexture.
  29180. * Base class of all the textures in babylon.
  29181. * It groups all the common properties the materials, post process, lights... might need
  29182. * in order to make a correct use of the texture.
  29183. * @param scene Define the scene the texture blongs to
  29184. */
  29185. constructor(scene: Nullable<Scene>);
  29186. /**
  29187. * Get the scene the texture belongs to.
  29188. * @returns the scene or null if undefined
  29189. */
  29190. getScene(): Nullable<Scene>;
  29191. /**
  29192. * Get the texture transform matrix used to offset tile the texture for istance.
  29193. * @returns the transformation matrix
  29194. */
  29195. getTextureMatrix(): Matrix;
  29196. /**
  29197. * Get the texture reflection matrix used to rotate/transform the reflection.
  29198. * @returns the reflection matrix
  29199. */
  29200. getReflectionTextureMatrix(): Matrix;
  29201. /**
  29202. * Get the underlying lower level texture from Babylon.
  29203. * @returns the insternal texture
  29204. */
  29205. getInternalTexture(): Nullable<InternalTexture>;
  29206. /**
  29207. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29208. * @returns true if ready or not blocking
  29209. */
  29210. isReadyOrNotBlocking(): boolean;
  29211. /**
  29212. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29213. * @returns true if fully ready
  29214. */
  29215. isReady(): boolean;
  29216. private _cachedSize;
  29217. /**
  29218. * Get the size of the texture.
  29219. * @returns the texture size.
  29220. */
  29221. getSize(): ISize;
  29222. /**
  29223. * Get the base size of the texture.
  29224. * It can be different from the size if the texture has been resized for POT for instance
  29225. * @returns the base size
  29226. */
  29227. getBaseSize(): ISize;
  29228. /**
  29229. * Update the sampling mode of the texture.
  29230. * Default is Trilinear mode.
  29231. *
  29232. * | Value | Type | Description |
  29233. * | ----- | ------------------ | ----------- |
  29234. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29235. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29236. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29237. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29238. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29239. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29240. * | 7 | NEAREST_LINEAR | |
  29241. * | 8 | NEAREST_NEAREST | |
  29242. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29243. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29244. * | 11 | LINEAR_LINEAR | |
  29245. * | 12 | LINEAR_NEAREST | |
  29246. *
  29247. * > _mag_: magnification filter (close to the viewer)
  29248. * > _min_: minification filter (far from the viewer)
  29249. * > _mip_: filter used between mip map levels
  29250. *@param samplingMode Define the new sampling mode of the texture
  29251. */
  29252. updateSamplingMode(samplingMode: number): void;
  29253. /**
  29254. * Scales the texture if is `canRescale()`
  29255. * @param ratio the resize factor we want to use to rescale
  29256. */
  29257. scale(ratio: number): void;
  29258. /**
  29259. * Get if the texture can rescale.
  29260. */
  29261. readonly canRescale: boolean;
  29262. /** @hidden */
  29263. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29264. /** @hidden */
  29265. _rebuild(): void;
  29266. /**
  29267. * Triggers the load sequence in delayed load mode.
  29268. */
  29269. delayLoad(): void;
  29270. /**
  29271. * Clones the texture.
  29272. * @returns the cloned texture
  29273. */
  29274. clone(): Nullable<BaseTexture>;
  29275. /**
  29276. * Get the texture underlying type (INT, FLOAT...)
  29277. */
  29278. readonly textureType: number;
  29279. /**
  29280. * Get the texture underlying format (RGB, RGBA...)
  29281. */
  29282. readonly textureFormat: number;
  29283. /**
  29284. * Indicates that textures need to be re-calculated for all materials
  29285. */
  29286. protected _markAllSubMeshesAsTexturesDirty(): void;
  29287. /**
  29288. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29289. * This will returns an RGBA array buffer containing either in values (0-255) or
  29290. * float values (0-1) depending of the underlying buffer type.
  29291. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29292. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29293. * @param buffer defines a user defined buffer to fill with data (can be null)
  29294. * @returns The Array buffer containing the pixels data.
  29295. */
  29296. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29297. /**
  29298. * Release and destroy the underlying lower level texture aka internalTexture.
  29299. */
  29300. releaseInternalTexture(): void;
  29301. /** @hidden */
  29302. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29303. /** @hidden */
  29304. readonly _lodTextureMid: Nullable<BaseTexture>;
  29305. /** @hidden */
  29306. readonly _lodTextureLow: Nullable<BaseTexture>;
  29307. /**
  29308. * Dispose the texture and release its associated resources.
  29309. */
  29310. dispose(): void;
  29311. /**
  29312. * Serialize the texture into a JSON representation that can be parsed later on.
  29313. * @returns the JSON representation of the texture
  29314. */
  29315. serialize(): any;
  29316. /**
  29317. * Helper function to be called back once a list of texture contains only ready textures.
  29318. * @param textures Define the list of textures to wait for
  29319. * @param callback Define the callback triggered once the entire list will be ready
  29320. */
  29321. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29322. }
  29323. }
  29324. declare module "babylonjs/Materials/effect" {
  29325. import { Observable } from "babylonjs/Misc/observable";
  29326. import { Nullable } from "babylonjs/types";
  29327. import { IDisposable } from "babylonjs/scene";
  29328. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29329. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29330. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29331. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29332. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29333. import { Engine } from "babylonjs/Engines/engine";
  29334. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29336. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29337. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29338. /**
  29339. * Options to be used when creating an effect.
  29340. */
  29341. export interface IEffectCreationOptions {
  29342. /**
  29343. * Atrributes that will be used in the shader.
  29344. */
  29345. attributes: string[];
  29346. /**
  29347. * Uniform varible names that will be set in the shader.
  29348. */
  29349. uniformsNames: string[];
  29350. /**
  29351. * Uniform buffer variable names that will be set in the shader.
  29352. */
  29353. uniformBuffersNames: string[];
  29354. /**
  29355. * Sampler texture variable names that will be set in the shader.
  29356. */
  29357. samplers: string[];
  29358. /**
  29359. * Define statements that will be set in the shader.
  29360. */
  29361. defines: any;
  29362. /**
  29363. * Possible fallbacks for this effect to improve performance when needed.
  29364. */
  29365. fallbacks: Nullable<IEffectFallbacks>;
  29366. /**
  29367. * Callback that will be called when the shader is compiled.
  29368. */
  29369. onCompiled: Nullable<(effect: Effect) => void>;
  29370. /**
  29371. * Callback that will be called if an error occurs during shader compilation.
  29372. */
  29373. onError: Nullable<(effect: Effect, errors: string) => void>;
  29374. /**
  29375. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29376. */
  29377. indexParameters?: any;
  29378. /**
  29379. * Max number of lights that can be used in the shader.
  29380. */
  29381. maxSimultaneousLights?: number;
  29382. /**
  29383. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29384. */
  29385. transformFeedbackVaryings?: Nullable<string[]>;
  29386. }
  29387. /**
  29388. * Effect containing vertex and fragment shader that can be executed on an object.
  29389. */
  29390. export class Effect implements IDisposable {
  29391. /**
  29392. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29393. */
  29394. static ShadersRepository: string;
  29395. /**
  29396. * Name of the effect.
  29397. */
  29398. name: any;
  29399. /**
  29400. * String container all the define statements that should be set on the shader.
  29401. */
  29402. defines: string;
  29403. /**
  29404. * Callback that will be called when the shader is compiled.
  29405. */
  29406. onCompiled: Nullable<(effect: Effect) => void>;
  29407. /**
  29408. * Callback that will be called if an error occurs during shader compilation.
  29409. */
  29410. onError: Nullable<(effect: Effect, errors: string) => void>;
  29411. /**
  29412. * Callback that will be called when effect is bound.
  29413. */
  29414. onBind: Nullable<(effect: Effect) => void>;
  29415. /**
  29416. * Unique ID of the effect.
  29417. */
  29418. uniqueId: number;
  29419. /**
  29420. * Observable that will be called when the shader is compiled.
  29421. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29422. */
  29423. onCompileObservable: Observable<Effect>;
  29424. /**
  29425. * Observable that will be called if an error occurs during shader compilation.
  29426. */
  29427. onErrorObservable: Observable<Effect>;
  29428. /** @hidden */
  29429. _onBindObservable: Nullable<Observable<Effect>>;
  29430. /**
  29431. * Observable that will be called when effect is bound.
  29432. */
  29433. readonly onBindObservable: Observable<Effect>;
  29434. /** @hidden */
  29435. _bonesComputationForcedToCPU: boolean;
  29436. private static _uniqueIdSeed;
  29437. private _engine;
  29438. private _uniformBuffersNames;
  29439. private _uniformsNames;
  29440. private _samplerList;
  29441. private _samplers;
  29442. private _isReady;
  29443. private _compilationError;
  29444. private _allFallbacksProcessed;
  29445. private _attributesNames;
  29446. private _attributes;
  29447. private _uniforms;
  29448. /**
  29449. * Key for the effect.
  29450. * @hidden
  29451. */
  29452. _key: string;
  29453. private _indexParameters;
  29454. private _fallbacks;
  29455. private _vertexSourceCode;
  29456. private _fragmentSourceCode;
  29457. private _vertexSourceCodeOverride;
  29458. private _fragmentSourceCodeOverride;
  29459. private _transformFeedbackVaryings;
  29460. /**
  29461. * Compiled shader to webGL program.
  29462. * @hidden
  29463. */
  29464. _pipelineContext: Nullable<IPipelineContext>;
  29465. private _valueCache;
  29466. private static _baseCache;
  29467. /**
  29468. * Instantiates an effect.
  29469. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29470. * @param baseName Name of the effect.
  29471. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29472. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29473. * @param samplers List of sampler variables that will be passed to the shader.
  29474. * @param engine Engine to be used to render the effect
  29475. * @param defines Define statements to be added to the shader.
  29476. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29477. * @param onCompiled Callback that will be called when the shader is compiled.
  29478. * @param onError Callback that will be called if an error occurs during shader compilation.
  29479. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29480. */
  29481. 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);
  29482. private _useFinalCode;
  29483. /**
  29484. * Unique key for this effect
  29485. */
  29486. readonly key: string;
  29487. /**
  29488. * If the effect has been compiled and prepared.
  29489. * @returns if the effect is compiled and prepared.
  29490. */
  29491. isReady(): boolean;
  29492. private _isReadyInternal;
  29493. /**
  29494. * The engine the effect was initialized with.
  29495. * @returns the engine.
  29496. */
  29497. getEngine(): Engine;
  29498. /**
  29499. * The pipeline context for this effect
  29500. * @returns the associated pipeline context
  29501. */
  29502. getPipelineContext(): Nullable<IPipelineContext>;
  29503. /**
  29504. * The set of names of attribute variables for the shader.
  29505. * @returns An array of attribute names.
  29506. */
  29507. getAttributesNames(): string[];
  29508. /**
  29509. * Returns the attribute at the given index.
  29510. * @param index The index of the attribute.
  29511. * @returns The location of the attribute.
  29512. */
  29513. getAttributeLocation(index: number): number;
  29514. /**
  29515. * Returns the attribute based on the name of the variable.
  29516. * @param name of the attribute to look up.
  29517. * @returns the attribute location.
  29518. */
  29519. getAttributeLocationByName(name: string): number;
  29520. /**
  29521. * The number of attributes.
  29522. * @returns the numnber of attributes.
  29523. */
  29524. getAttributesCount(): number;
  29525. /**
  29526. * Gets the index of a uniform variable.
  29527. * @param uniformName of the uniform to look up.
  29528. * @returns the index.
  29529. */
  29530. getUniformIndex(uniformName: string): number;
  29531. /**
  29532. * Returns the attribute based on the name of the variable.
  29533. * @param uniformName of the uniform to look up.
  29534. * @returns the location of the uniform.
  29535. */
  29536. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29537. /**
  29538. * Returns an array of sampler variable names
  29539. * @returns The array of sampler variable neames.
  29540. */
  29541. getSamplers(): string[];
  29542. /**
  29543. * The error from the last compilation.
  29544. * @returns the error string.
  29545. */
  29546. getCompilationError(): string;
  29547. /**
  29548. * Gets a boolean indicating that all fallbacks were used during compilation
  29549. * @returns true if all fallbacks were used
  29550. */
  29551. allFallbacksProcessed(): boolean;
  29552. /**
  29553. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29554. * @param func The callback to be used.
  29555. */
  29556. executeWhenCompiled(func: (effect: Effect) => void): void;
  29557. private _checkIsReady;
  29558. private _loadShader;
  29559. /**
  29560. * Recompiles the webGL program
  29561. * @param vertexSourceCode The source code for the vertex shader.
  29562. * @param fragmentSourceCode The source code for the fragment shader.
  29563. * @param onCompiled Callback called when completed.
  29564. * @param onError Callback called on error.
  29565. * @hidden
  29566. */
  29567. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29568. /**
  29569. * Prepares the effect
  29570. * @hidden
  29571. */
  29572. _prepareEffect(): void;
  29573. private _processCompilationErrors;
  29574. /**
  29575. * Checks if the effect is supported. (Must be called after compilation)
  29576. */
  29577. readonly isSupported: boolean;
  29578. /**
  29579. * Binds a texture to the engine to be used as output of the shader.
  29580. * @param channel Name of the output variable.
  29581. * @param texture Texture to bind.
  29582. * @hidden
  29583. */
  29584. _bindTexture(channel: string, texture: InternalTexture): void;
  29585. /**
  29586. * Sets a texture on the engine to be used in the shader.
  29587. * @param channel Name of the sampler variable.
  29588. * @param texture Texture to set.
  29589. */
  29590. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29591. /**
  29592. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29593. * @param channel Name of the sampler variable.
  29594. * @param texture Texture to set.
  29595. */
  29596. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29597. /**
  29598. * Sets an array of textures on the engine to be used in the shader.
  29599. * @param channel Name of the variable.
  29600. * @param textures Textures to set.
  29601. */
  29602. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29603. /**
  29604. * 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)
  29605. * @param channel Name of the sampler variable.
  29606. * @param postProcess Post process to get the input texture from.
  29607. */
  29608. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29609. /**
  29610. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29611. * 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)
  29612. * @param channel Name of the sampler variable.
  29613. * @param postProcess Post process to get the output texture from.
  29614. */
  29615. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29616. /** @hidden */
  29617. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29618. /** @hidden */
  29619. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29620. /** @hidden */
  29621. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29622. /** @hidden */
  29623. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29624. /**
  29625. * Binds a buffer to a uniform.
  29626. * @param buffer Buffer to bind.
  29627. * @param name Name of the uniform variable to bind to.
  29628. */
  29629. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29630. /**
  29631. * Binds block to a uniform.
  29632. * @param blockName Name of the block to bind.
  29633. * @param index Index to bind.
  29634. */
  29635. bindUniformBlock(blockName: string, index: number): void;
  29636. /**
  29637. * Sets an interger value on a uniform variable.
  29638. * @param uniformName Name of the variable.
  29639. * @param value Value to be set.
  29640. * @returns this effect.
  29641. */
  29642. setInt(uniformName: string, value: number): Effect;
  29643. /**
  29644. * Sets an int array on a uniform variable.
  29645. * @param uniformName Name of the variable.
  29646. * @param array array to be set.
  29647. * @returns this effect.
  29648. */
  29649. setIntArray(uniformName: string, array: Int32Array): Effect;
  29650. /**
  29651. * 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)
  29652. * @param uniformName Name of the variable.
  29653. * @param array array to be set.
  29654. * @returns this effect.
  29655. */
  29656. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29657. /**
  29658. * 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)
  29659. * @param uniformName Name of the variable.
  29660. * @param array array to be set.
  29661. * @returns this effect.
  29662. */
  29663. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29664. /**
  29665. * 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)
  29666. * @param uniformName Name of the variable.
  29667. * @param array array to be set.
  29668. * @returns this effect.
  29669. */
  29670. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29671. /**
  29672. * Sets an float array on a uniform variable.
  29673. * @param uniformName Name of the variable.
  29674. * @param array array to be set.
  29675. * @returns this effect.
  29676. */
  29677. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29678. /**
  29679. * 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)
  29680. * @param uniformName Name of the variable.
  29681. * @param array array to be set.
  29682. * @returns this effect.
  29683. */
  29684. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29685. /**
  29686. * 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)
  29687. * @param uniformName Name of the variable.
  29688. * @param array array to be set.
  29689. * @returns this effect.
  29690. */
  29691. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29692. /**
  29693. * 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)
  29694. * @param uniformName Name of the variable.
  29695. * @param array array to be set.
  29696. * @returns this effect.
  29697. */
  29698. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29699. /**
  29700. * Sets an array on a uniform variable.
  29701. * @param uniformName Name of the variable.
  29702. * @param array array to be set.
  29703. * @returns this effect.
  29704. */
  29705. setArray(uniformName: string, array: number[]): Effect;
  29706. /**
  29707. * 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)
  29708. * @param uniformName Name of the variable.
  29709. * @param array array to be set.
  29710. * @returns this effect.
  29711. */
  29712. setArray2(uniformName: string, array: number[]): Effect;
  29713. /**
  29714. * 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)
  29715. * @param uniformName Name of the variable.
  29716. * @param array array to be set.
  29717. * @returns this effect.
  29718. */
  29719. setArray3(uniformName: string, array: number[]): Effect;
  29720. /**
  29721. * 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)
  29722. * @param uniformName Name of the variable.
  29723. * @param array array to be set.
  29724. * @returns this effect.
  29725. */
  29726. setArray4(uniformName: string, array: number[]): Effect;
  29727. /**
  29728. * Sets matrices on a uniform variable.
  29729. * @param uniformName Name of the variable.
  29730. * @param matrices matrices to be set.
  29731. * @returns this effect.
  29732. */
  29733. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29734. /**
  29735. * Sets matrix on a uniform variable.
  29736. * @param uniformName Name of the variable.
  29737. * @param matrix matrix to be set.
  29738. * @returns this effect.
  29739. */
  29740. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29741. /**
  29742. * 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)
  29743. * @param uniformName Name of the variable.
  29744. * @param matrix matrix to be set.
  29745. * @returns this effect.
  29746. */
  29747. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29748. /**
  29749. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29750. * @param uniformName Name of the variable.
  29751. * @param matrix matrix to be set.
  29752. * @returns this effect.
  29753. */
  29754. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29755. /**
  29756. * Sets a float on a uniform variable.
  29757. * @param uniformName Name of the variable.
  29758. * @param value value to be set.
  29759. * @returns this effect.
  29760. */
  29761. setFloat(uniformName: string, value: number): Effect;
  29762. /**
  29763. * Sets a boolean on a uniform variable.
  29764. * @param uniformName Name of the variable.
  29765. * @param bool value to be set.
  29766. * @returns this effect.
  29767. */
  29768. setBool(uniformName: string, bool: boolean): Effect;
  29769. /**
  29770. * Sets a Vector2 on a uniform variable.
  29771. * @param uniformName Name of the variable.
  29772. * @param vector2 vector2 to be set.
  29773. * @returns this effect.
  29774. */
  29775. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29776. /**
  29777. * Sets a float2 on a uniform variable.
  29778. * @param uniformName Name of the variable.
  29779. * @param x First float in float2.
  29780. * @param y Second float in float2.
  29781. * @returns this effect.
  29782. */
  29783. setFloat2(uniformName: string, x: number, y: number): Effect;
  29784. /**
  29785. * Sets a Vector3 on a uniform variable.
  29786. * @param uniformName Name of the variable.
  29787. * @param vector3 Value to be set.
  29788. * @returns this effect.
  29789. */
  29790. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29791. /**
  29792. * Sets a float3 on a uniform variable.
  29793. * @param uniformName Name of the variable.
  29794. * @param x First float in float3.
  29795. * @param y Second float in float3.
  29796. * @param z Third float in float3.
  29797. * @returns this effect.
  29798. */
  29799. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29800. /**
  29801. * Sets a Vector4 on a uniform variable.
  29802. * @param uniformName Name of the variable.
  29803. * @param vector4 Value to be set.
  29804. * @returns this effect.
  29805. */
  29806. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29807. /**
  29808. * Sets a float4 on a uniform variable.
  29809. * @param uniformName Name of the variable.
  29810. * @param x First float in float4.
  29811. * @param y Second float in float4.
  29812. * @param z Third float in float4.
  29813. * @param w Fourth float in float4.
  29814. * @returns this effect.
  29815. */
  29816. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29817. /**
  29818. * Sets a Color3 on a uniform variable.
  29819. * @param uniformName Name of the variable.
  29820. * @param color3 Value to be set.
  29821. * @returns this effect.
  29822. */
  29823. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29824. /**
  29825. * Sets a Color4 on a uniform variable.
  29826. * @param uniformName Name of the variable.
  29827. * @param color3 Value to be set.
  29828. * @param alpha Alpha value to be set.
  29829. * @returns this effect.
  29830. */
  29831. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29832. /**
  29833. * Sets a Color4 on a uniform variable
  29834. * @param uniformName defines the name of the variable
  29835. * @param color4 defines the value to be set
  29836. * @returns this effect.
  29837. */
  29838. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29839. /** Release all associated resources */
  29840. dispose(): void;
  29841. /**
  29842. * This function will add a new shader to the shader store
  29843. * @param name the name of the shader
  29844. * @param pixelShader optional pixel shader content
  29845. * @param vertexShader optional vertex shader content
  29846. */
  29847. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29848. /**
  29849. * Store of each shader (The can be looked up using effect.key)
  29850. */
  29851. static ShadersStore: {
  29852. [key: string]: string;
  29853. };
  29854. /**
  29855. * Store of each included file for a shader (The can be looked up using effect.key)
  29856. */
  29857. static IncludesShadersStore: {
  29858. [key: string]: string;
  29859. };
  29860. /**
  29861. * Resets the cache of effects.
  29862. */
  29863. static ResetCache(): void;
  29864. }
  29865. }
  29866. declare module "babylonjs/Engines/engineCapabilities" {
  29867. /**
  29868. * Interface used to describe the capabilities of the engine relatively to the current browser
  29869. */
  29870. export interface EngineCapabilities {
  29871. /** Maximum textures units per fragment shader */
  29872. maxTexturesImageUnits: number;
  29873. /** Maximum texture units per vertex shader */
  29874. maxVertexTextureImageUnits: number;
  29875. /** Maximum textures units in the entire pipeline */
  29876. maxCombinedTexturesImageUnits: number;
  29877. /** Maximum texture size */
  29878. maxTextureSize: number;
  29879. /** Maximum texture samples */
  29880. maxSamples?: number;
  29881. /** Maximum cube texture size */
  29882. maxCubemapTextureSize: number;
  29883. /** Maximum render texture size */
  29884. maxRenderTextureSize: number;
  29885. /** Maximum number of vertex attributes */
  29886. maxVertexAttribs: number;
  29887. /** Maximum number of varyings */
  29888. maxVaryingVectors: number;
  29889. /** Maximum number of uniforms per vertex shader */
  29890. maxVertexUniformVectors: number;
  29891. /** Maximum number of uniforms per fragment shader */
  29892. maxFragmentUniformVectors: number;
  29893. /** Defines if standard derivates (dx/dy) are supported */
  29894. standardDerivatives: boolean;
  29895. /** Defines if s3tc texture compression is supported */
  29896. s3tc?: WEBGL_compressed_texture_s3tc;
  29897. /** Defines if pvrtc texture compression is supported */
  29898. pvrtc: any;
  29899. /** Defines if etc1 texture compression is supported */
  29900. etc1: any;
  29901. /** Defines if etc2 texture compression is supported */
  29902. etc2: any;
  29903. /** Defines if astc texture compression is supported */
  29904. astc: any;
  29905. /** Defines if float textures are supported */
  29906. textureFloat: boolean;
  29907. /** Defines if vertex array objects are supported */
  29908. vertexArrayObject: boolean;
  29909. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29910. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29911. /** Gets the maximum level of anisotropy supported */
  29912. maxAnisotropy: number;
  29913. /** Defines if instancing is supported */
  29914. instancedArrays: boolean;
  29915. /** Defines if 32 bits indices are supported */
  29916. uintIndices: boolean;
  29917. /** Defines if high precision shaders are supported */
  29918. highPrecisionShaderSupported: boolean;
  29919. /** Defines if depth reading in the fragment shader is supported */
  29920. fragmentDepthSupported: boolean;
  29921. /** Defines if float texture linear filtering is supported*/
  29922. textureFloatLinearFiltering: boolean;
  29923. /** Defines if rendering to float textures is supported */
  29924. textureFloatRender: boolean;
  29925. /** Defines if half float textures are supported*/
  29926. textureHalfFloat: boolean;
  29927. /** Defines if half float texture linear filtering is supported*/
  29928. textureHalfFloatLinearFiltering: boolean;
  29929. /** Defines if rendering to half float textures is supported */
  29930. textureHalfFloatRender: boolean;
  29931. /** Defines if textureLOD shader command is supported */
  29932. textureLOD: boolean;
  29933. /** Defines if draw buffers extension is supported */
  29934. drawBuffersExtension: boolean;
  29935. /** Defines if depth textures are supported */
  29936. depthTextureExtension: boolean;
  29937. /** Defines if float color buffer are supported */
  29938. colorBufferFloat: boolean;
  29939. /** Gets disjoint timer query extension (null if not supported) */
  29940. timerQuery?: EXT_disjoint_timer_query;
  29941. /** Defines if timestamp can be used with timer query */
  29942. canUseTimestampForTimerQuery: boolean;
  29943. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29944. multiview?: any;
  29945. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  29946. oculusMultiview?: any;
  29947. /** Function used to let the system compiles shaders in background */
  29948. parallelShaderCompile?: {
  29949. COMPLETION_STATUS_KHR: number;
  29950. };
  29951. /** Max number of texture samples for MSAA */
  29952. maxMSAASamples: number;
  29953. /** Defines if the blend min max extension is supported */
  29954. blendMinMax: boolean;
  29955. }
  29956. }
  29957. declare module "babylonjs/States/depthCullingState" {
  29958. import { Nullable } from "babylonjs/types";
  29959. /**
  29960. * @hidden
  29961. **/
  29962. export class DepthCullingState {
  29963. private _isDepthTestDirty;
  29964. private _isDepthMaskDirty;
  29965. private _isDepthFuncDirty;
  29966. private _isCullFaceDirty;
  29967. private _isCullDirty;
  29968. private _isZOffsetDirty;
  29969. private _isFrontFaceDirty;
  29970. private _depthTest;
  29971. private _depthMask;
  29972. private _depthFunc;
  29973. private _cull;
  29974. private _cullFace;
  29975. private _zOffset;
  29976. private _frontFace;
  29977. /**
  29978. * Initializes the state.
  29979. */
  29980. constructor();
  29981. readonly isDirty: boolean;
  29982. zOffset: number;
  29983. cullFace: Nullable<number>;
  29984. cull: Nullable<boolean>;
  29985. depthFunc: Nullable<number>;
  29986. depthMask: boolean;
  29987. depthTest: boolean;
  29988. frontFace: Nullable<number>;
  29989. reset(): void;
  29990. apply(gl: WebGLRenderingContext): void;
  29991. }
  29992. }
  29993. declare module "babylonjs/States/stencilState" {
  29994. /**
  29995. * @hidden
  29996. **/
  29997. export class StencilState {
  29998. /** 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 */
  29999. static readonly ALWAYS: number;
  30000. /** Passed to stencilOperation to specify that stencil value must be kept */
  30001. static readonly KEEP: number;
  30002. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30003. static readonly REPLACE: number;
  30004. private _isStencilTestDirty;
  30005. private _isStencilMaskDirty;
  30006. private _isStencilFuncDirty;
  30007. private _isStencilOpDirty;
  30008. private _stencilTest;
  30009. private _stencilMask;
  30010. private _stencilFunc;
  30011. private _stencilFuncRef;
  30012. private _stencilFuncMask;
  30013. private _stencilOpStencilFail;
  30014. private _stencilOpDepthFail;
  30015. private _stencilOpStencilDepthPass;
  30016. readonly isDirty: boolean;
  30017. stencilFunc: number;
  30018. stencilFuncRef: number;
  30019. stencilFuncMask: number;
  30020. stencilOpStencilFail: number;
  30021. stencilOpDepthFail: number;
  30022. stencilOpStencilDepthPass: number;
  30023. stencilMask: number;
  30024. stencilTest: boolean;
  30025. constructor();
  30026. reset(): void;
  30027. apply(gl: WebGLRenderingContext): void;
  30028. }
  30029. }
  30030. declare module "babylonjs/States/alphaCullingState" {
  30031. /**
  30032. * @hidden
  30033. **/
  30034. export class AlphaState {
  30035. private _isAlphaBlendDirty;
  30036. private _isBlendFunctionParametersDirty;
  30037. private _isBlendEquationParametersDirty;
  30038. private _isBlendConstantsDirty;
  30039. private _alphaBlend;
  30040. private _blendFunctionParameters;
  30041. private _blendEquationParameters;
  30042. private _blendConstants;
  30043. /**
  30044. * Initializes the state.
  30045. */
  30046. constructor();
  30047. readonly isDirty: boolean;
  30048. alphaBlend: boolean;
  30049. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30050. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30051. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30052. reset(): void;
  30053. apply(gl: WebGLRenderingContext): void;
  30054. }
  30055. }
  30056. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30057. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30058. /** @hidden */
  30059. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30060. attributeProcessor(attribute: string): string;
  30061. varyingProcessor(varying: string, isFragment: boolean): string;
  30062. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30063. }
  30064. }
  30065. declare module "babylonjs/Engines/instancingAttributeInfo" {
  30066. /**
  30067. * Interface for attribute information associated with buffer instanciation
  30068. */
  30069. export interface InstancingAttributeInfo {
  30070. /**
  30071. * Index/offset of the attribute in the vertex shader
  30072. */
  30073. index: number;
  30074. /**
  30075. * size of the attribute, 1, 2, 3 or 4
  30076. */
  30077. attributeSize: number;
  30078. /**
  30079. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30080. * default is FLOAT
  30081. */
  30082. attributeType: number;
  30083. /**
  30084. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30085. */
  30086. normalized: boolean;
  30087. /**
  30088. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30089. */
  30090. offset: number;
  30091. /**
  30092. * Name of the GLSL attribute, for debugging purpose only
  30093. */
  30094. attributeName: string;
  30095. }
  30096. }
  30097. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  30098. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30099. import { Nullable } from "babylonjs/types";
  30100. module "babylonjs/Engines/thinEngine" {
  30101. interface ThinEngine {
  30102. /**
  30103. * Update a video texture
  30104. * @param texture defines the texture to update
  30105. * @param video defines the video element to use
  30106. * @param invertY defines if data must be stored with Y axis inverted
  30107. */
  30108. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30109. }
  30110. }
  30111. }
  30112. declare module "babylonjs/Materials/Textures/videoTexture" {
  30113. import { Observable } from "babylonjs/Misc/observable";
  30114. import { Nullable } from "babylonjs/types";
  30115. import { Scene } from "babylonjs/scene";
  30116. import { Texture } from "babylonjs/Materials/Textures/texture";
  30117. import "babylonjs/Engines/Extensions/engine.videoTexture";
  30118. /**
  30119. * Settings for finer control over video usage
  30120. */
  30121. export interface VideoTextureSettings {
  30122. /**
  30123. * Applies `autoplay` to video, if specified
  30124. */
  30125. autoPlay?: boolean;
  30126. /**
  30127. * Applies `loop` to video, if specified
  30128. */
  30129. loop?: boolean;
  30130. /**
  30131. * Automatically updates internal texture from video at every frame in the render loop
  30132. */
  30133. autoUpdateTexture: boolean;
  30134. /**
  30135. * Image src displayed during the video loading or until the user interacts with the video.
  30136. */
  30137. poster?: string;
  30138. }
  30139. /**
  30140. * If you want to display a video in your scene, this is the special texture for that.
  30141. * This special texture works similar to other textures, with the exception of a few parameters.
  30142. * @see https://doc.babylonjs.com/how_to/video_texture
  30143. */
  30144. export class VideoTexture extends Texture {
  30145. /**
  30146. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30147. */
  30148. readonly autoUpdateTexture: boolean;
  30149. /**
  30150. * The video instance used by the texture internally
  30151. */
  30152. readonly video: HTMLVideoElement;
  30153. private _onUserActionRequestedObservable;
  30154. /**
  30155. * Event triggerd when a dom action is required by the user to play the video.
  30156. * This happens due to recent changes in browser policies preventing video to auto start.
  30157. */
  30158. readonly onUserActionRequestedObservable: Observable<Texture>;
  30159. private _generateMipMaps;
  30160. private _engine;
  30161. private _stillImageCaptured;
  30162. private _displayingPosterTexture;
  30163. private _settings;
  30164. private _createInternalTextureOnEvent;
  30165. private _frameId;
  30166. /**
  30167. * Creates a video texture.
  30168. * If you want to display a video in your scene, this is the special texture for that.
  30169. * This special texture works similar to other textures, with the exception of a few parameters.
  30170. * @see https://doc.babylonjs.com/how_to/video_texture
  30171. * @param name optional name, will detect from video source, if not defined
  30172. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30173. * @param scene is obviously the current scene.
  30174. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30175. * @param invertY is false by default but can be used to invert video on Y axis
  30176. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30177. * @param settings allows finer control over video usage
  30178. */
  30179. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30180. private _getName;
  30181. private _getVideo;
  30182. private _createInternalTexture;
  30183. private reset;
  30184. /**
  30185. * @hidden Internal method to initiate `update`.
  30186. */
  30187. _rebuild(): void;
  30188. /**
  30189. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30190. */
  30191. update(): void;
  30192. /**
  30193. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30194. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30195. */
  30196. updateTexture(isVisible: boolean): void;
  30197. protected _updateInternalTexture: () => void;
  30198. /**
  30199. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30200. * @param url New url.
  30201. */
  30202. updateURL(url: string): void;
  30203. /**
  30204. * Dispose the texture and release its associated resources.
  30205. */
  30206. dispose(): void;
  30207. /**
  30208. * Creates a video texture straight from a stream.
  30209. * @param scene Define the scene the texture should be created in
  30210. * @param stream Define the stream the texture should be created from
  30211. * @returns The created video texture as a promise
  30212. */
  30213. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30214. /**
  30215. * Creates a video texture straight from your WebCam video feed.
  30216. * @param scene Define the scene the texture should be created in
  30217. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30218. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30219. * @returns The created video texture as a promise
  30220. */
  30221. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30222. minWidth: number;
  30223. maxWidth: number;
  30224. minHeight: number;
  30225. maxHeight: number;
  30226. deviceId: string;
  30227. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30228. /**
  30229. * Creates a video texture straight from your WebCam video feed.
  30230. * @param scene Define the scene the texture should be created in
  30231. * @param onReady Define a callback to triggered once the texture will be ready
  30232. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30233. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30234. */
  30235. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30236. minWidth: number;
  30237. maxWidth: number;
  30238. minHeight: number;
  30239. maxHeight: number;
  30240. deviceId: string;
  30241. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30242. }
  30243. }
  30244. declare module "babylonjs/Engines/thinEngine" {
  30245. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30246. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30247. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30248. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30249. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30250. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30251. import { Observable } from "babylonjs/Misc/observable";
  30252. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30253. import { StencilState } from "babylonjs/States/stencilState";
  30254. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30255. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30256. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30257. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30258. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30259. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30260. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30261. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30262. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30264. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30265. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30266. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30267. /**
  30268. * Defines the interface used by objects working like Scene
  30269. * @hidden
  30270. */
  30271. interface ISceneLike {
  30272. _addPendingData(data: any): void;
  30273. _removePendingData(data: any): void;
  30274. offlineProvider: IOfflineProvider;
  30275. }
  30276. /** Interface defining initialization parameters for Engine class */
  30277. export interface EngineOptions extends WebGLContextAttributes {
  30278. /**
  30279. * Defines if the engine should no exceed a specified device ratio
  30280. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30281. */
  30282. limitDeviceRatio?: number;
  30283. /**
  30284. * Defines if webvr should be enabled automatically
  30285. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30286. */
  30287. autoEnableWebVR?: boolean;
  30288. /**
  30289. * Defines if webgl2 should be turned off even if supported
  30290. * @see http://doc.babylonjs.com/features/webgl2
  30291. */
  30292. disableWebGL2Support?: boolean;
  30293. /**
  30294. * Defines if webaudio should be initialized as well
  30295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30296. */
  30297. audioEngine?: boolean;
  30298. /**
  30299. * Defines if animations should run using a deterministic lock step
  30300. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30301. */
  30302. deterministicLockstep?: boolean;
  30303. /** Defines the maximum steps to use with deterministic lock step mode */
  30304. lockstepMaxSteps?: number;
  30305. /** Defines the seconds between each deterministic lock step */
  30306. timeStep?: number;
  30307. /**
  30308. * Defines that engine should ignore context lost events
  30309. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30310. */
  30311. doNotHandleContextLost?: boolean;
  30312. /**
  30313. * Defines that engine should ignore modifying touch action attribute and style
  30314. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30315. */
  30316. doNotHandleTouchAction?: boolean;
  30317. /**
  30318. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30319. */
  30320. useHighPrecisionFloats?: boolean;
  30321. }
  30322. /**
  30323. * The base engine class (root of all engines)
  30324. */
  30325. export class ThinEngine {
  30326. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30327. static ExceptionList: ({
  30328. key: string;
  30329. capture: string;
  30330. captureConstraint: number;
  30331. targets: string[];
  30332. } | {
  30333. key: string;
  30334. capture: null;
  30335. captureConstraint: null;
  30336. targets: string[];
  30337. })[];
  30338. /** @hidden */
  30339. static _TextureLoaders: IInternalTextureLoader[];
  30340. /**
  30341. * Returns the current npm package of the sdk
  30342. */
  30343. static readonly NpmPackage: string;
  30344. /**
  30345. * Returns the current version of the framework
  30346. */
  30347. static readonly Version: string;
  30348. /**
  30349. * Returns a string describing the current engine
  30350. */
  30351. readonly description: string;
  30352. /**
  30353. * Gets or sets the epsilon value used by collision engine
  30354. */
  30355. static CollisionsEpsilon: number;
  30356. /**
  30357. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30358. */
  30359. static ShadersRepository: string;
  30360. /** @hidden */
  30361. _shaderProcessor: IShaderProcessor;
  30362. /**
  30363. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30364. */
  30365. forcePOTTextures: boolean;
  30366. /**
  30367. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30368. */
  30369. isFullscreen: boolean;
  30370. /**
  30371. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30372. */
  30373. cullBackFaces: boolean;
  30374. /**
  30375. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30376. */
  30377. renderEvenInBackground: boolean;
  30378. /**
  30379. * Gets or sets a boolean indicating that cache can be kept between frames
  30380. */
  30381. preventCacheWipeBetweenFrames: boolean;
  30382. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30383. validateShaderPrograms: boolean;
  30384. /**
  30385. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30386. * This can provide greater z depth for distant objects.
  30387. */
  30388. useReverseDepthBuffer: boolean;
  30389. /**
  30390. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30391. */
  30392. disableUniformBuffers: boolean;
  30393. /** @hidden */
  30394. _uniformBuffers: UniformBuffer[];
  30395. /**
  30396. * Gets a boolean indicating that the engine supports uniform buffers
  30397. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30398. */
  30399. readonly supportsUniformBuffers: boolean;
  30400. /** @hidden */
  30401. _gl: WebGLRenderingContext;
  30402. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30403. protected _windowIsBackground: boolean;
  30404. protected _webGLVersion: number;
  30405. protected _creationOptions: EngineOptions;
  30406. protected _highPrecisionShadersAllowed: boolean;
  30407. /** @hidden */
  30408. readonly _shouldUseHighPrecisionShader: boolean;
  30409. /**
  30410. * Gets a boolean indicating that only power of 2 textures are supported
  30411. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30412. */
  30413. readonly needPOTTextures: boolean;
  30414. /** @hidden */
  30415. _badOS: boolean;
  30416. /** @hidden */
  30417. _badDesktopOS: boolean;
  30418. private _hardwareScalingLevel;
  30419. /** @hidden */
  30420. _caps: EngineCapabilities;
  30421. private _isStencilEnable;
  30422. protected _colorWrite: boolean;
  30423. private _glVersion;
  30424. private _glRenderer;
  30425. private _glVendor;
  30426. /** @hidden */
  30427. _videoTextureSupported: boolean;
  30428. protected _renderingQueueLaunched: boolean;
  30429. protected _activeRenderLoops: (() => void)[];
  30430. /**
  30431. * Observable signaled when a context lost event is raised
  30432. */
  30433. onContextLostObservable: Observable<ThinEngine>;
  30434. /**
  30435. * Observable signaled when a context restored event is raised
  30436. */
  30437. onContextRestoredObservable: Observable<ThinEngine>;
  30438. private _onContextLost;
  30439. private _onContextRestored;
  30440. protected _contextWasLost: boolean;
  30441. /** @hidden */
  30442. _doNotHandleContextLost: boolean;
  30443. /**
  30444. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30445. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30446. */
  30447. doNotHandleContextLost: boolean;
  30448. /**
  30449. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30450. */
  30451. disableVertexArrayObjects: boolean;
  30452. /** @hidden */
  30453. protected _depthCullingState: DepthCullingState;
  30454. /** @hidden */
  30455. protected _stencilState: StencilState;
  30456. /** @hidden */
  30457. protected _alphaState: AlphaState;
  30458. /** @hidden */
  30459. _internalTexturesCache: InternalTexture[];
  30460. /** @hidden */
  30461. protected _activeChannel: number;
  30462. private _currentTextureChannel;
  30463. /** @hidden */
  30464. protected _boundTexturesCache: {
  30465. [key: string]: Nullable<InternalTexture>;
  30466. };
  30467. /** @hidden */
  30468. protected _currentEffect: Nullable<Effect>;
  30469. /** @hidden */
  30470. protected _currentProgram: Nullable<WebGLProgram>;
  30471. private _compiledEffects;
  30472. private _vertexAttribArraysEnabled;
  30473. /** @hidden */
  30474. protected _cachedViewport: Nullable<IViewportLike>;
  30475. private _cachedVertexArrayObject;
  30476. /** @hidden */
  30477. protected _cachedVertexBuffers: any;
  30478. /** @hidden */
  30479. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30480. /** @hidden */
  30481. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30482. /** @hidden */
  30483. _currentRenderTarget: Nullable<InternalTexture>;
  30484. private _uintIndicesCurrentlySet;
  30485. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30486. /** @hidden */
  30487. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30488. private _currentBufferPointers;
  30489. private _currentInstanceLocations;
  30490. private _currentInstanceBuffers;
  30491. private _textureUnits;
  30492. /** @hidden */
  30493. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30494. /** @hidden */
  30495. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30496. /** @hidden */
  30497. _boundRenderFunction: any;
  30498. private _vaoRecordInProgress;
  30499. private _mustWipeVertexAttributes;
  30500. private _emptyTexture;
  30501. private _emptyCubeTexture;
  30502. private _emptyTexture3D;
  30503. private _emptyTexture2DArray;
  30504. /** @hidden */
  30505. _frameHandler: number;
  30506. private _nextFreeTextureSlots;
  30507. private _maxSimultaneousTextures;
  30508. private _activeRequests;
  30509. protected _texturesSupported: string[];
  30510. /** @hidden */
  30511. _textureFormatInUse: Nullable<string>;
  30512. protected readonly _supportsHardwareTextureRescaling: boolean;
  30513. /**
  30514. * Gets the list of texture formats supported
  30515. */
  30516. readonly texturesSupported: Array<string>;
  30517. /**
  30518. * Gets the list of texture formats in use
  30519. */
  30520. readonly textureFormatInUse: Nullable<string>;
  30521. /**
  30522. * Gets the current viewport
  30523. */
  30524. readonly currentViewport: Nullable<IViewportLike>;
  30525. /**
  30526. * Gets the default empty texture
  30527. */
  30528. readonly emptyTexture: InternalTexture;
  30529. /**
  30530. * Gets the default empty 3D texture
  30531. */
  30532. readonly emptyTexture3D: InternalTexture;
  30533. /**
  30534. * Gets the default empty 2D array texture
  30535. */
  30536. readonly emptyTexture2DArray: InternalTexture;
  30537. /**
  30538. * Gets the default empty cube texture
  30539. */
  30540. readonly emptyCubeTexture: InternalTexture;
  30541. /**
  30542. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30543. */
  30544. readonly premultipliedAlpha: boolean;
  30545. /**
  30546. * Observable event triggered before each texture is initialized
  30547. */
  30548. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30549. /**
  30550. * Creates a new engine
  30551. * @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
  30552. * @param antialias defines enable antialiasing (default: false)
  30553. * @param options defines further options to be sent to the getContext() function
  30554. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30555. */
  30556. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30557. private _rebuildInternalTextures;
  30558. private _rebuildEffects;
  30559. /**
  30560. * Gets a boolean indicating if all created effects are ready
  30561. * @returns true if all effects are ready
  30562. */
  30563. areAllEffectsReady(): boolean;
  30564. protected _rebuildBuffers(): void;
  30565. private _initGLContext;
  30566. /**
  30567. * Gets version of the current webGL context
  30568. */
  30569. readonly webGLVersion: number;
  30570. /**
  30571. * Gets a string idenfifying the name of the class
  30572. * @returns "Engine" string
  30573. */
  30574. getClassName(): string;
  30575. /**
  30576. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30577. */
  30578. readonly isStencilEnable: boolean;
  30579. /** @hidden */
  30580. _prepareWorkingCanvas(): void;
  30581. /**
  30582. * Reset the texture cache to empty state
  30583. */
  30584. resetTextureCache(): void;
  30585. /**
  30586. * Gets an object containing information about the current webGL context
  30587. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30588. */
  30589. getGlInfo(): {
  30590. vendor: string;
  30591. renderer: string;
  30592. version: string;
  30593. };
  30594. /**
  30595. * Defines the hardware scaling level.
  30596. * By default the hardware scaling level is computed from the window device ratio.
  30597. * 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.
  30598. * @param level defines the level to use
  30599. */
  30600. setHardwareScalingLevel(level: number): void;
  30601. /**
  30602. * Gets the current hardware scaling level.
  30603. * By default the hardware scaling level is computed from the window device ratio.
  30604. * 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.
  30605. * @returns a number indicating the current hardware scaling level
  30606. */
  30607. getHardwareScalingLevel(): number;
  30608. /**
  30609. * Gets the list of loaded textures
  30610. * @returns an array containing all loaded textures
  30611. */
  30612. getLoadedTexturesCache(): InternalTexture[];
  30613. /**
  30614. * Gets the object containing all engine capabilities
  30615. * @returns the EngineCapabilities object
  30616. */
  30617. getCaps(): EngineCapabilities;
  30618. /**
  30619. * stop executing a render loop function and remove it from the execution array
  30620. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30621. */
  30622. stopRenderLoop(renderFunction?: () => void): void;
  30623. /** @hidden */
  30624. _renderLoop(): void;
  30625. /**
  30626. * Gets the HTML canvas attached with the current webGL context
  30627. * @returns a HTML canvas
  30628. */
  30629. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30630. /**
  30631. * Gets host window
  30632. * @returns the host window object
  30633. */
  30634. getHostWindow(): Nullable<Window>;
  30635. /**
  30636. * Gets the current render width
  30637. * @param useScreen defines if screen size must be used (or the current render target if any)
  30638. * @returns a number defining the current render width
  30639. */
  30640. getRenderWidth(useScreen?: boolean): number;
  30641. /**
  30642. * Gets the current render height
  30643. * @param useScreen defines if screen size must be used (or the current render target if any)
  30644. * @returns a number defining the current render height
  30645. */
  30646. getRenderHeight(useScreen?: boolean): number;
  30647. /**
  30648. * Can be used to override the current requestAnimationFrame requester.
  30649. * @hidden
  30650. */
  30651. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30652. /**
  30653. * Register and execute a render loop. The engine can have more than one render function
  30654. * @param renderFunction defines the function to continuously execute
  30655. */
  30656. runRenderLoop(renderFunction: () => void): void;
  30657. /**
  30658. * Clear the current render buffer or the current render target (if any is set up)
  30659. * @param color defines the color to use
  30660. * @param backBuffer defines if the back buffer must be cleared
  30661. * @param depth defines if the depth buffer must be cleared
  30662. * @param stencil defines if the stencil buffer must be cleared
  30663. */
  30664. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30665. private _viewportCached;
  30666. /** @hidden */
  30667. _viewport(x: number, y: number, width: number, height: number): void;
  30668. /**
  30669. * Set the WebGL's viewport
  30670. * @param viewport defines the viewport element to be used
  30671. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30672. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30673. */
  30674. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30675. /**
  30676. * Begin a new frame
  30677. */
  30678. beginFrame(): void;
  30679. /**
  30680. * Enf the current frame
  30681. */
  30682. endFrame(): void;
  30683. /**
  30684. * Resize the view according to the canvas' size
  30685. */
  30686. resize(): void;
  30687. /**
  30688. * Force a specific size of the canvas
  30689. * @param width defines the new canvas' width
  30690. * @param height defines the new canvas' height
  30691. */
  30692. setSize(width: number, height: number): void;
  30693. /**
  30694. * Binds the frame buffer to the specified texture.
  30695. * @param texture The texture to render to or null for the default canvas
  30696. * @param faceIndex The face of the texture to render to in case of cube texture
  30697. * @param requiredWidth The width of the target to render to
  30698. * @param requiredHeight The height of the target to render to
  30699. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30700. * @param depthStencilTexture The depth stencil texture to use to render
  30701. * @param lodLevel defines le lod level to bind to the frame buffer
  30702. */
  30703. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30704. /** @hidden */
  30705. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30706. /**
  30707. * Unbind the current render target texture from the webGL context
  30708. * @param texture defines the render target texture to unbind
  30709. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30710. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30711. */
  30712. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30713. /**
  30714. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30715. */
  30716. flushFramebuffer(): void;
  30717. /**
  30718. * Unbind the current render target and bind the default framebuffer
  30719. */
  30720. restoreDefaultFramebuffer(): void;
  30721. /** @hidden */
  30722. protected _resetVertexBufferBinding(): void;
  30723. /**
  30724. * Creates a vertex buffer
  30725. * @param data the data for the vertex buffer
  30726. * @returns the new WebGL static buffer
  30727. */
  30728. createVertexBuffer(data: DataArray): DataBuffer;
  30729. private _createVertexBuffer;
  30730. /**
  30731. * Creates a dynamic vertex buffer
  30732. * @param data the data for the dynamic vertex buffer
  30733. * @returns the new WebGL dynamic buffer
  30734. */
  30735. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30736. protected _resetIndexBufferBinding(): void;
  30737. /**
  30738. * Creates a new index buffer
  30739. * @param indices defines the content of the index buffer
  30740. * @param updatable defines if the index buffer must be updatable
  30741. * @returns a new webGL buffer
  30742. */
  30743. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30744. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30745. /**
  30746. * Bind a webGL buffer to the webGL context
  30747. * @param buffer defines the buffer to bind
  30748. */
  30749. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30750. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30751. private bindBuffer;
  30752. /**
  30753. * update the bound buffer with the given data
  30754. * @param data defines the data to update
  30755. */
  30756. updateArrayBuffer(data: Float32Array): void;
  30757. private _vertexAttribPointer;
  30758. private _bindIndexBufferWithCache;
  30759. private _bindVertexBuffersAttributes;
  30760. /**
  30761. * Records a vertex array object
  30762. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30763. * @param vertexBuffers defines the list of vertex buffers to store
  30764. * @param indexBuffer defines the index buffer to store
  30765. * @param effect defines the effect to store
  30766. * @returns the new vertex array object
  30767. */
  30768. recordVertexArrayObject(vertexBuffers: {
  30769. [key: string]: VertexBuffer;
  30770. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30771. /**
  30772. * Bind a specific vertex array object
  30773. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30774. * @param vertexArrayObject defines the vertex array object to bind
  30775. * @param indexBuffer defines the index buffer to bind
  30776. */
  30777. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30778. /**
  30779. * Bind webGl buffers directly to the webGL context
  30780. * @param vertexBuffer defines the vertex buffer to bind
  30781. * @param indexBuffer defines the index buffer to bind
  30782. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30783. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30784. * @param effect defines the effect associated with the vertex buffer
  30785. */
  30786. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30787. private _unbindVertexArrayObject;
  30788. /**
  30789. * Bind a list of vertex buffers to the webGL context
  30790. * @param vertexBuffers defines the list of vertex buffers to bind
  30791. * @param indexBuffer defines the index buffer to bind
  30792. * @param effect defines the effect associated with the vertex buffers
  30793. */
  30794. bindBuffers(vertexBuffers: {
  30795. [key: string]: Nullable<VertexBuffer>;
  30796. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30797. /**
  30798. * Unbind all instance attributes
  30799. */
  30800. unbindInstanceAttributes(): void;
  30801. /**
  30802. * Release and free the memory of a vertex array object
  30803. * @param vao defines the vertex array object to delete
  30804. */
  30805. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30806. /** @hidden */
  30807. _releaseBuffer(buffer: DataBuffer): boolean;
  30808. protected _deleteBuffer(buffer: DataBuffer): void;
  30809. /**
  30810. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30811. * @param instancesBuffer defines the webGL buffer to update and bind
  30812. * @param data defines the data to store in the buffer
  30813. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30814. */
  30815. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30816. /**
  30817. * Apply all cached states (depth, culling, stencil and alpha)
  30818. */
  30819. applyStates(): void;
  30820. /**
  30821. * Send a draw order
  30822. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30823. * @param indexStart defines the starting index
  30824. * @param indexCount defines the number of index to draw
  30825. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30826. */
  30827. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30828. /**
  30829. * Draw a list of points
  30830. * @param verticesStart defines the index of first vertex to draw
  30831. * @param verticesCount defines the count of vertices to draw
  30832. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30833. */
  30834. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30835. /**
  30836. * Draw a list of unindexed primitives
  30837. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30838. * @param verticesStart defines the index of first vertex to draw
  30839. * @param verticesCount defines the count of vertices to draw
  30840. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30841. */
  30842. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30843. /**
  30844. * Draw a list of indexed primitives
  30845. * @param fillMode defines the primitive to use
  30846. * @param indexStart defines the starting index
  30847. * @param indexCount defines the number of index to draw
  30848. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30849. */
  30850. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30851. /**
  30852. * Draw a list of unindexed primitives
  30853. * @param fillMode defines the primitive to use
  30854. * @param verticesStart defines the index of first vertex to draw
  30855. * @param verticesCount defines the count of vertices to draw
  30856. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30857. */
  30858. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30859. private _drawMode;
  30860. /** @hidden */
  30861. protected _reportDrawCall(): void;
  30862. /** @hidden */
  30863. _releaseEffect(effect: Effect): void;
  30864. /** @hidden */
  30865. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30866. /**
  30867. * Create a new effect (used to store vertex/fragment shaders)
  30868. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30869. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30870. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30871. * @param samplers defines an array of string used to represent textures
  30872. * @param defines defines the string containing the defines to use to compile the shaders
  30873. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30874. * @param onCompiled defines a function to call when the effect creation is successful
  30875. * @param onError defines a function to call when the effect creation has failed
  30876. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30877. * @returns the new Effect
  30878. */
  30879. 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;
  30880. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30881. private _compileShader;
  30882. private _compileRawShader;
  30883. /**
  30884. * Directly creates a webGL program
  30885. * @param pipelineContext defines the pipeline context to attach to
  30886. * @param vertexCode defines the vertex shader code to use
  30887. * @param fragmentCode defines the fragment shader code to use
  30888. * @param context defines the webGL context to use (if not set, the current one will be used)
  30889. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30890. * @returns the new webGL program
  30891. */
  30892. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30893. /**
  30894. * Creates a webGL program
  30895. * @param pipelineContext defines the pipeline context to attach to
  30896. * @param vertexCode defines the vertex shader code to use
  30897. * @param fragmentCode defines the fragment shader code to use
  30898. * @param defines defines the string containing the defines to use to compile the shaders
  30899. * @param context defines the webGL context to use (if not set, the current one will be used)
  30900. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30901. * @returns the new webGL program
  30902. */
  30903. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30904. /**
  30905. * Creates a new pipeline context
  30906. * @returns the new pipeline
  30907. */
  30908. createPipelineContext(): IPipelineContext;
  30909. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30910. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30911. /** @hidden */
  30912. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30913. /** @hidden */
  30914. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30915. /** @hidden */
  30916. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30917. /**
  30918. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30919. * @param pipelineContext defines the pipeline context to use
  30920. * @param uniformsNames defines the list of uniform names
  30921. * @returns an array of webGL uniform locations
  30922. */
  30923. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30924. /**
  30925. * Gets the lsit of active attributes for a given webGL program
  30926. * @param pipelineContext defines the pipeline context to use
  30927. * @param attributesNames defines the list of attribute names to get
  30928. * @returns an array of indices indicating the offset of each attribute
  30929. */
  30930. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30931. /**
  30932. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30933. * @param effect defines the effect to activate
  30934. */
  30935. enableEffect(effect: Nullable<Effect>): void;
  30936. /**
  30937. * Set the value of an uniform to a number (int)
  30938. * @param uniform defines the webGL uniform location where to store the value
  30939. * @param value defines the int number to store
  30940. */
  30941. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30942. /**
  30943. * Set the value of an uniform to an array of int32
  30944. * @param uniform defines the webGL uniform location where to store the value
  30945. * @param array defines the array of int32 to store
  30946. */
  30947. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30948. /**
  30949. * Set the value of an uniform to an array of int32 (stored as vec2)
  30950. * @param uniform defines the webGL uniform location where to store the value
  30951. * @param array defines the array of int32 to store
  30952. */
  30953. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30954. /**
  30955. * Set the value of an uniform to an array of int32 (stored as vec3)
  30956. * @param uniform defines the webGL uniform location where to store the value
  30957. * @param array defines the array of int32 to store
  30958. */
  30959. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30960. /**
  30961. * Set the value of an uniform to an array of int32 (stored as vec4)
  30962. * @param uniform defines the webGL uniform location where to store the value
  30963. * @param array defines the array of int32 to store
  30964. */
  30965. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30966. /**
  30967. * Set the value of an uniform to an array of number
  30968. * @param uniform defines the webGL uniform location where to store the value
  30969. * @param array defines the array of number to store
  30970. */
  30971. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30972. /**
  30973. * Set the value of an uniform to an array of number (stored as vec2)
  30974. * @param uniform defines the webGL uniform location where to store the value
  30975. * @param array defines the array of number to store
  30976. */
  30977. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30978. /**
  30979. * Set the value of an uniform to an array of number (stored as vec3)
  30980. * @param uniform defines the webGL uniform location where to store the value
  30981. * @param array defines the array of number to store
  30982. */
  30983. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30984. /**
  30985. * Set the value of an uniform to an array of number (stored as vec4)
  30986. * @param uniform defines the webGL uniform location where to store the value
  30987. * @param array defines the array of number to store
  30988. */
  30989. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30990. /**
  30991. * Set the value of an uniform to an array of float32 (stored as matrices)
  30992. * @param uniform defines the webGL uniform location where to store the value
  30993. * @param matrices defines the array of float32 to store
  30994. */
  30995. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30996. /**
  30997. * Set the value of an uniform to a matrix (3x3)
  30998. * @param uniform defines the webGL uniform location where to store the value
  30999. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31000. */
  31001. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31002. /**
  31003. * Set the value of an uniform to a matrix (2x2)
  31004. * @param uniform defines the webGL uniform location where to store the value
  31005. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31006. */
  31007. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31008. /**
  31009. * Set the value of an uniform to a number (float)
  31010. * @param uniform defines the webGL uniform location where to store the value
  31011. * @param value defines the float number to store
  31012. */
  31013. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31014. /**
  31015. * Set the value of an uniform to a vec2
  31016. * @param uniform defines the webGL uniform location where to store the value
  31017. * @param x defines the 1st component of the value
  31018. * @param y defines the 2nd component of the value
  31019. */
  31020. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31021. /**
  31022. * Set the value of an uniform to a vec3
  31023. * @param uniform defines the webGL uniform location where to store the value
  31024. * @param x defines the 1st component of the value
  31025. * @param y defines the 2nd component of the value
  31026. * @param z defines the 3rd component of the value
  31027. */
  31028. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31029. /**
  31030. * Set the value of an uniform to a vec4
  31031. * @param uniform defines the webGL uniform location where to store the value
  31032. * @param x defines the 1st component of the value
  31033. * @param y defines the 2nd component of the value
  31034. * @param z defines the 3rd component of the value
  31035. * @param w defines the 4th component of the value
  31036. */
  31037. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31038. /**
  31039. * Gets the depth culling state manager
  31040. */
  31041. readonly depthCullingState: DepthCullingState;
  31042. /**
  31043. * Gets the alpha state manager
  31044. */
  31045. readonly alphaState: AlphaState;
  31046. /**
  31047. * Gets the stencil state manager
  31048. */
  31049. readonly stencilState: StencilState;
  31050. /**
  31051. * Clears the list of texture accessible through engine.
  31052. * This can help preventing texture load conflict due to name collision.
  31053. */
  31054. clearInternalTexturesCache(): void;
  31055. /**
  31056. * Force the entire cache to be cleared
  31057. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31058. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31059. */
  31060. wipeCaches(bruteForce?: boolean): void;
  31061. /** @hidden */
  31062. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31063. min: number;
  31064. mag: number;
  31065. };
  31066. /** @hidden */
  31067. _createTexture(): WebGLTexture;
  31068. /**
  31069. * Usually called from Texture.ts.
  31070. * Passed information to create a WebGLTexture
  31071. * @param urlArg defines a value which contains one of the following:
  31072. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31073. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31074. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31075. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31076. * @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)
  31077. * @param scene needed for loading to the correct scene
  31078. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31079. * @param onLoad optional callback to be called upon successful completion
  31080. * @param onError optional callback to be called upon failure
  31081. * @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
  31082. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31083. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31084. * @param forcedExtension defines the extension to use to pick the right loader
  31085. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31086. * @param mimeType defines an optional mime type
  31087. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31088. */
  31089. 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;
  31090. /**
  31091. * @hidden
  31092. */
  31093. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31094. /**
  31095. * Creates a raw texture
  31096. * @param data defines the data to store in the texture
  31097. * @param width defines the width of the texture
  31098. * @param height defines the height of the texture
  31099. * @param format defines the format of the data
  31100. * @param generateMipMaps defines if the engine should generate the mip levels
  31101. * @param invertY defines if data must be stored with Y axis inverted
  31102. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31103. * @param compression defines the compression used (null by default)
  31104. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31105. * @returns the raw texture inside an InternalTexture
  31106. */
  31107. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31108. /**
  31109. * Creates a new raw cube texture
  31110. * @param data defines the array of data to use to create each face
  31111. * @param size defines the size of the textures
  31112. * @param format defines the format of the data
  31113. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31114. * @param generateMipMaps defines if the engine should generate the mip levels
  31115. * @param invertY defines if data must be stored with Y axis inverted
  31116. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31117. * @param compression defines the compression used (null by default)
  31118. * @returns the cube texture as an InternalTexture
  31119. */
  31120. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31121. /**
  31122. * Creates a new raw 3D texture
  31123. * @param data defines the data used to create the texture
  31124. * @param width defines the width of the texture
  31125. * @param height defines the height of the texture
  31126. * @param depth defines the depth of the texture
  31127. * @param format defines the format of the texture
  31128. * @param generateMipMaps defines if the engine must generate mip levels
  31129. * @param invertY defines if data must be stored with Y axis inverted
  31130. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31131. * @param compression defines the compressed used (can be null)
  31132. * @param textureType defines the compressed used (can be null)
  31133. * @returns a new raw 3D texture (stored in an InternalTexture)
  31134. */
  31135. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31136. /**
  31137. * Creates a new raw 2D array texture
  31138. * @param data defines the data used to create the texture
  31139. * @param width defines the width of the texture
  31140. * @param height defines the height of the texture
  31141. * @param depth defines the number of layers of the texture
  31142. * @param format defines the format of the texture
  31143. * @param generateMipMaps defines if the engine must generate mip levels
  31144. * @param invertY defines if data must be stored with Y axis inverted
  31145. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31146. * @param compression defines the compressed used (can be null)
  31147. * @param textureType defines the compressed used (can be null)
  31148. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31149. */
  31150. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31151. private _unpackFlipYCached;
  31152. /**
  31153. * In case you are sharing the context with other applications, it might
  31154. * be interested to not cache the unpack flip y state to ensure a consistent
  31155. * value would be set.
  31156. */
  31157. enableUnpackFlipYCached: boolean;
  31158. /** @hidden */
  31159. _unpackFlipY(value: boolean): void;
  31160. /** @hidden */
  31161. _getUnpackAlignement(): number;
  31162. /**
  31163. * Update the sampling mode of a given texture
  31164. * @param samplingMode defines the required sampling mode
  31165. * @param texture defines the texture to update
  31166. */
  31167. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31168. /** @hidden */
  31169. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31170. width: number;
  31171. height: number;
  31172. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31173. /** @hidden */
  31174. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31175. /** @hidden */
  31176. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31177. /** @hidden */
  31178. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31179. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31180. private _prepareWebGLTexture;
  31181. /** @hidden */
  31182. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31183. /** @hidden */
  31184. _releaseFramebufferObjects(texture: InternalTexture): void;
  31185. /** @hidden */
  31186. _releaseTexture(texture: InternalTexture): void;
  31187. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31188. protected _setProgram(program: WebGLProgram): void;
  31189. protected _boundUniforms: {
  31190. [key: number]: WebGLUniformLocation;
  31191. };
  31192. /**
  31193. * Binds an effect to the webGL context
  31194. * @param effect defines the effect to bind
  31195. */
  31196. bindSamplers(effect: Effect): void;
  31197. private _activateCurrentTexture;
  31198. /** @hidden */
  31199. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31200. /** @hidden */
  31201. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31202. /**
  31203. * Unbind all textures from the webGL context
  31204. */
  31205. unbindAllTextures(): void;
  31206. /**
  31207. * Sets a texture to the according uniform.
  31208. * @param channel The texture channel
  31209. * @param uniform The uniform to set
  31210. * @param texture The texture to apply
  31211. */
  31212. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31213. private _bindSamplerUniformToChannel;
  31214. private _getTextureWrapMode;
  31215. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31216. /**
  31217. * Sets an array of texture to the webGL context
  31218. * @param channel defines the channel where the texture array must be set
  31219. * @param uniform defines the associated uniform location
  31220. * @param textures defines the array of textures to bind
  31221. */
  31222. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31223. /** @hidden */
  31224. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31225. private _setTextureParameterFloat;
  31226. private _setTextureParameterInteger;
  31227. /**
  31228. * Unbind all vertex attributes from the webGL context
  31229. */
  31230. unbindAllAttributes(): void;
  31231. /**
  31232. * 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
  31233. */
  31234. releaseEffects(): void;
  31235. /**
  31236. * Dispose and release all associated resources
  31237. */
  31238. dispose(): void;
  31239. /**
  31240. * Attach a new callback raised when context lost event is fired
  31241. * @param callback defines the callback to call
  31242. */
  31243. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31244. /**
  31245. * Attach a new callback raised when context restored event is fired
  31246. * @param callback defines the callback to call
  31247. */
  31248. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31249. /**
  31250. * Get the current error code of the webGL context
  31251. * @returns the error code
  31252. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31253. */
  31254. getError(): number;
  31255. private _canRenderToFloatFramebuffer;
  31256. private _canRenderToHalfFloatFramebuffer;
  31257. private _canRenderToFramebuffer;
  31258. /** @hidden */
  31259. _getWebGLTextureType(type: number): number;
  31260. /** @hidden */
  31261. _getInternalFormat(format: number): number;
  31262. /** @hidden */
  31263. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31264. /** @hidden */
  31265. _getRGBAMultiSampleBufferFormat(type: number): number;
  31266. /** @hidden */
  31267. _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;
  31268. /**
  31269. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31270. * @returns true if the engine can be created
  31271. * @ignorenaming
  31272. */
  31273. static isSupported(): boolean;
  31274. /**
  31275. * Find the next highest power of two.
  31276. * @param x Number to start search from.
  31277. * @return Next highest power of two.
  31278. */
  31279. static CeilingPOT(x: number): number;
  31280. /**
  31281. * Find the next lowest power of two.
  31282. * @param x Number to start search from.
  31283. * @return Next lowest power of two.
  31284. */
  31285. static FloorPOT(x: number): number;
  31286. /**
  31287. * Find the nearest power of two.
  31288. * @param x Number to start search from.
  31289. * @return Next nearest power of two.
  31290. */
  31291. static NearestPOT(x: number): number;
  31292. /**
  31293. * Get the closest exponent of two
  31294. * @param value defines the value to approximate
  31295. * @param max defines the maximum value to return
  31296. * @param mode defines how to define the closest value
  31297. * @returns closest exponent of two of the given value
  31298. */
  31299. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31300. /**
  31301. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31302. * @param func - the function to be called
  31303. * @param requester - the object that will request the next frame. Falls back to window.
  31304. * @returns frame number
  31305. */
  31306. static QueueNewFrame(func: () => void, requester?: any): number;
  31307. /**
  31308. * Gets host document
  31309. * @returns the host document object
  31310. */
  31311. getHostDocument(): Document;
  31312. }
  31313. }
  31314. declare module "babylonjs/Maths/sphericalPolynomial" {
  31315. import { Vector3 } from "babylonjs/Maths/math.vector";
  31316. import { Color3 } from "babylonjs/Maths/math.color";
  31317. /**
  31318. * Class representing spherical harmonics coefficients to the 3rd degree
  31319. */
  31320. export class SphericalHarmonics {
  31321. /**
  31322. * Defines whether or not the harmonics have been prescaled for rendering.
  31323. */
  31324. preScaled: boolean;
  31325. /**
  31326. * The l0,0 coefficients of the spherical harmonics
  31327. */
  31328. l00: Vector3;
  31329. /**
  31330. * The l1,-1 coefficients of the spherical harmonics
  31331. */
  31332. l1_1: Vector3;
  31333. /**
  31334. * The l1,0 coefficients of the spherical harmonics
  31335. */
  31336. l10: Vector3;
  31337. /**
  31338. * The l1,1 coefficients of the spherical harmonics
  31339. */
  31340. l11: Vector3;
  31341. /**
  31342. * The l2,-2 coefficients of the spherical harmonics
  31343. */
  31344. l2_2: Vector3;
  31345. /**
  31346. * The l2,-1 coefficients of the spherical harmonics
  31347. */
  31348. l2_1: Vector3;
  31349. /**
  31350. * The l2,0 coefficients of the spherical harmonics
  31351. */
  31352. l20: Vector3;
  31353. /**
  31354. * The l2,1 coefficients of the spherical harmonics
  31355. */
  31356. l21: Vector3;
  31357. /**
  31358. * The l2,2 coefficients of the spherical harmonics
  31359. */
  31360. l22: Vector3;
  31361. /**
  31362. * Adds a light to the spherical harmonics
  31363. * @param direction the direction of the light
  31364. * @param color the color of the light
  31365. * @param deltaSolidAngle the delta solid angle of the light
  31366. */
  31367. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31368. /**
  31369. * Scales the spherical harmonics by the given amount
  31370. * @param scale the amount to scale
  31371. */
  31372. scaleInPlace(scale: number): void;
  31373. /**
  31374. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31375. *
  31376. * ```
  31377. * E_lm = A_l * L_lm
  31378. * ```
  31379. *
  31380. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31381. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31382. * the scaling factors are given in equation 9.
  31383. */
  31384. convertIncidentRadianceToIrradiance(): void;
  31385. /**
  31386. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31387. *
  31388. * ```
  31389. * L = (1/pi) * E * rho
  31390. * ```
  31391. *
  31392. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31393. */
  31394. convertIrradianceToLambertianRadiance(): void;
  31395. /**
  31396. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31397. * required operations at run time.
  31398. *
  31399. * This is simply done by scaling back the SH with Ylm constants parameter.
  31400. * The trigonometric part being applied by the shader at run time.
  31401. */
  31402. preScaleForRendering(): void;
  31403. /**
  31404. * Constructs a spherical harmonics from an array.
  31405. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31406. * @returns the spherical harmonics
  31407. */
  31408. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31409. /**
  31410. * Gets the spherical harmonics from polynomial
  31411. * @param polynomial the spherical polynomial
  31412. * @returns the spherical harmonics
  31413. */
  31414. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31415. }
  31416. /**
  31417. * Class representing spherical polynomial coefficients to the 3rd degree
  31418. */
  31419. export class SphericalPolynomial {
  31420. private _harmonics;
  31421. /**
  31422. * The spherical harmonics used to create the polynomials.
  31423. */
  31424. readonly preScaledHarmonics: SphericalHarmonics;
  31425. /**
  31426. * The x coefficients of the spherical polynomial
  31427. */
  31428. x: Vector3;
  31429. /**
  31430. * The y coefficients of the spherical polynomial
  31431. */
  31432. y: Vector3;
  31433. /**
  31434. * The z coefficients of the spherical polynomial
  31435. */
  31436. z: Vector3;
  31437. /**
  31438. * The xx coefficients of the spherical polynomial
  31439. */
  31440. xx: Vector3;
  31441. /**
  31442. * The yy coefficients of the spherical polynomial
  31443. */
  31444. yy: Vector3;
  31445. /**
  31446. * The zz coefficients of the spherical polynomial
  31447. */
  31448. zz: Vector3;
  31449. /**
  31450. * The xy coefficients of the spherical polynomial
  31451. */
  31452. xy: Vector3;
  31453. /**
  31454. * The yz coefficients of the spherical polynomial
  31455. */
  31456. yz: Vector3;
  31457. /**
  31458. * The zx coefficients of the spherical polynomial
  31459. */
  31460. zx: Vector3;
  31461. /**
  31462. * Adds an ambient color to the spherical polynomial
  31463. * @param color the color to add
  31464. */
  31465. addAmbient(color: Color3): void;
  31466. /**
  31467. * Scales the spherical polynomial by the given amount
  31468. * @param scale the amount to scale
  31469. */
  31470. scaleInPlace(scale: number): void;
  31471. /**
  31472. * Gets the spherical polynomial from harmonics
  31473. * @param harmonics the spherical harmonics
  31474. * @returns the spherical polynomial
  31475. */
  31476. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31477. /**
  31478. * Constructs a spherical polynomial from an array.
  31479. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31480. * @returns the spherical polynomial
  31481. */
  31482. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31483. }
  31484. }
  31485. declare module "babylonjs/Materials/Textures/internalTexture" {
  31486. import { Observable } from "babylonjs/Misc/observable";
  31487. import { Nullable, int } from "babylonjs/types";
  31488. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31490. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31491. /**
  31492. * Defines the source of the internal texture
  31493. */
  31494. export enum InternalTextureSource {
  31495. /**
  31496. * The source of the texture data is unknown
  31497. */
  31498. Unknown = 0,
  31499. /**
  31500. * Texture data comes from an URL
  31501. */
  31502. Url = 1,
  31503. /**
  31504. * Texture data is only used for temporary storage
  31505. */
  31506. Temp = 2,
  31507. /**
  31508. * Texture data comes from raw data (ArrayBuffer)
  31509. */
  31510. Raw = 3,
  31511. /**
  31512. * Texture content is dynamic (video or dynamic texture)
  31513. */
  31514. Dynamic = 4,
  31515. /**
  31516. * Texture content is generated by rendering to it
  31517. */
  31518. RenderTarget = 5,
  31519. /**
  31520. * Texture content is part of a multi render target process
  31521. */
  31522. MultiRenderTarget = 6,
  31523. /**
  31524. * Texture data comes from a cube data file
  31525. */
  31526. Cube = 7,
  31527. /**
  31528. * Texture data comes from a raw cube data
  31529. */
  31530. CubeRaw = 8,
  31531. /**
  31532. * Texture data come from a prefiltered cube data file
  31533. */
  31534. CubePrefiltered = 9,
  31535. /**
  31536. * Texture content is raw 3D data
  31537. */
  31538. Raw3D = 10,
  31539. /**
  31540. * Texture content is raw 2D array data
  31541. */
  31542. Raw2DArray = 11,
  31543. /**
  31544. * Texture content is a depth texture
  31545. */
  31546. Depth = 12,
  31547. /**
  31548. * Texture data comes from a raw cube data encoded with RGBD
  31549. */
  31550. CubeRawRGBD = 13
  31551. }
  31552. /**
  31553. * Class used to store data associated with WebGL texture data for the engine
  31554. * This class should not be used directly
  31555. */
  31556. export class InternalTexture {
  31557. /** @hidden */
  31558. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31559. /**
  31560. * Defines if the texture is ready
  31561. */
  31562. isReady: boolean;
  31563. /**
  31564. * Defines if the texture is a cube texture
  31565. */
  31566. isCube: boolean;
  31567. /**
  31568. * Defines if the texture contains 3D data
  31569. */
  31570. is3D: boolean;
  31571. /**
  31572. * Defines if the texture contains 2D array data
  31573. */
  31574. is2DArray: boolean;
  31575. /**
  31576. * Defines if the texture contains multiview data
  31577. */
  31578. isMultiview: boolean;
  31579. /**
  31580. * Gets the URL used to load this texture
  31581. */
  31582. url: string;
  31583. /**
  31584. * Gets the sampling mode of the texture
  31585. */
  31586. samplingMode: number;
  31587. /**
  31588. * Gets a boolean indicating if the texture needs mipmaps generation
  31589. */
  31590. generateMipMaps: boolean;
  31591. /**
  31592. * Gets the number of samples used by the texture (WebGL2+ only)
  31593. */
  31594. samples: number;
  31595. /**
  31596. * Gets the type of the texture (int, float...)
  31597. */
  31598. type: number;
  31599. /**
  31600. * Gets the format of the texture (RGB, RGBA...)
  31601. */
  31602. format: number;
  31603. /**
  31604. * Observable called when the texture is loaded
  31605. */
  31606. onLoadedObservable: Observable<InternalTexture>;
  31607. /**
  31608. * Gets the width of the texture
  31609. */
  31610. width: number;
  31611. /**
  31612. * Gets the height of the texture
  31613. */
  31614. height: number;
  31615. /**
  31616. * Gets the depth of the texture
  31617. */
  31618. depth: number;
  31619. /**
  31620. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31621. */
  31622. baseWidth: number;
  31623. /**
  31624. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31625. */
  31626. baseHeight: number;
  31627. /**
  31628. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31629. */
  31630. baseDepth: number;
  31631. /**
  31632. * Gets a boolean indicating if the texture is inverted on Y axis
  31633. */
  31634. invertY: boolean;
  31635. /** @hidden */
  31636. _invertVScale: boolean;
  31637. /** @hidden */
  31638. _associatedChannel: number;
  31639. /** @hidden */
  31640. _source: InternalTextureSource;
  31641. /** @hidden */
  31642. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31643. /** @hidden */
  31644. _bufferView: Nullable<ArrayBufferView>;
  31645. /** @hidden */
  31646. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31647. /** @hidden */
  31648. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31649. /** @hidden */
  31650. _size: number;
  31651. /** @hidden */
  31652. _extension: string;
  31653. /** @hidden */
  31654. _files: Nullable<string[]>;
  31655. /** @hidden */
  31656. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31657. /** @hidden */
  31658. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31659. /** @hidden */
  31660. _framebuffer: Nullable<WebGLFramebuffer>;
  31661. /** @hidden */
  31662. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31663. /** @hidden */
  31664. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31665. /** @hidden */
  31666. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31667. /** @hidden */
  31668. _attachments: Nullable<number[]>;
  31669. /** @hidden */
  31670. _cachedCoordinatesMode: Nullable<number>;
  31671. /** @hidden */
  31672. _cachedWrapU: Nullable<number>;
  31673. /** @hidden */
  31674. _cachedWrapV: Nullable<number>;
  31675. /** @hidden */
  31676. _cachedWrapR: Nullable<number>;
  31677. /** @hidden */
  31678. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31679. /** @hidden */
  31680. _isDisabled: boolean;
  31681. /** @hidden */
  31682. _compression: Nullable<string>;
  31683. /** @hidden */
  31684. _generateStencilBuffer: boolean;
  31685. /** @hidden */
  31686. _generateDepthBuffer: boolean;
  31687. /** @hidden */
  31688. _comparisonFunction: number;
  31689. /** @hidden */
  31690. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31691. /** @hidden */
  31692. _lodGenerationScale: number;
  31693. /** @hidden */
  31694. _lodGenerationOffset: number;
  31695. /** @hidden */
  31696. _colorTextureArray: Nullable<WebGLTexture>;
  31697. /** @hidden */
  31698. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31699. /** @hidden */
  31700. _lodTextureHigh: Nullable<BaseTexture>;
  31701. /** @hidden */
  31702. _lodTextureMid: Nullable<BaseTexture>;
  31703. /** @hidden */
  31704. _lodTextureLow: Nullable<BaseTexture>;
  31705. /** @hidden */
  31706. _isRGBD: boolean;
  31707. /** @hidden */
  31708. _linearSpecularLOD: boolean;
  31709. /** @hidden */
  31710. _irradianceTexture: Nullable<BaseTexture>;
  31711. /** @hidden */
  31712. _webGLTexture: Nullable<WebGLTexture>;
  31713. /** @hidden */
  31714. _references: number;
  31715. private _engine;
  31716. /**
  31717. * Gets the Engine the texture belongs to.
  31718. * @returns The babylon engine
  31719. */
  31720. getEngine(): ThinEngine;
  31721. /**
  31722. * Gets the data source type of the texture
  31723. */
  31724. readonly source: InternalTextureSource;
  31725. /**
  31726. * Creates a new InternalTexture
  31727. * @param engine defines the engine to use
  31728. * @param source defines the type of data that will be used
  31729. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31730. */
  31731. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31732. /**
  31733. * Increments the number of references (ie. the number of Texture that point to it)
  31734. */
  31735. incrementReferences(): void;
  31736. /**
  31737. * Change the size of the texture (not the size of the content)
  31738. * @param width defines the new width
  31739. * @param height defines the new height
  31740. * @param depth defines the new depth (1 by default)
  31741. */
  31742. updateSize(width: int, height: int, depth?: int): void;
  31743. /** @hidden */
  31744. _rebuild(): void;
  31745. /** @hidden */
  31746. _swapAndDie(target: InternalTexture): void;
  31747. /**
  31748. * Dispose the current allocated resources
  31749. */
  31750. dispose(): void;
  31751. }
  31752. }
  31753. declare module "babylonjs/Audio/analyser" {
  31754. import { Scene } from "babylonjs/scene";
  31755. /**
  31756. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31758. */
  31759. export class Analyser {
  31760. /**
  31761. * Gets or sets the smoothing
  31762. * @ignorenaming
  31763. */
  31764. SMOOTHING: number;
  31765. /**
  31766. * Gets or sets the FFT table size
  31767. * @ignorenaming
  31768. */
  31769. FFT_SIZE: number;
  31770. /**
  31771. * Gets or sets the bar graph amplitude
  31772. * @ignorenaming
  31773. */
  31774. BARGRAPHAMPLITUDE: number;
  31775. /**
  31776. * Gets or sets the position of the debug canvas
  31777. * @ignorenaming
  31778. */
  31779. DEBUGCANVASPOS: {
  31780. x: number;
  31781. y: number;
  31782. };
  31783. /**
  31784. * Gets or sets the debug canvas size
  31785. * @ignorenaming
  31786. */
  31787. DEBUGCANVASSIZE: {
  31788. width: number;
  31789. height: number;
  31790. };
  31791. private _byteFreqs;
  31792. private _byteTime;
  31793. private _floatFreqs;
  31794. private _webAudioAnalyser;
  31795. private _debugCanvas;
  31796. private _debugCanvasContext;
  31797. private _scene;
  31798. private _registerFunc;
  31799. private _audioEngine;
  31800. /**
  31801. * Creates a new analyser
  31802. * @param scene defines hosting scene
  31803. */
  31804. constructor(scene: Scene);
  31805. /**
  31806. * Get the number of data values you will have to play with for the visualization
  31807. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31808. * @returns a number
  31809. */
  31810. getFrequencyBinCount(): number;
  31811. /**
  31812. * Gets the current frequency data as a byte array
  31813. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31814. * @returns a Uint8Array
  31815. */
  31816. getByteFrequencyData(): Uint8Array;
  31817. /**
  31818. * Gets the current waveform as a byte array
  31819. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31820. * @returns a Uint8Array
  31821. */
  31822. getByteTimeDomainData(): Uint8Array;
  31823. /**
  31824. * Gets the current frequency data as a float array
  31825. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31826. * @returns a Float32Array
  31827. */
  31828. getFloatFrequencyData(): Float32Array;
  31829. /**
  31830. * Renders the debug canvas
  31831. */
  31832. drawDebugCanvas(): void;
  31833. /**
  31834. * Stops rendering the debug canvas and removes it
  31835. */
  31836. stopDebugCanvas(): void;
  31837. /**
  31838. * Connects two audio nodes
  31839. * @param inputAudioNode defines first node to connect
  31840. * @param outputAudioNode defines second node to connect
  31841. */
  31842. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31843. /**
  31844. * Releases all associated resources
  31845. */
  31846. dispose(): void;
  31847. }
  31848. }
  31849. declare module "babylonjs/Audio/audioEngine" {
  31850. import { IDisposable } from "babylonjs/scene";
  31851. import { Analyser } from "babylonjs/Audio/analyser";
  31852. import { Nullable } from "babylonjs/types";
  31853. import { Observable } from "babylonjs/Misc/observable";
  31854. /**
  31855. * This represents an audio engine and it is responsible
  31856. * to play, synchronize and analyse sounds throughout the application.
  31857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31858. */
  31859. export interface IAudioEngine extends IDisposable {
  31860. /**
  31861. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31862. */
  31863. readonly canUseWebAudio: boolean;
  31864. /**
  31865. * Gets the current AudioContext if available.
  31866. */
  31867. readonly audioContext: Nullable<AudioContext>;
  31868. /**
  31869. * The master gain node defines the global audio volume of your audio engine.
  31870. */
  31871. readonly masterGain: GainNode;
  31872. /**
  31873. * Gets whether or not mp3 are supported by your browser.
  31874. */
  31875. readonly isMP3supported: boolean;
  31876. /**
  31877. * Gets whether or not ogg are supported by your browser.
  31878. */
  31879. readonly isOGGsupported: boolean;
  31880. /**
  31881. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31882. * @ignoreNaming
  31883. */
  31884. WarnedWebAudioUnsupported: boolean;
  31885. /**
  31886. * Defines if the audio engine relies on a custom unlocked button.
  31887. * In this case, the embedded button will not be displayed.
  31888. */
  31889. useCustomUnlockedButton: boolean;
  31890. /**
  31891. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31892. */
  31893. readonly unlocked: boolean;
  31894. /**
  31895. * Event raised when audio has been unlocked on the browser.
  31896. */
  31897. onAudioUnlockedObservable: Observable<AudioEngine>;
  31898. /**
  31899. * Event raised when audio has been locked on the browser.
  31900. */
  31901. onAudioLockedObservable: Observable<AudioEngine>;
  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. }
  31913. /**
  31914. * This represents the default audio engine used in babylon.
  31915. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31917. */
  31918. export class AudioEngine implements IAudioEngine {
  31919. private _audioContext;
  31920. private _audioContextInitialized;
  31921. private _muteButton;
  31922. private _hostElement;
  31923. /**
  31924. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31925. */
  31926. canUseWebAudio: boolean;
  31927. /**
  31928. * The master gain node defines the global audio volume of your audio engine.
  31929. */
  31930. masterGain: GainNode;
  31931. /**
  31932. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31933. * @ignoreNaming
  31934. */
  31935. WarnedWebAudioUnsupported: boolean;
  31936. /**
  31937. * Gets whether or not mp3 are supported by your browser.
  31938. */
  31939. isMP3supported: boolean;
  31940. /**
  31941. * Gets whether or not ogg are supported by your browser.
  31942. */
  31943. isOGGsupported: boolean;
  31944. /**
  31945. * Gets whether audio has been unlocked on the device.
  31946. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31947. * a user interaction has happened.
  31948. */
  31949. unlocked: boolean;
  31950. /**
  31951. * Defines if the audio engine relies on a custom unlocked button.
  31952. * In this case, the embedded button will not be displayed.
  31953. */
  31954. useCustomUnlockedButton: boolean;
  31955. /**
  31956. * Event raised when audio has been unlocked on the browser.
  31957. */
  31958. onAudioUnlockedObservable: Observable<AudioEngine>;
  31959. /**
  31960. * Event raised when audio has been locked on the browser.
  31961. */
  31962. onAudioLockedObservable: Observable<AudioEngine>;
  31963. /**
  31964. * Gets the current AudioContext if available.
  31965. */
  31966. readonly audioContext: Nullable<AudioContext>;
  31967. private _connectedAnalyser;
  31968. /**
  31969. * Instantiates a new audio engine.
  31970. *
  31971. * There should be only one per page as some browsers restrict the number
  31972. * of audio contexts you can create.
  31973. * @param hostElement defines the host element where to display the mute icon if necessary
  31974. */
  31975. constructor(hostElement?: Nullable<HTMLElement>);
  31976. /**
  31977. * Flags the audio engine in Locked state.
  31978. * This happens due to new browser policies preventing audio to autoplay.
  31979. */
  31980. lock(): void;
  31981. /**
  31982. * Unlocks the audio engine once a user action has been done on the dom.
  31983. * This is helpful to resume play once browser policies have been satisfied.
  31984. */
  31985. unlock(): void;
  31986. private _resumeAudioContext;
  31987. private _initializeAudioContext;
  31988. private _tryToRun;
  31989. private _triggerRunningState;
  31990. private _triggerSuspendedState;
  31991. private _displayMuteButton;
  31992. private _moveButtonToTopLeft;
  31993. private _onResize;
  31994. private _hideMuteButton;
  31995. /**
  31996. * Destroy and release the resources associated with the audio ccontext.
  31997. */
  31998. dispose(): void;
  31999. /**
  32000. * Gets the global volume sets on the master gain.
  32001. * @returns the global volume if set or -1 otherwise
  32002. */
  32003. getGlobalVolume(): number;
  32004. /**
  32005. * Sets the global volume of your experience (sets on the master gain).
  32006. * @param newVolume Defines the new global volume of the application
  32007. */
  32008. setGlobalVolume(newVolume: number): void;
  32009. /**
  32010. * Connect the audio engine to an audio analyser allowing some amazing
  32011. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32013. * @param analyser The analyser to connect to the engine
  32014. */
  32015. connectToAnalyser(analyser: Analyser): void;
  32016. }
  32017. }
  32018. declare module "babylonjs/Loading/loadingScreen" {
  32019. /**
  32020. * Interface used to present a loading screen while loading a scene
  32021. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32022. */
  32023. export interface ILoadingScreen {
  32024. /**
  32025. * Function called to display the loading screen
  32026. */
  32027. displayLoadingUI: () => void;
  32028. /**
  32029. * Function called to hide the loading screen
  32030. */
  32031. hideLoadingUI: () => void;
  32032. /**
  32033. * Gets or sets the color to use for the background
  32034. */
  32035. loadingUIBackgroundColor: string;
  32036. /**
  32037. * Gets or sets the text to display while loading
  32038. */
  32039. loadingUIText: string;
  32040. }
  32041. /**
  32042. * Class used for the default loading screen
  32043. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32044. */
  32045. export class DefaultLoadingScreen implements ILoadingScreen {
  32046. private _renderingCanvas;
  32047. private _loadingText;
  32048. private _loadingDivBackgroundColor;
  32049. private _loadingDiv;
  32050. private _loadingTextDiv;
  32051. /** Gets or sets the logo url to use for the default loading screen */
  32052. static DefaultLogoUrl: string;
  32053. /** Gets or sets the spinner url to use for the default loading screen */
  32054. static DefaultSpinnerUrl: string;
  32055. /**
  32056. * Creates a new default loading screen
  32057. * @param _renderingCanvas defines the canvas used to render the scene
  32058. * @param _loadingText defines the default text to display
  32059. * @param _loadingDivBackgroundColor defines the default background color
  32060. */
  32061. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32062. /**
  32063. * Function called to display the loading screen
  32064. */
  32065. displayLoadingUI(): void;
  32066. /**
  32067. * Function called to hide the loading screen
  32068. */
  32069. hideLoadingUI(): void;
  32070. /**
  32071. * Gets or sets the text to display while loading
  32072. */
  32073. loadingUIText: string;
  32074. /**
  32075. * Gets or sets the color to use for the background
  32076. */
  32077. loadingUIBackgroundColor: string;
  32078. private _resizeLoadingUI;
  32079. }
  32080. }
  32081. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  32082. /**
  32083. * Interface for any object that can request an animation frame
  32084. */
  32085. export interface ICustomAnimationFrameRequester {
  32086. /**
  32087. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32088. */
  32089. renderFunction?: Function;
  32090. /**
  32091. * Called to request the next frame to render to
  32092. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32093. */
  32094. requestAnimationFrame: Function;
  32095. /**
  32096. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32097. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32098. */
  32099. requestID?: number;
  32100. }
  32101. }
  32102. declare module "babylonjs/Misc/performanceMonitor" {
  32103. /**
  32104. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32105. */
  32106. export class PerformanceMonitor {
  32107. private _enabled;
  32108. private _rollingFrameTime;
  32109. private _lastFrameTimeMs;
  32110. /**
  32111. * constructor
  32112. * @param frameSampleSize The number of samples required to saturate the sliding window
  32113. */
  32114. constructor(frameSampleSize?: number);
  32115. /**
  32116. * Samples current frame
  32117. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32118. */
  32119. sampleFrame(timeMs?: number): void;
  32120. /**
  32121. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32122. */
  32123. readonly averageFrameTime: number;
  32124. /**
  32125. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32126. */
  32127. readonly averageFrameTimeVariance: number;
  32128. /**
  32129. * Returns the frame time of the most recent frame
  32130. */
  32131. readonly instantaneousFrameTime: number;
  32132. /**
  32133. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32134. */
  32135. readonly averageFPS: number;
  32136. /**
  32137. * Returns the average framerate in frames per second using the most recent frame time
  32138. */
  32139. readonly instantaneousFPS: number;
  32140. /**
  32141. * Returns true if enough samples have been taken to completely fill the sliding window
  32142. */
  32143. readonly isSaturated: boolean;
  32144. /**
  32145. * Enables contributions to the sliding window sample set
  32146. */
  32147. enable(): void;
  32148. /**
  32149. * Disables contributions to the sliding window sample set
  32150. * Samples will not be interpolated over the disabled period
  32151. */
  32152. disable(): void;
  32153. /**
  32154. * Returns true if sampling is enabled
  32155. */
  32156. readonly isEnabled: boolean;
  32157. /**
  32158. * Resets performance monitor
  32159. */
  32160. reset(): void;
  32161. }
  32162. /**
  32163. * RollingAverage
  32164. *
  32165. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32166. */
  32167. export class RollingAverage {
  32168. /**
  32169. * Current average
  32170. */
  32171. average: number;
  32172. /**
  32173. * Current variance
  32174. */
  32175. variance: number;
  32176. protected _samples: Array<number>;
  32177. protected _sampleCount: number;
  32178. protected _pos: number;
  32179. protected _m2: number;
  32180. /**
  32181. * constructor
  32182. * @param length The number of samples required to saturate the sliding window
  32183. */
  32184. constructor(length: number);
  32185. /**
  32186. * Adds a sample to the sample set
  32187. * @param v The sample value
  32188. */
  32189. add(v: number): void;
  32190. /**
  32191. * Returns previously added values or null if outside of history or outside the sliding window domain
  32192. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32193. * @return Value previously recorded with add() or null if outside of range
  32194. */
  32195. history(i: number): number;
  32196. /**
  32197. * Returns true if enough samples have been taken to completely fill the sliding window
  32198. * @return true if sample-set saturated
  32199. */
  32200. isSaturated(): boolean;
  32201. /**
  32202. * Resets the rolling average (equivalent to 0 samples taken so far)
  32203. */
  32204. reset(): void;
  32205. /**
  32206. * Wraps a value around the sample range boundaries
  32207. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32208. * @return Wrapped position in sample range
  32209. */
  32210. protected _wrapPosition(i: number): number;
  32211. }
  32212. }
  32213. declare module "babylonjs/Misc/perfCounter" {
  32214. /**
  32215. * This class is used to track a performance counter which is number based.
  32216. * The user has access to many properties which give statistics of different nature.
  32217. *
  32218. * The implementer can track two kinds of Performance Counter: time and count.
  32219. * 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.
  32220. * 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.
  32221. */
  32222. export class PerfCounter {
  32223. /**
  32224. * Gets or sets a global boolean to turn on and off all the counters
  32225. */
  32226. static Enabled: boolean;
  32227. /**
  32228. * Returns the smallest value ever
  32229. */
  32230. readonly min: number;
  32231. /**
  32232. * Returns the biggest value ever
  32233. */
  32234. readonly max: number;
  32235. /**
  32236. * Returns the average value since the performance counter is running
  32237. */
  32238. readonly average: number;
  32239. /**
  32240. * Returns the average value of the last second the counter was monitored
  32241. */
  32242. readonly lastSecAverage: number;
  32243. /**
  32244. * Returns the current value
  32245. */
  32246. readonly current: number;
  32247. /**
  32248. * Gets the accumulated total
  32249. */
  32250. readonly total: number;
  32251. /**
  32252. * Gets the total value count
  32253. */
  32254. readonly count: number;
  32255. /**
  32256. * Creates a new counter
  32257. */
  32258. constructor();
  32259. /**
  32260. * Call this method to start monitoring a new frame.
  32261. * 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.
  32262. */
  32263. fetchNewFrame(): void;
  32264. /**
  32265. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32266. * @param newCount the count value to add to the monitored count
  32267. * @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.
  32268. */
  32269. addCount(newCount: number, fetchResult: boolean): void;
  32270. /**
  32271. * Start monitoring this performance counter
  32272. */
  32273. beginMonitoring(): void;
  32274. /**
  32275. * Compute the time lapsed since the previous beginMonitoring() call.
  32276. * @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
  32277. */
  32278. endMonitoring(newFrame?: boolean): void;
  32279. private _fetchResult;
  32280. private _startMonitoringTime;
  32281. private _min;
  32282. private _max;
  32283. private _average;
  32284. private _current;
  32285. private _totalValueCount;
  32286. private _totalAccumulated;
  32287. private _lastSecAverage;
  32288. private _lastSecAccumulated;
  32289. private _lastSecTime;
  32290. private _lastSecValueCount;
  32291. }
  32292. }
  32293. declare module "babylonjs/Engines/engine" {
  32294. import { Observable } from "babylonjs/Misc/observable";
  32295. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32296. import { Scene } from "babylonjs/scene";
  32297. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32298. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32299. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32300. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32301. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32302. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32303. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32304. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32305. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32306. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32307. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32308. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32309. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32310. import { Material } from "babylonjs/Materials/material";
  32311. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32312. /**
  32313. * Defines the interface used by display changed events
  32314. */
  32315. export interface IDisplayChangedEventArgs {
  32316. /** Gets the vrDisplay object (if any) */
  32317. vrDisplay: Nullable<any>;
  32318. /** Gets a boolean indicating if webVR is supported */
  32319. vrSupported: boolean;
  32320. }
  32321. /**
  32322. * Defines the interface used by objects containing a viewport (like a camera)
  32323. */
  32324. interface IViewportOwnerLike {
  32325. /**
  32326. * Gets or sets the viewport
  32327. */
  32328. viewport: IViewportLike;
  32329. }
  32330. /**
  32331. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32332. */
  32333. export class Engine extends ThinEngine {
  32334. /** Defines that alpha blending is disabled */
  32335. static readonly ALPHA_DISABLE: number;
  32336. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32337. static readonly ALPHA_ADD: number;
  32338. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32339. static readonly ALPHA_COMBINE: number;
  32340. /** Defines that alpha blending to DEST - SRC * DEST */
  32341. static readonly ALPHA_SUBTRACT: number;
  32342. /** Defines that alpha blending to SRC * DEST */
  32343. static readonly ALPHA_MULTIPLY: number;
  32344. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32345. static readonly ALPHA_MAXIMIZED: number;
  32346. /** Defines that alpha blending to SRC + DEST */
  32347. static readonly ALPHA_ONEONE: number;
  32348. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32349. static readonly ALPHA_PREMULTIPLIED: number;
  32350. /**
  32351. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32352. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32353. */
  32354. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32355. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32356. static readonly ALPHA_INTERPOLATE: number;
  32357. /**
  32358. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32359. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32360. */
  32361. static readonly ALPHA_SCREENMODE: number;
  32362. /** Defines that the ressource is not delayed*/
  32363. static readonly DELAYLOADSTATE_NONE: number;
  32364. /** Defines that the ressource was successfully delay loaded */
  32365. static readonly DELAYLOADSTATE_LOADED: number;
  32366. /** Defines that the ressource is currently delay loading */
  32367. static readonly DELAYLOADSTATE_LOADING: number;
  32368. /** Defines that the ressource is delayed and has not started loading */
  32369. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32370. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32371. static readonly NEVER: number;
  32372. /** 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 */
  32373. static readonly ALWAYS: number;
  32374. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32375. static readonly LESS: number;
  32376. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32377. static readonly EQUAL: number;
  32378. /** 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 */
  32379. static readonly LEQUAL: number;
  32380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32381. static readonly GREATER: number;
  32382. /** 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 */
  32383. static readonly GEQUAL: number;
  32384. /** 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 */
  32385. static readonly NOTEQUAL: number;
  32386. /** Passed to stencilOperation to specify that stencil value must be kept */
  32387. static readonly KEEP: number;
  32388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32389. static readonly REPLACE: number;
  32390. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32391. static readonly INCR: number;
  32392. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32393. static readonly DECR: number;
  32394. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32395. static readonly INVERT: number;
  32396. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32397. static readonly INCR_WRAP: number;
  32398. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32399. static readonly DECR_WRAP: number;
  32400. /** Texture is not repeating outside of 0..1 UVs */
  32401. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32402. /** Texture is repeating outside of 0..1 UVs */
  32403. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32404. /** Texture is repeating and mirrored */
  32405. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32406. /** ALPHA */
  32407. static readonly TEXTUREFORMAT_ALPHA: number;
  32408. /** LUMINANCE */
  32409. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32410. /** LUMINANCE_ALPHA */
  32411. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32412. /** RGB */
  32413. static readonly TEXTUREFORMAT_RGB: number;
  32414. /** RGBA */
  32415. static readonly TEXTUREFORMAT_RGBA: number;
  32416. /** RED */
  32417. static readonly TEXTUREFORMAT_RED: number;
  32418. /** RED (2nd reference) */
  32419. static readonly TEXTUREFORMAT_R: number;
  32420. /** RG */
  32421. static readonly TEXTUREFORMAT_RG: number;
  32422. /** RED_INTEGER */
  32423. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32424. /** RED_INTEGER (2nd reference) */
  32425. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32426. /** RG_INTEGER */
  32427. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32428. /** RGB_INTEGER */
  32429. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32430. /** RGBA_INTEGER */
  32431. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32432. /** UNSIGNED_BYTE */
  32433. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32434. /** UNSIGNED_BYTE (2nd reference) */
  32435. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32436. /** FLOAT */
  32437. static readonly TEXTURETYPE_FLOAT: number;
  32438. /** HALF_FLOAT */
  32439. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32440. /** BYTE */
  32441. static readonly TEXTURETYPE_BYTE: number;
  32442. /** SHORT */
  32443. static readonly TEXTURETYPE_SHORT: number;
  32444. /** UNSIGNED_SHORT */
  32445. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32446. /** INT */
  32447. static readonly TEXTURETYPE_INT: number;
  32448. /** UNSIGNED_INT */
  32449. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32450. /** UNSIGNED_SHORT_4_4_4_4 */
  32451. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32452. /** UNSIGNED_SHORT_5_5_5_1 */
  32453. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32454. /** UNSIGNED_SHORT_5_6_5 */
  32455. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32456. /** UNSIGNED_INT_2_10_10_10_REV */
  32457. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32458. /** UNSIGNED_INT_24_8 */
  32459. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32460. /** UNSIGNED_INT_10F_11F_11F_REV */
  32461. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32462. /** UNSIGNED_INT_5_9_9_9_REV */
  32463. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32464. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32465. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32466. /** nearest is mag = nearest and min = nearest and mip = linear */
  32467. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32468. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32469. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32470. /** Trilinear is mag = linear and min = linear and mip = linear */
  32471. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32472. /** nearest is mag = nearest and min = nearest and mip = linear */
  32473. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32474. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32475. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32476. /** Trilinear is mag = linear and min = linear and mip = linear */
  32477. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32478. /** mag = nearest and min = nearest and mip = nearest */
  32479. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32480. /** mag = nearest and min = linear and mip = nearest */
  32481. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32482. /** mag = nearest and min = linear and mip = linear */
  32483. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32484. /** mag = nearest and min = linear and mip = none */
  32485. static readonly TEXTURE_NEAREST_LINEAR: number;
  32486. /** mag = nearest and min = nearest and mip = none */
  32487. static readonly TEXTURE_NEAREST_NEAREST: number;
  32488. /** mag = linear and min = nearest and mip = nearest */
  32489. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32490. /** mag = linear and min = nearest and mip = linear */
  32491. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32492. /** mag = linear and min = linear and mip = none */
  32493. static readonly TEXTURE_LINEAR_LINEAR: number;
  32494. /** mag = linear and min = nearest and mip = none */
  32495. static readonly TEXTURE_LINEAR_NEAREST: number;
  32496. /** Explicit coordinates mode */
  32497. static readonly TEXTURE_EXPLICIT_MODE: number;
  32498. /** Spherical coordinates mode */
  32499. static readonly TEXTURE_SPHERICAL_MODE: number;
  32500. /** Planar coordinates mode */
  32501. static readonly TEXTURE_PLANAR_MODE: number;
  32502. /** Cubic coordinates mode */
  32503. static readonly TEXTURE_CUBIC_MODE: number;
  32504. /** Projection coordinates mode */
  32505. static readonly TEXTURE_PROJECTION_MODE: number;
  32506. /** Skybox coordinates mode */
  32507. static readonly TEXTURE_SKYBOX_MODE: number;
  32508. /** Inverse Cubic coordinates mode */
  32509. static readonly TEXTURE_INVCUBIC_MODE: number;
  32510. /** Equirectangular coordinates mode */
  32511. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32512. /** Equirectangular Fixed coordinates mode */
  32513. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32514. /** Equirectangular Fixed Mirrored coordinates mode */
  32515. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32516. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32517. static readonly SCALEMODE_FLOOR: number;
  32518. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32519. static readonly SCALEMODE_NEAREST: number;
  32520. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32521. static readonly SCALEMODE_CEILING: number;
  32522. /**
  32523. * Returns the current npm package of the sdk
  32524. */
  32525. static readonly NpmPackage: string;
  32526. /**
  32527. * Returns the current version of the framework
  32528. */
  32529. static readonly Version: string;
  32530. /** Gets the list of created engines */
  32531. static readonly Instances: Engine[];
  32532. /**
  32533. * Gets the latest created engine
  32534. */
  32535. static readonly LastCreatedEngine: Nullable<Engine>;
  32536. /**
  32537. * Gets the latest created scene
  32538. */
  32539. static readonly LastCreatedScene: Nullable<Scene>;
  32540. /**
  32541. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32542. * @param flag defines which part of the materials must be marked as dirty
  32543. * @param predicate defines a predicate used to filter which materials should be affected
  32544. */
  32545. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32546. /**
  32547. * Method called to create the default loading screen.
  32548. * This can be overriden in your own app.
  32549. * @param canvas The rendering canvas element
  32550. * @returns The loading screen
  32551. */
  32552. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32553. /**
  32554. * Method called to create the default rescale post process on each engine.
  32555. */
  32556. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32557. /**
  32558. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32559. **/
  32560. enableOfflineSupport: boolean;
  32561. /**
  32562. * 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)
  32563. **/
  32564. disableManifestCheck: boolean;
  32565. /**
  32566. * Gets the list of created scenes
  32567. */
  32568. scenes: Scene[];
  32569. /**
  32570. * Event raised when a new scene is created
  32571. */
  32572. onNewSceneAddedObservable: Observable<Scene>;
  32573. /**
  32574. * Gets the list of created postprocesses
  32575. */
  32576. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32577. /**
  32578. * Gets a boolean indicating if the pointer is currently locked
  32579. */
  32580. isPointerLock: boolean;
  32581. /**
  32582. * Observable event triggered each time the rendering canvas is resized
  32583. */
  32584. onResizeObservable: Observable<Engine>;
  32585. /**
  32586. * Observable event triggered each time the canvas loses focus
  32587. */
  32588. onCanvasBlurObservable: Observable<Engine>;
  32589. /**
  32590. * Observable event triggered each time the canvas gains focus
  32591. */
  32592. onCanvasFocusObservable: Observable<Engine>;
  32593. /**
  32594. * Observable event triggered each time the canvas receives pointerout event
  32595. */
  32596. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32597. /**
  32598. * Observable raised when the engine begins a new frame
  32599. */
  32600. onBeginFrameObservable: Observable<Engine>;
  32601. /**
  32602. * If set, will be used to request the next animation frame for the render loop
  32603. */
  32604. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32605. /**
  32606. * Observable raised when the engine ends the current frame
  32607. */
  32608. onEndFrameObservable: Observable<Engine>;
  32609. /**
  32610. * Observable raised when the engine is about to compile a shader
  32611. */
  32612. onBeforeShaderCompilationObservable: Observable<Engine>;
  32613. /**
  32614. * Observable raised when the engine has jsut compiled a shader
  32615. */
  32616. onAfterShaderCompilationObservable: Observable<Engine>;
  32617. /**
  32618. * Gets the audio engine
  32619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32620. * @ignorenaming
  32621. */
  32622. static audioEngine: IAudioEngine;
  32623. /**
  32624. * Default AudioEngine factory responsible of creating the Audio Engine.
  32625. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32626. */
  32627. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32628. /**
  32629. * Default offline support factory responsible of creating a tool used to store data locally.
  32630. * By default, this will create a Database object if the workload has been embedded.
  32631. */
  32632. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32633. private _loadingScreen;
  32634. private _pointerLockRequested;
  32635. private _dummyFramebuffer;
  32636. private _rescalePostProcess;
  32637. /** @hidden */
  32638. protected _alphaMode: number;
  32639. /** @hidden */
  32640. protected _alphaEquation: number;
  32641. private _deterministicLockstep;
  32642. private _lockstepMaxSteps;
  32643. private _timeStep;
  32644. protected readonly _supportsHardwareTextureRescaling: boolean;
  32645. private _fps;
  32646. private _deltaTime;
  32647. /** @hidden */
  32648. _drawCalls: PerfCounter;
  32649. /**
  32650. * Turn this value on if you want to pause FPS computation when in background
  32651. */
  32652. disablePerformanceMonitorInBackground: boolean;
  32653. private _performanceMonitor;
  32654. /**
  32655. * Gets the performance monitor attached to this engine
  32656. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32657. */
  32658. readonly performanceMonitor: PerformanceMonitor;
  32659. private _onFocus;
  32660. private _onBlur;
  32661. private _onCanvasPointerOut;
  32662. private _onCanvasBlur;
  32663. private _onCanvasFocus;
  32664. private _onFullscreenChange;
  32665. private _onPointerLockChange;
  32666. /**
  32667. * Gets the HTML element used to attach event listeners
  32668. * @returns a HTML element
  32669. */
  32670. getInputElement(): Nullable<HTMLElement>;
  32671. /**
  32672. * Creates a new engine
  32673. * @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
  32674. * @param antialias defines enable antialiasing (default: false)
  32675. * @param options defines further options to be sent to the getContext() function
  32676. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32677. */
  32678. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32679. /**
  32680. * Gets current aspect ratio
  32681. * @param viewportOwner defines the camera to use to get the aspect ratio
  32682. * @param useScreen defines if screen size must be used (or the current render target if any)
  32683. * @returns a number defining the aspect ratio
  32684. */
  32685. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32686. /**
  32687. * Gets current screen aspect ratio
  32688. * @returns a number defining the aspect ratio
  32689. */
  32690. getScreenAspectRatio(): number;
  32691. /**
  32692. * Gets the client rect of the HTML canvas attached with the current webGL context
  32693. * @returns a client rectanglee
  32694. */
  32695. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32696. /**
  32697. * Gets the client rect of the HTML element used for events
  32698. * @returns a client rectanglee
  32699. */
  32700. getInputElementClientRect(): Nullable<ClientRect>;
  32701. /**
  32702. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32704. * @returns true if engine is in deterministic lock step mode
  32705. */
  32706. isDeterministicLockStep(): boolean;
  32707. /**
  32708. * Gets the max steps when engine is running in deterministic lock step
  32709. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32710. * @returns the max steps
  32711. */
  32712. getLockstepMaxSteps(): number;
  32713. /**
  32714. * Returns the time in ms between steps when using deterministic lock step.
  32715. * @returns time step in (ms)
  32716. */
  32717. getTimeStep(): number;
  32718. /**
  32719. * Force the mipmap generation for the given render target texture
  32720. * @param texture defines the render target texture to use
  32721. */
  32722. generateMipMapsForCubemap(texture: InternalTexture): void;
  32723. /** States */
  32724. /**
  32725. * Set various states to the webGL context
  32726. * @param culling defines backface culling state
  32727. * @param zOffset defines the value to apply to zOffset (0 by default)
  32728. * @param force defines if states must be applied even if cache is up to date
  32729. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32730. */
  32731. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32732. /**
  32733. * Set the z offset to apply to current rendering
  32734. * @param value defines the offset to apply
  32735. */
  32736. setZOffset(value: number): void;
  32737. /**
  32738. * Gets the current value of the zOffset
  32739. * @returns the current zOffset state
  32740. */
  32741. getZOffset(): number;
  32742. /**
  32743. * Enable or disable depth buffering
  32744. * @param enable defines the state to set
  32745. */
  32746. setDepthBuffer(enable: boolean): void;
  32747. /**
  32748. * Gets a boolean indicating if depth writing is enabled
  32749. * @returns the current depth writing state
  32750. */
  32751. getDepthWrite(): boolean;
  32752. /**
  32753. * Enable or disable depth writing
  32754. * @param enable defines the state to set
  32755. */
  32756. setDepthWrite(enable: boolean): void;
  32757. /**
  32758. * Enable or disable color writing
  32759. * @param enable defines the state to set
  32760. */
  32761. setColorWrite(enable: boolean): void;
  32762. /**
  32763. * Gets a boolean indicating if color writing is enabled
  32764. * @returns the current color writing state
  32765. */
  32766. getColorWrite(): boolean;
  32767. /**
  32768. * Sets alpha constants used by some alpha blending modes
  32769. * @param r defines the red component
  32770. * @param g defines the green component
  32771. * @param b defines the blue component
  32772. * @param a defines the alpha component
  32773. */
  32774. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32775. /**
  32776. * Sets the current alpha mode
  32777. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32778. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32779. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32780. */
  32781. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32782. /**
  32783. * Gets the current alpha mode
  32784. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32785. * @returns the current alpha mode
  32786. */
  32787. getAlphaMode(): number;
  32788. /**
  32789. * Sets the current alpha equation
  32790. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32791. */
  32792. setAlphaEquation(equation: number): void;
  32793. /**
  32794. * Gets the current alpha equation.
  32795. * @returns the current alpha equation
  32796. */
  32797. getAlphaEquation(): number;
  32798. /**
  32799. * Gets a boolean indicating if stencil buffer is enabled
  32800. * @returns the current stencil buffer state
  32801. */
  32802. getStencilBuffer(): boolean;
  32803. /**
  32804. * Enable or disable the stencil buffer
  32805. * @param enable defines if the stencil buffer must be enabled or disabled
  32806. */
  32807. setStencilBuffer(enable: boolean): void;
  32808. /**
  32809. * Gets the current stencil mask
  32810. * @returns a number defining the new stencil mask to use
  32811. */
  32812. getStencilMask(): number;
  32813. /**
  32814. * Sets the current stencil mask
  32815. * @param mask defines the new stencil mask to use
  32816. */
  32817. setStencilMask(mask: number): void;
  32818. /**
  32819. * Gets the current stencil function
  32820. * @returns a number defining the stencil function to use
  32821. */
  32822. getStencilFunction(): number;
  32823. /**
  32824. * Gets the current stencil reference value
  32825. * @returns a number defining the stencil reference value to use
  32826. */
  32827. getStencilFunctionReference(): number;
  32828. /**
  32829. * Gets the current stencil mask
  32830. * @returns a number defining the stencil mask to use
  32831. */
  32832. getStencilFunctionMask(): number;
  32833. /**
  32834. * Sets the current stencil function
  32835. * @param stencilFunc defines the new stencil function to use
  32836. */
  32837. setStencilFunction(stencilFunc: number): void;
  32838. /**
  32839. * Sets the current stencil reference
  32840. * @param reference defines the new stencil reference to use
  32841. */
  32842. setStencilFunctionReference(reference: number): void;
  32843. /**
  32844. * Sets the current stencil mask
  32845. * @param mask defines the new stencil mask to use
  32846. */
  32847. setStencilFunctionMask(mask: number): void;
  32848. /**
  32849. * Gets the current stencil operation when stencil fails
  32850. * @returns a number defining stencil operation to use when stencil fails
  32851. */
  32852. getStencilOperationFail(): number;
  32853. /**
  32854. * Gets the current stencil operation when depth fails
  32855. * @returns a number defining stencil operation to use when depth fails
  32856. */
  32857. getStencilOperationDepthFail(): number;
  32858. /**
  32859. * Gets the current stencil operation when stencil passes
  32860. * @returns a number defining stencil operation to use when stencil passes
  32861. */
  32862. getStencilOperationPass(): number;
  32863. /**
  32864. * Sets the stencil operation to use when stencil fails
  32865. * @param operation defines the stencil operation to use when stencil fails
  32866. */
  32867. setStencilOperationFail(operation: number): void;
  32868. /**
  32869. * Sets the stencil operation to use when depth fails
  32870. * @param operation defines the stencil operation to use when depth fails
  32871. */
  32872. setStencilOperationDepthFail(operation: number): void;
  32873. /**
  32874. * Sets the stencil operation to use when stencil passes
  32875. * @param operation defines the stencil operation to use when stencil passes
  32876. */
  32877. setStencilOperationPass(operation: number): void;
  32878. /**
  32879. * Sets a boolean indicating if the dithering state is enabled or disabled
  32880. * @param value defines the dithering state
  32881. */
  32882. setDitheringState(value: boolean): void;
  32883. /**
  32884. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32885. * @param value defines the rasterizer state
  32886. */
  32887. setRasterizerState(value: boolean): void;
  32888. /**
  32889. * Gets the current depth function
  32890. * @returns a number defining the depth function
  32891. */
  32892. getDepthFunction(): Nullable<number>;
  32893. /**
  32894. * Sets the current depth function
  32895. * @param depthFunc defines the function to use
  32896. */
  32897. setDepthFunction(depthFunc: number): void;
  32898. /**
  32899. * Sets the current depth function to GREATER
  32900. */
  32901. setDepthFunctionToGreater(): void;
  32902. /**
  32903. * Sets the current depth function to GEQUAL
  32904. */
  32905. setDepthFunctionToGreaterOrEqual(): void;
  32906. /**
  32907. * Sets the current depth function to LESS
  32908. */
  32909. setDepthFunctionToLess(): void;
  32910. /**
  32911. * Sets the current depth function to LEQUAL
  32912. */
  32913. setDepthFunctionToLessOrEqual(): void;
  32914. private _cachedStencilBuffer;
  32915. private _cachedStencilFunction;
  32916. private _cachedStencilMask;
  32917. private _cachedStencilOperationPass;
  32918. private _cachedStencilOperationFail;
  32919. private _cachedStencilOperationDepthFail;
  32920. private _cachedStencilReference;
  32921. /**
  32922. * Caches the the state of the stencil buffer
  32923. */
  32924. cacheStencilState(): void;
  32925. /**
  32926. * Restores the state of the stencil buffer
  32927. */
  32928. restoreStencilState(): void;
  32929. /**
  32930. * Directly set the WebGL Viewport
  32931. * @param x defines the x coordinate of the viewport (in screen space)
  32932. * @param y defines the y coordinate of the viewport (in screen space)
  32933. * @param width defines the width of the viewport (in screen space)
  32934. * @param height defines the height of the viewport (in screen space)
  32935. * @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
  32936. */
  32937. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32938. /**
  32939. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32940. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32941. * @param y defines the y-coordinate of the corner of the clear rectangle
  32942. * @param width defines the width of the clear rectangle
  32943. * @param height defines the height of the clear rectangle
  32944. * @param clearColor defines the clear color
  32945. */
  32946. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32947. /**
  32948. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32949. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32950. * @param y defines the y-coordinate of the corner of the clear rectangle
  32951. * @param width defines the width of the clear rectangle
  32952. * @param height defines the height of the clear rectangle
  32953. */
  32954. enableScissor(x: number, y: number, width: number, height: number): void;
  32955. /**
  32956. * Disable previously set scissor test rectangle
  32957. */
  32958. disableScissor(): void;
  32959. protected _reportDrawCall(): void;
  32960. /**
  32961. * Initializes a webVR display and starts listening to display change events
  32962. * The onVRDisplayChangedObservable will be notified upon these changes
  32963. * @returns The onVRDisplayChangedObservable
  32964. */
  32965. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32966. /** @hidden */
  32967. _prepareVRComponent(): void;
  32968. /** @hidden */
  32969. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32970. /** @hidden */
  32971. _submitVRFrame(): void;
  32972. /**
  32973. * Call this function to leave webVR mode
  32974. * Will do nothing if webVR is not supported or if there is no webVR device
  32975. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32976. */
  32977. disableVR(): void;
  32978. /**
  32979. * Gets a boolean indicating that the system is in VR mode and is presenting
  32980. * @returns true if VR mode is engaged
  32981. */
  32982. isVRPresenting(): boolean;
  32983. /** @hidden */
  32984. _requestVRFrame(): void;
  32985. /** @hidden */
  32986. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32987. /**
  32988. * Gets the source code of the vertex shader associated with a specific webGL program
  32989. * @param program defines the program to use
  32990. * @returns a string containing the source code of the vertex shader associated with the program
  32991. */
  32992. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32993. /**
  32994. * Gets the source code of the fragment shader associated with a specific webGL program
  32995. * @param program defines the program to use
  32996. * @returns a string containing the source code of the fragment shader associated with the program
  32997. */
  32998. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32999. /**
  33000. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33001. * @param x defines the x coordinate of the rectangle where pixels must be read
  33002. * @param y defines the y coordinate of the rectangle where pixels must be read
  33003. * @param width defines the width of the rectangle where pixels must be read
  33004. * @param height defines the height of the rectangle where pixels must be read
  33005. * @returns a Uint8Array containing RGBA colors
  33006. */
  33007. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  33008. /**
  33009. * Sets a depth stencil texture from a render target to the according uniform.
  33010. * @param channel The texture channel
  33011. * @param uniform The uniform to set
  33012. * @param texture The render target texture containing the depth stencil texture to apply
  33013. */
  33014. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33015. /**
  33016. * Sets a texture to the webGL context from a postprocess
  33017. * @param channel defines the channel to use
  33018. * @param postProcess defines the source postprocess
  33019. */
  33020. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33021. /**
  33022. * Binds the output of the passed in post process to the texture channel specified
  33023. * @param channel The channel the texture should be bound to
  33024. * @param postProcess The post process which's output should be bound
  33025. */
  33026. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33027. /** @hidden */
  33028. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33029. protected _rebuildBuffers(): void;
  33030. /** @hidden */
  33031. _renderFrame(): void;
  33032. _renderLoop(): void;
  33033. /** @hidden */
  33034. _renderViews(): boolean;
  33035. /**
  33036. * Toggle full screen mode
  33037. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33038. */
  33039. switchFullscreen(requestPointerLock: boolean): void;
  33040. /**
  33041. * Enters full screen mode
  33042. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33043. */
  33044. enterFullscreen(requestPointerLock: boolean): void;
  33045. /**
  33046. * Exits full screen mode
  33047. */
  33048. exitFullscreen(): void;
  33049. /**
  33050. * Enters Pointerlock mode
  33051. */
  33052. enterPointerlock(): void;
  33053. /**
  33054. * Exits Pointerlock mode
  33055. */
  33056. exitPointerlock(): void;
  33057. /**
  33058. * Begin a new frame
  33059. */
  33060. beginFrame(): void;
  33061. /**
  33062. * Enf the current frame
  33063. */
  33064. endFrame(): void;
  33065. resize(): void;
  33066. /**
  33067. * Set the compressed texture format to use, based on the formats you have, and the formats
  33068. * supported by the hardware / browser.
  33069. *
  33070. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33071. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33072. * to API arguments needed to compressed textures. This puts the burden on the container
  33073. * generator to house the arcane code for determining these for current & future formats.
  33074. *
  33075. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33076. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33077. *
  33078. * Note: The result of this call is not taken into account when a texture is base64.
  33079. *
  33080. * @param formatsAvailable defines the list of those format families you have created
  33081. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33082. *
  33083. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33084. * @returns The extension selected.
  33085. */
  33086. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33087. /**
  33088. * Force a specific size of the canvas
  33089. * @param width defines the new canvas' width
  33090. * @param height defines the new canvas' height
  33091. */
  33092. setSize(width: number, height: number): void;
  33093. /**
  33094. * Updates a dynamic vertex buffer.
  33095. * @param vertexBuffer the vertex buffer to update
  33096. * @param data the data used to update the vertex buffer
  33097. * @param byteOffset the byte offset of the data
  33098. * @param byteLength the byte length of the data
  33099. */
  33100. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33101. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33102. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33103. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33104. _releaseTexture(texture: InternalTexture): void;
  33105. /**
  33106. * @hidden
  33107. * Rescales a texture
  33108. * @param source input texutre
  33109. * @param destination destination texture
  33110. * @param scene scene to use to render the resize
  33111. * @param internalFormat format to use when resizing
  33112. * @param onComplete callback to be called when resize has completed
  33113. */
  33114. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33115. /**
  33116. * Gets the current framerate
  33117. * @returns a number representing the framerate
  33118. */
  33119. getFps(): number;
  33120. /**
  33121. * Gets the time spent between current and previous frame
  33122. * @returns a number representing the delta time in ms
  33123. */
  33124. getDeltaTime(): number;
  33125. private _measureFps;
  33126. /** @hidden */
  33127. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33128. /**
  33129. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33130. * @param renderTarget The render target to set the frame buffer for
  33131. */
  33132. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33133. /**
  33134. * Update a dynamic index buffer
  33135. * @param indexBuffer defines the target index buffer
  33136. * @param indices defines the data to update
  33137. * @param offset defines the offset in the target index buffer where update should start
  33138. */
  33139. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33140. /**
  33141. * Updates the sample count of a render target texture
  33142. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33143. * @param texture defines the texture to update
  33144. * @param samples defines the sample count to set
  33145. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33146. */
  33147. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33148. /**
  33149. * Updates a depth texture Comparison Mode and Function.
  33150. * If the comparison Function is equal to 0, the mode will be set to none.
  33151. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33152. * @param texture The texture to set the comparison function for
  33153. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33154. */
  33155. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33156. /**
  33157. * Creates a webGL buffer to use with instanciation
  33158. * @param capacity defines the size of the buffer
  33159. * @returns the webGL buffer
  33160. */
  33161. createInstancesBuffer(capacity: number): DataBuffer;
  33162. /**
  33163. * Delete a webGL buffer used with instanciation
  33164. * @param buffer defines the webGL buffer to delete
  33165. */
  33166. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33167. /** @hidden */
  33168. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33169. dispose(): void;
  33170. private _disableTouchAction;
  33171. /**
  33172. * Display the loading screen
  33173. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33174. */
  33175. displayLoadingUI(): void;
  33176. /**
  33177. * Hide the loading screen
  33178. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33179. */
  33180. hideLoadingUI(): void;
  33181. /**
  33182. * Gets the current loading screen object
  33183. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33184. */
  33185. /**
  33186. * Sets the current loading screen object
  33187. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33188. */
  33189. loadingScreen: ILoadingScreen;
  33190. /**
  33191. * Sets the current loading screen text
  33192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33193. */
  33194. loadingUIText: string;
  33195. /**
  33196. * Sets the current loading screen background color
  33197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33198. */
  33199. loadingUIBackgroundColor: string;
  33200. /** Pointerlock and fullscreen */
  33201. /**
  33202. * Ask the browser to promote the current element to pointerlock mode
  33203. * @param element defines the DOM element to promote
  33204. */
  33205. static _RequestPointerlock(element: HTMLElement): void;
  33206. /**
  33207. * Asks the browser to exit pointerlock mode
  33208. */
  33209. static _ExitPointerlock(): void;
  33210. /**
  33211. * Ask the browser to promote the current element to fullscreen rendering mode
  33212. * @param element defines the DOM element to promote
  33213. */
  33214. static _RequestFullscreen(element: HTMLElement): void;
  33215. /**
  33216. * Asks the browser to exit fullscreen mode
  33217. */
  33218. static _ExitFullscreen(): void;
  33219. }
  33220. }
  33221. declare module "babylonjs/Engines/engineStore" {
  33222. import { Nullable } from "babylonjs/types";
  33223. import { Engine } from "babylonjs/Engines/engine";
  33224. import { Scene } from "babylonjs/scene";
  33225. /**
  33226. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33227. * during the life time of the application.
  33228. */
  33229. export class EngineStore {
  33230. /** Gets the list of created engines */
  33231. static Instances: import("babylonjs/Engines/engine").Engine[];
  33232. /** @hidden */
  33233. static _LastCreatedScene: Nullable<Scene>;
  33234. /**
  33235. * Gets the latest created engine
  33236. */
  33237. static readonly LastCreatedEngine: Nullable<Engine>;
  33238. /**
  33239. * Gets the latest created scene
  33240. */
  33241. static readonly LastCreatedScene: Nullable<Scene>;
  33242. /**
  33243. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33244. * @ignorenaming
  33245. */
  33246. static UseFallbackTexture: boolean;
  33247. /**
  33248. * Texture content used if a texture cannot loaded
  33249. * @ignorenaming
  33250. */
  33251. static FallbackTexture: string;
  33252. }
  33253. }
  33254. declare module "babylonjs/Misc/promise" {
  33255. /**
  33256. * Helper class that provides a small promise polyfill
  33257. */
  33258. export class PromisePolyfill {
  33259. /**
  33260. * Static function used to check if the polyfill is required
  33261. * If this is the case then the function will inject the polyfill to window.Promise
  33262. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33263. */
  33264. static Apply(force?: boolean): void;
  33265. }
  33266. }
  33267. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33268. /**
  33269. * Interface for screenshot methods with describe argument called `size` as object with options
  33270. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33271. */
  33272. export interface IScreenshotSize {
  33273. /**
  33274. * number in pixels for canvas height
  33275. */
  33276. height?: number;
  33277. /**
  33278. * multiplier allowing render at a higher or lower resolution
  33279. * If value is defined then height and width will be ignored and taken from camera
  33280. */
  33281. precision?: number;
  33282. /**
  33283. * number in pixels for canvas width
  33284. */
  33285. width?: number;
  33286. }
  33287. }
  33288. declare module "babylonjs/Misc/tools" {
  33289. import { Nullable, float } from "babylonjs/types";
  33290. import { DomManagement } from "babylonjs/Misc/domManagement";
  33291. import { WebRequest } from "babylonjs/Misc/webRequest";
  33292. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33293. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33294. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33295. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33296. import { Camera } from "babylonjs/Cameras/camera";
  33297. import { Engine } from "babylonjs/Engines/engine";
  33298. interface IColor4Like {
  33299. r: float;
  33300. g: float;
  33301. b: float;
  33302. a: float;
  33303. }
  33304. /**
  33305. * Class containing a set of static utilities functions
  33306. */
  33307. export class Tools {
  33308. /**
  33309. * Gets or sets the base URL to use to load assets
  33310. */
  33311. static BaseUrl: string;
  33312. /**
  33313. * Enable/Disable Custom HTTP Request Headers globally.
  33314. * default = false
  33315. * @see CustomRequestHeaders
  33316. */
  33317. static UseCustomRequestHeaders: boolean;
  33318. /**
  33319. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33320. * i.e. when loading files, where the server/service expects an Authorization header
  33321. */
  33322. static CustomRequestHeaders: {
  33323. [key: string]: string;
  33324. };
  33325. /**
  33326. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33327. */
  33328. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33329. /**
  33330. * Default behaviour for cors in the application.
  33331. * It can be a string if the expected behavior is identical in the entire app.
  33332. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33333. */
  33334. static CorsBehavior: string | ((url: string | string[]) => string);
  33335. /**
  33336. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33337. * @ignorenaming
  33338. */
  33339. static UseFallbackTexture: boolean;
  33340. /**
  33341. * Use this object to register external classes like custom textures or material
  33342. * to allow the laoders to instantiate them
  33343. */
  33344. static RegisteredExternalClasses: {
  33345. [key: string]: Object;
  33346. };
  33347. /**
  33348. * Texture content used if a texture cannot loaded
  33349. * @ignorenaming
  33350. */
  33351. static fallbackTexture: string;
  33352. /**
  33353. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33354. * @param u defines the coordinate on X axis
  33355. * @param v defines the coordinate on Y axis
  33356. * @param width defines the width of the source data
  33357. * @param height defines the height of the source data
  33358. * @param pixels defines the source byte array
  33359. * @param color defines the output color
  33360. */
  33361. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33362. /**
  33363. * Interpolates between a and b via alpha
  33364. * @param a The lower value (returned when alpha = 0)
  33365. * @param b The upper value (returned when alpha = 1)
  33366. * @param alpha The interpolation-factor
  33367. * @return The mixed value
  33368. */
  33369. static Mix(a: number, b: number, alpha: number): number;
  33370. /**
  33371. * Tries to instantiate a new object from a given class name
  33372. * @param className defines the class name to instantiate
  33373. * @returns the new object or null if the system was not able to do the instantiation
  33374. */
  33375. static Instantiate(className: string): any;
  33376. /**
  33377. * Provides a slice function that will work even on IE
  33378. * @param data defines the array to slice
  33379. * @param start defines the start of the data (optional)
  33380. * @param end defines the end of the data (optional)
  33381. * @returns the new sliced array
  33382. */
  33383. static Slice<T>(data: T, start?: number, end?: number): T;
  33384. /**
  33385. * Polyfill for setImmediate
  33386. * @param action defines the action to execute after the current execution block
  33387. */
  33388. static SetImmediate(action: () => void): void;
  33389. /**
  33390. * Function indicating if a number is an exponent of 2
  33391. * @param value defines the value to test
  33392. * @returns true if the value is an exponent of 2
  33393. */
  33394. static IsExponentOfTwo(value: number): boolean;
  33395. private static _tmpFloatArray;
  33396. /**
  33397. * Returns the nearest 32-bit single precision float representation of a Number
  33398. * @param value A Number. If the parameter is of a different type, it will get converted
  33399. * to a number or to NaN if it cannot be converted
  33400. * @returns number
  33401. */
  33402. static FloatRound(value: number): number;
  33403. /**
  33404. * Extracts the filename from a path
  33405. * @param path defines the path to use
  33406. * @returns the filename
  33407. */
  33408. static GetFilename(path: string): string;
  33409. /**
  33410. * Extracts the "folder" part of a path (everything before the filename).
  33411. * @param uri The URI to extract the info from
  33412. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33413. * @returns The "folder" part of the path
  33414. */
  33415. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33416. /**
  33417. * Extracts text content from a DOM element hierarchy
  33418. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33419. */
  33420. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33421. /**
  33422. * Convert an angle in radians to degrees
  33423. * @param angle defines the angle to convert
  33424. * @returns the angle in degrees
  33425. */
  33426. static ToDegrees(angle: number): number;
  33427. /**
  33428. * Convert an angle in degrees to radians
  33429. * @param angle defines the angle to convert
  33430. * @returns the angle in radians
  33431. */
  33432. static ToRadians(angle: number): number;
  33433. /**
  33434. * Returns an array if obj is not an array
  33435. * @param obj defines the object to evaluate as an array
  33436. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33437. * @returns either obj directly if obj is an array or a new array containing obj
  33438. */
  33439. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33440. /**
  33441. * Gets the pointer prefix to use
  33442. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33443. */
  33444. static GetPointerPrefix(): string;
  33445. /**
  33446. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33447. * @param url define the url we are trying
  33448. * @param element define the dom element where to configure the cors policy
  33449. */
  33450. static SetCorsBehavior(url: string | string[], element: {
  33451. crossOrigin: string | null;
  33452. }): void;
  33453. /**
  33454. * Removes unwanted characters from an url
  33455. * @param url defines the url to clean
  33456. * @returns the cleaned url
  33457. */
  33458. static CleanUrl(url: string): string;
  33459. /**
  33460. * Gets or sets a function used to pre-process url before using them to load assets
  33461. */
  33462. static PreprocessUrl: (url: string) => string;
  33463. /**
  33464. * Loads an image as an HTMLImageElement.
  33465. * @param input url string, ArrayBuffer, or Blob to load
  33466. * @param onLoad callback called when the image successfully loads
  33467. * @param onError callback called when the image fails to load
  33468. * @param offlineProvider offline provider for caching
  33469. * @param mimeType optional mime type
  33470. * @returns the HTMLImageElement of the loaded image
  33471. */
  33472. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33473. /**
  33474. * Loads a file from a url
  33475. * @param url url string, ArrayBuffer, or Blob to load
  33476. * @param onSuccess callback called when the file successfully loads
  33477. * @param onProgress callback called while file is loading (if the server supports this mode)
  33478. * @param offlineProvider defines the offline provider for caching
  33479. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33480. * @param onError callback called when the file fails to load
  33481. * @returns a file request object
  33482. */
  33483. 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;
  33484. /**
  33485. * Loads a file from a url
  33486. * @param url the file url to load
  33487. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33488. */
  33489. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33490. /**
  33491. * Load a script (identified by an url). When the url returns, the
  33492. * content of this file is added into a new script element, attached to the DOM (body element)
  33493. * @param scriptUrl defines the url of the script to laod
  33494. * @param onSuccess defines the callback called when the script is loaded
  33495. * @param onError defines the callback to call if an error occurs
  33496. * @param scriptId defines the id of the script element
  33497. */
  33498. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33499. /**
  33500. * Load an asynchronous script (identified by an url). When the url returns, the
  33501. * content of this file is added into a new script element, attached to the DOM (body element)
  33502. * @param scriptUrl defines the url of the script to laod
  33503. * @param scriptId defines the id of the script element
  33504. * @returns a promise request object
  33505. */
  33506. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33507. /**
  33508. * Loads a file from a blob
  33509. * @param fileToLoad defines the blob to use
  33510. * @param callback defines the callback to call when data is loaded
  33511. * @param progressCallback defines the callback to call during loading process
  33512. * @returns a file request object
  33513. */
  33514. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33515. /**
  33516. * Reads a file from a File object
  33517. * @param file defines the file to load
  33518. * @param onSuccess defines the callback to call when data is loaded
  33519. * @param onProgress defines the callback to call during loading process
  33520. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33521. * @param onError defines the callback to call when an error occurs
  33522. * @returns a file request object
  33523. */
  33524. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33525. /**
  33526. * Creates a data url from a given string content
  33527. * @param content defines the content to convert
  33528. * @returns the new data url link
  33529. */
  33530. static FileAsURL(content: string): string;
  33531. /**
  33532. * Format the given number to a specific decimal format
  33533. * @param value defines the number to format
  33534. * @param decimals defines the number of decimals to use
  33535. * @returns the formatted string
  33536. */
  33537. static Format(value: number, decimals?: number): string;
  33538. /**
  33539. * Tries to copy an object by duplicating every property
  33540. * @param source defines the source object
  33541. * @param destination defines the target object
  33542. * @param doNotCopyList defines a list of properties to avoid
  33543. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33544. */
  33545. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33546. /**
  33547. * Gets a boolean indicating if the given object has no own property
  33548. * @param obj defines the object to test
  33549. * @returns true if object has no own property
  33550. */
  33551. static IsEmpty(obj: any): boolean;
  33552. /**
  33553. * Function used to register events at window level
  33554. * @param windowElement defines the Window object to use
  33555. * @param events defines the events to register
  33556. */
  33557. static RegisterTopRootEvents(windowElement: Window, events: {
  33558. name: string;
  33559. handler: Nullable<(e: FocusEvent) => any>;
  33560. }[]): void;
  33561. /**
  33562. * Function used to unregister events from window level
  33563. * @param windowElement defines the Window object to use
  33564. * @param events defines the events to unregister
  33565. */
  33566. static UnregisterTopRootEvents(windowElement: Window, events: {
  33567. name: string;
  33568. handler: Nullable<(e: FocusEvent) => any>;
  33569. }[]): void;
  33570. /**
  33571. * @ignore
  33572. */
  33573. static _ScreenshotCanvas: HTMLCanvasElement;
  33574. /**
  33575. * Dumps the current bound framebuffer
  33576. * @param width defines the rendering width
  33577. * @param height defines the rendering height
  33578. * @param engine defines the hosting engine
  33579. * @param successCallback defines the callback triggered once the data are available
  33580. * @param mimeType defines the mime type of the result
  33581. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33582. */
  33583. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33584. /**
  33585. * Converts the canvas data to blob.
  33586. * This acts as a polyfill for browsers not supporting the to blob function.
  33587. * @param canvas Defines the canvas to extract the data from
  33588. * @param successCallback Defines the callback triggered once the data are available
  33589. * @param mimeType Defines the mime type of the result
  33590. */
  33591. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33592. /**
  33593. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33594. * @param successCallback defines the callback triggered once the data are available
  33595. * @param mimeType defines the mime type of the result
  33596. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33597. */
  33598. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33599. /**
  33600. * Downloads a blob in the browser
  33601. * @param blob defines the blob to download
  33602. * @param fileName defines the name of the downloaded file
  33603. */
  33604. static Download(blob: Blob, fileName: string): void;
  33605. /**
  33606. * Captures a screenshot of the current rendering
  33607. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33608. * @param engine defines the rendering engine
  33609. * @param camera defines the source camera
  33610. * @param size This parameter can be set to a single number or to an object with the
  33611. * following (optional) properties: precision, width, height. If a single number is passed,
  33612. * it will be used for both width and height. If an object is passed, the screenshot size
  33613. * will be derived from the parameters. The precision property is a multiplier allowing
  33614. * rendering at a higher or lower resolution
  33615. * @param successCallback defines the callback receives a single parameter which contains the
  33616. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33617. * src parameter of an <img> to display it
  33618. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33619. * Check your browser for supported MIME types
  33620. */
  33621. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33622. /**
  33623. * Captures a screenshot of the current rendering
  33624. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33625. * @param engine defines the rendering engine
  33626. * @param camera defines the source camera
  33627. * @param size This parameter can be set to a single number or to an object with the
  33628. * following (optional) properties: precision, width, height. If a single number is passed,
  33629. * it will be used for both width and height. If an object is passed, the screenshot size
  33630. * will be derived from the parameters. The precision property is a multiplier allowing
  33631. * rendering at a higher or lower resolution
  33632. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33633. * Check your browser for supported MIME types
  33634. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33635. * to the src parameter of an <img> to display it
  33636. */
  33637. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33638. /**
  33639. * Generates an image screenshot from the specified camera.
  33640. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33641. * @param engine The engine to use for rendering
  33642. * @param camera The camera to use for rendering
  33643. * @param size This parameter can be set to a single number or to an object with the
  33644. * following (optional) properties: precision, width, height. If a single number is passed,
  33645. * it will be used for both width and height. If an object is passed, the screenshot size
  33646. * will be derived from the parameters. The precision property is a multiplier allowing
  33647. * rendering at a higher or lower resolution
  33648. * @param successCallback The callback receives a single parameter which contains the
  33649. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33650. * src parameter of an <img> to display it
  33651. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33652. * Check your browser for supported MIME types
  33653. * @param samples Texture samples (default: 1)
  33654. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33655. * @param fileName A name for for the downloaded file.
  33656. */
  33657. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33658. /**
  33659. * Generates an image screenshot from the specified camera.
  33660. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33661. * @param engine The engine to use for rendering
  33662. * @param camera The camera to use for rendering
  33663. * @param size This parameter can be set to a single number or to an object with the
  33664. * following (optional) properties: precision, width, height. If a single number is passed,
  33665. * it will be used for both width and height. If an object is passed, the screenshot size
  33666. * will be derived from the parameters. The precision property is a multiplier allowing
  33667. * rendering at a higher or lower resolution
  33668. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33669. * Check your browser for supported MIME types
  33670. * @param samples Texture samples (default: 1)
  33671. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33672. * @param fileName A name for for the downloaded file.
  33673. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33674. * to the src parameter of an <img> to display it
  33675. */
  33676. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33677. /**
  33678. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33679. * Be aware Math.random() could cause collisions, but:
  33680. * "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"
  33681. * @returns a pseudo random id
  33682. */
  33683. static RandomId(): string;
  33684. /**
  33685. * Test if the given uri is a base64 string
  33686. * @param uri The uri to test
  33687. * @return True if the uri is a base64 string or false otherwise
  33688. */
  33689. static IsBase64(uri: string): boolean;
  33690. /**
  33691. * Decode the given base64 uri.
  33692. * @param uri The uri to decode
  33693. * @return The decoded base64 data.
  33694. */
  33695. static DecodeBase64(uri: string): ArrayBuffer;
  33696. /**
  33697. * Gets the absolute url.
  33698. * @param url the input url
  33699. * @return the absolute url
  33700. */
  33701. static GetAbsoluteUrl(url: string): string;
  33702. /**
  33703. * No log
  33704. */
  33705. static readonly NoneLogLevel: number;
  33706. /**
  33707. * Only message logs
  33708. */
  33709. static readonly MessageLogLevel: number;
  33710. /**
  33711. * Only warning logs
  33712. */
  33713. static readonly WarningLogLevel: number;
  33714. /**
  33715. * Only error logs
  33716. */
  33717. static readonly ErrorLogLevel: number;
  33718. /**
  33719. * All logs
  33720. */
  33721. static readonly AllLogLevel: number;
  33722. /**
  33723. * Gets a value indicating the number of loading errors
  33724. * @ignorenaming
  33725. */
  33726. static readonly errorsCount: number;
  33727. /**
  33728. * Callback called when a new log is added
  33729. */
  33730. static OnNewCacheEntry: (entry: string) => void;
  33731. /**
  33732. * Log a message to the console
  33733. * @param message defines the message to log
  33734. */
  33735. static Log(message: string): void;
  33736. /**
  33737. * Write a warning message to the console
  33738. * @param message defines the message to log
  33739. */
  33740. static Warn(message: string): void;
  33741. /**
  33742. * Write an error message to the console
  33743. * @param message defines the message to log
  33744. */
  33745. static Error(message: string): void;
  33746. /**
  33747. * Gets current log cache (list of logs)
  33748. */
  33749. static readonly LogCache: string;
  33750. /**
  33751. * Clears the log cache
  33752. */
  33753. static ClearLogCache(): void;
  33754. /**
  33755. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33756. */
  33757. static LogLevels: number;
  33758. /**
  33759. * Checks if the window object exists
  33760. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33761. */
  33762. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33763. /**
  33764. * No performance log
  33765. */
  33766. static readonly PerformanceNoneLogLevel: number;
  33767. /**
  33768. * Use user marks to log performance
  33769. */
  33770. static readonly PerformanceUserMarkLogLevel: number;
  33771. /**
  33772. * Log performance to the console
  33773. */
  33774. static readonly PerformanceConsoleLogLevel: number;
  33775. private static _performance;
  33776. /**
  33777. * Sets the current performance log level
  33778. */
  33779. static PerformanceLogLevel: number;
  33780. private static _StartPerformanceCounterDisabled;
  33781. private static _EndPerformanceCounterDisabled;
  33782. private static _StartUserMark;
  33783. private static _EndUserMark;
  33784. private static _StartPerformanceConsole;
  33785. private static _EndPerformanceConsole;
  33786. /**
  33787. * Starts a performance counter
  33788. */
  33789. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33790. /**
  33791. * Ends a specific performance coutner
  33792. */
  33793. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33794. /**
  33795. * Gets either window.performance.now() if supported or Date.now() else
  33796. */
  33797. static readonly Now: number;
  33798. /**
  33799. * This method will return the name of the class used to create the instance of the given object.
  33800. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33801. * @param object the object to get the class name from
  33802. * @param isType defines if the object is actually a type
  33803. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33804. */
  33805. static GetClassName(object: any, isType?: boolean): string;
  33806. /**
  33807. * Gets the first element of an array satisfying a given predicate
  33808. * @param array defines the array to browse
  33809. * @param predicate defines the predicate to use
  33810. * @returns null if not found or the element
  33811. */
  33812. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33813. /**
  33814. * This method will return the name of the full name of the class, including its owning module (if any).
  33815. * 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).
  33816. * @param object the object to get the class name from
  33817. * @param isType defines if the object is actually a type
  33818. * @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.
  33819. * @ignorenaming
  33820. */
  33821. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33822. /**
  33823. * Returns a promise that resolves after the given amount of time.
  33824. * @param delay Number of milliseconds to delay
  33825. * @returns Promise that resolves after the given amount of time
  33826. */
  33827. static DelayAsync(delay: number): Promise<void>;
  33828. }
  33829. /**
  33830. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33831. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33832. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33833. * @param name The name of the class, case should be preserved
  33834. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33835. */
  33836. export function className(name: string, module?: string): (target: Object) => void;
  33837. /**
  33838. * An implementation of a loop for asynchronous functions.
  33839. */
  33840. export class AsyncLoop {
  33841. /**
  33842. * Defines the number of iterations for the loop
  33843. */
  33844. iterations: number;
  33845. /**
  33846. * Defines the current index of the loop.
  33847. */
  33848. index: number;
  33849. private _done;
  33850. private _fn;
  33851. private _successCallback;
  33852. /**
  33853. * Constructor.
  33854. * @param iterations the number of iterations.
  33855. * @param func the function to run each iteration
  33856. * @param successCallback the callback that will be called upon succesful execution
  33857. * @param offset starting offset.
  33858. */
  33859. constructor(
  33860. /**
  33861. * Defines the number of iterations for the loop
  33862. */
  33863. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33864. /**
  33865. * Execute the next iteration. Must be called after the last iteration was finished.
  33866. */
  33867. executeNext(): void;
  33868. /**
  33869. * Break the loop and run the success callback.
  33870. */
  33871. breakLoop(): void;
  33872. /**
  33873. * Create and run an async loop.
  33874. * @param iterations the number of iterations.
  33875. * @param fn the function to run each iteration
  33876. * @param successCallback the callback that will be called upon succesful execution
  33877. * @param offset starting offset.
  33878. * @returns the created async loop object
  33879. */
  33880. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33881. /**
  33882. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33883. * @param iterations total number of iterations
  33884. * @param syncedIterations number of synchronous iterations in each async iteration.
  33885. * @param fn the function to call each iteration.
  33886. * @param callback a success call back that will be called when iterating stops.
  33887. * @param breakFunction a break condition (optional)
  33888. * @param timeout timeout settings for the setTimeout function. default - 0.
  33889. * @returns the created async loop object
  33890. */
  33891. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33892. }
  33893. }
  33894. declare module "babylonjs/Misc/stringDictionary" {
  33895. import { Nullable } from "babylonjs/types";
  33896. /**
  33897. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33898. * The underlying implementation relies on an associative array to ensure the best performances.
  33899. * The value can be anything including 'null' but except 'undefined'
  33900. */
  33901. export class StringDictionary<T> {
  33902. /**
  33903. * This will clear this dictionary and copy the content from the 'source' one.
  33904. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33905. * @param source the dictionary to take the content from and copy to this dictionary
  33906. */
  33907. copyFrom(source: StringDictionary<T>): void;
  33908. /**
  33909. * Get a value based from its key
  33910. * @param key the given key to get the matching value from
  33911. * @return the value if found, otherwise undefined is returned
  33912. */
  33913. get(key: string): T | undefined;
  33914. /**
  33915. * Get a value from its key or add it if it doesn't exist.
  33916. * This method will ensure you that a given key/data will be present in the dictionary.
  33917. * @param key the given key to get the matching value from
  33918. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33919. * The factory will only be invoked if there's no data for the given key.
  33920. * @return the value corresponding to the key.
  33921. */
  33922. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33923. /**
  33924. * Get a value from its key if present in the dictionary otherwise add it
  33925. * @param key the key to get the value from
  33926. * @param val if there's no such key/value pair in the dictionary add it with this value
  33927. * @return the value corresponding to the key
  33928. */
  33929. getOrAdd(key: string, val: T): T;
  33930. /**
  33931. * Check if there's a given key in the dictionary
  33932. * @param key the key to check for
  33933. * @return true if the key is present, false otherwise
  33934. */
  33935. contains(key: string): boolean;
  33936. /**
  33937. * Add a new key and its corresponding value
  33938. * @param key the key to add
  33939. * @param value the value corresponding to the key
  33940. * @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
  33941. */
  33942. add(key: string, value: T): boolean;
  33943. /**
  33944. * Update a specific value associated to a key
  33945. * @param key defines the key to use
  33946. * @param value defines the value to store
  33947. * @returns true if the value was updated (or false if the key was not found)
  33948. */
  33949. set(key: string, value: T): boolean;
  33950. /**
  33951. * Get the element of the given key and remove it from the dictionary
  33952. * @param key defines the key to search
  33953. * @returns the value associated with the key or null if not found
  33954. */
  33955. getAndRemove(key: string): Nullable<T>;
  33956. /**
  33957. * Remove a key/value from the dictionary.
  33958. * @param key the key to remove
  33959. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33960. */
  33961. remove(key: string): boolean;
  33962. /**
  33963. * Clear the whole content of the dictionary
  33964. */
  33965. clear(): void;
  33966. /**
  33967. * Gets the current count
  33968. */
  33969. readonly count: number;
  33970. /**
  33971. * Execute a callback on each key/val of the dictionary.
  33972. * Note that you can remove any element in this dictionary in the callback implementation
  33973. * @param callback the callback to execute on a given key/value pair
  33974. */
  33975. forEach(callback: (key: string, val: T) => void): void;
  33976. /**
  33977. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33978. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33979. * Note that you can remove any element in this dictionary in the callback implementation
  33980. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33981. * @returns the first item
  33982. */
  33983. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33984. private _count;
  33985. private _data;
  33986. }
  33987. }
  33988. declare module "babylonjs/Collisions/collisionCoordinator" {
  33989. import { Nullable } from "babylonjs/types";
  33990. import { Scene } from "babylonjs/scene";
  33991. import { Vector3 } from "babylonjs/Maths/math.vector";
  33992. import { Collider } from "babylonjs/Collisions/collider";
  33993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33994. /** @hidden */
  33995. export interface ICollisionCoordinator {
  33996. createCollider(): Collider;
  33997. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33998. init(scene: Scene): void;
  33999. }
  34000. /** @hidden */
  34001. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34002. private _scene;
  34003. private _scaledPosition;
  34004. private _scaledVelocity;
  34005. private _finalPosition;
  34006. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34007. createCollider(): Collider;
  34008. init(scene: Scene): void;
  34009. private _collideWithWorld;
  34010. }
  34011. }
  34012. declare module "babylonjs/Inputs/scene.inputManager" {
  34013. import { Nullable } from "babylonjs/types";
  34014. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34015. import { Vector2 } from "babylonjs/Maths/math.vector";
  34016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34017. import { Scene } from "babylonjs/scene";
  34018. /**
  34019. * Class used to manage all inputs for the scene.
  34020. */
  34021. export class InputManager {
  34022. /** The distance in pixel that you have to move to prevent some events */
  34023. static DragMovementThreshold: number;
  34024. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34025. static LongPressDelay: number;
  34026. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34027. static DoubleClickDelay: number;
  34028. /** If you need to check double click without raising a single click at first click, enable this flag */
  34029. static ExclusiveDoubleClickMode: boolean;
  34030. private _wheelEventName;
  34031. private _onPointerMove;
  34032. private _onPointerDown;
  34033. private _onPointerUp;
  34034. private _initClickEvent;
  34035. private _initActionManager;
  34036. private _delayedSimpleClick;
  34037. private _delayedSimpleClickTimeout;
  34038. private _previousDelayedSimpleClickTimeout;
  34039. private _meshPickProceed;
  34040. private _previousButtonPressed;
  34041. private _currentPickResult;
  34042. private _previousPickResult;
  34043. private _totalPointersPressed;
  34044. private _doubleClickOccured;
  34045. private _pointerOverMesh;
  34046. private _pickedDownMesh;
  34047. private _pickedUpMesh;
  34048. private _pointerX;
  34049. private _pointerY;
  34050. private _unTranslatedPointerX;
  34051. private _unTranslatedPointerY;
  34052. private _startingPointerPosition;
  34053. private _previousStartingPointerPosition;
  34054. private _startingPointerTime;
  34055. private _previousStartingPointerTime;
  34056. private _pointerCaptures;
  34057. private _onKeyDown;
  34058. private _onKeyUp;
  34059. private _onCanvasFocusObserver;
  34060. private _onCanvasBlurObserver;
  34061. private _scene;
  34062. /**
  34063. * Creates a new InputManager
  34064. * @param scene defines the hosting scene
  34065. */
  34066. constructor(scene: Scene);
  34067. /**
  34068. * Gets the mesh that is currently under the pointer
  34069. */
  34070. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34071. /**
  34072. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34073. */
  34074. readonly unTranslatedPointer: Vector2;
  34075. /**
  34076. * Gets or sets the current on-screen X position of the pointer
  34077. */
  34078. pointerX: number;
  34079. /**
  34080. * Gets or sets the current on-screen Y position of the pointer
  34081. */
  34082. pointerY: number;
  34083. private _updatePointerPosition;
  34084. private _processPointerMove;
  34085. private _setRayOnPointerInfo;
  34086. private _checkPrePointerObservable;
  34087. /**
  34088. * Use this method to simulate a pointer move on a mesh
  34089. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34090. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34091. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34092. */
  34093. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34094. /**
  34095. * Use this method to simulate a pointer down on a mesh
  34096. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34097. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34098. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34099. */
  34100. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34101. private _processPointerDown;
  34102. /** @hidden */
  34103. _isPointerSwiping(): boolean;
  34104. /**
  34105. * Use this method to simulate a pointer up on a mesh
  34106. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34107. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34108. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34109. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34110. */
  34111. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34112. private _processPointerUp;
  34113. /**
  34114. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34115. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34116. * @returns true if the pointer was captured
  34117. */
  34118. isPointerCaptured(pointerId?: number): boolean;
  34119. /**
  34120. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34121. * @param attachUp defines if you want to attach events to pointerup
  34122. * @param attachDown defines if you want to attach events to pointerdown
  34123. * @param attachMove defines if you want to attach events to pointermove
  34124. */
  34125. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34126. /**
  34127. * Detaches all event handlers
  34128. */
  34129. detachControl(): void;
  34130. /**
  34131. * Force the value of meshUnderPointer
  34132. * @param mesh defines the mesh to use
  34133. */
  34134. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34135. /**
  34136. * Gets the mesh under the pointer
  34137. * @returns a Mesh or null if no mesh is under the pointer
  34138. */
  34139. getPointerOverMesh(): Nullable<AbstractMesh>;
  34140. }
  34141. }
  34142. declare module "babylonjs/Misc/uniqueIdGenerator" {
  34143. /**
  34144. * Helper class used to generate session unique ID
  34145. */
  34146. export class UniqueIdGenerator {
  34147. private static _UniqueIdCounter;
  34148. /**
  34149. * Gets an unique (relatively to the current scene) Id
  34150. */
  34151. static readonly UniqueId: number;
  34152. }
  34153. }
  34154. declare module "babylonjs/Animations/animationGroup" {
  34155. import { Animatable } from "babylonjs/Animations/animatable";
  34156. import { Animation } from "babylonjs/Animations/animation";
  34157. import { Scene, IDisposable } from "babylonjs/scene";
  34158. import { Observable } from "babylonjs/Misc/observable";
  34159. import { Nullable } from "babylonjs/types";
  34160. import "babylonjs/Animations/animatable";
  34161. /**
  34162. * This class defines the direct association between an animation and a target
  34163. */
  34164. export class TargetedAnimation {
  34165. /**
  34166. * Animation to perform
  34167. */
  34168. animation: Animation;
  34169. /**
  34170. * Target to animate
  34171. */
  34172. target: any;
  34173. /**
  34174. * Serialize the object
  34175. * @returns the JSON object representing the current entity
  34176. */
  34177. serialize(): any;
  34178. }
  34179. /**
  34180. * Use this class to create coordinated animations on multiple targets
  34181. */
  34182. export class AnimationGroup implements IDisposable {
  34183. /** The name of the animation group */
  34184. name: string;
  34185. private _scene;
  34186. private _targetedAnimations;
  34187. private _animatables;
  34188. private _from;
  34189. private _to;
  34190. private _isStarted;
  34191. private _isPaused;
  34192. private _speedRatio;
  34193. private _loopAnimation;
  34194. /**
  34195. * Gets or sets the unique id of the node
  34196. */
  34197. uniqueId: number;
  34198. /**
  34199. * This observable will notify when one animation have ended
  34200. */
  34201. onAnimationEndObservable: Observable<TargetedAnimation>;
  34202. /**
  34203. * Observer raised when one animation loops
  34204. */
  34205. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34206. /**
  34207. * Observer raised when all animations have looped
  34208. */
  34209. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34210. /**
  34211. * This observable will notify when all animations have ended.
  34212. */
  34213. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34214. /**
  34215. * This observable will notify when all animations have paused.
  34216. */
  34217. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34218. /**
  34219. * This observable will notify when all animations are playing.
  34220. */
  34221. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34222. /**
  34223. * Gets the first frame
  34224. */
  34225. readonly from: number;
  34226. /**
  34227. * Gets the last frame
  34228. */
  34229. readonly to: number;
  34230. /**
  34231. * Define if the animations are started
  34232. */
  34233. readonly isStarted: boolean;
  34234. /**
  34235. * Gets a value indicating that the current group is playing
  34236. */
  34237. readonly isPlaying: boolean;
  34238. /**
  34239. * Gets or sets the speed ratio to use for all animations
  34240. */
  34241. /**
  34242. * Gets or sets the speed ratio to use for all animations
  34243. */
  34244. speedRatio: number;
  34245. /**
  34246. * Gets or sets if all animations should loop or not
  34247. */
  34248. loopAnimation: boolean;
  34249. /**
  34250. * Gets the targeted animations for this animation group
  34251. */
  34252. readonly targetedAnimations: Array<TargetedAnimation>;
  34253. /**
  34254. * returning the list of animatables controlled by this animation group.
  34255. */
  34256. readonly animatables: Array<Animatable>;
  34257. /**
  34258. * Instantiates a new Animation Group.
  34259. * This helps managing several animations at once.
  34260. * @see http://doc.babylonjs.com/how_to/group
  34261. * @param name Defines the name of the group
  34262. * @param scene Defines the scene the group belongs to
  34263. */
  34264. constructor(
  34265. /** The name of the animation group */
  34266. name: string, scene?: Nullable<Scene>);
  34267. /**
  34268. * Add an animation (with its target) in the group
  34269. * @param animation defines the animation we want to add
  34270. * @param target defines the target of the animation
  34271. * @returns the TargetedAnimation object
  34272. */
  34273. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34274. /**
  34275. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34276. * It can add constant keys at begin or end
  34277. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34278. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34279. * @returns the animation group
  34280. */
  34281. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34282. private _animationLoopCount;
  34283. private _animationLoopFlags;
  34284. private _processLoop;
  34285. /**
  34286. * Start all animations on given targets
  34287. * @param loop defines if animations must loop
  34288. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34289. * @param from defines the from key (optional)
  34290. * @param to defines the to key (optional)
  34291. * @returns the current animation group
  34292. */
  34293. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34294. /**
  34295. * Pause all animations
  34296. * @returns the animation group
  34297. */
  34298. pause(): AnimationGroup;
  34299. /**
  34300. * Play all animations to initial state
  34301. * This function will start() the animations if they were not started or will restart() them if they were paused
  34302. * @param loop defines if animations must loop
  34303. * @returns the animation group
  34304. */
  34305. play(loop?: boolean): AnimationGroup;
  34306. /**
  34307. * Reset all animations to initial state
  34308. * @returns the animation group
  34309. */
  34310. reset(): AnimationGroup;
  34311. /**
  34312. * Restart animations from key 0
  34313. * @returns the animation group
  34314. */
  34315. restart(): AnimationGroup;
  34316. /**
  34317. * Stop all animations
  34318. * @returns the animation group
  34319. */
  34320. stop(): AnimationGroup;
  34321. /**
  34322. * Set animation weight for all animatables
  34323. * @param weight defines the weight to use
  34324. * @return the animationGroup
  34325. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34326. */
  34327. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34328. /**
  34329. * Synchronize and normalize all animatables with a source animatable
  34330. * @param root defines the root animatable to synchronize with
  34331. * @return the animationGroup
  34332. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34333. */
  34334. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34335. /**
  34336. * Goes to a specific frame in this animation group
  34337. * @param frame the frame number to go to
  34338. * @return the animationGroup
  34339. */
  34340. goToFrame(frame: number): AnimationGroup;
  34341. /**
  34342. * Dispose all associated resources
  34343. */
  34344. dispose(): void;
  34345. private _checkAnimationGroupEnded;
  34346. /**
  34347. * Clone the current animation group and returns a copy
  34348. * @param newName defines the name of the new group
  34349. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34350. * @returns the new aniamtion group
  34351. */
  34352. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34353. /**
  34354. * Serializes the animationGroup to an object
  34355. * @returns Serialized object
  34356. */
  34357. serialize(): any;
  34358. /**
  34359. * Returns a new AnimationGroup object parsed from the source provided.
  34360. * @param parsedAnimationGroup defines the source
  34361. * @param scene defines the scene that will receive the animationGroup
  34362. * @returns a new AnimationGroup
  34363. */
  34364. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34365. /**
  34366. * Returns the string "AnimationGroup"
  34367. * @returns "AnimationGroup"
  34368. */
  34369. getClassName(): string;
  34370. /**
  34371. * Creates a detailled string about the object
  34372. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34373. * @returns a string representing the object
  34374. */
  34375. toString(fullDetails?: boolean): string;
  34376. }
  34377. }
  34378. declare module "babylonjs/scene" {
  34379. import { Nullable } from "babylonjs/types";
  34380. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34381. import { Observable } from "babylonjs/Misc/observable";
  34382. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34383. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34384. import { Geometry } from "babylonjs/Meshes/geometry";
  34385. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34386. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34388. import { Mesh } from "babylonjs/Meshes/mesh";
  34389. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34390. import { Bone } from "babylonjs/Bones/bone";
  34391. import { Skeleton } from "babylonjs/Bones/skeleton";
  34392. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34393. import { Camera } from "babylonjs/Cameras/camera";
  34394. import { AbstractScene } from "babylonjs/abstractScene";
  34395. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34397. import { Material } from "babylonjs/Materials/material";
  34398. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34399. import { Effect } from "babylonjs/Materials/effect";
  34400. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34401. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34402. import { Light } from "babylonjs/Lights/light";
  34403. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34404. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34405. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34406. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34407. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34408. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34409. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34410. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34411. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34412. import { Engine } from "babylonjs/Engines/engine";
  34413. import { Node } from "babylonjs/node";
  34414. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34415. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34416. import { WebRequest } from "babylonjs/Misc/webRequest";
  34417. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34418. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34419. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34420. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34421. import { Plane } from "babylonjs/Maths/math.plane";
  34422. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34423. import { Ray } from "babylonjs/Culling/ray";
  34424. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34425. import { Animation } from "babylonjs/Animations/animation";
  34426. import { Animatable } from "babylonjs/Animations/animatable";
  34427. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34428. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34429. import { Collider } from "babylonjs/Collisions/collider";
  34430. /**
  34431. * Define an interface for all classes that will hold resources
  34432. */
  34433. export interface IDisposable {
  34434. /**
  34435. * Releases all held resources
  34436. */
  34437. dispose(): void;
  34438. }
  34439. /** Interface defining initialization parameters for Scene class */
  34440. export interface SceneOptions {
  34441. /**
  34442. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34443. * It will improve performance when the number of geometries becomes important.
  34444. */
  34445. useGeometryUniqueIdsMap?: boolean;
  34446. /**
  34447. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34448. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34449. */
  34450. useMaterialMeshMap?: boolean;
  34451. /**
  34452. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34453. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34454. */
  34455. useClonedMeshhMap?: boolean;
  34456. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34457. virtual?: boolean;
  34458. }
  34459. /**
  34460. * Represents a scene to be rendered by the engine.
  34461. * @see http://doc.babylonjs.com/features/scene
  34462. */
  34463. export class Scene extends AbstractScene implements IAnimatable {
  34464. /** The fog is deactivated */
  34465. static readonly FOGMODE_NONE: number;
  34466. /** The fog density is following an exponential function */
  34467. static readonly FOGMODE_EXP: number;
  34468. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34469. static readonly FOGMODE_EXP2: number;
  34470. /** The fog density is following a linear function. */
  34471. static readonly FOGMODE_LINEAR: number;
  34472. /**
  34473. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34475. */
  34476. static MinDeltaTime: number;
  34477. /**
  34478. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34479. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34480. */
  34481. static MaxDeltaTime: number;
  34482. /**
  34483. * Factory used to create the default material.
  34484. * @param name The name of the material to create
  34485. * @param scene The scene to create the material for
  34486. * @returns The default material
  34487. */
  34488. static DefaultMaterialFactory(scene: Scene): Material;
  34489. /**
  34490. * Factory used to create the a collision coordinator.
  34491. * @returns The collision coordinator
  34492. */
  34493. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34494. /** @hidden */
  34495. _inputManager: InputManager;
  34496. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34497. cameraToUseForPointers: Nullable<Camera>;
  34498. /** @hidden */
  34499. readonly _isScene: boolean;
  34500. /**
  34501. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34502. */
  34503. autoClear: boolean;
  34504. /**
  34505. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34506. */
  34507. autoClearDepthAndStencil: boolean;
  34508. /**
  34509. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34510. */
  34511. clearColor: Color4;
  34512. /**
  34513. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34514. */
  34515. ambientColor: Color3;
  34516. /**
  34517. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34518. * It should only be one of the following (if not the default embedded one):
  34519. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34520. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34521. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34522. * The material properties need to be setup according to the type of texture in use.
  34523. */
  34524. environmentBRDFTexture: BaseTexture;
  34525. /** @hidden */
  34526. protected _environmentTexture: Nullable<BaseTexture>;
  34527. /**
  34528. * Texture used in all pbr material as the reflection texture.
  34529. * As in the majority of the scene they are the same (exception for multi room and so on),
  34530. * this is easier to reference from here than from all the materials.
  34531. */
  34532. /**
  34533. * Texture used in all pbr material as the reflection texture.
  34534. * As in the majority of the scene they are the same (exception for multi room and so on),
  34535. * this is easier to set here than in all the materials.
  34536. */
  34537. environmentTexture: Nullable<BaseTexture>;
  34538. /** @hidden */
  34539. protected _environmentIntensity: number;
  34540. /**
  34541. * Intensity of the environment in all pbr material.
  34542. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34543. * As in the majority of the scene they are the same (exception for multi room and so on),
  34544. * this is easier to reference from here than from all the materials.
  34545. */
  34546. /**
  34547. * Intensity of the environment in all pbr material.
  34548. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34549. * As in the majority of the scene they are the same (exception for multi room and so on),
  34550. * this is easier to set here than in all the materials.
  34551. */
  34552. environmentIntensity: number;
  34553. /** @hidden */
  34554. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34555. /**
  34556. * Default image processing configuration used either in the rendering
  34557. * Forward main pass or through the imageProcessingPostProcess if present.
  34558. * As in the majority of the scene they are the same (exception for multi camera),
  34559. * this is easier to reference from here than from all the materials and post process.
  34560. *
  34561. * No setter as we it is a shared configuration, you can set the values instead.
  34562. */
  34563. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34564. private _forceWireframe;
  34565. /**
  34566. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34567. */
  34568. forceWireframe: boolean;
  34569. private _forcePointsCloud;
  34570. /**
  34571. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34572. */
  34573. forcePointsCloud: boolean;
  34574. /**
  34575. * Gets or sets the active clipplane 1
  34576. */
  34577. clipPlane: Nullable<Plane>;
  34578. /**
  34579. * Gets or sets the active clipplane 2
  34580. */
  34581. clipPlane2: Nullable<Plane>;
  34582. /**
  34583. * Gets or sets the active clipplane 3
  34584. */
  34585. clipPlane3: Nullable<Plane>;
  34586. /**
  34587. * Gets or sets the active clipplane 4
  34588. */
  34589. clipPlane4: Nullable<Plane>;
  34590. /**
  34591. * Gets or sets a boolean indicating if animations are enabled
  34592. */
  34593. animationsEnabled: boolean;
  34594. private _animationPropertiesOverride;
  34595. /**
  34596. * Gets or sets the animation properties override
  34597. */
  34598. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34599. /**
  34600. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34601. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34602. */
  34603. useConstantAnimationDeltaTime: boolean;
  34604. /**
  34605. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34606. * Please note that it requires to run a ray cast through the scene on every frame
  34607. */
  34608. constantlyUpdateMeshUnderPointer: boolean;
  34609. /**
  34610. * Defines the HTML cursor to use when hovering over interactive elements
  34611. */
  34612. hoverCursor: string;
  34613. /**
  34614. * Defines the HTML default cursor to use (empty by default)
  34615. */
  34616. defaultCursor: string;
  34617. /**
  34618. * Defines wether cursors are handled by the scene.
  34619. */
  34620. doNotHandleCursors: boolean;
  34621. /**
  34622. * This is used to call preventDefault() on pointer down
  34623. * in order to block unwanted artifacts like system double clicks
  34624. */
  34625. preventDefaultOnPointerDown: boolean;
  34626. /**
  34627. * This is used to call preventDefault() on pointer up
  34628. * in order to block unwanted artifacts like system double clicks
  34629. */
  34630. preventDefaultOnPointerUp: boolean;
  34631. /**
  34632. * Gets or sets user defined metadata
  34633. */
  34634. metadata: any;
  34635. /**
  34636. * For internal use only. Please do not use.
  34637. */
  34638. reservedDataStore: any;
  34639. /**
  34640. * Gets the name of the plugin used to load this scene (null by default)
  34641. */
  34642. loadingPluginName: string;
  34643. /**
  34644. * Use this array to add regular expressions used to disable offline support for specific urls
  34645. */
  34646. disableOfflineSupportExceptionRules: RegExp[];
  34647. /**
  34648. * An event triggered when the scene is disposed.
  34649. */
  34650. onDisposeObservable: Observable<Scene>;
  34651. private _onDisposeObserver;
  34652. /** Sets a function to be executed when this scene is disposed. */
  34653. onDispose: () => void;
  34654. /**
  34655. * An event triggered before rendering the scene (right after animations and physics)
  34656. */
  34657. onBeforeRenderObservable: Observable<Scene>;
  34658. private _onBeforeRenderObserver;
  34659. /** Sets a function to be executed before rendering this scene */
  34660. beforeRender: Nullable<() => void>;
  34661. /**
  34662. * An event triggered after rendering the scene
  34663. */
  34664. onAfterRenderObservable: Observable<Scene>;
  34665. /**
  34666. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34667. */
  34668. onAfterRenderCameraObservable: Observable<Camera>;
  34669. private _onAfterRenderObserver;
  34670. /** Sets a function to be executed after rendering this scene */
  34671. afterRender: Nullable<() => void>;
  34672. /**
  34673. * An event triggered before animating the scene
  34674. */
  34675. onBeforeAnimationsObservable: Observable<Scene>;
  34676. /**
  34677. * An event triggered after animations processing
  34678. */
  34679. onAfterAnimationsObservable: Observable<Scene>;
  34680. /**
  34681. * An event triggered before draw calls are ready to be sent
  34682. */
  34683. onBeforeDrawPhaseObservable: Observable<Scene>;
  34684. /**
  34685. * An event triggered after draw calls have been sent
  34686. */
  34687. onAfterDrawPhaseObservable: Observable<Scene>;
  34688. /**
  34689. * An event triggered when the scene is ready
  34690. */
  34691. onReadyObservable: Observable<Scene>;
  34692. /**
  34693. * An event triggered before rendering a camera
  34694. */
  34695. onBeforeCameraRenderObservable: Observable<Camera>;
  34696. private _onBeforeCameraRenderObserver;
  34697. /** Sets a function to be executed before rendering a camera*/
  34698. beforeCameraRender: () => void;
  34699. /**
  34700. * An event triggered after rendering a camera
  34701. */
  34702. onAfterCameraRenderObservable: Observable<Camera>;
  34703. private _onAfterCameraRenderObserver;
  34704. /** Sets a function to be executed after rendering a camera*/
  34705. afterCameraRender: () => void;
  34706. /**
  34707. * An event triggered when active meshes evaluation is about to start
  34708. */
  34709. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34710. /**
  34711. * An event triggered when active meshes evaluation is done
  34712. */
  34713. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34714. /**
  34715. * An event triggered when particles rendering is about to start
  34716. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34717. */
  34718. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34719. /**
  34720. * An event triggered when particles rendering is done
  34721. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34722. */
  34723. onAfterParticlesRenderingObservable: Observable<Scene>;
  34724. /**
  34725. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34726. */
  34727. onDataLoadedObservable: Observable<Scene>;
  34728. /**
  34729. * An event triggered when a camera is created
  34730. */
  34731. onNewCameraAddedObservable: Observable<Camera>;
  34732. /**
  34733. * An event triggered when a camera is removed
  34734. */
  34735. onCameraRemovedObservable: Observable<Camera>;
  34736. /**
  34737. * An event triggered when a light is created
  34738. */
  34739. onNewLightAddedObservable: Observable<Light>;
  34740. /**
  34741. * An event triggered when a light is removed
  34742. */
  34743. onLightRemovedObservable: Observable<Light>;
  34744. /**
  34745. * An event triggered when a geometry is created
  34746. */
  34747. onNewGeometryAddedObservable: Observable<Geometry>;
  34748. /**
  34749. * An event triggered when a geometry is removed
  34750. */
  34751. onGeometryRemovedObservable: Observable<Geometry>;
  34752. /**
  34753. * An event triggered when a transform node is created
  34754. */
  34755. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34756. /**
  34757. * An event triggered when a transform node is removed
  34758. */
  34759. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34760. /**
  34761. * An event triggered when a mesh is created
  34762. */
  34763. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34764. /**
  34765. * An event triggered when a mesh is removed
  34766. */
  34767. onMeshRemovedObservable: Observable<AbstractMesh>;
  34768. /**
  34769. * An event triggered when a skeleton is created
  34770. */
  34771. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34772. /**
  34773. * An event triggered when a skeleton is removed
  34774. */
  34775. onSkeletonRemovedObservable: Observable<Skeleton>;
  34776. /**
  34777. * An event triggered when a material is created
  34778. */
  34779. onNewMaterialAddedObservable: Observable<Material>;
  34780. /**
  34781. * An event triggered when a material is removed
  34782. */
  34783. onMaterialRemovedObservable: Observable<Material>;
  34784. /**
  34785. * An event triggered when a texture is created
  34786. */
  34787. onNewTextureAddedObservable: Observable<BaseTexture>;
  34788. /**
  34789. * An event triggered when a texture is removed
  34790. */
  34791. onTextureRemovedObservable: Observable<BaseTexture>;
  34792. /**
  34793. * An event triggered when render targets are about to be rendered
  34794. * Can happen multiple times per frame.
  34795. */
  34796. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34797. /**
  34798. * An event triggered when render targets were rendered.
  34799. * Can happen multiple times per frame.
  34800. */
  34801. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34802. /**
  34803. * An event triggered before calculating deterministic simulation step
  34804. */
  34805. onBeforeStepObservable: Observable<Scene>;
  34806. /**
  34807. * An event triggered after calculating deterministic simulation step
  34808. */
  34809. onAfterStepObservable: Observable<Scene>;
  34810. /**
  34811. * An event triggered when the activeCamera property is updated
  34812. */
  34813. onActiveCameraChanged: Observable<Scene>;
  34814. /**
  34815. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34816. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34817. * 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)
  34818. */
  34819. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34820. /**
  34821. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34822. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34823. * 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)
  34824. */
  34825. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34826. /**
  34827. * This Observable will when a mesh has been imported into the scene.
  34828. */
  34829. onMeshImportedObservable: Observable<AbstractMesh>;
  34830. /**
  34831. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34832. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34833. */
  34834. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34835. /** @hidden */
  34836. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34837. /**
  34838. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34839. */
  34840. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34841. /**
  34842. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34843. */
  34844. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34845. /**
  34846. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34847. */
  34848. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34849. /** Callback called when a pointer move is detected */
  34850. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34851. /** Callback called when a pointer down is detected */
  34852. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34853. /** Callback called when a pointer up is detected */
  34854. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34855. /** Callback called when a pointer pick is detected */
  34856. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34857. /**
  34858. * 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).
  34859. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34860. */
  34861. onPrePointerObservable: Observable<PointerInfoPre>;
  34862. /**
  34863. * Observable event triggered each time an input event is received from the rendering canvas
  34864. */
  34865. onPointerObservable: Observable<PointerInfo>;
  34866. /**
  34867. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34868. */
  34869. readonly unTranslatedPointer: Vector2;
  34870. /**
  34871. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34872. */
  34873. static DragMovementThreshold: number;
  34874. /**
  34875. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34876. */
  34877. static LongPressDelay: number;
  34878. /**
  34879. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34880. */
  34881. static DoubleClickDelay: number;
  34882. /** If you need to check double click without raising a single click at first click, enable this flag */
  34883. static ExclusiveDoubleClickMode: boolean;
  34884. /** @hidden */
  34885. _mirroredCameraPosition: Nullable<Vector3>;
  34886. /**
  34887. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34888. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34889. */
  34890. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34891. /**
  34892. * Observable event triggered each time an keyboard event is received from the hosting window
  34893. */
  34894. onKeyboardObservable: Observable<KeyboardInfo>;
  34895. private _useRightHandedSystem;
  34896. /**
  34897. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34898. */
  34899. useRightHandedSystem: boolean;
  34900. private _timeAccumulator;
  34901. private _currentStepId;
  34902. private _currentInternalStep;
  34903. /**
  34904. * Sets the step Id used by deterministic lock step
  34905. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34906. * @param newStepId defines the step Id
  34907. */
  34908. setStepId(newStepId: number): void;
  34909. /**
  34910. * Gets the step Id used by deterministic lock step
  34911. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34912. * @returns the step Id
  34913. */
  34914. getStepId(): number;
  34915. /**
  34916. * Gets the internal step used by deterministic lock step
  34917. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34918. * @returns the internal step
  34919. */
  34920. getInternalStep(): number;
  34921. private _fogEnabled;
  34922. /**
  34923. * Gets or sets a boolean indicating if fog is enabled on this scene
  34924. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34925. * (Default is true)
  34926. */
  34927. fogEnabled: boolean;
  34928. private _fogMode;
  34929. /**
  34930. * Gets or sets the fog mode to use
  34931. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34932. * | mode | value |
  34933. * | --- | --- |
  34934. * | FOGMODE_NONE | 0 |
  34935. * | FOGMODE_EXP | 1 |
  34936. * | FOGMODE_EXP2 | 2 |
  34937. * | FOGMODE_LINEAR | 3 |
  34938. */
  34939. fogMode: number;
  34940. /**
  34941. * Gets or sets the fog color to use
  34942. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34943. * (Default is Color3(0.2, 0.2, 0.3))
  34944. */
  34945. fogColor: Color3;
  34946. /**
  34947. * Gets or sets the fog density to use
  34948. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34949. * (Default is 0.1)
  34950. */
  34951. fogDensity: number;
  34952. /**
  34953. * Gets or sets the fog start distance to use
  34954. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34955. * (Default is 0)
  34956. */
  34957. fogStart: number;
  34958. /**
  34959. * Gets or sets the fog end distance to use
  34960. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34961. * (Default is 1000)
  34962. */
  34963. fogEnd: number;
  34964. private _shadowsEnabled;
  34965. /**
  34966. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34967. */
  34968. shadowsEnabled: boolean;
  34969. private _lightsEnabled;
  34970. /**
  34971. * Gets or sets a boolean indicating if lights are enabled on this scene
  34972. */
  34973. lightsEnabled: boolean;
  34974. /** All of the active cameras added to this scene. */
  34975. activeCameras: Camera[];
  34976. /** @hidden */
  34977. _activeCamera: Nullable<Camera>;
  34978. /** Gets or sets the current active camera */
  34979. activeCamera: Nullable<Camera>;
  34980. private _defaultMaterial;
  34981. /** The default material used on meshes when no material is affected */
  34982. /** The default material used on meshes when no material is affected */
  34983. defaultMaterial: Material;
  34984. private _texturesEnabled;
  34985. /**
  34986. * Gets or sets a boolean indicating if textures are enabled on this scene
  34987. */
  34988. texturesEnabled: boolean;
  34989. /**
  34990. * Gets or sets a boolean indicating if particles are enabled on this scene
  34991. */
  34992. particlesEnabled: boolean;
  34993. /**
  34994. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34995. */
  34996. spritesEnabled: boolean;
  34997. private _skeletonsEnabled;
  34998. /**
  34999. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35000. */
  35001. skeletonsEnabled: boolean;
  35002. /**
  35003. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35004. */
  35005. lensFlaresEnabled: boolean;
  35006. /**
  35007. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35008. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35009. */
  35010. collisionsEnabled: boolean;
  35011. private _collisionCoordinator;
  35012. /** @hidden */
  35013. readonly collisionCoordinator: ICollisionCoordinator;
  35014. /**
  35015. * Defines the gravity applied to this scene (used only for collisions)
  35016. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35017. */
  35018. gravity: Vector3;
  35019. /**
  35020. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35021. */
  35022. postProcessesEnabled: boolean;
  35023. /**
  35024. * The list of postprocesses added to the scene
  35025. */
  35026. postProcesses: PostProcess[];
  35027. /**
  35028. * Gets the current postprocess manager
  35029. */
  35030. postProcessManager: PostProcessManager;
  35031. /**
  35032. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35033. */
  35034. renderTargetsEnabled: boolean;
  35035. /**
  35036. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35037. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35038. */
  35039. dumpNextRenderTargets: boolean;
  35040. /**
  35041. * The list of user defined render targets added to the scene
  35042. */
  35043. customRenderTargets: RenderTargetTexture[];
  35044. /**
  35045. * Defines if texture loading must be delayed
  35046. * If true, textures will only be loaded when they need to be rendered
  35047. */
  35048. useDelayedTextureLoading: boolean;
  35049. /**
  35050. * Gets the list of meshes imported to the scene through SceneLoader
  35051. */
  35052. importedMeshesFiles: String[];
  35053. /**
  35054. * Gets or sets a boolean indicating if probes are enabled on this scene
  35055. */
  35056. probesEnabled: boolean;
  35057. /**
  35058. * Gets or sets the current offline provider to use to store scene data
  35059. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35060. */
  35061. offlineProvider: IOfflineProvider;
  35062. /**
  35063. * Gets or sets the action manager associated with the scene
  35064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35065. */
  35066. actionManager: AbstractActionManager;
  35067. private _meshesForIntersections;
  35068. /**
  35069. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35070. */
  35071. proceduralTexturesEnabled: boolean;
  35072. private _engine;
  35073. private _totalVertices;
  35074. /** @hidden */
  35075. _activeIndices: PerfCounter;
  35076. /** @hidden */
  35077. _activeParticles: PerfCounter;
  35078. /** @hidden */
  35079. _activeBones: PerfCounter;
  35080. private _animationRatio;
  35081. /** @hidden */
  35082. _animationTimeLast: number;
  35083. /** @hidden */
  35084. _animationTime: number;
  35085. /**
  35086. * Gets or sets a general scale for animation speed
  35087. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35088. */
  35089. animationTimeScale: number;
  35090. /** @hidden */
  35091. _cachedMaterial: Nullable<Material>;
  35092. /** @hidden */
  35093. _cachedEffect: Nullable<Effect>;
  35094. /** @hidden */
  35095. _cachedVisibility: Nullable<number>;
  35096. private _renderId;
  35097. private _frameId;
  35098. private _executeWhenReadyTimeoutId;
  35099. private _intermediateRendering;
  35100. private _viewUpdateFlag;
  35101. private _projectionUpdateFlag;
  35102. /** @hidden */
  35103. _toBeDisposed: Nullable<IDisposable>[];
  35104. private _activeRequests;
  35105. /** @hidden */
  35106. _pendingData: any[];
  35107. private _isDisposed;
  35108. /**
  35109. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35110. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35111. */
  35112. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35113. private _activeMeshes;
  35114. private _processedMaterials;
  35115. private _renderTargets;
  35116. /** @hidden */
  35117. _activeParticleSystems: SmartArray<IParticleSystem>;
  35118. private _activeSkeletons;
  35119. private _softwareSkinnedMeshes;
  35120. private _renderingManager;
  35121. /** @hidden */
  35122. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  35123. private _transformMatrix;
  35124. private _sceneUbo;
  35125. /** @hidden */
  35126. _viewMatrix: Matrix;
  35127. private _projectionMatrix;
  35128. /** @hidden */
  35129. _forcedViewPosition: Nullable<Vector3>;
  35130. /** @hidden */
  35131. _frustumPlanes: Plane[];
  35132. /**
  35133. * Gets the list of frustum planes (built from the active camera)
  35134. */
  35135. readonly frustumPlanes: Plane[];
  35136. /**
  35137. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35138. * This is useful if there are more lights that the maximum simulteanous authorized
  35139. */
  35140. requireLightSorting: boolean;
  35141. /** @hidden */
  35142. readonly useMaterialMeshMap: boolean;
  35143. /** @hidden */
  35144. readonly useClonedMeshhMap: boolean;
  35145. private _externalData;
  35146. private _uid;
  35147. /**
  35148. * @hidden
  35149. * Backing store of defined scene components.
  35150. */
  35151. _components: ISceneComponent[];
  35152. /**
  35153. * @hidden
  35154. * Backing store of defined scene components.
  35155. */
  35156. _serializableComponents: ISceneSerializableComponent[];
  35157. /**
  35158. * List of components to register on the next registration step.
  35159. */
  35160. private _transientComponents;
  35161. /**
  35162. * Registers the transient components if needed.
  35163. */
  35164. private _registerTransientComponents;
  35165. /**
  35166. * @hidden
  35167. * Add a component to the scene.
  35168. * Note that the ccomponent could be registered on th next frame if this is called after
  35169. * the register component stage.
  35170. * @param component Defines the component to add to the scene
  35171. */
  35172. _addComponent(component: ISceneComponent): void;
  35173. /**
  35174. * @hidden
  35175. * Gets a component from the scene.
  35176. * @param name defines the name of the component to retrieve
  35177. * @returns the component or null if not present
  35178. */
  35179. _getComponent(name: string): Nullable<ISceneComponent>;
  35180. /**
  35181. * @hidden
  35182. * Defines the actions happening before camera updates.
  35183. */
  35184. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35185. /**
  35186. * @hidden
  35187. * Defines the actions happening before clear the canvas.
  35188. */
  35189. _beforeClearStage: Stage<SimpleStageAction>;
  35190. /**
  35191. * @hidden
  35192. * Defines the actions when collecting render targets for the frame.
  35193. */
  35194. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35195. /**
  35196. * @hidden
  35197. * Defines the actions happening for one camera in the frame.
  35198. */
  35199. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35200. /**
  35201. * @hidden
  35202. * Defines the actions happening during the per mesh ready checks.
  35203. */
  35204. _isReadyForMeshStage: Stage<MeshStageAction>;
  35205. /**
  35206. * @hidden
  35207. * Defines the actions happening before evaluate active mesh checks.
  35208. */
  35209. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35210. /**
  35211. * @hidden
  35212. * Defines the actions happening during the evaluate sub mesh checks.
  35213. */
  35214. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35215. /**
  35216. * @hidden
  35217. * Defines the actions happening during the active mesh stage.
  35218. */
  35219. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35220. /**
  35221. * @hidden
  35222. * Defines the actions happening during the per camera render target step.
  35223. */
  35224. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35225. /**
  35226. * @hidden
  35227. * Defines the actions happening just before the active camera is drawing.
  35228. */
  35229. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35230. /**
  35231. * @hidden
  35232. * Defines the actions happening just before a render target is drawing.
  35233. */
  35234. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35235. /**
  35236. * @hidden
  35237. * Defines the actions happening just before a rendering group is drawing.
  35238. */
  35239. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35240. /**
  35241. * @hidden
  35242. * Defines the actions happening just before a mesh is drawing.
  35243. */
  35244. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35245. /**
  35246. * @hidden
  35247. * Defines the actions happening just after a mesh has been drawn.
  35248. */
  35249. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35250. /**
  35251. * @hidden
  35252. * Defines the actions happening just after a rendering group has been drawn.
  35253. */
  35254. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35255. /**
  35256. * @hidden
  35257. * Defines the actions happening just after the active camera has been drawn.
  35258. */
  35259. _afterCameraDrawStage: Stage<CameraStageAction>;
  35260. /**
  35261. * @hidden
  35262. * Defines the actions happening just after a render target has been drawn.
  35263. */
  35264. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35265. /**
  35266. * @hidden
  35267. * Defines the actions happening just after rendering all cameras and computing intersections.
  35268. */
  35269. _afterRenderStage: Stage<SimpleStageAction>;
  35270. /**
  35271. * @hidden
  35272. * Defines the actions happening when a pointer move event happens.
  35273. */
  35274. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35275. /**
  35276. * @hidden
  35277. * Defines the actions happening when a pointer down event happens.
  35278. */
  35279. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35280. /**
  35281. * @hidden
  35282. * Defines the actions happening when a pointer up event happens.
  35283. */
  35284. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35285. /**
  35286. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35287. */
  35288. private geometriesByUniqueId;
  35289. /**
  35290. * Creates a new Scene
  35291. * @param engine defines the engine to use to render this scene
  35292. * @param options defines the scene options
  35293. */
  35294. constructor(engine: Engine, options?: SceneOptions);
  35295. /**
  35296. * Gets a string idenfifying the name of the class
  35297. * @returns "Scene" string
  35298. */
  35299. getClassName(): string;
  35300. private _defaultMeshCandidates;
  35301. /**
  35302. * @hidden
  35303. */
  35304. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35305. private _defaultSubMeshCandidates;
  35306. /**
  35307. * @hidden
  35308. */
  35309. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35310. /**
  35311. * Sets the default candidate providers for the scene.
  35312. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35313. * and getCollidingSubMeshCandidates to their default function
  35314. */
  35315. setDefaultCandidateProviders(): void;
  35316. /**
  35317. * Gets the mesh that is currently under the pointer
  35318. */
  35319. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35320. /**
  35321. * Gets or sets the current on-screen X position of the pointer
  35322. */
  35323. pointerX: number;
  35324. /**
  35325. * Gets or sets the current on-screen Y position of the pointer
  35326. */
  35327. pointerY: number;
  35328. /**
  35329. * Gets the cached material (ie. the latest rendered one)
  35330. * @returns the cached material
  35331. */
  35332. getCachedMaterial(): Nullable<Material>;
  35333. /**
  35334. * Gets the cached effect (ie. the latest rendered one)
  35335. * @returns the cached effect
  35336. */
  35337. getCachedEffect(): Nullable<Effect>;
  35338. /**
  35339. * Gets the cached visibility state (ie. the latest rendered one)
  35340. * @returns the cached visibility state
  35341. */
  35342. getCachedVisibility(): Nullable<number>;
  35343. /**
  35344. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35345. * @param material defines the current material
  35346. * @param effect defines the current effect
  35347. * @param visibility defines the current visibility state
  35348. * @returns true if one parameter is not cached
  35349. */
  35350. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35351. /**
  35352. * Gets the engine associated with the scene
  35353. * @returns an Engine
  35354. */
  35355. getEngine(): Engine;
  35356. /**
  35357. * Gets the total number of vertices rendered per frame
  35358. * @returns the total number of vertices rendered per frame
  35359. */
  35360. getTotalVertices(): number;
  35361. /**
  35362. * Gets the performance counter for total vertices
  35363. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35364. */
  35365. readonly totalVerticesPerfCounter: PerfCounter;
  35366. /**
  35367. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35368. * @returns the total number of active indices rendered per frame
  35369. */
  35370. getActiveIndices(): number;
  35371. /**
  35372. * Gets the performance counter for active indices
  35373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35374. */
  35375. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35376. /**
  35377. * Gets the total number of active particles rendered per frame
  35378. * @returns the total number of active particles rendered per frame
  35379. */
  35380. getActiveParticles(): number;
  35381. /**
  35382. * Gets the performance counter for active particles
  35383. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35384. */
  35385. readonly activeParticlesPerfCounter: PerfCounter;
  35386. /**
  35387. * Gets the total number of active bones rendered per frame
  35388. * @returns the total number of active bones rendered per frame
  35389. */
  35390. getActiveBones(): number;
  35391. /**
  35392. * Gets the performance counter for active bones
  35393. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35394. */
  35395. readonly activeBonesPerfCounter: PerfCounter;
  35396. /**
  35397. * Gets the array of active meshes
  35398. * @returns an array of AbstractMesh
  35399. */
  35400. getActiveMeshes(): SmartArray<AbstractMesh>;
  35401. /**
  35402. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35403. * @returns a number
  35404. */
  35405. getAnimationRatio(): number;
  35406. /**
  35407. * Gets an unique Id for the current render phase
  35408. * @returns a number
  35409. */
  35410. getRenderId(): number;
  35411. /**
  35412. * Gets an unique Id for the current frame
  35413. * @returns a number
  35414. */
  35415. getFrameId(): number;
  35416. /** Call this function if you want to manually increment the render Id*/
  35417. incrementRenderId(): void;
  35418. private _createUbo;
  35419. /**
  35420. * Use this method to simulate a pointer move on a mesh
  35421. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35422. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35423. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35424. * @returns the current scene
  35425. */
  35426. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35427. /**
  35428. * Use this method to simulate a pointer down on a mesh
  35429. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35430. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35431. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35432. * @returns the current scene
  35433. */
  35434. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35435. /**
  35436. * Use this method to simulate a pointer up on a mesh
  35437. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35438. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35439. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35440. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35441. * @returns the current scene
  35442. */
  35443. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35444. /**
  35445. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35446. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35447. * @returns true if the pointer was captured
  35448. */
  35449. isPointerCaptured(pointerId?: number): boolean;
  35450. /**
  35451. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35452. * @param attachUp defines if you want to attach events to pointerup
  35453. * @param attachDown defines if you want to attach events to pointerdown
  35454. * @param attachMove defines if you want to attach events to pointermove
  35455. */
  35456. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35457. /** Detaches all event handlers*/
  35458. detachControl(): void;
  35459. /**
  35460. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35461. * Delay loaded resources are not taking in account
  35462. * @return true if all required resources are ready
  35463. */
  35464. isReady(): boolean;
  35465. /** Resets all cached information relative to material (including effect and visibility) */
  35466. resetCachedMaterial(): void;
  35467. /**
  35468. * Registers a function to be called before every frame render
  35469. * @param func defines the function to register
  35470. */
  35471. registerBeforeRender(func: () => void): void;
  35472. /**
  35473. * Unregisters a function called before every frame render
  35474. * @param func defines the function to unregister
  35475. */
  35476. unregisterBeforeRender(func: () => void): void;
  35477. /**
  35478. * Registers a function to be called after every frame render
  35479. * @param func defines the function to register
  35480. */
  35481. registerAfterRender(func: () => void): void;
  35482. /**
  35483. * Unregisters a function called after every frame render
  35484. * @param func defines the function to unregister
  35485. */
  35486. unregisterAfterRender(func: () => void): void;
  35487. private _executeOnceBeforeRender;
  35488. /**
  35489. * The provided function will run before render once and will be disposed afterwards.
  35490. * A timeout delay can be provided so that the function will be executed in N ms.
  35491. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35492. * @param func The function to be executed.
  35493. * @param timeout optional delay in ms
  35494. */
  35495. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35496. /** @hidden */
  35497. _addPendingData(data: any): void;
  35498. /** @hidden */
  35499. _removePendingData(data: any): void;
  35500. /**
  35501. * Returns the number of items waiting to be loaded
  35502. * @returns the number of items waiting to be loaded
  35503. */
  35504. getWaitingItemsCount(): number;
  35505. /**
  35506. * Returns a boolean indicating if the scene is still loading data
  35507. */
  35508. readonly isLoading: boolean;
  35509. /**
  35510. * Registers a function to be executed when the scene is ready
  35511. * @param {Function} func - the function to be executed
  35512. */
  35513. executeWhenReady(func: () => void): void;
  35514. /**
  35515. * Returns a promise that resolves when the scene is ready
  35516. * @returns A promise that resolves when the scene is ready
  35517. */
  35518. whenReadyAsync(): Promise<void>;
  35519. /** @hidden */
  35520. _checkIsReady(): void;
  35521. /**
  35522. * Gets all animatable attached to the scene
  35523. */
  35524. readonly animatables: Animatable[];
  35525. /**
  35526. * Resets the last animation time frame.
  35527. * Useful to override when animations start running when loading a scene for the first time.
  35528. */
  35529. resetLastAnimationTimeFrame(): void;
  35530. /**
  35531. * Gets the current view matrix
  35532. * @returns a Matrix
  35533. */
  35534. getViewMatrix(): Matrix;
  35535. /**
  35536. * Gets the current projection matrix
  35537. * @returns a Matrix
  35538. */
  35539. getProjectionMatrix(): Matrix;
  35540. /**
  35541. * Gets the current transform matrix
  35542. * @returns a Matrix made of View * Projection
  35543. */
  35544. getTransformMatrix(): Matrix;
  35545. /**
  35546. * Sets the current transform matrix
  35547. * @param viewL defines the View matrix to use
  35548. * @param projectionL defines the Projection matrix to use
  35549. * @param viewR defines the right View matrix to use (if provided)
  35550. * @param projectionR defines the right Projection matrix to use (if provided)
  35551. */
  35552. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35553. /**
  35554. * Gets the uniform buffer used to store scene data
  35555. * @returns a UniformBuffer
  35556. */
  35557. getSceneUniformBuffer(): UniformBuffer;
  35558. /**
  35559. * Gets an unique (relatively to the current scene) Id
  35560. * @returns an unique number for the scene
  35561. */
  35562. getUniqueId(): number;
  35563. /**
  35564. * Add a mesh to the list of scene's meshes
  35565. * @param newMesh defines the mesh to add
  35566. * @param recursive if all child meshes should also be added to the scene
  35567. */
  35568. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35569. /**
  35570. * Remove a mesh for the list of scene's meshes
  35571. * @param toRemove defines the mesh to remove
  35572. * @param recursive if all child meshes should also be removed from the scene
  35573. * @returns the index where the mesh was in the mesh list
  35574. */
  35575. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35576. /**
  35577. * Add a transform node to the list of scene's transform nodes
  35578. * @param newTransformNode defines the transform node to add
  35579. */
  35580. addTransformNode(newTransformNode: TransformNode): void;
  35581. /**
  35582. * Remove a transform node for the list of scene's transform nodes
  35583. * @param toRemove defines the transform node to remove
  35584. * @returns the index where the transform node was in the transform node list
  35585. */
  35586. removeTransformNode(toRemove: TransformNode): number;
  35587. /**
  35588. * Remove a skeleton for the list of scene's skeletons
  35589. * @param toRemove defines the skeleton to remove
  35590. * @returns the index where the skeleton was in the skeleton list
  35591. */
  35592. removeSkeleton(toRemove: Skeleton): number;
  35593. /**
  35594. * Remove a morph target for the list of scene's morph targets
  35595. * @param toRemove defines the morph target to remove
  35596. * @returns the index where the morph target was in the morph target list
  35597. */
  35598. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35599. /**
  35600. * Remove a light for the list of scene's lights
  35601. * @param toRemove defines the light to remove
  35602. * @returns the index where the light was in the light list
  35603. */
  35604. removeLight(toRemove: Light): number;
  35605. /**
  35606. * Remove a camera for the list of scene's cameras
  35607. * @param toRemove defines the camera to remove
  35608. * @returns the index where the camera was in the camera list
  35609. */
  35610. removeCamera(toRemove: Camera): number;
  35611. /**
  35612. * Remove a particle system for the list of scene's particle systems
  35613. * @param toRemove defines the particle system to remove
  35614. * @returns the index where the particle system was in the particle system list
  35615. */
  35616. removeParticleSystem(toRemove: IParticleSystem): number;
  35617. /**
  35618. * Remove a animation for the list of scene's animations
  35619. * @param toRemove defines the animation to remove
  35620. * @returns the index where the animation was in the animation list
  35621. */
  35622. removeAnimation(toRemove: Animation): number;
  35623. /**
  35624. * Will stop the animation of the given target
  35625. * @param target - the target
  35626. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35627. * @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)
  35628. */
  35629. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35630. /**
  35631. * Removes the given animation group from this scene.
  35632. * @param toRemove The animation group to remove
  35633. * @returns The index of the removed animation group
  35634. */
  35635. removeAnimationGroup(toRemove: AnimationGroup): number;
  35636. /**
  35637. * Removes the given multi-material from this scene.
  35638. * @param toRemove The multi-material to remove
  35639. * @returns The index of the removed multi-material
  35640. */
  35641. removeMultiMaterial(toRemove: MultiMaterial): number;
  35642. /**
  35643. * Removes the given material from this scene.
  35644. * @param toRemove The material to remove
  35645. * @returns The index of the removed material
  35646. */
  35647. removeMaterial(toRemove: Material): number;
  35648. /**
  35649. * Removes the given action manager from this scene.
  35650. * @param toRemove The action manager to remove
  35651. * @returns The index of the removed action manager
  35652. */
  35653. removeActionManager(toRemove: AbstractActionManager): number;
  35654. /**
  35655. * Removes the given texture from this scene.
  35656. * @param toRemove The texture to remove
  35657. * @returns The index of the removed texture
  35658. */
  35659. removeTexture(toRemove: BaseTexture): number;
  35660. /**
  35661. * Adds the given light to this scene
  35662. * @param newLight The light to add
  35663. */
  35664. addLight(newLight: Light): void;
  35665. /**
  35666. * Sorts the list list based on light priorities
  35667. */
  35668. sortLightsByPriority(): void;
  35669. /**
  35670. * Adds the given camera to this scene
  35671. * @param newCamera The camera to add
  35672. */
  35673. addCamera(newCamera: Camera): void;
  35674. /**
  35675. * Adds the given skeleton to this scene
  35676. * @param newSkeleton The skeleton to add
  35677. */
  35678. addSkeleton(newSkeleton: Skeleton): void;
  35679. /**
  35680. * Adds the given particle system to this scene
  35681. * @param newParticleSystem The particle system to add
  35682. */
  35683. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35684. /**
  35685. * Adds the given animation to this scene
  35686. * @param newAnimation The animation to add
  35687. */
  35688. addAnimation(newAnimation: Animation): void;
  35689. /**
  35690. * Adds the given animation group to this scene.
  35691. * @param newAnimationGroup The animation group to add
  35692. */
  35693. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35694. /**
  35695. * Adds the given multi-material to this scene
  35696. * @param newMultiMaterial The multi-material to add
  35697. */
  35698. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35699. /**
  35700. * Adds the given material to this scene
  35701. * @param newMaterial The material to add
  35702. */
  35703. addMaterial(newMaterial: Material): void;
  35704. /**
  35705. * Adds the given morph target to this scene
  35706. * @param newMorphTargetManager The morph target to add
  35707. */
  35708. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35709. /**
  35710. * Adds the given geometry to this scene
  35711. * @param newGeometry The geometry to add
  35712. */
  35713. addGeometry(newGeometry: Geometry): void;
  35714. /**
  35715. * Adds the given action manager to this scene
  35716. * @param newActionManager The action manager to add
  35717. */
  35718. addActionManager(newActionManager: AbstractActionManager): void;
  35719. /**
  35720. * Adds the given texture to this scene.
  35721. * @param newTexture The texture to add
  35722. */
  35723. addTexture(newTexture: BaseTexture): void;
  35724. /**
  35725. * Switch active camera
  35726. * @param newCamera defines the new active camera
  35727. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35728. */
  35729. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35730. /**
  35731. * sets the active camera of the scene using its ID
  35732. * @param id defines the camera's ID
  35733. * @return the new active camera or null if none found.
  35734. */
  35735. setActiveCameraByID(id: string): Nullable<Camera>;
  35736. /**
  35737. * sets the active camera of the scene using its name
  35738. * @param name defines the camera's name
  35739. * @returns the new active camera or null if none found.
  35740. */
  35741. setActiveCameraByName(name: string): Nullable<Camera>;
  35742. /**
  35743. * get an animation group using its name
  35744. * @param name defines the material's name
  35745. * @return the animation group or null if none found.
  35746. */
  35747. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35748. /**
  35749. * Get a material using its unique id
  35750. * @param uniqueId defines the material's unique id
  35751. * @return the material or null if none found.
  35752. */
  35753. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35754. /**
  35755. * get a material using its id
  35756. * @param id defines the material's ID
  35757. * @return the material or null if none found.
  35758. */
  35759. getMaterialByID(id: string): Nullable<Material>;
  35760. /**
  35761. * Gets a the last added material using a given id
  35762. * @param id defines the material's ID
  35763. * @return the last material with the given id or null if none found.
  35764. */
  35765. getLastMaterialByID(id: string): Nullable<Material>;
  35766. /**
  35767. * Gets a material using its name
  35768. * @param name defines the material's name
  35769. * @return the material or null if none found.
  35770. */
  35771. getMaterialByName(name: string): Nullable<Material>;
  35772. /**
  35773. * Get a texture using its unique id
  35774. * @param uniqueId defines the texture's unique id
  35775. * @return the texture or null if none found.
  35776. */
  35777. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35778. /**
  35779. * Gets a camera using its id
  35780. * @param id defines the id to look for
  35781. * @returns the camera or null if not found
  35782. */
  35783. getCameraByID(id: string): Nullable<Camera>;
  35784. /**
  35785. * Gets a camera using its unique id
  35786. * @param uniqueId defines the unique id to look for
  35787. * @returns the camera or null if not found
  35788. */
  35789. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35790. /**
  35791. * Gets a camera using its name
  35792. * @param name defines the camera's name
  35793. * @return the camera or null if none found.
  35794. */
  35795. getCameraByName(name: string): Nullable<Camera>;
  35796. /**
  35797. * Gets a bone using its id
  35798. * @param id defines the bone's id
  35799. * @return the bone or null if not found
  35800. */
  35801. getBoneByID(id: string): Nullable<Bone>;
  35802. /**
  35803. * Gets a bone using its id
  35804. * @param name defines the bone's name
  35805. * @return the bone or null if not found
  35806. */
  35807. getBoneByName(name: string): Nullable<Bone>;
  35808. /**
  35809. * Gets a light node using its name
  35810. * @param name defines the the light's name
  35811. * @return the light or null if none found.
  35812. */
  35813. getLightByName(name: string): Nullable<Light>;
  35814. /**
  35815. * Gets a light node using its id
  35816. * @param id defines the light's id
  35817. * @return the light or null if none found.
  35818. */
  35819. getLightByID(id: string): Nullable<Light>;
  35820. /**
  35821. * Gets a light node using its scene-generated unique ID
  35822. * @param uniqueId defines the light's unique id
  35823. * @return the light or null if none found.
  35824. */
  35825. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35826. /**
  35827. * Gets a particle system by id
  35828. * @param id defines the particle system id
  35829. * @return the corresponding system or null if none found
  35830. */
  35831. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35832. /**
  35833. * Gets a geometry using its ID
  35834. * @param id defines the geometry's id
  35835. * @return the geometry or null if none found.
  35836. */
  35837. getGeometryByID(id: string): Nullable<Geometry>;
  35838. private _getGeometryByUniqueID;
  35839. /**
  35840. * Add a new geometry to this scene
  35841. * @param geometry defines the geometry to be added to the scene.
  35842. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35843. * @return a boolean defining if the geometry was added or not
  35844. */
  35845. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35846. /**
  35847. * Removes an existing geometry
  35848. * @param geometry defines the geometry to be removed from the scene
  35849. * @return a boolean defining if the geometry was removed or not
  35850. */
  35851. removeGeometry(geometry: Geometry): boolean;
  35852. /**
  35853. * Gets the list of geometries attached to the scene
  35854. * @returns an array of Geometry
  35855. */
  35856. getGeometries(): Geometry[];
  35857. /**
  35858. * Gets the first added mesh found of a given ID
  35859. * @param id defines the id to search for
  35860. * @return the mesh found or null if not found at all
  35861. */
  35862. getMeshByID(id: string): Nullable<AbstractMesh>;
  35863. /**
  35864. * Gets a list of meshes using their id
  35865. * @param id defines the id to search for
  35866. * @returns a list of meshes
  35867. */
  35868. getMeshesByID(id: string): Array<AbstractMesh>;
  35869. /**
  35870. * Gets the first added transform node found of a given ID
  35871. * @param id defines the id to search for
  35872. * @return the found transform node or null if not found at all.
  35873. */
  35874. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35875. /**
  35876. * Gets a transform node with its auto-generated unique id
  35877. * @param uniqueId efines the unique id to search for
  35878. * @return the found transform node or null if not found at all.
  35879. */
  35880. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35881. /**
  35882. * Gets a list of transform nodes using their id
  35883. * @param id defines the id to search for
  35884. * @returns a list of transform nodes
  35885. */
  35886. getTransformNodesByID(id: string): Array<TransformNode>;
  35887. /**
  35888. * Gets a mesh with its auto-generated unique id
  35889. * @param uniqueId defines the unique id to search for
  35890. * @return the found mesh or null if not found at all.
  35891. */
  35892. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35893. /**
  35894. * Gets a the last added mesh using a given id
  35895. * @param id defines the id to search for
  35896. * @return the found mesh or null if not found at all.
  35897. */
  35898. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35899. /**
  35900. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35901. * @param id defines the id to search for
  35902. * @return the found node or null if not found at all
  35903. */
  35904. getLastEntryByID(id: string): Nullable<Node>;
  35905. /**
  35906. * Gets a node (Mesh, Camera, Light) using a given id
  35907. * @param id defines the id to search for
  35908. * @return the found node or null if not found at all
  35909. */
  35910. getNodeByID(id: string): Nullable<Node>;
  35911. /**
  35912. * Gets a node (Mesh, Camera, Light) using a given name
  35913. * @param name defines the name to search for
  35914. * @return the found node or null if not found at all.
  35915. */
  35916. getNodeByName(name: string): Nullable<Node>;
  35917. /**
  35918. * Gets a mesh using a given name
  35919. * @param name defines the name to search for
  35920. * @return the found mesh or null if not found at all.
  35921. */
  35922. getMeshByName(name: string): Nullable<AbstractMesh>;
  35923. /**
  35924. * Gets a transform node using a given name
  35925. * @param name defines the name to search for
  35926. * @return the found transform node or null if not found at all.
  35927. */
  35928. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35929. /**
  35930. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35931. * @param id defines the id to search for
  35932. * @return the found skeleton or null if not found at all.
  35933. */
  35934. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35935. /**
  35936. * Gets a skeleton using a given auto generated unique id
  35937. * @param uniqueId defines the unique id to search for
  35938. * @return the found skeleton or null if not found at all.
  35939. */
  35940. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35941. /**
  35942. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35943. * @param id defines the id to search for
  35944. * @return the found skeleton or null if not found at all.
  35945. */
  35946. getSkeletonById(id: string): Nullable<Skeleton>;
  35947. /**
  35948. * Gets a skeleton using a given name
  35949. * @param name defines the name to search for
  35950. * @return the found skeleton or null if not found at all.
  35951. */
  35952. getSkeletonByName(name: string): Nullable<Skeleton>;
  35953. /**
  35954. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35955. * @param id defines the id to search for
  35956. * @return the found morph target manager or null if not found at all.
  35957. */
  35958. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35959. /**
  35960. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35961. * @param id defines the id to search for
  35962. * @return the found morph target or null if not found at all.
  35963. */
  35964. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35965. /**
  35966. * Gets a boolean indicating if the given mesh is active
  35967. * @param mesh defines the mesh to look for
  35968. * @returns true if the mesh is in the active list
  35969. */
  35970. isActiveMesh(mesh: AbstractMesh): boolean;
  35971. /**
  35972. * Return a unique id as a string which can serve as an identifier for the scene
  35973. */
  35974. readonly uid: string;
  35975. /**
  35976. * Add an externaly attached data from its key.
  35977. * This method call will fail and return false, if such key already exists.
  35978. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35979. * @param key the unique key that identifies the data
  35980. * @param data the data object to associate to the key for this Engine instance
  35981. * @return true if no such key were already present and the data was added successfully, false otherwise
  35982. */
  35983. addExternalData<T>(key: string, data: T): boolean;
  35984. /**
  35985. * Get an externaly attached data from its key
  35986. * @param key the unique key that identifies the data
  35987. * @return the associated data, if present (can be null), or undefined if not present
  35988. */
  35989. getExternalData<T>(key: string): Nullable<T>;
  35990. /**
  35991. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35992. * @param key the unique key that identifies the data
  35993. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35994. * @return the associated data, can be null if the factory returned null.
  35995. */
  35996. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35997. /**
  35998. * Remove an externaly attached data from the Engine instance
  35999. * @param key the unique key that identifies the data
  36000. * @return true if the data was successfully removed, false if it doesn't exist
  36001. */
  36002. removeExternalData(key: string): boolean;
  36003. private _evaluateSubMesh;
  36004. /**
  36005. * Clear the processed materials smart array preventing retention point in material dispose.
  36006. */
  36007. freeProcessedMaterials(): void;
  36008. private _preventFreeActiveMeshesAndRenderingGroups;
  36009. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36010. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36011. * when disposing several meshes in a row or a hierarchy of meshes.
  36012. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36013. */
  36014. blockfreeActiveMeshesAndRenderingGroups: boolean;
  36015. /**
  36016. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36017. */
  36018. freeActiveMeshes(): void;
  36019. /**
  36020. * Clear the info related to rendering groups preventing retention points during dispose.
  36021. */
  36022. freeRenderingGroups(): void;
  36023. /** @hidden */
  36024. _isInIntermediateRendering(): boolean;
  36025. /**
  36026. * Lambda returning the list of potentially active meshes.
  36027. */
  36028. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36029. /**
  36030. * Lambda returning the list of potentially active sub meshes.
  36031. */
  36032. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36033. /**
  36034. * Lambda returning the list of potentially intersecting sub meshes.
  36035. */
  36036. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36037. /**
  36038. * Lambda returning the list of potentially colliding sub meshes.
  36039. */
  36040. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36041. private _activeMeshesFrozen;
  36042. private _skipEvaluateActiveMeshesCompletely;
  36043. /**
  36044. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36045. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36046. * @returns the current scene
  36047. */
  36048. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36049. /**
  36050. * Use this function to restart evaluating active meshes on every frame
  36051. * @returns the current scene
  36052. */
  36053. unfreezeActiveMeshes(): Scene;
  36054. private _evaluateActiveMeshes;
  36055. private _activeMesh;
  36056. /**
  36057. * Update the transform matrix to update from the current active camera
  36058. * @param force defines a boolean used to force the update even if cache is up to date
  36059. */
  36060. updateTransformMatrix(force?: boolean): void;
  36061. private _bindFrameBuffer;
  36062. /** @hidden */
  36063. _allowPostProcessClearColor: boolean;
  36064. /** @hidden */
  36065. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36066. private _processSubCameras;
  36067. private _checkIntersections;
  36068. /** @hidden */
  36069. _advancePhysicsEngineStep(step: number): void;
  36070. /**
  36071. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36072. */
  36073. getDeterministicFrameTime: () => number;
  36074. /** @hidden */
  36075. _animate(): void;
  36076. /** Execute all animations (for a frame) */
  36077. animate(): void;
  36078. /**
  36079. * Render the scene
  36080. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36081. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36082. */
  36083. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36084. /**
  36085. * Freeze all materials
  36086. * A frozen material will not be updatable but should be faster to render
  36087. */
  36088. freezeMaterials(): void;
  36089. /**
  36090. * Unfreeze all materials
  36091. * A frozen material will not be updatable but should be faster to render
  36092. */
  36093. unfreezeMaterials(): void;
  36094. /**
  36095. * Releases all held ressources
  36096. */
  36097. dispose(): void;
  36098. /**
  36099. * Gets if the scene is already disposed
  36100. */
  36101. readonly isDisposed: boolean;
  36102. /**
  36103. * Call this function to reduce memory footprint of the scene.
  36104. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36105. */
  36106. clearCachedVertexData(): void;
  36107. /**
  36108. * This function will remove the local cached buffer data from texture.
  36109. * It will save memory but will prevent the texture from being rebuilt
  36110. */
  36111. cleanCachedTextureBuffer(): void;
  36112. /**
  36113. * Get the world extend vectors with an optional filter
  36114. *
  36115. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36116. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36117. */
  36118. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36119. min: Vector3;
  36120. max: Vector3;
  36121. };
  36122. /**
  36123. * Creates a ray that can be used to pick in the scene
  36124. * @param x defines the x coordinate of the origin (on-screen)
  36125. * @param y defines the y coordinate of the origin (on-screen)
  36126. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36127. * @param camera defines the camera to use for the picking
  36128. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36129. * @returns a Ray
  36130. */
  36131. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36132. /**
  36133. * Creates a ray that can be used to pick in the scene
  36134. * @param x defines the x coordinate of the origin (on-screen)
  36135. * @param y defines the y coordinate of the origin (on-screen)
  36136. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36137. * @param result defines the ray where to store the picking ray
  36138. * @param camera defines the camera to use for the picking
  36139. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36140. * @returns the current scene
  36141. */
  36142. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36143. /**
  36144. * Creates a ray that can be used to pick in the scene
  36145. * @param x defines the x coordinate of the origin (on-screen)
  36146. * @param y defines the y coordinate of the origin (on-screen)
  36147. * @param camera defines the camera to use for the picking
  36148. * @returns a Ray
  36149. */
  36150. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36151. /**
  36152. * Creates a ray that can be used to pick in the scene
  36153. * @param x defines the x coordinate of the origin (on-screen)
  36154. * @param y defines the y coordinate of the origin (on-screen)
  36155. * @param result defines the ray where to store the picking ray
  36156. * @param camera defines the camera to use for the picking
  36157. * @returns the current scene
  36158. */
  36159. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36160. /** Launch a ray to try to pick a mesh in the scene
  36161. * @param x position on screen
  36162. * @param y position on screen
  36163. * @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
  36164. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36165. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36166. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36167. * @returns a PickingInfo
  36168. */
  36169. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36170. /** Use the given ray to pick a mesh in the scene
  36171. * @param ray The ray to use to pick meshes
  36172. * @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
  36173. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36174. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36175. * @returns a PickingInfo
  36176. */
  36177. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36178. /**
  36179. * Launch a ray to try to pick a mesh in the scene
  36180. * @param x X position on screen
  36181. * @param y Y position on screen
  36182. * @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
  36183. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36184. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36185. * @returns an array of PickingInfo
  36186. */
  36187. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36188. /**
  36189. * Launch a ray to try to pick a mesh in the scene
  36190. * @param ray Ray to use
  36191. * @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
  36192. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36193. * @returns an array of PickingInfo
  36194. */
  36195. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36196. /**
  36197. * Force the value of meshUnderPointer
  36198. * @param mesh defines the mesh to use
  36199. */
  36200. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36201. /**
  36202. * Gets the mesh under the pointer
  36203. * @returns a Mesh or null if no mesh is under the pointer
  36204. */
  36205. getPointerOverMesh(): Nullable<AbstractMesh>;
  36206. /** @hidden */
  36207. _rebuildGeometries(): void;
  36208. /** @hidden */
  36209. _rebuildTextures(): void;
  36210. private _getByTags;
  36211. /**
  36212. * Get a list of meshes by tags
  36213. * @param tagsQuery defines the tags query to use
  36214. * @param forEach defines a predicate used to filter results
  36215. * @returns an array of Mesh
  36216. */
  36217. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36218. /**
  36219. * Get a list of cameras by tags
  36220. * @param tagsQuery defines the tags query to use
  36221. * @param forEach defines a predicate used to filter results
  36222. * @returns an array of Camera
  36223. */
  36224. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36225. /**
  36226. * Get a list of lights by tags
  36227. * @param tagsQuery defines the tags query to use
  36228. * @param forEach defines a predicate used to filter results
  36229. * @returns an array of Light
  36230. */
  36231. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36232. /**
  36233. * Get a list of materials by tags
  36234. * @param tagsQuery defines the tags query to use
  36235. * @param forEach defines a predicate used to filter results
  36236. * @returns an array of Material
  36237. */
  36238. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36239. /**
  36240. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36241. * This allowed control for front to back rendering or reversly depending of the special needs.
  36242. *
  36243. * @param renderingGroupId The rendering group id corresponding to its index
  36244. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36245. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36246. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36247. */
  36248. 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;
  36249. /**
  36250. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36251. *
  36252. * @param renderingGroupId The rendering group id corresponding to its index
  36253. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36254. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36255. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36256. */
  36257. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36258. /**
  36259. * Gets the current auto clear configuration for one rendering group of the rendering
  36260. * manager.
  36261. * @param index the rendering group index to get the information for
  36262. * @returns The auto clear setup for the requested rendering group
  36263. */
  36264. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36265. private _blockMaterialDirtyMechanism;
  36266. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36267. blockMaterialDirtyMechanism: boolean;
  36268. /**
  36269. * Will flag all materials as dirty to trigger new shader compilation
  36270. * @param flag defines the flag used to specify which material part must be marked as dirty
  36271. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36272. */
  36273. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36274. /** @hidden */
  36275. _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;
  36276. /** @hidden */
  36277. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36278. /** @hidden */
  36279. _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;
  36280. /** @hidden */
  36281. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36282. /** @hidden */
  36283. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36284. /** @hidden */
  36285. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36286. }
  36287. }
  36288. declare module "babylonjs/assetContainer" {
  36289. import { AbstractScene } from "babylonjs/abstractScene";
  36290. import { Scene } from "babylonjs/scene";
  36291. import { Mesh } from "babylonjs/Meshes/mesh";
  36292. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36293. import { Skeleton } from "babylonjs/Bones/skeleton";
  36294. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36295. /**
  36296. * Set of assets to keep when moving a scene into an asset container.
  36297. */
  36298. export class KeepAssets extends AbstractScene {
  36299. }
  36300. /**
  36301. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36302. */
  36303. export class InstantiatedEntries {
  36304. /**
  36305. * List of new root nodes (eg. nodes with no parent)
  36306. */
  36307. rootNodes: TransformNode[];
  36308. /**
  36309. * List of new skeletons
  36310. */
  36311. skeletons: Skeleton[];
  36312. /**
  36313. * List of new animation groups
  36314. */
  36315. animationGroups: AnimationGroup[];
  36316. }
  36317. /**
  36318. * Container with a set of assets that can be added or removed from a scene.
  36319. */
  36320. export class AssetContainer extends AbstractScene {
  36321. /**
  36322. * The scene the AssetContainer belongs to.
  36323. */
  36324. scene: Scene;
  36325. /**
  36326. * Instantiates an AssetContainer.
  36327. * @param scene The scene the AssetContainer belongs to.
  36328. */
  36329. constructor(scene: Scene);
  36330. /**
  36331. * Instantiate or clone all meshes and add the new ones to the scene.
  36332. * Skeletons and animation groups will all be cloned
  36333. * @param nameFunction defines an optional function used to get new names for clones
  36334. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36335. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36336. */
  36337. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36338. /**
  36339. * Adds all the assets from the container to the scene.
  36340. */
  36341. addAllToScene(): void;
  36342. /**
  36343. * Removes all the assets in the container from the scene
  36344. */
  36345. removeAllFromScene(): void;
  36346. /**
  36347. * Disposes all the assets in the container
  36348. */
  36349. dispose(): void;
  36350. private _moveAssets;
  36351. /**
  36352. * Removes all the assets contained in the scene and adds them to the container.
  36353. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36354. */
  36355. moveAllFromScene(keepAssets?: KeepAssets): void;
  36356. /**
  36357. * 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.
  36358. * @returns the root mesh
  36359. */
  36360. createRootMesh(): Mesh;
  36361. }
  36362. }
  36363. declare module "babylonjs/abstractScene" {
  36364. import { Scene } from "babylonjs/scene";
  36365. import { Nullable } from "babylonjs/types";
  36366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36367. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36368. import { Geometry } from "babylonjs/Meshes/geometry";
  36369. import { Skeleton } from "babylonjs/Bones/skeleton";
  36370. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36371. import { AssetContainer } from "babylonjs/assetContainer";
  36372. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36373. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36375. import { Material } from "babylonjs/Materials/material";
  36376. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36377. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36378. import { Camera } from "babylonjs/Cameras/camera";
  36379. import { Light } from "babylonjs/Lights/light";
  36380. import { Node } from "babylonjs/node";
  36381. import { Animation } from "babylonjs/Animations/animation";
  36382. /**
  36383. * Defines how the parser contract is defined.
  36384. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36385. */
  36386. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36387. /**
  36388. * Defines how the individual parser contract is defined.
  36389. * These parser can parse an individual asset
  36390. */
  36391. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36392. /**
  36393. * Base class of the scene acting as a container for the different elements composing a scene.
  36394. * This class is dynamically extended by the different components of the scene increasing
  36395. * flexibility and reducing coupling
  36396. */
  36397. export abstract class AbstractScene {
  36398. /**
  36399. * Stores the list of available parsers in the application.
  36400. */
  36401. private static _BabylonFileParsers;
  36402. /**
  36403. * Stores the list of available individual parsers in the application.
  36404. */
  36405. private static _IndividualBabylonFileParsers;
  36406. /**
  36407. * Adds a parser in the list of available ones
  36408. * @param name Defines the name of the parser
  36409. * @param parser Defines the parser to add
  36410. */
  36411. static AddParser(name: string, parser: BabylonFileParser): void;
  36412. /**
  36413. * Gets a general parser from the list of avaialble ones
  36414. * @param name Defines the name of the parser
  36415. * @returns the requested parser or null
  36416. */
  36417. static GetParser(name: string): Nullable<BabylonFileParser>;
  36418. /**
  36419. * Adds n individual parser in the list of available ones
  36420. * @param name Defines the name of the parser
  36421. * @param parser Defines the parser to add
  36422. */
  36423. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36424. /**
  36425. * Gets an individual parser from the list of avaialble ones
  36426. * @param name Defines the name of the parser
  36427. * @returns the requested parser or null
  36428. */
  36429. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36430. /**
  36431. * Parser json data and populate both a scene and its associated container object
  36432. * @param jsonData Defines the data to parse
  36433. * @param scene Defines the scene to parse the data for
  36434. * @param container Defines the container attached to the parsing sequence
  36435. * @param rootUrl Defines the root url of the data
  36436. */
  36437. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36438. /**
  36439. * Gets the list of root nodes (ie. nodes with no parent)
  36440. */
  36441. rootNodes: Node[];
  36442. /** All of the cameras added to this scene
  36443. * @see http://doc.babylonjs.com/babylon101/cameras
  36444. */
  36445. cameras: Camera[];
  36446. /**
  36447. * All of the lights added to this scene
  36448. * @see http://doc.babylonjs.com/babylon101/lights
  36449. */
  36450. lights: Light[];
  36451. /**
  36452. * All of the (abstract) meshes added to this scene
  36453. */
  36454. meshes: AbstractMesh[];
  36455. /**
  36456. * The list of skeletons added to the scene
  36457. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36458. */
  36459. skeletons: Skeleton[];
  36460. /**
  36461. * All of the particle systems added to this scene
  36462. * @see http://doc.babylonjs.com/babylon101/particles
  36463. */
  36464. particleSystems: IParticleSystem[];
  36465. /**
  36466. * Gets a list of Animations associated with the scene
  36467. */
  36468. animations: Animation[];
  36469. /**
  36470. * All of the animation groups added to this scene
  36471. * @see http://doc.babylonjs.com/how_to/group
  36472. */
  36473. animationGroups: AnimationGroup[];
  36474. /**
  36475. * All of the multi-materials added to this scene
  36476. * @see http://doc.babylonjs.com/how_to/multi_materials
  36477. */
  36478. multiMaterials: MultiMaterial[];
  36479. /**
  36480. * All of the materials added to this scene
  36481. * In the context of a Scene, it is not supposed to be modified manually.
  36482. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36483. * Note also that the order of the Material within the array is not significant and might change.
  36484. * @see http://doc.babylonjs.com/babylon101/materials
  36485. */
  36486. materials: Material[];
  36487. /**
  36488. * The list of morph target managers added to the scene
  36489. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36490. */
  36491. morphTargetManagers: MorphTargetManager[];
  36492. /**
  36493. * The list of geometries used in the scene.
  36494. */
  36495. geometries: Geometry[];
  36496. /**
  36497. * All of the tranform nodes added to this scene
  36498. * In the context of a Scene, it is not supposed to be modified manually.
  36499. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36500. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36501. * @see http://doc.babylonjs.com/how_to/transformnode
  36502. */
  36503. transformNodes: TransformNode[];
  36504. /**
  36505. * ActionManagers available on the scene.
  36506. */
  36507. actionManagers: AbstractActionManager[];
  36508. /**
  36509. * Textures to keep.
  36510. */
  36511. textures: BaseTexture[];
  36512. /**
  36513. * Environment texture for the scene
  36514. */
  36515. environmentTexture: Nullable<BaseTexture>;
  36516. }
  36517. }
  36518. declare module "babylonjs/Audio/sound" {
  36519. import { Observable } from "babylonjs/Misc/observable";
  36520. import { Vector3 } from "babylonjs/Maths/math.vector";
  36521. import { Nullable } from "babylonjs/types";
  36522. import { Scene } from "babylonjs/scene";
  36523. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36524. /**
  36525. * Interface used to define options for Sound class
  36526. */
  36527. export interface ISoundOptions {
  36528. /**
  36529. * Does the sound autoplay once loaded.
  36530. */
  36531. autoplay?: boolean;
  36532. /**
  36533. * Does the sound loop after it finishes playing once.
  36534. */
  36535. loop?: boolean;
  36536. /**
  36537. * Sound's volume
  36538. */
  36539. volume?: number;
  36540. /**
  36541. * Is it a spatial sound?
  36542. */
  36543. spatialSound?: boolean;
  36544. /**
  36545. * Maximum distance to hear that sound
  36546. */
  36547. maxDistance?: number;
  36548. /**
  36549. * Uses user defined attenuation function
  36550. */
  36551. useCustomAttenuation?: boolean;
  36552. /**
  36553. * Define the roll off factor of spatial sounds.
  36554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36555. */
  36556. rolloffFactor?: number;
  36557. /**
  36558. * Define the reference distance the sound should be heard perfectly.
  36559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36560. */
  36561. refDistance?: number;
  36562. /**
  36563. * Define the distance attenuation model the sound will follow.
  36564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36565. */
  36566. distanceModel?: string;
  36567. /**
  36568. * Defines the playback speed (1 by default)
  36569. */
  36570. playbackRate?: number;
  36571. /**
  36572. * Defines if the sound is from a streaming source
  36573. */
  36574. streaming?: boolean;
  36575. /**
  36576. * Defines an optional length (in seconds) inside the sound file
  36577. */
  36578. length?: number;
  36579. /**
  36580. * Defines an optional offset (in seconds) inside the sound file
  36581. */
  36582. offset?: number;
  36583. /**
  36584. * If true, URLs will not be required to state the audio file codec to use.
  36585. */
  36586. skipCodecCheck?: boolean;
  36587. }
  36588. /**
  36589. * Defines a sound that can be played in the application.
  36590. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36592. */
  36593. export class Sound {
  36594. /**
  36595. * The name of the sound in the scene.
  36596. */
  36597. name: string;
  36598. /**
  36599. * Does the sound autoplay once loaded.
  36600. */
  36601. autoplay: boolean;
  36602. /**
  36603. * Does the sound loop after it finishes playing once.
  36604. */
  36605. loop: boolean;
  36606. /**
  36607. * Does the sound use a custom attenuation curve to simulate the falloff
  36608. * happening when the source gets further away from the camera.
  36609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36610. */
  36611. useCustomAttenuation: boolean;
  36612. /**
  36613. * The sound track id this sound belongs to.
  36614. */
  36615. soundTrackId: number;
  36616. /**
  36617. * Is this sound currently played.
  36618. */
  36619. isPlaying: boolean;
  36620. /**
  36621. * Is this sound currently paused.
  36622. */
  36623. isPaused: boolean;
  36624. /**
  36625. * Does this sound enables spatial sound.
  36626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36627. */
  36628. spatialSound: boolean;
  36629. /**
  36630. * Define the reference distance the sound should be heard perfectly.
  36631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36632. */
  36633. refDistance: number;
  36634. /**
  36635. * Define the roll off factor of spatial sounds.
  36636. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36637. */
  36638. rolloffFactor: number;
  36639. /**
  36640. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36641. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36642. */
  36643. maxDistance: number;
  36644. /**
  36645. * Define the distance attenuation model the sound will follow.
  36646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36647. */
  36648. distanceModel: string;
  36649. /**
  36650. * @hidden
  36651. * Back Compat
  36652. **/
  36653. onended: () => any;
  36654. /**
  36655. * Observable event when the current playing sound finishes.
  36656. */
  36657. onEndedObservable: Observable<Sound>;
  36658. private _panningModel;
  36659. private _playbackRate;
  36660. private _streaming;
  36661. private _startTime;
  36662. private _startOffset;
  36663. private _position;
  36664. /** @hidden */
  36665. _positionInEmitterSpace: boolean;
  36666. private _localDirection;
  36667. private _volume;
  36668. private _isReadyToPlay;
  36669. private _isDirectional;
  36670. private _readyToPlayCallback;
  36671. private _audioBuffer;
  36672. private _soundSource;
  36673. private _streamingSource;
  36674. private _soundPanner;
  36675. private _soundGain;
  36676. private _inputAudioNode;
  36677. private _outputAudioNode;
  36678. private _coneInnerAngle;
  36679. private _coneOuterAngle;
  36680. private _coneOuterGain;
  36681. private _scene;
  36682. private _connectedTransformNode;
  36683. private _customAttenuationFunction;
  36684. private _registerFunc;
  36685. private _isOutputConnected;
  36686. private _htmlAudioElement;
  36687. private _urlType;
  36688. private _length?;
  36689. private _offset?;
  36690. /** @hidden */
  36691. static _SceneComponentInitialization: (scene: Scene) => void;
  36692. /**
  36693. * Create a sound and attach it to a scene
  36694. * @param name Name of your sound
  36695. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36696. * @param scene defines the scene the sound belongs to
  36697. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36698. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36699. */
  36700. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36701. /**
  36702. * Release the sound and its associated resources
  36703. */
  36704. dispose(): void;
  36705. /**
  36706. * Gets if the sounds is ready to be played or not.
  36707. * @returns true if ready, otherwise false
  36708. */
  36709. isReady(): boolean;
  36710. private _soundLoaded;
  36711. /**
  36712. * Sets the data of the sound from an audiobuffer
  36713. * @param audioBuffer The audioBuffer containing the data
  36714. */
  36715. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36716. /**
  36717. * Updates the current sounds options such as maxdistance, loop...
  36718. * @param options A JSON object containing values named as the object properties
  36719. */
  36720. updateOptions(options: ISoundOptions): void;
  36721. private _createSpatialParameters;
  36722. private _updateSpatialParameters;
  36723. /**
  36724. * Switch the panning model to HRTF:
  36725. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36727. */
  36728. switchPanningModelToHRTF(): void;
  36729. /**
  36730. * Switch the panning model to Equal Power:
  36731. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36733. */
  36734. switchPanningModelToEqualPower(): void;
  36735. private _switchPanningModel;
  36736. /**
  36737. * Connect this sound to a sound track audio node like gain...
  36738. * @param soundTrackAudioNode the sound track audio node to connect to
  36739. */
  36740. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36741. /**
  36742. * Transform this sound into a directional source
  36743. * @param coneInnerAngle Size of the inner cone in degree
  36744. * @param coneOuterAngle Size of the outer cone in degree
  36745. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36746. */
  36747. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36748. /**
  36749. * Gets or sets the inner angle for the directional cone.
  36750. */
  36751. /**
  36752. * Gets or sets the inner angle for the directional cone.
  36753. */
  36754. directionalConeInnerAngle: number;
  36755. /**
  36756. * Gets or sets the outer angle for the directional cone.
  36757. */
  36758. /**
  36759. * Gets or sets the outer angle for the directional cone.
  36760. */
  36761. directionalConeOuterAngle: number;
  36762. /**
  36763. * Sets the position of the emitter if spatial sound is enabled
  36764. * @param newPosition Defines the new posisiton
  36765. */
  36766. setPosition(newPosition: Vector3): void;
  36767. /**
  36768. * Sets the local direction of the emitter if spatial sound is enabled
  36769. * @param newLocalDirection Defines the new local direction
  36770. */
  36771. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36772. private _updateDirection;
  36773. /** @hidden */
  36774. updateDistanceFromListener(): void;
  36775. /**
  36776. * Sets a new custom attenuation function for the sound.
  36777. * @param callback Defines the function used for the attenuation
  36778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36779. */
  36780. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36781. /**
  36782. * Play the sound
  36783. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36784. * @param offset (optional) Start the sound at a specific time in seconds
  36785. * @param length (optional) Sound duration (in seconds)
  36786. */
  36787. play(time?: number, offset?: number, length?: number): void;
  36788. private _onended;
  36789. /**
  36790. * Stop the sound
  36791. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36792. */
  36793. stop(time?: number): void;
  36794. /**
  36795. * Put the sound in pause
  36796. */
  36797. pause(): void;
  36798. /**
  36799. * Sets a dedicated volume for this sounds
  36800. * @param newVolume Define the new volume of the sound
  36801. * @param time Define time for gradual change to new volume
  36802. */
  36803. setVolume(newVolume: number, time?: number): void;
  36804. /**
  36805. * Set the sound play back rate
  36806. * @param newPlaybackRate Define the playback rate the sound should be played at
  36807. */
  36808. setPlaybackRate(newPlaybackRate: number): void;
  36809. /**
  36810. * Gets the volume of the sound.
  36811. * @returns the volume of the sound
  36812. */
  36813. getVolume(): number;
  36814. /**
  36815. * Attach the sound to a dedicated mesh
  36816. * @param transformNode The transform node to connect the sound with
  36817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36818. */
  36819. attachToMesh(transformNode: TransformNode): void;
  36820. /**
  36821. * Detach the sound from the previously attached mesh
  36822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36823. */
  36824. detachFromMesh(): void;
  36825. private _onRegisterAfterWorldMatrixUpdate;
  36826. /**
  36827. * Clone the current sound in the scene.
  36828. * @returns the new sound clone
  36829. */
  36830. clone(): Nullable<Sound>;
  36831. /**
  36832. * Gets the current underlying audio buffer containing the data
  36833. * @returns the audio buffer
  36834. */
  36835. getAudioBuffer(): Nullable<AudioBuffer>;
  36836. /**
  36837. * Serializes the Sound in a JSON representation
  36838. * @returns the JSON representation of the sound
  36839. */
  36840. serialize(): any;
  36841. /**
  36842. * Parse a JSON representation of a sound to innstantiate in a given scene
  36843. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36844. * @param scene Define the scene the new parsed sound should be created in
  36845. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36846. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36847. * @returns the newly parsed sound
  36848. */
  36849. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36850. }
  36851. }
  36852. declare module "babylonjs/Actions/directAudioActions" {
  36853. import { Action } from "babylonjs/Actions/action";
  36854. import { Condition } from "babylonjs/Actions/condition";
  36855. import { Sound } from "babylonjs/Audio/sound";
  36856. /**
  36857. * This defines an action helpful to play a defined sound on a triggered action.
  36858. */
  36859. export class PlaySoundAction extends Action {
  36860. private _sound;
  36861. /**
  36862. * Instantiate the action
  36863. * @param triggerOptions defines the trigger options
  36864. * @param sound defines the sound to play
  36865. * @param condition defines the trigger related conditions
  36866. */
  36867. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36868. /** @hidden */
  36869. _prepare(): void;
  36870. /**
  36871. * Execute the action and play the sound.
  36872. */
  36873. execute(): void;
  36874. /**
  36875. * Serializes the actions and its related information.
  36876. * @param parent defines the object to serialize in
  36877. * @returns the serialized object
  36878. */
  36879. serialize(parent: any): any;
  36880. }
  36881. /**
  36882. * This defines an action helpful to stop a defined sound on a triggered action.
  36883. */
  36884. export class StopSoundAction extends Action {
  36885. private _sound;
  36886. /**
  36887. * Instantiate the action
  36888. * @param triggerOptions defines the trigger options
  36889. * @param sound defines the sound to stop
  36890. * @param condition defines the trigger related conditions
  36891. */
  36892. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36893. /** @hidden */
  36894. _prepare(): void;
  36895. /**
  36896. * Execute the action and stop the sound.
  36897. */
  36898. execute(): void;
  36899. /**
  36900. * Serializes the actions and its related information.
  36901. * @param parent defines the object to serialize in
  36902. * @returns the serialized object
  36903. */
  36904. serialize(parent: any): any;
  36905. }
  36906. }
  36907. declare module "babylonjs/Actions/interpolateValueAction" {
  36908. import { Action } from "babylonjs/Actions/action";
  36909. import { Condition } from "babylonjs/Actions/condition";
  36910. import { Observable } from "babylonjs/Misc/observable";
  36911. /**
  36912. * This defines an action responsible to change the value of a property
  36913. * by interpolating between its current value and the newly set one once triggered.
  36914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36915. */
  36916. export class InterpolateValueAction extends Action {
  36917. /**
  36918. * Defines the path of the property where the value should be interpolated
  36919. */
  36920. propertyPath: string;
  36921. /**
  36922. * Defines the target value at the end of the interpolation.
  36923. */
  36924. value: any;
  36925. /**
  36926. * Defines the time it will take for the property to interpolate to the value.
  36927. */
  36928. duration: number;
  36929. /**
  36930. * Defines if the other scene animations should be stopped when the action has been triggered
  36931. */
  36932. stopOtherAnimations?: boolean;
  36933. /**
  36934. * Defines a callback raised once the interpolation animation has been done.
  36935. */
  36936. onInterpolationDone?: () => void;
  36937. /**
  36938. * Observable triggered once the interpolation animation has been done.
  36939. */
  36940. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36941. private _target;
  36942. private _effectiveTarget;
  36943. private _property;
  36944. /**
  36945. * Instantiate the action
  36946. * @param triggerOptions defines the trigger options
  36947. * @param target defines the object containing the value to interpolate
  36948. * @param propertyPath defines the path to the property in the target object
  36949. * @param value defines the target value at the end of the interpolation
  36950. * @param duration deines the time it will take for the property to interpolate to the value.
  36951. * @param condition defines the trigger related conditions
  36952. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36953. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36954. */
  36955. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36956. /** @hidden */
  36957. _prepare(): void;
  36958. /**
  36959. * Execute the action starts the value interpolation.
  36960. */
  36961. execute(): void;
  36962. /**
  36963. * Serializes the actions and its related information.
  36964. * @param parent defines the object to serialize in
  36965. * @returns the serialized object
  36966. */
  36967. serialize(parent: any): any;
  36968. }
  36969. }
  36970. declare module "babylonjs/Actions/index" {
  36971. export * from "babylonjs/Actions/abstractActionManager";
  36972. export * from "babylonjs/Actions/action";
  36973. export * from "babylonjs/Actions/actionEvent";
  36974. export * from "babylonjs/Actions/actionManager";
  36975. export * from "babylonjs/Actions/condition";
  36976. export * from "babylonjs/Actions/directActions";
  36977. export * from "babylonjs/Actions/directAudioActions";
  36978. export * from "babylonjs/Actions/interpolateValueAction";
  36979. }
  36980. declare module "babylonjs/Animations/index" {
  36981. export * from "babylonjs/Animations/animatable";
  36982. export * from "babylonjs/Animations/animation";
  36983. export * from "babylonjs/Animations/animationGroup";
  36984. export * from "babylonjs/Animations/animationPropertiesOverride";
  36985. export * from "babylonjs/Animations/easing";
  36986. export * from "babylonjs/Animations/runtimeAnimation";
  36987. export * from "babylonjs/Animations/animationEvent";
  36988. export * from "babylonjs/Animations/animationGroup";
  36989. export * from "babylonjs/Animations/animationKey";
  36990. export * from "babylonjs/Animations/animationRange";
  36991. export * from "babylonjs/Animations/animatable.interface";
  36992. }
  36993. declare module "babylonjs/Audio/soundTrack" {
  36994. import { Sound } from "babylonjs/Audio/sound";
  36995. import { Analyser } from "babylonjs/Audio/analyser";
  36996. import { Scene } from "babylonjs/scene";
  36997. /**
  36998. * Options allowed during the creation of a sound track.
  36999. */
  37000. export interface ISoundTrackOptions {
  37001. /**
  37002. * The volume the sound track should take during creation
  37003. */
  37004. volume?: number;
  37005. /**
  37006. * Define if the sound track is the main sound track of the scene
  37007. */
  37008. mainTrack?: boolean;
  37009. }
  37010. /**
  37011. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37012. * It will be also used in a future release to apply effects on a specific track.
  37013. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37014. */
  37015. export class SoundTrack {
  37016. /**
  37017. * The unique identifier of the sound track in the scene.
  37018. */
  37019. id: number;
  37020. /**
  37021. * The list of sounds included in the sound track.
  37022. */
  37023. soundCollection: Array<Sound>;
  37024. private _outputAudioNode;
  37025. private _scene;
  37026. private _connectedAnalyser;
  37027. private _options;
  37028. private _isInitialized;
  37029. /**
  37030. * Creates a new sound track.
  37031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37032. * @param scene Define the scene the sound track belongs to
  37033. * @param options
  37034. */
  37035. constructor(scene: Scene, options?: ISoundTrackOptions);
  37036. private _initializeSoundTrackAudioGraph;
  37037. /**
  37038. * Release the sound track and its associated resources
  37039. */
  37040. dispose(): void;
  37041. /**
  37042. * Adds a sound to this sound track
  37043. * @param sound define the cound to add
  37044. * @ignoreNaming
  37045. */
  37046. AddSound(sound: Sound): void;
  37047. /**
  37048. * Removes a sound to this sound track
  37049. * @param sound define the cound to remove
  37050. * @ignoreNaming
  37051. */
  37052. RemoveSound(sound: Sound): void;
  37053. /**
  37054. * Set a global volume for the full sound track.
  37055. * @param newVolume Define the new volume of the sound track
  37056. */
  37057. setVolume(newVolume: number): void;
  37058. /**
  37059. * Switch the panning model to HRTF:
  37060. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37062. */
  37063. switchPanningModelToHRTF(): void;
  37064. /**
  37065. * Switch the panning model to Equal Power:
  37066. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37068. */
  37069. switchPanningModelToEqualPower(): void;
  37070. /**
  37071. * Connect the sound track to an audio analyser allowing some amazing
  37072. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37074. * @param analyser The analyser to connect to the engine
  37075. */
  37076. connectToAnalyser(analyser: Analyser): void;
  37077. }
  37078. }
  37079. declare module "babylonjs/Audio/audioSceneComponent" {
  37080. import { Sound } from "babylonjs/Audio/sound";
  37081. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  37082. import { Nullable } from "babylonjs/types";
  37083. import { Vector3 } from "babylonjs/Maths/math.vector";
  37084. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  37085. import { Scene } from "babylonjs/scene";
  37086. import { AbstractScene } from "babylonjs/abstractScene";
  37087. import "babylonjs/Audio/audioEngine";
  37088. module "babylonjs/abstractScene" {
  37089. interface AbstractScene {
  37090. /**
  37091. * The list of sounds used in the scene.
  37092. */
  37093. sounds: Nullable<Array<Sound>>;
  37094. }
  37095. }
  37096. module "babylonjs/scene" {
  37097. interface Scene {
  37098. /**
  37099. * @hidden
  37100. * Backing field
  37101. */
  37102. _mainSoundTrack: SoundTrack;
  37103. /**
  37104. * The main sound track played by the scene.
  37105. * It cotains your primary collection of sounds.
  37106. */
  37107. mainSoundTrack: SoundTrack;
  37108. /**
  37109. * The list of sound tracks added to the scene
  37110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37111. */
  37112. soundTracks: Nullable<Array<SoundTrack>>;
  37113. /**
  37114. * Gets a sound using a given name
  37115. * @param name defines the name to search for
  37116. * @return the found sound or null if not found at all.
  37117. */
  37118. getSoundByName(name: string): Nullable<Sound>;
  37119. /**
  37120. * Gets or sets if audio support is enabled
  37121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37122. */
  37123. audioEnabled: boolean;
  37124. /**
  37125. * Gets or sets if audio will be output to headphones
  37126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37127. */
  37128. headphone: boolean;
  37129. /**
  37130. * Gets or sets custom audio listener position provider
  37131. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37132. */
  37133. audioListenerPositionProvider: Nullable<() => Vector3>;
  37134. /**
  37135. * Gets or sets a refresh rate when using 3D audio positioning
  37136. */
  37137. audioPositioningRefreshRate: number;
  37138. }
  37139. }
  37140. /**
  37141. * Defines the sound scene component responsible to manage any sounds
  37142. * in a given scene.
  37143. */
  37144. export class AudioSceneComponent implements ISceneSerializableComponent {
  37145. /**
  37146. * The component name helpfull to identify the component in the list of scene components.
  37147. */
  37148. readonly name: string;
  37149. /**
  37150. * The scene the component belongs to.
  37151. */
  37152. scene: Scene;
  37153. private _audioEnabled;
  37154. /**
  37155. * Gets whether audio is enabled or not.
  37156. * Please use related enable/disable method to switch state.
  37157. */
  37158. readonly audioEnabled: boolean;
  37159. private _headphone;
  37160. /**
  37161. * Gets whether audio is outputing to headphone or not.
  37162. * Please use the according Switch methods to change output.
  37163. */
  37164. readonly headphone: boolean;
  37165. /**
  37166. * Gets or sets a refresh rate when using 3D audio positioning
  37167. */
  37168. audioPositioningRefreshRate: number;
  37169. private _audioListenerPositionProvider;
  37170. /**
  37171. * Gets the current audio listener position provider
  37172. */
  37173. /**
  37174. * Sets a custom listener position for all sounds in the scene
  37175. * By default, this is the position of the first active camera
  37176. */
  37177. audioListenerPositionProvider: Nullable<() => Vector3>;
  37178. /**
  37179. * Creates a new instance of the component for the given scene
  37180. * @param scene Defines the scene to register the component in
  37181. */
  37182. constructor(scene: Scene);
  37183. /**
  37184. * Registers the component in a given scene
  37185. */
  37186. register(): void;
  37187. /**
  37188. * Rebuilds the elements related to this component in case of
  37189. * context lost for instance.
  37190. */
  37191. rebuild(): void;
  37192. /**
  37193. * Serializes the component data to the specified json object
  37194. * @param serializationObject The object to serialize to
  37195. */
  37196. serialize(serializationObject: any): void;
  37197. /**
  37198. * Adds all the elements from the container to the scene
  37199. * @param container the container holding the elements
  37200. */
  37201. addFromContainer(container: AbstractScene): void;
  37202. /**
  37203. * Removes all the elements in the container from the scene
  37204. * @param container contains the elements to remove
  37205. * @param dispose if the removed element should be disposed (default: false)
  37206. */
  37207. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37208. /**
  37209. * Disposes the component and the associated ressources.
  37210. */
  37211. dispose(): void;
  37212. /**
  37213. * Disables audio in the associated scene.
  37214. */
  37215. disableAudio(): void;
  37216. /**
  37217. * Enables audio in the associated scene.
  37218. */
  37219. enableAudio(): void;
  37220. /**
  37221. * Switch audio to headphone output.
  37222. */
  37223. switchAudioModeForHeadphones(): void;
  37224. /**
  37225. * Switch audio to normal speakers.
  37226. */
  37227. switchAudioModeForNormalSpeakers(): void;
  37228. private _cachedCameraDirection;
  37229. private _cachedCameraPosition;
  37230. private _lastCheck;
  37231. private _afterRender;
  37232. }
  37233. }
  37234. declare module "babylonjs/Audio/weightedsound" {
  37235. import { Sound } from "babylonjs/Audio/sound";
  37236. /**
  37237. * Wraps one or more Sound objects and selects one with random weight for playback.
  37238. */
  37239. export class WeightedSound {
  37240. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37241. loop: boolean;
  37242. private _coneInnerAngle;
  37243. private _coneOuterAngle;
  37244. private _volume;
  37245. /** A Sound is currently playing. */
  37246. isPlaying: boolean;
  37247. /** A Sound is currently paused. */
  37248. isPaused: boolean;
  37249. private _sounds;
  37250. private _weights;
  37251. private _currentIndex?;
  37252. /**
  37253. * Creates a new WeightedSound from the list of sounds given.
  37254. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37255. * @param sounds Array of Sounds that will be selected from.
  37256. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37257. */
  37258. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37259. /**
  37260. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37261. */
  37262. /**
  37263. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37264. */
  37265. directionalConeInnerAngle: number;
  37266. /**
  37267. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37268. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37269. */
  37270. /**
  37271. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37272. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37273. */
  37274. directionalConeOuterAngle: number;
  37275. /**
  37276. * Playback volume.
  37277. */
  37278. /**
  37279. * Playback volume.
  37280. */
  37281. volume: number;
  37282. private _onended;
  37283. /**
  37284. * Suspend playback
  37285. */
  37286. pause(): void;
  37287. /**
  37288. * Stop playback
  37289. */
  37290. stop(): void;
  37291. /**
  37292. * Start playback.
  37293. * @param startOffset Position the clip head at a specific time in seconds.
  37294. */
  37295. play(startOffset?: number): void;
  37296. }
  37297. }
  37298. declare module "babylonjs/Audio/index" {
  37299. export * from "babylonjs/Audio/analyser";
  37300. export * from "babylonjs/Audio/audioEngine";
  37301. export * from "babylonjs/Audio/audioSceneComponent";
  37302. export * from "babylonjs/Audio/sound";
  37303. export * from "babylonjs/Audio/soundTrack";
  37304. export * from "babylonjs/Audio/weightedsound";
  37305. }
  37306. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37307. import { Behavior } from "babylonjs/Behaviors/behavior";
  37308. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37309. import { BackEase } from "babylonjs/Animations/easing";
  37310. /**
  37311. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37312. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37313. */
  37314. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37315. /**
  37316. * Gets the name of the behavior.
  37317. */
  37318. readonly name: string;
  37319. /**
  37320. * The easing function used by animations
  37321. */
  37322. static EasingFunction: BackEase;
  37323. /**
  37324. * The easing mode used by animations
  37325. */
  37326. static EasingMode: number;
  37327. /**
  37328. * The duration of the animation, in milliseconds
  37329. */
  37330. transitionDuration: number;
  37331. /**
  37332. * Length of the distance animated by the transition when lower radius is reached
  37333. */
  37334. lowerRadiusTransitionRange: number;
  37335. /**
  37336. * Length of the distance animated by the transition when upper radius is reached
  37337. */
  37338. upperRadiusTransitionRange: number;
  37339. private _autoTransitionRange;
  37340. /**
  37341. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37342. */
  37343. /**
  37344. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37345. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37346. */
  37347. autoTransitionRange: boolean;
  37348. private _attachedCamera;
  37349. private _onAfterCheckInputsObserver;
  37350. private _onMeshTargetChangedObserver;
  37351. /**
  37352. * Initializes the behavior.
  37353. */
  37354. init(): void;
  37355. /**
  37356. * Attaches the behavior to its arc rotate camera.
  37357. * @param camera Defines the camera to attach the behavior to
  37358. */
  37359. attach(camera: ArcRotateCamera): void;
  37360. /**
  37361. * Detaches the behavior from its current arc rotate camera.
  37362. */
  37363. detach(): void;
  37364. private _radiusIsAnimating;
  37365. private _radiusBounceTransition;
  37366. private _animatables;
  37367. private _cachedWheelPrecision;
  37368. /**
  37369. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37370. * @param radiusLimit The limit to check against.
  37371. * @return Bool to indicate if at limit.
  37372. */
  37373. private _isRadiusAtLimit;
  37374. /**
  37375. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37376. * @param radiusDelta The delta by which to animate to. Can be negative.
  37377. */
  37378. private _applyBoundRadiusAnimation;
  37379. /**
  37380. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37381. */
  37382. protected _clearAnimationLocks(): void;
  37383. /**
  37384. * Stops and removes all animations that have been applied to the camera
  37385. */
  37386. stopAllAnimations(): void;
  37387. }
  37388. }
  37389. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37390. import { Behavior } from "babylonjs/Behaviors/behavior";
  37391. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37392. import { ExponentialEase } from "babylonjs/Animations/easing";
  37393. import { Nullable } from "babylonjs/types";
  37394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37395. import { Vector3 } from "babylonjs/Maths/math.vector";
  37396. /**
  37397. * 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.
  37398. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37399. */
  37400. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37401. /**
  37402. * Gets the name of the behavior.
  37403. */
  37404. readonly name: string;
  37405. private _mode;
  37406. private _radiusScale;
  37407. private _positionScale;
  37408. private _defaultElevation;
  37409. private _elevationReturnTime;
  37410. private _elevationReturnWaitTime;
  37411. private _zoomStopsAnimation;
  37412. private _framingTime;
  37413. /**
  37414. * The easing function used by animations
  37415. */
  37416. static EasingFunction: ExponentialEase;
  37417. /**
  37418. * The easing mode used by animations
  37419. */
  37420. static EasingMode: number;
  37421. /**
  37422. * Sets the current mode used by the behavior
  37423. */
  37424. /**
  37425. * Gets current mode used by the behavior.
  37426. */
  37427. mode: number;
  37428. /**
  37429. * Sets the scale applied to the radius (1 by default)
  37430. */
  37431. /**
  37432. * Gets the scale applied to the radius
  37433. */
  37434. radiusScale: number;
  37435. /**
  37436. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37437. */
  37438. /**
  37439. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37440. */
  37441. positionScale: number;
  37442. /**
  37443. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37444. * behaviour is triggered, in radians.
  37445. */
  37446. /**
  37447. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37448. * behaviour is triggered, in radians.
  37449. */
  37450. defaultElevation: number;
  37451. /**
  37452. * Sets the time (in milliseconds) taken to return to the default beta position.
  37453. * Negative value indicates camera should not return to default.
  37454. */
  37455. /**
  37456. * Gets the time (in milliseconds) taken to return to the default beta position.
  37457. * Negative value indicates camera should not return to default.
  37458. */
  37459. elevationReturnTime: number;
  37460. /**
  37461. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37462. */
  37463. /**
  37464. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37465. */
  37466. elevationReturnWaitTime: number;
  37467. /**
  37468. * Sets the flag that indicates if user zooming should stop animation.
  37469. */
  37470. /**
  37471. * Gets the flag that indicates if user zooming should stop animation.
  37472. */
  37473. zoomStopsAnimation: boolean;
  37474. /**
  37475. * Sets the transition time when framing the mesh, in milliseconds
  37476. */
  37477. /**
  37478. * Gets the transition time when framing the mesh, in milliseconds
  37479. */
  37480. framingTime: number;
  37481. /**
  37482. * Define if the behavior should automatically change the configured
  37483. * camera limits and sensibilities.
  37484. */
  37485. autoCorrectCameraLimitsAndSensibility: boolean;
  37486. private _onPrePointerObservableObserver;
  37487. private _onAfterCheckInputsObserver;
  37488. private _onMeshTargetChangedObserver;
  37489. private _attachedCamera;
  37490. private _isPointerDown;
  37491. private _lastInteractionTime;
  37492. /**
  37493. * Initializes the behavior.
  37494. */
  37495. init(): void;
  37496. /**
  37497. * Attaches the behavior to its arc rotate camera.
  37498. * @param camera Defines the camera to attach the behavior to
  37499. */
  37500. attach(camera: ArcRotateCamera): void;
  37501. /**
  37502. * Detaches the behavior from its current arc rotate camera.
  37503. */
  37504. detach(): void;
  37505. private _animatables;
  37506. private _betaIsAnimating;
  37507. private _betaTransition;
  37508. private _radiusTransition;
  37509. private _vectorTransition;
  37510. /**
  37511. * Targets the given mesh and updates zoom level accordingly.
  37512. * @param mesh The mesh to target.
  37513. * @param radius Optional. If a cached radius position already exists, overrides default.
  37514. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37515. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37516. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37517. */
  37518. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37519. /**
  37520. * Targets the given mesh with its children and updates zoom level accordingly.
  37521. * @param mesh The mesh to target.
  37522. * @param radius Optional. If a cached radius position already exists, overrides default.
  37523. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37524. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37525. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37526. */
  37527. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37528. /**
  37529. * Targets the given meshes with their children and updates zoom level accordingly.
  37530. * @param meshes The mesh to target.
  37531. * @param radius Optional. If a cached radius position already exists, overrides default.
  37532. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37533. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37534. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37535. */
  37536. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37537. /**
  37538. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37539. * @param minimumWorld Determines the smaller position of the bounding box extend
  37540. * @param maximumWorld Determines the bigger position of the bounding box extend
  37541. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37542. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37543. */
  37544. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37545. /**
  37546. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37547. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37548. * frustum width.
  37549. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37550. * to fully enclose the mesh in the viewing frustum.
  37551. */
  37552. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37553. /**
  37554. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37555. * is automatically returned to its default position (expected to be above ground plane).
  37556. */
  37557. private _maintainCameraAboveGround;
  37558. /**
  37559. * Returns the frustum slope based on the canvas ratio and camera FOV
  37560. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37561. */
  37562. private _getFrustumSlope;
  37563. /**
  37564. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37565. */
  37566. private _clearAnimationLocks;
  37567. /**
  37568. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37569. */
  37570. private _applyUserInteraction;
  37571. /**
  37572. * Stops and removes all animations that have been applied to the camera
  37573. */
  37574. stopAllAnimations(): void;
  37575. /**
  37576. * Gets a value indicating if the user is moving the camera
  37577. */
  37578. readonly isUserIsMoving: boolean;
  37579. /**
  37580. * The camera can move all the way towards the mesh.
  37581. */
  37582. static IgnoreBoundsSizeMode: number;
  37583. /**
  37584. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37585. */
  37586. static FitFrustumSidesMode: number;
  37587. }
  37588. }
  37589. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37590. import { Nullable } from "babylonjs/types";
  37591. import { Camera } from "babylonjs/Cameras/camera";
  37592. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37593. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37594. /**
  37595. * Base class for Camera Pointer Inputs.
  37596. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37597. * for example usage.
  37598. */
  37599. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37600. /**
  37601. * Defines the camera the input is attached to.
  37602. */
  37603. abstract camera: Camera;
  37604. /**
  37605. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37606. */
  37607. protected _altKey: boolean;
  37608. protected _ctrlKey: boolean;
  37609. protected _metaKey: boolean;
  37610. protected _shiftKey: boolean;
  37611. /**
  37612. * Which mouse buttons were pressed at time of last mouse event.
  37613. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37614. */
  37615. protected _buttonsPressed: number;
  37616. /**
  37617. * Defines the buttons associated with the input to handle camera move.
  37618. */
  37619. buttons: number[];
  37620. /**
  37621. * Attach the input controls to a specific dom element to get the input from.
  37622. * @param element Defines the element the controls should be listened from
  37623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37624. */
  37625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37626. /**
  37627. * Detach the current controls from the specified dom element.
  37628. * @param element Defines the element to stop listening the inputs from
  37629. */
  37630. detachControl(element: Nullable<HTMLElement>): void;
  37631. /**
  37632. * Gets the class name of the current input.
  37633. * @returns the class name
  37634. */
  37635. getClassName(): string;
  37636. /**
  37637. * Get the friendly name associated with the input class.
  37638. * @returns the input friendly name
  37639. */
  37640. getSimpleName(): string;
  37641. /**
  37642. * Called on pointer POINTERDOUBLETAP event.
  37643. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37644. */
  37645. protected onDoubleTap(type: string): void;
  37646. /**
  37647. * Called on pointer POINTERMOVE event if only a single touch is active.
  37648. * Override this method to provide functionality.
  37649. */
  37650. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37651. /**
  37652. * Called on pointer POINTERMOVE event if multiple touches are active.
  37653. * Override this method to provide functionality.
  37654. */
  37655. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37656. /**
  37657. * Called on JS contextmenu event.
  37658. * Override this method to provide functionality.
  37659. */
  37660. protected onContextMenu(evt: PointerEvent): void;
  37661. /**
  37662. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37663. * press.
  37664. * Override this method to provide functionality.
  37665. */
  37666. protected onButtonDown(evt: PointerEvent): void;
  37667. /**
  37668. * Called each time a new POINTERUP event occurs. Ie, for each button
  37669. * release.
  37670. * Override this method to provide functionality.
  37671. */
  37672. protected onButtonUp(evt: PointerEvent): void;
  37673. /**
  37674. * Called when window becomes inactive.
  37675. * Override this method to provide functionality.
  37676. */
  37677. protected onLostFocus(): void;
  37678. private _pointerInput;
  37679. private _observer;
  37680. private _onLostFocus;
  37681. private pointA;
  37682. private pointB;
  37683. }
  37684. }
  37685. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37686. import { Nullable } from "babylonjs/types";
  37687. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37688. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37689. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37690. /**
  37691. * Manage the pointers inputs to control an arc rotate camera.
  37692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37693. */
  37694. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37695. /**
  37696. * Defines the camera the input is attached to.
  37697. */
  37698. camera: ArcRotateCamera;
  37699. /**
  37700. * Gets the class name of the current input.
  37701. * @returns the class name
  37702. */
  37703. getClassName(): string;
  37704. /**
  37705. * Defines the buttons associated with the input to handle camera move.
  37706. */
  37707. buttons: number[];
  37708. /**
  37709. * Defines the pointer angular sensibility along the X axis or how fast is
  37710. * the camera rotating.
  37711. */
  37712. angularSensibilityX: number;
  37713. /**
  37714. * Defines the pointer angular sensibility along the Y axis or how fast is
  37715. * the camera rotating.
  37716. */
  37717. angularSensibilityY: number;
  37718. /**
  37719. * Defines the pointer pinch precision or how fast is the camera zooming.
  37720. */
  37721. pinchPrecision: number;
  37722. /**
  37723. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37724. * from 0.
  37725. * It defines the percentage of current camera.radius to use as delta when
  37726. * pinch zoom is used.
  37727. */
  37728. pinchDeltaPercentage: number;
  37729. /**
  37730. * Defines the pointer panning sensibility or how fast is the camera moving.
  37731. */
  37732. panningSensibility: number;
  37733. /**
  37734. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37735. */
  37736. multiTouchPanning: boolean;
  37737. /**
  37738. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37739. * zoom (pinch) through multitouch.
  37740. */
  37741. multiTouchPanAndZoom: boolean;
  37742. /**
  37743. * Revers pinch action direction.
  37744. */
  37745. pinchInwards: boolean;
  37746. private _isPanClick;
  37747. private _twoFingerActivityCount;
  37748. private _isPinching;
  37749. /**
  37750. * Called on pointer POINTERMOVE event if only a single touch is active.
  37751. */
  37752. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37753. /**
  37754. * Called on pointer POINTERDOUBLETAP event.
  37755. */
  37756. protected onDoubleTap(type: string): void;
  37757. /**
  37758. * Called on pointer POINTERMOVE event if multiple touches are active.
  37759. */
  37760. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37761. /**
  37762. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37763. * press.
  37764. */
  37765. protected onButtonDown(evt: PointerEvent): void;
  37766. /**
  37767. * Called each time a new POINTERUP event occurs. Ie, for each button
  37768. * release.
  37769. */
  37770. protected onButtonUp(evt: PointerEvent): void;
  37771. /**
  37772. * Called when window becomes inactive.
  37773. */
  37774. protected onLostFocus(): void;
  37775. }
  37776. }
  37777. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37778. import { Nullable } from "babylonjs/types";
  37779. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37780. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37781. /**
  37782. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37784. */
  37785. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37786. /**
  37787. * Defines the camera the input is attached to.
  37788. */
  37789. camera: ArcRotateCamera;
  37790. /**
  37791. * Defines the list of key codes associated with the up action (increase alpha)
  37792. */
  37793. keysUp: number[];
  37794. /**
  37795. * Defines the list of key codes associated with the down action (decrease alpha)
  37796. */
  37797. keysDown: number[];
  37798. /**
  37799. * Defines the list of key codes associated with the left action (increase beta)
  37800. */
  37801. keysLeft: number[];
  37802. /**
  37803. * Defines the list of key codes associated with the right action (decrease beta)
  37804. */
  37805. keysRight: number[];
  37806. /**
  37807. * Defines the list of key codes associated with the reset action.
  37808. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37809. */
  37810. keysReset: number[];
  37811. /**
  37812. * Defines the panning sensibility of the inputs.
  37813. * (How fast is the camera paning)
  37814. */
  37815. panningSensibility: number;
  37816. /**
  37817. * Defines the zooming sensibility of the inputs.
  37818. * (How fast is the camera zooming)
  37819. */
  37820. zoomingSensibility: number;
  37821. /**
  37822. * Defines wether maintaining the alt key down switch the movement mode from
  37823. * orientation to zoom.
  37824. */
  37825. useAltToZoom: boolean;
  37826. /**
  37827. * Rotation speed of the camera
  37828. */
  37829. angularSpeed: number;
  37830. private _keys;
  37831. private _ctrlPressed;
  37832. private _altPressed;
  37833. private _onCanvasBlurObserver;
  37834. private _onKeyboardObserver;
  37835. private _engine;
  37836. private _scene;
  37837. /**
  37838. * Attach the input controls to a specific dom element to get the input from.
  37839. * @param element Defines the element the controls should be listened from
  37840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37841. */
  37842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37843. /**
  37844. * Detach the current controls from the specified dom element.
  37845. * @param element Defines the element to stop listening the inputs from
  37846. */
  37847. detachControl(element: Nullable<HTMLElement>): void;
  37848. /**
  37849. * Update the current camera state depending on the inputs that have been used this frame.
  37850. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37851. */
  37852. checkInputs(): void;
  37853. /**
  37854. * Gets the class name of the current intput.
  37855. * @returns the class name
  37856. */
  37857. getClassName(): string;
  37858. /**
  37859. * Get the friendly name associated with the input class.
  37860. * @returns the input friendly name
  37861. */
  37862. getSimpleName(): string;
  37863. }
  37864. }
  37865. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37866. import { Nullable } from "babylonjs/types";
  37867. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37868. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37869. /**
  37870. * Manage the mouse wheel inputs to control an arc rotate camera.
  37871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37872. */
  37873. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37874. /**
  37875. * Defines the camera the input is attached to.
  37876. */
  37877. camera: ArcRotateCamera;
  37878. /**
  37879. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37880. */
  37881. wheelPrecision: number;
  37882. /**
  37883. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37884. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37885. */
  37886. wheelDeltaPercentage: number;
  37887. private _wheel;
  37888. private _observer;
  37889. private computeDeltaFromMouseWheelLegacyEvent;
  37890. /**
  37891. * Attach the input controls to a specific dom element to get the input from.
  37892. * @param element Defines the element the controls should be listened from
  37893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37894. */
  37895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37896. /**
  37897. * Detach the current controls from the specified dom element.
  37898. * @param element Defines the element to stop listening the inputs from
  37899. */
  37900. detachControl(element: Nullable<HTMLElement>): void;
  37901. /**
  37902. * Gets the class name of the current intput.
  37903. * @returns the class name
  37904. */
  37905. getClassName(): string;
  37906. /**
  37907. * Get the friendly name associated with the input class.
  37908. * @returns the input friendly name
  37909. */
  37910. getSimpleName(): string;
  37911. }
  37912. }
  37913. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37914. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37915. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37916. /**
  37917. * Default Inputs manager for the ArcRotateCamera.
  37918. * It groups all the default supported inputs for ease of use.
  37919. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37920. */
  37921. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37922. /**
  37923. * Instantiates a new ArcRotateCameraInputsManager.
  37924. * @param camera Defines the camera the inputs belong to
  37925. */
  37926. constructor(camera: ArcRotateCamera);
  37927. /**
  37928. * Add mouse wheel input support to the input manager.
  37929. * @returns the current input manager
  37930. */
  37931. addMouseWheel(): ArcRotateCameraInputsManager;
  37932. /**
  37933. * Add pointers input support to the input manager.
  37934. * @returns the current input manager
  37935. */
  37936. addPointers(): ArcRotateCameraInputsManager;
  37937. /**
  37938. * Add keyboard input support to the input manager.
  37939. * @returns the current input manager
  37940. */
  37941. addKeyboard(): ArcRotateCameraInputsManager;
  37942. }
  37943. }
  37944. declare module "babylonjs/Cameras/arcRotateCamera" {
  37945. import { Observable } from "babylonjs/Misc/observable";
  37946. import { Nullable } from "babylonjs/types";
  37947. import { Scene } from "babylonjs/scene";
  37948. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37950. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37951. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37952. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37953. import { Camera } from "babylonjs/Cameras/camera";
  37954. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37955. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37956. import { Collider } from "babylonjs/Collisions/collider";
  37957. /**
  37958. * This represents an orbital type of camera.
  37959. *
  37960. * 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.
  37961. * 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.
  37962. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37963. */
  37964. export class ArcRotateCamera extends TargetCamera {
  37965. /**
  37966. * Defines the rotation angle of the camera along the longitudinal axis.
  37967. */
  37968. alpha: number;
  37969. /**
  37970. * Defines the rotation angle of the camera along the latitudinal axis.
  37971. */
  37972. beta: number;
  37973. /**
  37974. * Defines the radius of the camera from it s target point.
  37975. */
  37976. radius: number;
  37977. protected _target: Vector3;
  37978. protected _targetHost: Nullable<AbstractMesh>;
  37979. /**
  37980. * Defines the target point of the camera.
  37981. * The camera looks towards it form the radius distance.
  37982. */
  37983. target: Vector3;
  37984. /**
  37985. * Define the current local position of the camera in the scene
  37986. */
  37987. position: Vector3;
  37988. protected _upVector: Vector3;
  37989. protected _upToYMatrix: Matrix;
  37990. protected _YToUpMatrix: Matrix;
  37991. /**
  37992. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37993. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37994. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37995. */
  37996. upVector: Vector3;
  37997. /**
  37998. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37999. */
  38000. setMatUp(): void;
  38001. /**
  38002. * Current inertia value on the longitudinal axis.
  38003. * The bigger this number the longer it will take for the camera to stop.
  38004. */
  38005. inertialAlphaOffset: number;
  38006. /**
  38007. * Current inertia value on the latitudinal axis.
  38008. * The bigger this number the longer it will take for the camera to stop.
  38009. */
  38010. inertialBetaOffset: number;
  38011. /**
  38012. * Current inertia value on the radius axis.
  38013. * The bigger this number the longer it will take for the camera to stop.
  38014. */
  38015. inertialRadiusOffset: number;
  38016. /**
  38017. * Minimum allowed angle on the longitudinal axis.
  38018. * This can help limiting how the Camera is able to move in the scene.
  38019. */
  38020. lowerAlphaLimit: Nullable<number>;
  38021. /**
  38022. * Maximum allowed angle on the longitudinal axis.
  38023. * This can help limiting how the Camera is able to move in the scene.
  38024. */
  38025. upperAlphaLimit: Nullable<number>;
  38026. /**
  38027. * Minimum allowed angle on the latitudinal axis.
  38028. * This can help limiting how the Camera is able to move in the scene.
  38029. */
  38030. lowerBetaLimit: number;
  38031. /**
  38032. * Maximum allowed angle on the latitudinal axis.
  38033. * This can help limiting how the Camera is able to move in the scene.
  38034. */
  38035. upperBetaLimit: number;
  38036. /**
  38037. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38038. * This can help limiting how the Camera is able to move in the scene.
  38039. */
  38040. lowerRadiusLimit: Nullable<number>;
  38041. /**
  38042. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38043. * This can help limiting how the Camera is able to move in the scene.
  38044. */
  38045. upperRadiusLimit: Nullable<number>;
  38046. /**
  38047. * Defines the current inertia value used during panning of the camera along the X axis.
  38048. */
  38049. inertialPanningX: number;
  38050. /**
  38051. * Defines the current inertia value used during panning of the camera along the Y axis.
  38052. */
  38053. inertialPanningY: number;
  38054. /**
  38055. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38056. * Basically if your fingers moves away from more than this distance you will be considered
  38057. * in pinch mode.
  38058. */
  38059. pinchToPanMaxDistance: number;
  38060. /**
  38061. * Defines the maximum distance the camera can pan.
  38062. * This could help keeping the cammera always in your scene.
  38063. */
  38064. panningDistanceLimit: Nullable<number>;
  38065. /**
  38066. * Defines the target of the camera before paning.
  38067. */
  38068. panningOriginTarget: Vector3;
  38069. /**
  38070. * Defines the value of the inertia used during panning.
  38071. * 0 would mean stop inertia and one would mean no decelleration at all.
  38072. */
  38073. panningInertia: number;
  38074. /**
  38075. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38076. */
  38077. angularSensibilityX: number;
  38078. /**
  38079. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38080. */
  38081. angularSensibilityY: number;
  38082. /**
  38083. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38084. */
  38085. pinchPrecision: number;
  38086. /**
  38087. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38088. * It will be used instead of pinchDeltaPrecision if different from 0.
  38089. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38090. */
  38091. pinchDeltaPercentage: number;
  38092. /**
  38093. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38094. */
  38095. panningSensibility: number;
  38096. /**
  38097. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38098. */
  38099. keysUp: number[];
  38100. /**
  38101. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38102. */
  38103. keysDown: number[];
  38104. /**
  38105. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38106. */
  38107. keysLeft: number[];
  38108. /**
  38109. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38110. */
  38111. keysRight: number[];
  38112. /**
  38113. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38114. */
  38115. wheelPrecision: number;
  38116. /**
  38117. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38118. * It will be used instead of pinchDeltaPrecision if different from 0.
  38119. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38120. */
  38121. wheelDeltaPercentage: number;
  38122. /**
  38123. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38124. */
  38125. zoomOnFactor: number;
  38126. /**
  38127. * Defines a screen offset for the camera position.
  38128. */
  38129. targetScreenOffset: Vector2;
  38130. /**
  38131. * Allows the camera to be completely reversed.
  38132. * If false the camera can not arrive upside down.
  38133. */
  38134. allowUpsideDown: boolean;
  38135. /**
  38136. * Define if double tap/click is used to restore the previously saved state of the camera.
  38137. */
  38138. useInputToRestoreState: boolean;
  38139. /** @hidden */
  38140. _viewMatrix: Matrix;
  38141. /** @hidden */
  38142. _useCtrlForPanning: boolean;
  38143. /** @hidden */
  38144. _panningMouseButton: number;
  38145. /**
  38146. * Defines the input associated to the camera.
  38147. */
  38148. inputs: ArcRotateCameraInputsManager;
  38149. /** @hidden */
  38150. _reset: () => void;
  38151. /**
  38152. * Defines the allowed panning axis.
  38153. */
  38154. panningAxis: Vector3;
  38155. protected _localDirection: Vector3;
  38156. protected _transformedDirection: Vector3;
  38157. private _bouncingBehavior;
  38158. /**
  38159. * Gets the bouncing behavior of the camera if it has been enabled.
  38160. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38161. */
  38162. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38163. /**
  38164. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38165. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38166. */
  38167. useBouncingBehavior: boolean;
  38168. private _framingBehavior;
  38169. /**
  38170. * Gets the framing behavior of the camera if it has been enabled.
  38171. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38172. */
  38173. readonly framingBehavior: Nullable<FramingBehavior>;
  38174. /**
  38175. * Defines if the framing behavior of the camera is enabled on the camera.
  38176. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38177. */
  38178. useFramingBehavior: boolean;
  38179. private _autoRotationBehavior;
  38180. /**
  38181. * Gets the auto rotation behavior of the camera if it has been enabled.
  38182. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38183. */
  38184. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38185. /**
  38186. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38187. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38188. */
  38189. useAutoRotationBehavior: boolean;
  38190. /**
  38191. * Observable triggered when the mesh target has been changed on the camera.
  38192. */
  38193. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38194. /**
  38195. * Event raised when the camera is colliding with a mesh.
  38196. */
  38197. onCollide: (collidedMesh: AbstractMesh) => void;
  38198. /**
  38199. * Defines whether the camera should check collision with the objects oh the scene.
  38200. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38201. */
  38202. checkCollisions: boolean;
  38203. /**
  38204. * Defines the collision radius of the camera.
  38205. * This simulates a sphere around the camera.
  38206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38207. */
  38208. collisionRadius: Vector3;
  38209. protected _collider: Collider;
  38210. protected _previousPosition: Vector3;
  38211. protected _collisionVelocity: Vector3;
  38212. protected _newPosition: Vector3;
  38213. protected _previousAlpha: number;
  38214. protected _previousBeta: number;
  38215. protected _previousRadius: number;
  38216. protected _collisionTriggered: boolean;
  38217. protected _targetBoundingCenter: Nullable<Vector3>;
  38218. private _computationVector;
  38219. /**
  38220. * Instantiates a new ArcRotateCamera in a given scene
  38221. * @param name Defines the name of the camera
  38222. * @param alpha Defines the camera rotation along the logitudinal axis
  38223. * @param beta Defines the camera rotation along the latitudinal axis
  38224. * @param radius Defines the camera distance from its target
  38225. * @param target Defines the camera target
  38226. * @param scene Defines the scene the camera belongs to
  38227. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38228. */
  38229. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38230. /** @hidden */
  38231. _initCache(): void;
  38232. /** @hidden */
  38233. _updateCache(ignoreParentClass?: boolean): void;
  38234. protected _getTargetPosition(): Vector3;
  38235. private _storedAlpha;
  38236. private _storedBeta;
  38237. private _storedRadius;
  38238. private _storedTarget;
  38239. private _storedTargetScreenOffset;
  38240. /**
  38241. * Stores the current state of the camera (alpha, beta, radius and target)
  38242. * @returns the camera itself
  38243. */
  38244. storeState(): Camera;
  38245. /**
  38246. * @hidden
  38247. * Restored camera state. You must call storeState() first
  38248. */
  38249. _restoreStateValues(): boolean;
  38250. /** @hidden */
  38251. _isSynchronizedViewMatrix(): boolean;
  38252. /**
  38253. * Attached controls to the current camera.
  38254. * @param element Defines the element the controls should be listened from
  38255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38256. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38257. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38258. */
  38259. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38260. /**
  38261. * Detach the current controls from the camera.
  38262. * The camera will stop reacting to inputs.
  38263. * @param element Defines the element to stop listening the inputs from
  38264. */
  38265. detachControl(element: HTMLElement): void;
  38266. /** @hidden */
  38267. _checkInputs(): void;
  38268. protected _checkLimits(): void;
  38269. /**
  38270. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38271. */
  38272. rebuildAnglesAndRadius(): void;
  38273. /**
  38274. * Use a position to define the current camera related information like alpha, beta and radius
  38275. * @param position Defines the position to set the camera at
  38276. */
  38277. setPosition(position: Vector3): void;
  38278. /**
  38279. * Defines the target the camera should look at.
  38280. * This will automatically adapt alpha beta and radius to fit within the new target.
  38281. * @param target Defines the new target as a Vector or a mesh
  38282. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38283. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38284. */
  38285. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38286. /** @hidden */
  38287. _getViewMatrix(): Matrix;
  38288. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38289. /**
  38290. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38291. * @param meshes Defines the mesh to zoom on
  38292. * @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)
  38293. */
  38294. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38295. /**
  38296. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38297. * The target will be changed but the radius
  38298. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38299. * @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)
  38300. */
  38301. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38302. min: Vector3;
  38303. max: Vector3;
  38304. distance: number;
  38305. }, doNotUpdateMaxZ?: boolean): void;
  38306. /**
  38307. * @override
  38308. * Override Camera.createRigCamera
  38309. */
  38310. createRigCamera(name: string, cameraIndex: number): Camera;
  38311. /**
  38312. * @hidden
  38313. * @override
  38314. * Override Camera._updateRigCameras
  38315. */
  38316. _updateRigCameras(): void;
  38317. /**
  38318. * Destroy the camera and release the current resources hold by it.
  38319. */
  38320. dispose(): void;
  38321. /**
  38322. * Gets the current object class name.
  38323. * @return the class name
  38324. */
  38325. getClassName(): string;
  38326. }
  38327. }
  38328. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38329. import { Behavior } from "babylonjs/Behaviors/behavior";
  38330. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38331. /**
  38332. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38333. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38334. */
  38335. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38336. /**
  38337. * Gets the name of the behavior.
  38338. */
  38339. readonly name: string;
  38340. private _zoomStopsAnimation;
  38341. private _idleRotationSpeed;
  38342. private _idleRotationWaitTime;
  38343. private _idleRotationSpinupTime;
  38344. /**
  38345. * Sets the flag that indicates if user zooming should stop animation.
  38346. */
  38347. /**
  38348. * Gets the flag that indicates if user zooming should stop animation.
  38349. */
  38350. zoomStopsAnimation: boolean;
  38351. /**
  38352. * Sets the default speed at which the camera rotates around the model.
  38353. */
  38354. /**
  38355. * Gets the default speed at which the camera rotates around the model.
  38356. */
  38357. idleRotationSpeed: number;
  38358. /**
  38359. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38360. */
  38361. /**
  38362. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38363. */
  38364. idleRotationWaitTime: number;
  38365. /**
  38366. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38367. */
  38368. /**
  38369. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38370. */
  38371. idleRotationSpinupTime: number;
  38372. /**
  38373. * Gets a value indicating if the camera is currently rotating because of this behavior
  38374. */
  38375. readonly rotationInProgress: boolean;
  38376. private _onPrePointerObservableObserver;
  38377. private _onAfterCheckInputsObserver;
  38378. private _attachedCamera;
  38379. private _isPointerDown;
  38380. private _lastFrameTime;
  38381. private _lastInteractionTime;
  38382. private _cameraRotationSpeed;
  38383. /**
  38384. * Initializes the behavior.
  38385. */
  38386. init(): void;
  38387. /**
  38388. * Attaches the behavior to its arc rotate camera.
  38389. * @param camera Defines the camera to attach the behavior to
  38390. */
  38391. attach(camera: ArcRotateCamera): void;
  38392. /**
  38393. * Detaches the behavior from its current arc rotate camera.
  38394. */
  38395. detach(): void;
  38396. /**
  38397. * Returns true if user is scrolling.
  38398. * @return true if user is scrolling.
  38399. */
  38400. private _userIsZooming;
  38401. private _lastFrameRadius;
  38402. private _shouldAnimationStopForInteraction;
  38403. /**
  38404. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38405. */
  38406. private _applyUserInteraction;
  38407. private _userIsMoving;
  38408. }
  38409. }
  38410. declare module "babylonjs/Behaviors/Cameras/index" {
  38411. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38412. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38413. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38414. }
  38415. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38416. import { Mesh } from "babylonjs/Meshes/mesh";
  38417. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38418. import { Behavior } from "babylonjs/Behaviors/behavior";
  38419. /**
  38420. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38421. */
  38422. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38423. private ui;
  38424. /**
  38425. * The name of the behavior
  38426. */
  38427. name: string;
  38428. /**
  38429. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38430. */
  38431. distanceAwayFromFace: number;
  38432. /**
  38433. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38434. */
  38435. distanceAwayFromBottomOfFace: number;
  38436. private _faceVectors;
  38437. private _target;
  38438. private _scene;
  38439. private _onRenderObserver;
  38440. private _tmpMatrix;
  38441. private _tmpVector;
  38442. /**
  38443. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38444. * @param ui The transform node that should be attched to the mesh
  38445. */
  38446. constructor(ui: TransformNode);
  38447. /**
  38448. * Initializes the behavior
  38449. */
  38450. init(): void;
  38451. private _closestFace;
  38452. private _zeroVector;
  38453. private _lookAtTmpMatrix;
  38454. private _lookAtToRef;
  38455. /**
  38456. * Attaches the AttachToBoxBehavior to the passed in mesh
  38457. * @param target The mesh that the specified node will be attached to
  38458. */
  38459. attach(target: Mesh): void;
  38460. /**
  38461. * Detaches the behavior from the mesh
  38462. */
  38463. detach(): void;
  38464. }
  38465. }
  38466. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38467. import { Behavior } from "babylonjs/Behaviors/behavior";
  38468. import { Mesh } from "babylonjs/Meshes/mesh";
  38469. /**
  38470. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38471. */
  38472. export class FadeInOutBehavior implements Behavior<Mesh> {
  38473. /**
  38474. * Time in milliseconds to delay before fading in (Default: 0)
  38475. */
  38476. delay: number;
  38477. /**
  38478. * Time in milliseconds for the mesh to fade in (Default: 300)
  38479. */
  38480. fadeInTime: number;
  38481. private _millisecondsPerFrame;
  38482. private _hovered;
  38483. private _hoverValue;
  38484. private _ownerNode;
  38485. /**
  38486. * Instatiates the FadeInOutBehavior
  38487. */
  38488. constructor();
  38489. /**
  38490. * The name of the behavior
  38491. */
  38492. readonly name: string;
  38493. /**
  38494. * Initializes the behavior
  38495. */
  38496. init(): void;
  38497. /**
  38498. * Attaches the fade behavior on the passed in mesh
  38499. * @param ownerNode The mesh that will be faded in/out once attached
  38500. */
  38501. attach(ownerNode: Mesh): void;
  38502. /**
  38503. * Detaches the behavior from the mesh
  38504. */
  38505. detach(): void;
  38506. /**
  38507. * Triggers the mesh to begin fading in or out
  38508. * @param value if the object should fade in or out (true to fade in)
  38509. */
  38510. fadeIn(value: boolean): void;
  38511. private _update;
  38512. private _setAllVisibility;
  38513. }
  38514. }
  38515. declare module "babylonjs/Misc/pivotTools" {
  38516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38517. /**
  38518. * Class containing a set of static utilities functions for managing Pivots
  38519. * @hidden
  38520. */
  38521. export class PivotTools {
  38522. private static _PivotCached;
  38523. private static _OldPivotPoint;
  38524. private static _PivotTranslation;
  38525. private static _PivotTmpVector;
  38526. /** @hidden */
  38527. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38528. /** @hidden */
  38529. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38530. }
  38531. }
  38532. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38533. import { Scene } from "babylonjs/scene";
  38534. import { Vector4 } from "babylonjs/Maths/math.vector";
  38535. import { Mesh } from "babylonjs/Meshes/mesh";
  38536. import { Nullable } from "babylonjs/types";
  38537. import { Plane } from "babylonjs/Maths/math.plane";
  38538. /**
  38539. * Class containing static functions to help procedurally build meshes
  38540. */
  38541. export class PlaneBuilder {
  38542. /**
  38543. * Creates a plane mesh
  38544. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38545. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38546. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38550. * @param name defines the name of the mesh
  38551. * @param options defines the options used to create the mesh
  38552. * @param scene defines the hosting scene
  38553. * @returns the plane mesh
  38554. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38555. */
  38556. static CreatePlane(name: string, options: {
  38557. size?: number;
  38558. width?: number;
  38559. height?: number;
  38560. sideOrientation?: number;
  38561. frontUVs?: Vector4;
  38562. backUVs?: Vector4;
  38563. updatable?: boolean;
  38564. sourcePlane?: Plane;
  38565. }, scene?: Nullable<Scene>): Mesh;
  38566. }
  38567. }
  38568. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38569. import { Behavior } from "babylonjs/Behaviors/behavior";
  38570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38571. import { Observable } from "babylonjs/Misc/observable";
  38572. import { Vector3 } from "babylonjs/Maths/math.vector";
  38573. import { Ray } from "babylonjs/Culling/ray";
  38574. import "babylonjs/Meshes/Builders/planeBuilder";
  38575. /**
  38576. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38577. */
  38578. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38579. private static _AnyMouseID;
  38580. /**
  38581. * Abstract mesh the behavior is set on
  38582. */
  38583. attachedNode: AbstractMesh;
  38584. private _dragPlane;
  38585. private _scene;
  38586. private _pointerObserver;
  38587. private _beforeRenderObserver;
  38588. private static _planeScene;
  38589. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38590. /**
  38591. * 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)
  38592. */
  38593. maxDragAngle: number;
  38594. /**
  38595. * @hidden
  38596. */
  38597. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38598. /**
  38599. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38600. */
  38601. currentDraggingPointerID: number;
  38602. /**
  38603. * The last position where the pointer hit the drag plane in world space
  38604. */
  38605. lastDragPosition: Vector3;
  38606. /**
  38607. * If the behavior is currently in a dragging state
  38608. */
  38609. dragging: boolean;
  38610. /**
  38611. * 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)
  38612. */
  38613. dragDeltaRatio: number;
  38614. /**
  38615. * If the drag plane orientation should be updated during the dragging (Default: true)
  38616. */
  38617. updateDragPlane: boolean;
  38618. private _debugMode;
  38619. private _moving;
  38620. /**
  38621. * Fires each time the attached mesh is dragged with the pointer
  38622. * * delta between last drag position and current drag position in world space
  38623. * * dragDistance along the drag axis
  38624. * * dragPlaneNormal normal of the current drag plane used during the drag
  38625. * * dragPlanePoint in world space where the drag intersects the drag plane
  38626. */
  38627. onDragObservable: Observable<{
  38628. delta: Vector3;
  38629. dragPlanePoint: Vector3;
  38630. dragPlaneNormal: Vector3;
  38631. dragDistance: number;
  38632. pointerId: number;
  38633. }>;
  38634. /**
  38635. * Fires each time a drag begins (eg. mouse down on mesh)
  38636. */
  38637. onDragStartObservable: Observable<{
  38638. dragPlanePoint: Vector3;
  38639. pointerId: number;
  38640. }>;
  38641. /**
  38642. * Fires each time a drag ends (eg. mouse release after drag)
  38643. */
  38644. onDragEndObservable: Observable<{
  38645. dragPlanePoint: Vector3;
  38646. pointerId: number;
  38647. }>;
  38648. /**
  38649. * If the attached mesh should be moved when dragged
  38650. */
  38651. moveAttached: boolean;
  38652. /**
  38653. * If the drag behavior will react to drag events (Default: true)
  38654. */
  38655. enabled: boolean;
  38656. /**
  38657. * If pointer events should start and release the drag (Default: true)
  38658. */
  38659. startAndReleaseDragOnPointerEvents: boolean;
  38660. /**
  38661. * If camera controls should be detached during the drag
  38662. */
  38663. detachCameraControls: boolean;
  38664. /**
  38665. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38666. */
  38667. useObjectOrienationForDragging: boolean;
  38668. private _options;
  38669. /**
  38670. * Creates a pointer drag behavior that can be attached to a mesh
  38671. * @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)
  38672. */
  38673. constructor(options?: {
  38674. dragAxis?: Vector3;
  38675. dragPlaneNormal?: Vector3;
  38676. });
  38677. /**
  38678. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38679. */
  38680. validateDrag: (targetPosition: Vector3) => boolean;
  38681. /**
  38682. * The name of the behavior
  38683. */
  38684. readonly name: string;
  38685. /**
  38686. * Initializes the behavior
  38687. */
  38688. init(): void;
  38689. private _tmpVector;
  38690. private _alternatePickedPoint;
  38691. private _worldDragAxis;
  38692. private _targetPosition;
  38693. private _attachedElement;
  38694. /**
  38695. * Attaches the drag behavior the passed in mesh
  38696. * @param ownerNode The mesh that will be dragged around once attached
  38697. * @param predicate Predicate to use for pick filtering
  38698. */
  38699. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38700. /**
  38701. * Force relase the drag action by code.
  38702. */
  38703. releaseDrag(): void;
  38704. private _startDragRay;
  38705. private _lastPointerRay;
  38706. /**
  38707. * Simulates the start of a pointer drag event on the behavior
  38708. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38709. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38710. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38711. */
  38712. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38713. private _startDrag;
  38714. private _dragDelta;
  38715. private _moveDrag;
  38716. private _pickWithRayOnDragPlane;
  38717. private _pointA;
  38718. private _pointB;
  38719. private _pointC;
  38720. private _lineA;
  38721. private _lineB;
  38722. private _localAxis;
  38723. private _lookAt;
  38724. private _updateDragPlanePosition;
  38725. /**
  38726. * Detaches the behavior from the mesh
  38727. */
  38728. detach(): void;
  38729. }
  38730. }
  38731. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38732. import { Mesh } from "babylonjs/Meshes/mesh";
  38733. import { Behavior } from "babylonjs/Behaviors/behavior";
  38734. /**
  38735. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38736. */
  38737. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38738. private _dragBehaviorA;
  38739. private _dragBehaviorB;
  38740. private _startDistance;
  38741. private _initialScale;
  38742. private _targetScale;
  38743. private _ownerNode;
  38744. private _sceneRenderObserver;
  38745. /**
  38746. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38747. */
  38748. constructor();
  38749. /**
  38750. * The name of the behavior
  38751. */
  38752. readonly name: string;
  38753. /**
  38754. * Initializes the behavior
  38755. */
  38756. init(): void;
  38757. private _getCurrentDistance;
  38758. /**
  38759. * Attaches the scale behavior the passed in mesh
  38760. * @param ownerNode The mesh that will be scaled around once attached
  38761. */
  38762. attach(ownerNode: Mesh): void;
  38763. /**
  38764. * Detaches the behavior from the mesh
  38765. */
  38766. detach(): void;
  38767. }
  38768. }
  38769. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38770. import { Behavior } from "babylonjs/Behaviors/behavior";
  38771. import { Mesh } from "babylonjs/Meshes/mesh";
  38772. import { Observable } from "babylonjs/Misc/observable";
  38773. /**
  38774. * 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
  38775. */
  38776. export class SixDofDragBehavior implements Behavior<Mesh> {
  38777. private static _virtualScene;
  38778. private _ownerNode;
  38779. private _sceneRenderObserver;
  38780. private _scene;
  38781. private _targetPosition;
  38782. private _virtualOriginMesh;
  38783. private _virtualDragMesh;
  38784. private _pointerObserver;
  38785. private _moving;
  38786. private _startingOrientation;
  38787. /**
  38788. * 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)
  38789. */
  38790. private zDragFactor;
  38791. /**
  38792. * If the object should rotate to face the drag origin
  38793. */
  38794. rotateDraggedObject: boolean;
  38795. /**
  38796. * If the behavior is currently in a dragging state
  38797. */
  38798. dragging: boolean;
  38799. /**
  38800. * 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)
  38801. */
  38802. dragDeltaRatio: number;
  38803. /**
  38804. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38805. */
  38806. currentDraggingPointerID: number;
  38807. /**
  38808. * If camera controls should be detached during the drag
  38809. */
  38810. detachCameraControls: boolean;
  38811. /**
  38812. * Fires each time a drag starts
  38813. */
  38814. onDragStartObservable: Observable<{}>;
  38815. /**
  38816. * Fires each time a drag ends (eg. mouse release after drag)
  38817. */
  38818. onDragEndObservable: Observable<{}>;
  38819. /**
  38820. * 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
  38821. */
  38822. constructor();
  38823. /**
  38824. * The name of the behavior
  38825. */
  38826. readonly name: string;
  38827. /**
  38828. * Initializes the behavior
  38829. */
  38830. init(): void;
  38831. /**
  38832. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38833. */
  38834. private readonly _pointerCamera;
  38835. /**
  38836. * Attaches the scale behavior the passed in mesh
  38837. * @param ownerNode The mesh that will be scaled around once attached
  38838. */
  38839. attach(ownerNode: Mesh): void;
  38840. /**
  38841. * Detaches the behavior from the mesh
  38842. */
  38843. detach(): void;
  38844. }
  38845. }
  38846. declare module "babylonjs/Behaviors/Meshes/index" {
  38847. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38848. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38849. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38850. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38851. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38852. }
  38853. declare module "babylonjs/Behaviors/index" {
  38854. export * from "babylonjs/Behaviors/behavior";
  38855. export * from "babylonjs/Behaviors/Cameras/index";
  38856. export * from "babylonjs/Behaviors/Meshes/index";
  38857. }
  38858. declare module "babylonjs/Bones/boneIKController" {
  38859. import { Bone } from "babylonjs/Bones/bone";
  38860. import { Vector3 } from "babylonjs/Maths/math.vector";
  38861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38862. import { Nullable } from "babylonjs/types";
  38863. /**
  38864. * Class used to apply inverse kinematics to bones
  38865. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38866. */
  38867. export class BoneIKController {
  38868. private static _tmpVecs;
  38869. private static _tmpQuat;
  38870. private static _tmpMats;
  38871. /**
  38872. * Gets or sets the target mesh
  38873. */
  38874. targetMesh: AbstractMesh;
  38875. /** Gets or sets the mesh used as pole */
  38876. poleTargetMesh: AbstractMesh;
  38877. /**
  38878. * Gets or sets the bone used as pole
  38879. */
  38880. poleTargetBone: Nullable<Bone>;
  38881. /**
  38882. * Gets or sets the target position
  38883. */
  38884. targetPosition: Vector3;
  38885. /**
  38886. * Gets or sets the pole target position
  38887. */
  38888. poleTargetPosition: Vector3;
  38889. /**
  38890. * Gets or sets the pole target local offset
  38891. */
  38892. poleTargetLocalOffset: Vector3;
  38893. /**
  38894. * Gets or sets the pole angle
  38895. */
  38896. poleAngle: number;
  38897. /**
  38898. * Gets or sets the mesh associated with the controller
  38899. */
  38900. mesh: AbstractMesh;
  38901. /**
  38902. * 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)
  38903. */
  38904. slerpAmount: number;
  38905. private _bone1Quat;
  38906. private _bone1Mat;
  38907. private _bone2Ang;
  38908. private _bone1;
  38909. private _bone2;
  38910. private _bone1Length;
  38911. private _bone2Length;
  38912. private _maxAngle;
  38913. private _maxReach;
  38914. private _rightHandedSystem;
  38915. private _bendAxis;
  38916. private _slerping;
  38917. private _adjustRoll;
  38918. /**
  38919. * Gets or sets maximum allowed angle
  38920. */
  38921. maxAngle: number;
  38922. /**
  38923. * Creates a new BoneIKController
  38924. * @param mesh defines the mesh to control
  38925. * @param bone defines the bone to control
  38926. * @param options defines options to set up the controller
  38927. */
  38928. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38929. targetMesh?: AbstractMesh;
  38930. poleTargetMesh?: AbstractMesh;
  38931. poleTargetBone?: Bone;
  38932. poleTargetLocalOffset?: Vector3;
  38933. poleAngle?: number;
  38934. bendAxis?: Vector3;
  38935. maxAngle?: number;
  38936. slerpAmount?: number;
  38937. });
  38938. private _setMaxAngle;
  38939. /**
  38940. * Force the controller to update the bones
  38941. */
  38942. update(): void;
  38943. }
  38944. }
  38945. declare module "babylonjs/Bones/boneLookController" {
  38946. import { Vector3 } from "babylonjs/Maths/math.vector";
  38947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38948. import { Bone } from "babylonjs/Bones/bone";
  38949. import { Space } from "babylonjs/Maths/math.axis";
  38950. /**
  38951. * Class used to make a bone look toward a point in space
  38952. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38953. */
  38954. export class BoneLookController {
  38955. private static _tmpVecs;
  38956. private static _tmpQuat;
  38957. private static _tmpMats;
  38958. /**
  38959. * The target Vector3 that the bone will look at
  38960. */
  38961. target: Vector3;
  38962. /**
  38963. * The mesh that the bone is attached to
  38964. */
  38965. mesh: AbstractMesh;
  38966. /**
  38967. * The bone that will be looking to the target
  38968. */
  38969. bone: Bone;
  38970. /**
  38971. * The up axis of the coordinate system that is used when the bone is rotated
  38972. */
  38973. upAxis: Vector3;
  38974. /**
  38975. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38976. */
  38977. upAxisSpace: Space;
  38978. /**
  38979. * Used to make an adjustment to the yaw of the bone
  38980. */
  38981. adjustYaw: number;
  38982. /**
  38983. * Used to make an adjustment to the pitch of the bone
  38984. */
  38985. adjustPitch: number;
  38986. /**
  38987. * Used to make an adjustment to the roll of the bone
  38988. */
  38989. adjustRoll: number;
  38990. /**
  38991. * 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)
  38992. */
  38993. slerpAmount: number;
  38994. private _minYaw;
  38995. private _maxYaw;
  38996. private _minPitch;
  38997. private _maxPitch;
  38998. private _minYawSin;
  38999. private _minYawCos;
  39000. private _maxYawSin;
  39001. private _maxYawCos;
  39002. private _midYawConstraint;
  39003. private _minPitchTan;
  39004. private _maxPitchTan;
  39005. private _boneQuat;
  39006. private _slerping;
  39007. private _transformYawPitch;
  39008. private _transformYawPitchInv;
  39009. private _firstFrameSkipped;
  39010. private _yawRange;
  39011. private _fowardAxis;
  39012. /**
  39013. * Gets or sets the minimum yaw angle that the bone can look to
  39014. */
  39015. minYaw: number;
  39016. /**
  39017. * Gets or sets the maximum yaw angle that the bone can look to
  39018. */
  39019. maxYaw: number;
  39020. /**
  39021. * Gets or sets the minimum pitch angle that the bone can look to
  39022. */
  39023. minPitch: number;
  39024. /**
  39025. * Gets or sets the maximum pitch angle that the bone can look to
  39026. */
  39027. maxPitch: number;
  39028. /**
  39029. * Create a BoneLookController
  39030. * @param mesh the mesh that the bone belongs to
  39031. * @param bone the bone that will be looking to the target
  39032. * @param target the target Vector3 to look at
  39033. * @param options optional settings:
  39034. * * maxYaw: the maximum angle the bone will yaw to
  39035. * * minYaw: the minimum angle the bone will yaw to
  39036. * * maxPitch: the maximum angle the bone will pitch to
  39037. * * minPitch: the minimum angle the bone will yaw to
  39038. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39039. * * upAxis: the up axis of the coordinate system
  39040. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39041. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39042. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39043. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39044. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39045. * * adjustRoll: used to make an adjustment to the roll of the bone
  39046. **/
  39047. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39048. maxYaw?: number;
  39049. minYaw?: number;
  39050. maxPitch?: number;
  39051. minPitch?: number;
  39052. slerpAmount?: number;
  39053. upAxis?: Vector3;
  39054. upAxisSpace?: Space;
  39055. yawAxis?: Vector3;
  39056. pitchAxis?: Vector3;
  39057. adjustYaw?: number;
  39058. adjustPitch?: number;
  39059. adjustRoll?: number;
  39060. });
  39061. /**
  39062. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39063. */
  39064. update(): void;
  39065. private _getAngleDiff;
  39066. private _getAngleBetween;
  39067. private _isAngleBetween;
  39068. }
  39069. }
  39070. declare module "babylonjs/Bones/index" {
  39071. export * from "babylonjs/Bones/bone";
  39072. export * from "babylonjs/Bones/boneIKController";
  39073. export * from "babylonjs/Bones/boneLookController";
  39074. export * from "babylonjs/Bones/skeleton";
  39075. }
  39076. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  39077. import { Nullable } from "babylonjs/types";
  39078. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39079. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39080. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39081. /**
  39082. * Manage the gamepad inputs to control an arc rotate camera.
  39083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39084. */
  39085. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39086. /**
  39087. * Defines the camera the input is attached to.
  39088. */
  39089. camera: ArcRotateCamera;
  39090. /**
  39091. * Defines the gamepad the input is gathering event from.
  39092. */
  39093. gamepad: Nullable<Gamepad>;
  39094. /**
  39095. * Defines the gamepad rotation sensiblity.
  39096. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39097. */
  39098. gamepadRotationSensibility: number;
  39099. /**
  39100. * Defines the gamepad move sensiblity.
  39101. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39102. */
  39103. gamepadMoveSensibility: number;
  39104. private _yAxisScale;
  39105. /**
  39106. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39107. */
  39108. invertYAxis: boolean;
  39109. private _onGamepadConnectedObserver;
  39110. private _onGamepadDisconnectedObserver;
  39111. /**
  39112. * Attach the input controls to a specific dom element to get the input from.
  39113. * @param element Defines the element the controls should be listened from
  39114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39115. */
  39116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39117. /**
  39118. * Detach the current controls from the specified dom element.
  39119. * @param element Defines the element to stop listening the inputs from
  39120. */
  39121. detachControl(element: Nullable<HTMLElement>): void;
  39122. /**
  39123. * Update the current camera state depending on the inputs that have been used this frame.
  39124. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39125. */
  39126. checkInputs(): void;
  39127. /**
  39128. * Gets the class name of the current intput.
  39129. * @returns the class name
  39130. */
  39131. getClassName(): string;
  39132. /**
  39133. * Get the friendly name associated with the input class.
  39134. * @returns the input friendly name
  39135. */
  39136. getSimpleName(): string;
  39137. }
  39138. }
  39139. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  39140. import { Nullable } from "babylonjs/types";
  39141. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39142. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39143. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39144. interface ArcRotateCameraInputsManager {
  39145. /**
  39146. * Add orientation input support to the input manager.
  39147. * @returns the current input manager
  39148. */
  39149. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39150. }
  39151. }
  39152. /**
  39153. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39155. */
  39156. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39157. /**
  39158. * Defines the camera the input is attached to.
  39159. */
  39160. camera: ArcRotateCamera;
  39161. /**
  39162. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39163. */
  39164. alphaCorrection: number;
  39165. /**
  39166. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39167. */
  39168. gammaCorrection: number;
  39169. private _alpha;
  39170. private _gamma;
  39171. private _dirty;
  39172. private _deviceOrientationHandler;
  39173. /**
  39174. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39175. */
  39176. constructor();
  39177. /**
  39178. * Attach the input controls to a specific dom element to get the input from.
  39179. * @param element Defines the element the controls should be listened from
  39180. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39181. */
  39182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39183. /** @hidden */
  39184. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39185. /**
  39186. * Update the current camera state depending on the inputs that have been used this frame.
  39187. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39188. */
  39189. checkInputs(): void;
  39190. /**
  39191. * Detach the current controls from the specified dom element.
  39192. * @param element Defines the element to stop listening the inputs from
  39193. */
  39194. detachControl(element: Nullable<HTMLElement>): void;
  39195. /**
  39196. * Gets the class name of the current intput.
  39197. * @returns the class name
  39198. */
  39199. getClassName(): string;
  39200. /**
  39201. * Get the friendly name associated with the input class.
  39202. * @returns the input friendly name
  39203. */
  39204. getSimpleName(): string;
  39205. }
  39206. }
  39207. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39208. import { Nullable } from "babylonjs/types";
  39209. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39210. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39211. /**
  39212. * Listen to mouse events to control the camera.
  39213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39214. */
  39215. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39216. /**
  39217. * Defines the camera the input is attached to.
  39218. */
  39219. camera: FlyCamera;
  39220. /**
  39221. * Defines if touch is enabled. (Default is true.)
  39222. */
  39223. touchEnabled: boolean;
  39224. /**
  39225. * Defines the buttons associated with the input to handle camera rotation.
  39226. */
  39227. buttons: number[];
  39228. /**
  39229. * Assign buttons for Yaw control.
  39230. */
  39231. buttonsYaw: number[];
  39232. /**
  39233. * Assign buttons for Pitch control.
  39234. */
  39235. buttonsPitch: number[];
  39236. /**
  39237. * Assign buttons for Roll control.
  39238. */
  39239. buttonsRoll: number[];
  39240. /**
  39241. * Detect if any button is being pressed while mouse is moved.
  39242. * -1 = Mouse locked.
  39243. * 0 = Left button.
  39244. * 1 = Middle Button.
  39245. * 2 = Right Button.
  39246. */
  39247. activeButton: number;
  39248. /**
  39249. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39250. * Higher values reduce its sensitivity.
  39251. */
  39252. angularSensibility: number;
  39253. private _mousemoveCallback;
  39254. private _observer;
  39255. private _rollObserver;
  39256. private previousPosition;
  39257. private noPreventDefault;
  39258. private element;
  39259. /**
  39260. * Listen to mouse events to control the camera.
  39261. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39263. */
  39264. constructor(touchEnabled?: boolean);
  39265. /**
  39266. * Attach the mouse control to the HTML DOM element.
  39267. * @param element Defines the element that listens to the input events.
  39268. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39269. */
  39270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39271. /**
  39272. * Detach the current controls from the specified dom element.
  39273. * @param element Defines the element to stop listening the inputs from
  39274. */
  39275. detachControl(element: Nullable<HTMLElement>): void;
  39276. /**
  39277. * Gets the class name of the current input.
  39278. * @returns the class name.
  39279. */
  39280. getClassName(): string;
  39281. /**
  39282. * Get the friendly name associated with the input class.
  39283. * @returns the input's friendly name.
  39284. */
  39285. getSimpleName(): string;
  39286. private _pointerInput;
  39287. private _onMouseMove;
  39288. /**
  39289. * Rotate camera by mouse offset.
  39290. */
  39291. private rotateCamera;
  39292. }
  39293. }
  39294. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39295. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39296. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39297. /**
  39298. * Default Inputs manager for the FlyCamera.
  39299. * It groups all the default supported inputs for ease of use.
  39300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39301. */
  39302. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39303. /**
  39304. * Instantiates a new FlyCameraInputsManager.
  39305. * @param camera Defines the camera the inputs belong to.
  39306. */
  39307. constructor(camera: FlyCamera);
  39308. /**
  39309. * Add keyboard input support to the input manager.
  39310. * @returns the new FlyCameraKeyboardMoveInput().
  39311. */
  39312. addKeyboard(): FlyCameraInputsManager;
  39313. /**
  39314. * Add mouse input support to the input manager.
  39315. * @param touchEnabled Enable touch screen support.
  39316. * @returns the new FlyCameraMouseInput().
  39317. */
  39318. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39319. }
  39320. }
  39321. declare module "babylonjs/Cameras/flyCamera" {
  39322. import { Scene } from "babylonjs/scene";
  39323. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39325. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39326. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39327. /**
  39328. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39329. * such as in a 3D Space Shooter or a Flight Simulator.
  39330. */
  39331. export class FlyCamera extends TargetCamera {
  39332. /**
  39333. * Define the collision ellipsoid of the camera.
  39334. * This is helpful for simulating a camera body, like a player's body.
  39335. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39336. */
  39337. ellipsoid: Vector3;
  39338. /**
  39339. * Define an offset for the position of the ellipsoid around the camera.
  39340. * This can be helpful if the camera is attached away from the player's body center,
  39341. * such as at its head.
  39342. */
  39343. ellipsoidOffset: Vector3;
  39344. /**
  39345. * Enable or disable collisions of the camera with the rest of the scene objects.
  39346. */
  39347. checkCollisions: boolean;
  39348. /**
  39349. * Enable or disable gravity on the camera.
  39350. */
  39351. applyGravity: boolean;
  39352. /**
  39353. * Define the current direction the camera is moving to.
  39354. */
  39355. cameraDirection: Vector3;
  39356. /**
  39357. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39358. * This overrides and empties cameraRotation.
  39359. */
  39360. rotationQuaternion: Quaternion;
  39361. /**
  39362. * Track Roll to maintain the wanted Rolling when looking around.
  39363. */
  39364. _trackRoll: number;
  39365. /**
  39366. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39367. */
  39368. rollCorrect: number;
  39369. /**
  39370. * Mimic a banked turn, Rolling the camera when Yawing.
  39371. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39372. */
  39373. bankedTurn: boolean;
  39374. /**
  39375. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39376. */
  39377. bankedTurnLimit: number;
  39378. /**
  39379. * Value of 0 disables the banked Roll.
  39380. * Value of 1 is equal to the Yaw angle in radians.
  39381. */
  39382. bankedTurnMultiplier: number;
  39383. /**
  39384. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39385. */
  39386. inputs: FlyCameraInputsManager;
  39387. /**
  39388. * Gets the input sensibility for mouse input.
  39389. * Higher values reduce sensitivity.
  39390. */
  39391. /**
  39392. * Sets the input sensibility for a mouse input.
  39393. * Higher values reduce sensitivity.
  39394. */
  39395. angularSensibility: number;
  39396. /**
  39397. * Get the keys for camera movement forward.
  39398. */
  39399. /**
  39400. * Set the keys for camera movement forward.
  39401. */
  39402. keysForward: number[];
  39403. /**
  39404. * Get the keys for camera movement backward.
  39405. */
  39406. keysBackward: number[];
  39407. /**
  39408. * Get the keys for camera movement up.
  39409. */
  39410. /**
  39411. * Set the keys for camera movement up.
  39412. */
  39413. keysUp: number[];
  39414. /**
  39415. * Get the keys for camera movement down.
  39416. */
  39417. /**
  39418. * Set the keys for camera movement down.
  39419. */
  39420. keysDown: number[];
  39421. /**
  39422. * Get the keys for camera movement left.
  39423. */
  39424. /**
  39425. * Set the keys for camera movement left.
  39426. */
  39427. keysLeft: number[];
  39428. /**
  39429. * Set the keys for camera movement right.
  39430. */
  39431. /**
  39432. * Set the keys for camera movement right.
  39433. */
  39434. keysRight: number[];
  39435. /**
  39436. * Event raised when the camera collides with a mesh in the scene.
  39437. */
  39438. onCollide: (collidedMesh: AbstractMesh) => void;
  39439. private _collider;
  39440. private _needMoveForGravity;
  39441. private _oldPosition;
  39442. private _diffPosition;
  39443. private _newPosition;
  39444. /** @hidden */
  39445. _localDirection: Vector3;
  39446. /** @hidden */
  39447. _transformedDirection: Vector3;
  39448. /**
  39449. * Instantiates a FlyCamera.
  39450. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39451. * such as in a 3D Space Shooter or a Flight Simulator.
  39452. * @param name Define the name of the camera in the scene.
  39453. * @param position Define the starting position of the camera in the scene.
  39454. * @param scene Define the scene the camera belongs to.
  39455. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39456. */
  39457. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39458. /**
  39459. * Attach a control to the HTML DOM element.
  39460. * @param element Defines the element that listens to the input events.
  39461. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39462. */
  39463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39464. /**
  39465. * Detach a control from the HTML DOM element.
  39466. * The camera will stop reacting to that input.
  39467. * @param element Defines the element that listens to the input events.
  39468. */
  39469. detachControl(element: HTMLElement): void;
  39470. private _collisionMask;
  39471. /**
  39472. * Get the mask that the camera ignores in collision events.
  39473. */
  39474. /**
  39475. * Set the mask that the camera ignores in collision events.
  39476. */
  39477. collisionMask: number;
  39478. /** @hidden */
  39479. _collideWithWorld(displacement: Vector3): void;
  39480. /** @hidden */
  39481. private _onCollisionPositionChange;
  39482. /** @hidden */
  39483. _checkInputs(): void;
  39484. /** @hidden */
  39485. _decideIfNeedsToMove(): boolean;
  39486. /** @hidden */
  39487. _updatePosition(): void;
  39488. /**
  39489. * Restore the Roll to its target value at the rate specified.
  39490. * @param rate - Higher means slower restoring.
  39491. * @hidden
  39492. */
  39493. restoreRoll(rate: number): void;
  39494. /**
  39495. * Destroy the camera and release the current resources held by it.
  39496. */
  39497. dispose(): void;
  39498. /**
  39499. * Get the current object class name.
  39500. * @returns the class name.
  39501. */
  39502. getClassName(): string;
  39503. }
  39504. }
  39505. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39506. import { Nullable } from "babylonjs/types";
  39507. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39508. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39509. /**
  39510. * Listen to keyboard events to control the camera.
  39511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39512. */
  39513. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39514. /**
  39515. * Defines the camera the input is attached to.
  39516. */
  39517. camera: FlyCamera;
  39518. /**
  39519. * The list of keyboard keys used to control the forward move of the camera.
  39520. */
  39521. keysForward: number[];
  39522. /**
  39523. * The list of keyboard keys used to control the backward move of the camera.
  39524. */
  39525. keysBackward: number[];
  39526. /**
  39527. * The list of keyboard keys used to control the forward move of the camera.
  39528. */
  39529. keysUp: number[];
  39530. /**
  39531. * The list of keyboard keys used to control the backward move of the camera.
  39532. */
  39533. keysDown: number[];
  39534. /**
  39535. * The list of keyboard keys used to control the right strafe move of the camera.
  39536. */
  39537. keysRight: number[];
  39538. /**
  39539. * The list of keyboard keys used to control the left strafe move of the camera.
  39540. */
  39541. keysLeft: number[];
  39542. private _keys;
  39543. private _onCanvasBlurObserver;
  39544. private _onKeyboardObserver;
  39545. private _engine;
  39546. private _scene;
  39547. /**
  39548. * Attach the input controls to a specific dom element to get the input from.
  39549. * @param element Defines the element the controls should be listened from
  39550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39551. */
  39552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39553. /**
  39554. * Detach the current controls from the specified dom element.
  39555. * @param element Defines the element to stop listening the inputs from
  39556. */
  39557. detachControl(element: Nullable<HTMLElement>): void;
  39558. /**
  39559. * Gets the class name of the current intput.
  39560. * @returns the class name
  39561. */
  39562. getClassName(): string;
  39563. /** @hidden */
  39564. _onLostFocus(e: FocusEvent): void;
  39565. /**
  39566. * Get the friendly name associated with the input class.
  39567. * @returns the input friendly name
  39568. */
  39569. getSimpleName(): string;
  39570. /**
  39571. * Update the current camera state depending on the inputs that have been used this frame.
  39572. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39573. */
  39574. checkInputs(): void;
  39575. }
  39576. }
  39577. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39578. import { Nullable } from "babylonjs/types";
  39579. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39580. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39581. /**
  39582. * Manage the mouse wheel inputs to control a follow camera.
  39583. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39584. */
  39585. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39586. /**
  39587. * Defines the camera the input is attached to.
  39588. */
  39589. camera: FollowCamera;
  39590. /**
  39591. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39592. */
  39593. axisControlRadius: boolean;
  39594. /**
  39595. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39596. */
  39597. axisControlHeight: boolean;
  39598. /**
  39599. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39600. */
  39601. axisControlRotation: boolean;
  39602. /**
  39603. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39604. * relation to mouseWheel events.
  39605. */
  39606. wheelPrecision: number;
  39607. /**
  39608. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39609. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39610. */
  39611. wheelDeltaPercentage: number;
  39612. private _wheel;
  39613. private _observer;
  39614. /**
  39615. * Attach the input controls to a specific dom element to get the input from.
  39616. * @param element Defines the element the controls should be listened from
  39617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39618. */
  39619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39620. /**
  39621. * Detach the current controls from the specified dom element.
  39622. * @param element Defines the element to stop listening the inputs from
  39623. */
  39624. detachControl(element: Nullable<HTMLElement>): void;
  39625. /**
  39626. * Gets the class name of the current intput.
  39627. * @returns the class name
  39628. */
  39629. getClassName(): string;
  39630. /**
  39631. * Get the friendly name associated with the input class.
  39632. * @returns the input friendly name
  39633. */
  39634. getSimpleName(): string;
  39635. }
  39636. }
  39637. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39638. import { Nullable } from "babylonjs/types";
  39639. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39640. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39641. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39642. /**
  39643. * Manage the pointers inputs to control an follow camera.
  39644. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39645. */
  39646. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39647. /**
  39648. * Defines the camera the input is attached to.
  39649. */
  39650. camera: FollowCamera;
  39651. /**
  39652. * Gets the class name of the current input.
  39653. * @returns the class name
  39654. */
  39655. getClassName(): string;
  39656. /**
  39657. * Defines the pointer angular sensibility along the X axis or how fast is
  39658. * the camera rotating.
  39659. * A negative number will reverse the axis direction.
  39660. */
  39661. angularSensibilityX: number;
  39662. /**
  39663. * Defines the pointer angular sensibility along the Y axis or how fast is
  39664. * the camera rotating.
  39665. * A negative number will reverse the axis direction.
  39666. */
  39667. angularSensibilityY: number;
  39668. /**
  39669. * Defines the pointer pinch precision or how fast is the camera zooming.
  39670. * A negative number will reverse the axis direction.
  39671. */
  39672. pinchPrecision: number;
  39673. /**
  39674. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39675. * from 0.
  39676. * It defines the percentage of current camera.radius to use as delta when
  39677. * pinch zoom is used.
  39678. */
  39679. pinchDeltaPercentage: number;
  39680. /**
  39681. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39682. */
  39683. axisXControlRadius: boolean;
  39684. /**
  39685. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39686. */
  39687. axisXControlHeight: boolean;
  39688. /**
  39689. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39690. */
  39691. axisXControlRotation: boolean;
  39692. /**
  39693. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39694. */
  39695. axisYControlRadius: boolean;
  39696. /**
  39697. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39698. */
  39699. axisYControlHeight: boolean;
  39700. /**
  39701. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39702. */
  39703. axisYControlRotation: boolean;
  39704. /**
  39705. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39706. */
  39707. axisPinchControlRadius: boolean;
  39708. /**
  39709. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39710. */
  39711. axisPinchControlHeight: boolean;
  39712. /**
  39713. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39714. */
  39715. axisPinchControlRotation: boolean;
  39716. /**
  39717. * Log error messages if basic misconfiguration has occurred.
  39718. */
  39719. warningEnable: boolean;
  39720. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39721. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39722. private _warningCounter;
  39723. private _warning;
  39724. }
  39725. }
  39726. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39727. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39728. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39729. /**
  39730. * Default Inputs manager for the FollowCamera.
  39731. * It groups all the default supported inputs for ease of use.
  39732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39733. */
  39734. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39735. /**
  39736. * Instantiates a new FollowCameraInputsManager.
  39737. * @param camera Defines the camera the inputs belong to
  39738. */
  39739. constructor(camera: FollowCamera);
  39740. /**
  39741. * Add keyboard input support to the input manager.
  39742. * @returns the current input manager
  39743. */
  39744. addKeyboard(): FollowCameraInputsManager;
  39745. /**
  39746. * Add mouse wheel input support to the input manager.
  39747. * @returns the current input manager
  39748. */
  39749. addMouseWheel(): FollowCameraInputsManager;
  39750. /**
  39751. * Add pointers input support to the input manager.
  39752. * @returns the current input manager
  39753. */
  39754. addPointers(): FollowCameraInputsManager;
  39755. /**
  39756. * Add orientation input support to the input manager.
  39757. * @returns the current input manager
  39758. */
  39759. addVRDeviceOrientation(): FollowCameraInputsManager;
  39760. }
  39761. }
  39762. declare module "babylonjs/Cameras/followCamera" {
  39763. import { Nullable } from "babylonjs/types";
  39764. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39765. import { Scene } from "babylonjs/scene";
  39766. import { Vector3 } from "babylonjs/Maths/math.vector";
  39767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39768. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39769. /**
  39770. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39771. * an arc rotate version arcFollowCamera are available.
  39772. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39773. */
  39774. export class FollowCamera extends TargetCamera {
  39775. /**
  39776. * Distance the follow camera should follow an object at
  39777. */
  39778. radius: number;
  39779. /**
  39780. * Minimum allowed distance of the camera to the axis of rotation
  39781. * (The camera can not get closer).
  39782. * This can help limiting how the Camera is able to move in the scene.
  39783. */
  39784. lowerRadiusLimit: Nullable<number>;
  39785. /**
  39786. * Maximum allowed distance of the camera to the axis of rotation
  39787. * (The camera can not get further).
  39788. * This can help limiting how the Camera is able to move in the scene.
  39789. */
  39790. upperRadiusLimit: Nullable<number>;
  39791. /**
  39792. * Define a rotation offset between the camera and the object it follows
  39793. */
  39794. rotationOffset: number;
  39795. /**
  39796. * Minimum allowed angle to camera position relative to target object.
  39797. * This can help limiting how the Camera is able to move in the scene.
  39798. */
  39799. lowerRotationOffsetLimit: Nullable<number>;
  39800. /**
  39801. * Maximum allowed angle to camera position relative to target object.
  39802. * This can help limiting how the Camera is able to move in the scene.
  39803. */
  39804. upperRotationOffsetLimit: Nullable<number>;
  39805. /**
  39806. * Define a height offset between the camera and the object it follows.
  39807. * It can help following an object from the top (like a car chaing a plane)
  39808. */
  39809. heightOffset: number;
  39810. /**
  39811. * Minimum allowed height of camera position relative to target object.
  39812. * This can help limiting how the Camera is able to move in the scene.
  39813. */
  39814. lowerHeightOffsetLimit: Nullable<number>;
  39815. /**
  39816. * Maximum allowed height of camera position relative to target object.
  39817. * This can help limiting how the Camera is able to move in the scene.
  39818. */
  39819. upperHeightOffsetLimit: Nullable<number>;
  39820. /**
  39821. * Define how fast the camera can accelerate to follow it s target.
  39822. */
  39823. cameraAcceleration: number;
  39824. /**
  39825. * Define the speed limit of the camera following an object.
  39826. */
  39827. maxCameraSpeed: number;
  39828. /**
  39829. * Define the target of the camera.
  39830. */
  39831. lockedTarget: Nullable<AbstractMesh>;
  39832. /**
  39833. * Defines the input associated with the camera.
  39834. */
  39835. inputs: FollowCameraInputsManager;
  39836. /**
  39837. * Instantiates the follow camera.
  39838. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39839. * @param name Define the name of the camera in the scene
  39840. * @param position Define the position of the camera
  39841. * @param scene Define the scene the camera belong to
  39842. * @param lockedTarget Define the target of the camera
  39843. */
  39844. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39845. private _follow;
  39846. /**
  39847. * Attached controls to the current camera.
  39848. * @param element Defines the element the controls should be listened from
  39849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39850. */
  39851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39852. /**
  39853. * Detach the current controls from the camera.
  39854. * The camera will stop reacting to inputs.
  39855. * @param element Defines the element to stop listening the inputs from
  39856. */
  39857. detachControl(element: HTMLElement): void;
  39858. /** @hidden */
  39859. _checkInputs(): void;
  39860. private _checkLimits;
  39861. /**
  39862. * Gets the camera class name.
  39863. * @returns the class name
  39864. */
  39865. getClassName(): string;
  39866. }
  39867. /**
  39868. * Arc Rotate version of the follow camera.
  39869. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39870. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39871. */
  39872. export class ArcFollowCamera extends TargetCamera {
  39873. /** The longitudinal angle of the camera */
  39874. alpha: number;
  39875. /** The latitudinal angle of the camera */
  39876. beta: number;
  39877. /** The radius of the camera from its target */
  39878. radius: number;
  39879. /** Define the camera target (the messh it should follow) */
  39880. target: Nullable<AbstractMesh>;
  39881. private _cartesianCoordinates;
  39882. /**
  39883. * Instantiates a new ArcFollowCamera
  39884. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39885. * @param name Define the name of the camera
  39886. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39887. * @param beta Define the rotation angle of the camera around the elevation axis
  39888. * @param radius Define the radius of the camera from its target point
  39889. * @param target Define the target of the camera
  39890. * @param scene Define the scene the camera belongs to
  39891. */
  39892. constructor(name: string,
  39893. /** The longitudinal angle of the camera */
  39894. alpha: number,
  39895. /** The latitudinal angle of the camera */
  39896. beta: number,
  39897. /** The radius of the camera from its target */
  39898. radius: number,
  39899. /** Define the camera target (the messh it should follow) */
  39900. target: Nullable<AbstractMesh>, scene: Scene);
  39901. private _follow;
  39902. /** @hidden */
  39903. _checkInputs(): void;
  39904. /**
  39905. * Returns the class name of the object.
  39906. * It is mostly used internally for serialization purposes.
  39907. */
  39908. getClassName(): string;
  39909. }
  39910. }
  39911. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39912. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39913. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39914. import { Nullable } from "babylonjs/types";
  39915. /**
  39916. * Manage the keyboard inputs to control the movement of a follow camera.
  39917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39918. */
  39919. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39920. /**
  39921. * Defines the camera the input is attached to.
  39922. */
  39923. camera: FollowCamera;
  39924. /**
  39925. * Defines the list of key codes associated with the up action (increase heightOffset)
  39926. */
  39927. keysHeightOffsetIncr: number[];
  39928. /**
  39929. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39930. */
  39931. keysHeightOffsetDecr: number[];
  39932. /**
  39933. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39934. */
  39935. keysHeightOffsetModifierAlt: boolean;
  39936. /**
  39937. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39938. */
  39939. keysHeightOffsetModifierCtrl: boolean;
  39940. /**
  39941. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39942. */
  39943. keysHeightOffsetModifierShift: boolean;
  39944. /**
  39945. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39946. */
  39947. keysRotationOffsetIncr: number[];
  39948. /**
  39949. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39950. */
  39951. keysRotationOffsetDecr: number[];
  39952. /**
  39953. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39954. */
  39955. keysRotationOffsetModifierAlt: boolean;
  39956. /**
  39957. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39958. */
  39959. keysRotationOffsetModifierCtrl: boolean;
  39960. /**
  39961. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39962. */
  39963. keysRotationOffsetModifierShift: boolean;
  39964. /**
  39965. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39966. */
  39967. keysRadiusIncr: number[];
  39968. /**
  39969. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39970. */
  39971. keysRadiusDecr: number[];
  39972. /**
  39973. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39974. */
  39975. keysRadiusModifierAlt: boolean;
  39976. /**
  39977. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39978. */
  39979. keysRadiusModifierCtrl: boolean;
  39980. /**
  39981. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39982. */
  39983. keysRadiusModifierShift: boolean;
  39984. /**
  39985. * Defines the rate of change of heightOffset.
  39986. */
  39987. heightSensibility: number;
  39988. /**
  39989. * Defines the rate of change of rotationOffset.
  39990. */
  39991. rotationSensibility: number;
  39992. /**
  39993. * Defines the rate of change of radius.
  39994. */
  39995. radiusSensibility: number;
  39996. private _keys;
  39997. private _ctrlPressed;
  39998. private _altPressed;
  39999. private _shiftPressed;
  40000. private _onCanvasBlurObserver;
  40001. private _onKeyboardObserver;
  40002. private _engine;
  40003. private _scene;
  40004. /**
  40005. * Attach the input controls to a specific dom element to get the input from.
  40006. * @param element Defines the element the controls should be listened from
  40007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40008. */
  40009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40010. /**
  40011. * Detach the current controls from the specified dom element.
  40012. * @param element Defines the element to stop listening the inputs from
  40013. */
  40014. detachControl(element: Nullable<HTMLElement>): void;
  40015. /**
  40016. * Update the current camera state depending on the inputs that have been used this frame.
  40017. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40018. */
  40019. checkInputs(): void;
  40020. /**
  40021. * Gets the class name of the current input.
  40022. * @returns the class name
  40023. */
  40024. getClassName(): string;
  40025. /**
  40026. * Get the friendly name associated with the input class.
  40027. * @returns the input friendly name
  40028. */
  40029. getSimpleName(): string;
  40030. /**
  40031. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40032. * allow modification of the heightOffset value.
  40033. */
  40034. private _modifierHeightOffset;
  40035. /**
  40036. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40037. * allow modification of the rotationOffset value.
  40038. */
  40039. private _modifierRotationOffset;
  40040. /**
  40041. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40042. * allow modification of the radius value.
  40043. */
  40044. private _modifierRadius;
  40045. }
  40046. }
  40047. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  40048. import { Nullable } from "babylonjs/types";
  40049. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40050. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40051. import { Observable } from "babylonjs/Misc/observable";
  40052. module "babylonjs/Cameras/freeCameraInputsManager" {
  40053. interface FreeCameraInputsManager {
  40054. /**
  40055. * @hidden
  40056. */
  40057. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40058. /**
  40059. * Add orientation input support to the input manager.
  40060. * @returns the current input manager
  40061. */
  40062. addDeviceOrientation(): FreeCameraInputsManager;
  40063. }
  40064. }
  40065. /**
  40066. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40067. * Screen rotation is taken into account.
  40068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40069. */
  40070. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40071. private _camera;
  40072. private _screenOrientationAngle;
  40073. private _constantTranform;
  40074. private _screenQuaternion;
  40075. private _alpha;
  40076. private _beta;
  40077. private _gamma;
  40078. /**
  40079. * Can be used to detect if a device orientation sensor is availible on a device
  40080. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40081. * @returns a promise that will resolve on orientation change
  40082. */
  40083. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40084. /**
  40085. * @hidden
  40086. */
  40087. _onDeviceOrientationChangedObservable: Observable<void>;
  40088. /**
  40089. * Instantiates a new input
  40090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40091. */
  40092. constructor();
  40093. /**
  40094. * Define the camera controlled by the input.
  40095. */
  40096. camera: FreeCamera;
  40097. /**
  40098. * Attach the input controls to a specific dom element to get the input from.
  40099. * @param element Defines the element the controls should be listened from
  40100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40101. */
  40102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40103. private _orientationChanged;
  40104. private _deviceOrientation;
  40105. /**
  40106. * Detach the current controls from the specified dom element.
  40107. * @param element Defines the element to stop listening the inputs from
  40108. */
  40109. detachControl(element: Nullable<HTMLElement>): void;
  40110. /**
  40111. * Update the current camera state depending on the inputs that have been used this frame.
  40112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40113. */
  40114. checkInputs(): void;
  40115. /**
  40116. * Gets the class name of the current intput.
  40117. * @returns the class name
  40118. */
  40119. getClassName(): string;
  40120. /**
  40121. * Get the friendly name associated with the input class.
  40122. * @returns the input friendly name
  40123. */
  40124. getSimpleName(): string;
  40125. }
  40126. }
  40127. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  40128. import { Nullable } from "babylonjs/types";
  40129. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40130. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40131. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40132. /**
  40133. * Manage the gamepad inputs to control a free camera.
  40134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40135. */
  40136. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40137. /**
  40138. * Define the camera the input is attached to.
  40139. */
  40140. camera: FreeCamera;
  40141. /**
  40142. * Define the Gamepad controlling the input
  40143. */
  40144. gamepad: Nullable<Gamepad>;
  40145. /**
  40146. * Defines the gamepad rotation sensiblity.
  40147. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40148. */
  40149. gamepadAngularSensibility: number;
  40150. /**
  40151. * Defines the gamepad move sensiblity.
  40152. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40153. */
  40154. gamepadMoveSensibility: number;
  40155. private _yAxisScale;
  40156. /**
  40157. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40158. */
  40159. invertYAxis: boolean;
  40160. private _onGamepadConnectedObserver;
  40161. private _onGamepadDisconnectedObserver;
  40162. private _cameraTransform;
  40163. private _deltaTransform;
  40164. private _vector3;
  40165. private _vector2;
  40166. /**
  40167. * Attach the input controls to a specific dom element to get the input from.
  40168. * @param element Defines the element the controls should be listened from
  40169. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40170. */
  40171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40172. /**
  40173. * Detach the current controls from the specified dom element.
  40174. * @param element Defines the element to stop listening the inputs from
  40175. */
  40176. detachControl(element: Nullable<HTMLElement>): void;
  40177. /**
  40178. * Update the current camera state depending on the inputs that have been used this frame.
  40179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40180. */
  40181. checkInputs(): void;
  40182. /**
  40183. * Gets the class name of the current intput.
  40184. * @returns the class name
  40185. */
  40186. getClassName(): string;
  40187. /**
  40188. * Get the friendly name associated with the input class.
  40189. * @returns the input friendly name
  40190. */
  40191. getSimpleName(): string;
  40192. }
  40193. }
  40194. declare module "babylonjs/Misc/virtualJoystick" {
  40195. import { Nullable } from "babylonjs/types";
  40196. import { Vector3 } from "babylonjs/Maths/math.vector";
  40197. /**
  40198. * Defines the potential axis of a Joystick
  40199. */
  40200. export enum JoystickAxis {
  40201. /** X axis */
  40202. X = 0,
  40203. /** Y axis */
  40204. Y = 1,
  40205. /** Z axis */
  40206. Z = 2
  40207. }
  40208. /**
  40209. * Class used to define virtual joystick (used in touch mode)
  40210. */
  40211. export class VirtualJoystick {
  40212. /**
  40213. * Gets or sets a boolean indicating that left and right values must be inverted
  40214. */
  40215. reverseLeftRight: boolean;
  40216. /**
  40217. * Gets or sets a boolean indicating that up and down values must be inverted
  40218. */
  40219. reverseUpDown: boolean;
  40220. /**
  40221. * Gets the offset value for the position (ie. the change of the position value)
  40222. */
  40223. deltaPosition: Vector3;
  40224. /**
  40225. * Gets a boolean indicating if the virtual joystick was pressed
  40226. */
  40227. pressed: boolean;
  40228. /**
  40229. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40230. */
  40231. static Canvas: Nullable<HTMLCanvasElement>;
  40232. private static _globalJoystickIndex;
  40233. private static vjCanvasContext;
  40234. private static vjCanvasWidth;
  40235. private static vjCanvasHeight;
  40236. private static halfWidth;
  40237. private _action;
  40238. private _axisTargetedByLeftAndRight;
  40239. private _axisTargetedByUpAndDown;
  40240. private _joystickSensibility;
  40241. private _inversedSensibility;
  40242. private _joystickPointerID;
  40243. private _joystickColor;
  40244. private _joystickPointerPos;
  40245. private _joystickPreviousPointerPos;
  40246. private _joystickPointerStartPos;
  40247. private _deltaJoystickVector;
  40248. private _leftJoystick;
  40249. private _touches;
  40250. private _onPointerDownHandlerRef;
  40251. private _onPointerMoveHandlerRef;
  40252. private _onPointerUpHandlerRef;
  40253. private _onResize;
  40254. /**
  40255. * Creates a new virtual joystick
  40256. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40257. */
  40258. constructor(leftJoystick?: boolean);
  40259. /**
  40260. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40261. * @param newJoystickSensibility defines the new sensibility
  40262. */
  40263. setJoystickSensibility(newJoystickSensibility: number): void;
  40264. private _onPointerDown;
  40265. private _onPointerMove;
  40266. private _onPointerUp;
  40267. /**
  40268. * Change the color of the virtual joystick
  40269. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40270. */
  40271. setJoystickColor(newColor: string): void;
  40272. /**
  40273. * Defines a callback to call when the joystick is touched
  40274. * @param action defines the callback
  40275. */
  40276. setActionOnTouch(action: () => any): void;
  40277. /**
  40278. * Defines which axis you'd like to control for left & right
  40279. * @param axis defines the axis to use
  40280. */
  40281. setAxisForLeftRight(axis: JoystickAxis): void;
  40282. /**
  40283. * Defines which axis you'd like to control for up & down
  40284. * @param axis defines the axis to use
  40285. */
  40286. setAxisForUpDown(axis: JoystickAxis): void;
  40287. private _drawVirtualJoystick;
  40288. /**
  40289. * Release internal HTML canvas
  40290. */
  40291. releaseCanvas(): void;
  40292. }
  40293. }
  40294. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40295. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40296. import { Nullable } from "babylonjs/types";
  40297. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40298. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40299. module "babylonjs/Cameras/freeCameraInputsManager" {
  40300. interface FreeCameraInputsManager {
  40301. /**
  40302. * Add virtual joystick input support to the input manager.
  40303. * @returns the current input manager
  40304. */
  40305. addVirtualJoystick(): FreeCameraInputsManager;
  40306. }
  40307. }
  40308. /**
  40309. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40311. */
  40312. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40313. /**
  40314. * Defines the camera the input is attached to.
  40315. */
  40316. camera: FreeCamera;
  40317. private _leftjoystick;
  40318. private _rightjoystick;
  40319. /**
  40320. * Gets the left stick of the virtual joystick.
  40321. * @returns The virtual Joystick
  40322. */
  40323. getLeftJoystick(): VirtualJoystick;
  40324. /**
  40325. * Gets the right stick of the virtual joystick.
  40326. * @returns The virtual Joystick
  40327. */
  40328. getRightJoystick(): VirtualJoystick;
  40329. /**
  40330. * Update the current camera state depending on the inputs that have been used this frame.
  40331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40332. */
  40333. checkInputs(): void;
  40334. /**
  40335. * Attach the input controls to a specific dom element to get the input from.
  40336. * @param element Defines the element the controls should be listened from
  40337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40338. */
  40339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40340. /**
  40341. * Detach the current controls from the specified dom element.
  40342. * @param element Defines the element to stop listening the inputs from
  40343. */
  40344. detachControl(element: Nullable<HTMLElement>): void;
  40345. /**
  40346. * Gets the class name of the current intput.
  40347. * @returns the class name
  40348. */
  40349. getClassName(): string;
  40350. /**
  40351. * Get the friendly name associated with the input class.
  40352. * @returns the input friendly name
  40353. */
  40354. getSimpleName(): string;
  40355. }
  40356. }
  40357. declare module "babylonjs/Cameras/Inputs/index" {
  40358. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40359. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40360. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40361. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40362. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40363. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40364. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40365. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40366. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40367. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40368. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40369. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40370. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40371. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40372. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40373. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40374. }
  40375. declare module "babylonjs/Cameras/touchCamera" {
  40376. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40377. import { Scene } from "babylonjs/scene";
  40378. import { Vector3 } from "babylonjs/Maths/math.vector";
  40379. /**
  40380. * This represents a FPS type of camera controlled by touch.
  40381. * This is like a universal camera minus the Gamepad controls.
  40382. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40383. */
  40384. export class TouchCamera extends FreeCamera {
  40385. /**
  40386. * Defines the touch sensibility for rotation.
  40387. * The higher the faster.
  40388. */
  40389. touchAngularSensibility: number;
  40390. /**
  40391. * Defines the touch sensibility for move.
  40392. * The higher the faster.
  40393. */
  40394. touchMoveSensibility: number;
  40395. /**
  40396. * Instantiates a new touch camera.
  40397. * This represents a FPS type of camera controlled by touch.
  40398. * This is like a universal camera minus the Gamepad controls.
  40399. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40400. * @param name Define the name of the camera in the scene
  40401. * @param position Define the start position of the camera in the scene
  40402. * @param scene Define the scene the camera belongs to
  40403. */
  40404. constructor(name: string, position: Vector3, scene: Scene);
  40405. /**
  40406. * Gets the current object class name.
  40407. * @return the class name
  40408. */
  40409. getClassName(): string;
  40410. /** @hidden */
  40411. _setupInputs(): void;
  40412. }
  40413. }
  40414. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40415. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40416. import { Scene } from "babylonjs/scene";
  40417. import { Vector3 } from "babylonjs/Maths/math.vector";
  40418. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40419. import { Axis } from "babylonjs/Maths/math.axis";
  40420. /**
  40421. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40422. * being tilted forward or back and left or right.
  40423. */
  40424. export class DeviceOrientationCamera extends FreeCamera {
  40425. private _initialQuaternion;
  40426. private _quaternionCache;
  40427. private _tmpDragQuaternion;
  40428. private _disablePointerInputWhenUsingDeviceOrientation;
  40429. /**
  40430. * Creates a new device orientation camera
  40431. * @param name The name of the camera
  40432. * @param position The start position camera
  40433. * @param scene The scene the camera belongs to
  40434. */
  40435. constructor(name: string, position: Vector3, scene: Scene);
  40436. /**
  40437. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40438. */
  40439. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40440. private _dragFactor;
  40441. /**
  40442. * Enabled turning on the y axis when the orientation sensor is active
  40443. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40444. */
  40445. enableHorizontalDragging(dragFactor?: number): void;
  40446. /**
  40447. * Gets the current instance class name ("DeviceOrientationCamera").
  40448. * This helps avoiding instanceof at run time.
  40449. * @returns the class name
  40450. */
  40451. getClassName(): string;
  40452. /**
  40453. * @hidden
  40454. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40455. */
  40456. _checkInputs(): void;
  40457. /**
  40458. * Reset the camera to its default orientation on the specified axis only.
  40459. * @param axis The axis to reset
  40460. */
  40461. resetToCurrentRotation(axis?: Axis): void;
  40462. }
  40463. }
  40464. declare module "babylonjs/Gamepads/xboxGamepad" {
  40465. import { Observable } from "babylonjs/Misc/observable";
  40466. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40467. /**
  40468. * Defines supported buttons for XBox360 compatible gamepads
  40469. */
  40470. export enum Xbox360Button {
  40471. /** A */
  40472. A = 0,
  40473. /** B */
  40474. B = 1,
  40475. /** X */
  40476. X = 2,
  40477. /** Y */
  40478. Y = 3,
  40479. /** Start */
  40480. Start = 4,
  40481. /** Back */
  40482. Back = 5,
  40483. /** Left button */
  40484. LB = 6,
  40485. /** Right button */
  40486. RB = 7,
  40487. /** Left stick */
  40488. LeftStick = 8,
  40489. /** Right stick */
  40490. RightStick = 9
  40491. }
  40492. /** Defines values for XBox360 DPad */
  40493. export enum Xbox360Dpad {
  40494. /** Up */
  40495. Up = 0,
  40496. /** Down */
  40497. Down = 1,
  40498. /** Left */
  40499. Left = 2,
  40500. /** Right */
  40501. Right = 3
  40502. }
  40503. /**
  40504. * Defines a XBox360 gamepad
  40505. */
  40506. export class Xbox360Pad extends Gamepad {
  40507. private _leftTrigger;
  40508. private _rightTrigger;
  40509. private _onlefttriggerchanged;
  40510. private _onrighttriggerchanged;
  40511. private _onbuttondown;
  40512. private _onbuttonup;
  40513. private _ondpaddown;
  40514. private _ondpadup;
  40515. /** Observable raised when a button is pressed */
  40516. onButtonDownObservable: Observable<Xbox360Button>;
  40517. /** Observable raised when a button is released */
  40518. onButtonUpObservable: Observable<Xbox360Button>;
  40519. /** Observable raised when a pad is pressed */
  40520. onPadDownObservable: Observable<Xbox360Dpad>;
  40521. /** Observable raised when a pad is released */
  40522. onPadUpObservable: Observable<Xbox360Dpad>;
  40523. private _buttonA;
  40524. private _buttonB;
  40525. private _buttonX;
  40526. private _buttonY;
  40527. private _buttonBack;
  40528. private _buttonStart;
  40529. private _buttonLB;
  40530. private _buttonRB;
  40531. private _buttonLeftStick;
  40532. private _buttonRightStick;
  40533. private _dPadUp;
  40534. private _dPadDown;
  40535. private _dPadLeft;
  40536. private _dPadRight;
  40537. private _isXboxOnePad;
  40538. /**
  40539. * Creates a new XBox360 gamepad object
  40540. * @param id defines the id of this gamepad
  40541. * @param index defines its index
  40542. * @param gamepad defines the internal HTML gamepad object
  40543. * @param xboxOne defines if it is a XBox One gamepad
  40544. */
  40545. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40546. /**
  40547. * Defines the callback to call when left trigger is pressed
  40548. * @param callback defines the callback to use
  40549. */
  40550. onlefttriggerchanged(callback: (value: number) => void): void;
  40551. /**
  40552. * Defines the callback to call when right trigger is pressed
  40553. * @param callback defines the callback to use
  40554. */
  40555. onrighttriggerchanged(callback: (value: number) => void): void;
  40556. /**
  40557. * Gets the left trigger value
  40558. */
  40559. /**
  40560. * Sets the left trigger value
  40561. */
  40562. leftTrigger: number;
  40563. /**
  40564. * Gets the right trigger value
  40565. */
  40566. /**
  40567. * Sets the right trigger value
  40568. */
  40569. rightTrigger: number;
  40570. /**
  40571. * Defines the callback to call when a button is pressed
  40572. * @param callback defines the callback to use
  40573. */
  40574. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40575. /**
  40576. * Defines the callback to call when a button is released
  40577. * @param callback defines the callback to use
  40578. */
  40579. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40580. /**
  40581. * Defines the callback to call when a pad is pressed
  40582. * @param callback defines the callback to use
  40583. */
  40584. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40585. /**
  40586. * Defines the callback to call when a pad is released
  40587. * @param callback defines the callback to use
  40588. */
  40589. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40590. private _setButtonValue;
  40591. private _setDPadValue;
  40592. /**
  40593. * Gets the value of the `A` button
  40594. */
  40595. /**
  40596. * Sets the value of the `A` button
  40597. */
  40598. buttonA: number;
  40599. /**
  40600. * Gets the value of the `B` button
  40601. */
  40602. /**
  40603. * Sets the value of the `B` button
  40604. */
  40605. buttonB: number;
  40606. /**
  40607. * Gets the value of the `X` button
  40608. */
  40609. /**
  40610. * Sets the value of the `X` button
  40611. */
  40612. buttonX: number;
  40613. /**
  40614. * Gets the value of the `Y` button
  40615. */
  40616. /**
  40617. * Sets the value of the `Y` button
  40618. */
  40619. buttonY: number;
  40620. /**
  40621. * Gets the value of the `Start` button
  40622. */
  40623. /**
  40624. * Sets the value of the `Start` button
  40625. */
  40626. buttonStart: number;
  40627. /**
  40628. * Gets the value of the `Back` button
  40629. */
  40630. /**
  40631. * Sets the value of the `Back` button
  40632. */
  40633. buttonBack: number;
  40634. /**
  40635. * Gets the value of the `Left` button
  40636. */
  40637. /**
  40638. * Sets the value of the `Left` button
  40639. */
  40640. buttonLB: number;
  40641. /**
  40642. * Gets the value of the `Right` button
  40643. */
  40644. /**
  40645. * Sets the value of the `Right` button
  40646. */
  40647. buttonRB: number;
  40648. /**
  40649. * Gets the value of the Left joystick
  40650. */
  40651. /**
  40652. * Sets the value of the Left joystick
  40653. */
  40654. buttonLeftStick: number;
  40655. /**
  40656. * Gets the value of the Right joystick
  40657. */
  40658. /**
  40659. * Sets the value of the Right joystick
  40660. */
  40661. buttonRightStick: number;
  40662. /**
  40663. * Gets the value of D-pad up
  40664. */
  40665. /**
  40666. * Sets the value of D-pad up
  40667. */
  40668. dPadUp: number;
  40669. /**
  40670. * Gets the value of D-pad down
  40671. */
  40672. /**
  40673. * Sets the value of D-pad down
  40674. */
  40675. dPadDown: number;
  40676. /**
  40677. * Gets the value of D-pad left
  40678. */
  40679. /**
  40680. * Sets the value of D-pad left
  40681. */
  40682. dPadLeft: number;
  40683. /**
  40684. * Gets the value of D-pad right
  40685. */
  40686. /**
  40687. * Sets the value of D-pad right
  40688. */
  40689. dPadRight: number;
  40690. /**
  40691. * Force the gamepad to synchronize with device values
  40692. */
  40693. update(): void;
  40694. /**
  40695. * Disposes the gamepad
  40696. */
  40697. dispose(): void;
  40698. }
  40699. }
  40700. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40701. import { Observable } from "babylonjs/Misc/observable";
  40702. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40703. /**
  40704. * Defines supported buttons for DualShock compatible gamepads
  40705. */
  40706. export enum DualShockButton {
  40707. /** Cross */
  40708. Cross = 0,
  40709. /** Circle */
  40710. Circle = 1,
  40711. /** Square */
  40712. Square = 2,
  40713. /** Triangle */
  40714. Triangle = 3,
  40715. /** Options */
  40716. Options = 4,
  40717. /** Share */
  40718. Share = 5,
  40719. /** L1 */
  40720. L1 = 6,
  40721. /** R1 */
  40722. R1 = 7,
  40723. /** Left stick */
  40724. LeftStick = 8,
  40725. /** Right stick */
  40726. RightStick = 9
  40727. }
  40728. /** Defines values for DualShock DPad */
  40729. export enum DualShockDpad {
  40730. /** Up */
  40731. Up = 0,
  40732. /** Down */
  40733. Down = 1,
  40734. /** Left */
  40735. Left = 2,
  40736. /** Right */
  40737. Right = 3
  40738. }
  40739. /**
  40740. * Defines a DualShock gamepad
  40741. */
  40742. export class DualShockPad extends Gamepad {
  40743. private _leftTrigger;
  40744. private _rightTrigger;
  40745. private _onlefttriggerchanged;
  40746. private _onrighttriggerchanged;
  40747. private _onbuttondown;
  40748. private _onbuttonup;
  40749. private _ondpaddown;
  40750. private _ondpadup;
  40751. /** Observable raised when a button is pressed */
  40752. onButtonDownObservable: Observable<DualShockButton>;
  40753. /** Observable raised when a button is released */
  40754. onButtonUpObservable: Observable<DualShockButton>;
  40755. /** Observable raised when a pad is pressed */
  40756. onPadDownObservable: Observable<DualShockDpad>;
  40757. /** Observable raised when a pad is released */
  40758. onPadUpObservable: Observable<DualShockDpad>;
  40759. private _buttonCross;
  40760. private _buttonCircle;
  40761. private _buttonSquare;
  40762. private _buttonTriangle;
  40763. private _buttonShare;
  40764. private _buttonOptions;
  40765. private _buttonL1;
  40766. private _buttonR1;
  40767. private _buttonLeftStick;
  40768. private _buttonRightStick;
  40769. private _dPadUp;
  40770. private _dPadDown;
  40771. private _dPadLeft;
  40772. private _dPadRight;
  40773. /**
  40774. * Creates a new DualShock gamepad object
  40775. * @param id defines the id of this gamepad
  40776. * @param index defines its index
  40777. * @param gamepad defines the internal HTML gamepad object
  40778. */
  40779. constructor(id: string, index: number, gamepad: any);
  40780. /**
  40781. * Defines the callback to call when left trigger is pressed
  40782. * @param callback defines the callback to use
  40783. */
  40784. onlefttriggerchanged(callback: (value: number) => void): void;
  40785. /**
  40786. * Defines the callback to call when right trigger is pressed
  40787. * @param callback defines the callback to use
  40788. */
  40789. onrighttriggerchanged(callback: (value: number) => void): void;
  40790. /**
  40791. * Gets the left trigger value
  40792. */
  40793. /**
  40794. * Sets the left trigger value
  40795. */
  40796. leftTrigger: number;
  40797. /**
  40798. * Gets the right trigger value
  40799. */
  40800. /**
  40801. * Sets the right trigger value
  40802. */
  40803. rightTrigger: number;
  40804. /**
  40805. * Defines the callback to call when a button is pressed
  40806. * @param callback defines the callback to use
  40807. */
  40808. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40809. /**
  40810. * Defines the callback to call when a button is released
  40811. * @param callback defines the callback to use
  40812. */
  40813. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40814. /**
  40815. * Defines the callback to call when a pad is pressed
  40816. * @param callback defines the callback to use
  40817. */
  40818. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40819. /**
  40820. * Defines the callback to call when a pad is released
  40821. * @param callback defines the callback to use
  40822. */
  40823. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40824. private _setButtonValue;
  40825. private _setDPadValue;
  40826. /**
  40827. * Gets the value of the `Cross` button
  40828. */
  40829. /**
  40830. * Sets the value of the `Cross` button
  40831. */
  40832. buttonCross: number;
  40833. /**
  40834. * Gets the value of the `Circle` button
  40835. */
  40836. /**
  40837. * Sets the value of the `Circle` button
  40838. */
  40839. buttonCircle: number;
  40840. /**
  40841. * Gets the value of the `Square` button
  40842. */
  40843. /**
  40844. * Sets the value of the `Square` button
  40845. */
  40846. buttonSquare: number;
  40847. /**
  40848. * Gets the value of the `Triangle` button
  40849. */
  40850. /**
  40851. * Sets the value of the `Triangle` button
  40852. */
  40853. buttonTriangle: number;
  40854. /**
  40855. * Gets the value of the `Options` button
  40856. */
  40857. /**
  40858. * Sets the value of the `Options` button
  40859. */
  40860. buttonOptions: number;
  40861. /**
  40862. * Gets the value of the `Share` button
  40863. */
  40864. /**
  40865. * Sets the value of the `Share` button
  40866. */
  40867. buttonShare: number;
  40868. /**
  40869. * Gets the value of the `L1` button
  40870. */
  40871. /**
  40872. * Sets the value of the `L1` button
  40873. */
  40874. buttonL1: number;
  40875. /**
  40876. * Gets the value of the `R1` button
  40877. */
  40878. /**
  40879. * Sets the value of the `R1` button
  40880. */
  40881. buttonR1: number;
  40882. /**
  40883. * Gets the value of the Left joystick
  40884. */
  40885. /**
  40886. * Sets the value of the Left joystick
  40887. */
  40888. buttonLeftStick: number;
  40889. /**
  40890. * Gets the value of the Right joystick
  40891. */
  40892. /**
  40893. * Sets the value of the Right joystick
  40894. */
  40895. buttonRightStick: number;
  40896. /**
  40897. * Gets the value of D-pad up
  40898. */
  40899. /**
  40900. * Sets the value of D-pad up
  40901. */
  40902. dPadUp: number;
  40903. /**
  40904. * Gets the value of D-pad down
  40905. */
  40906. /**
  40907. * Sets the value of D-pad down
  40908. */
  40909. dPadDown: number;
  40910. /**
  40911. * Gets the value of D-pad left
  40912. */
  40913. /**
  40914. * Sets the value of D-pad left
  40915. */
  40916. dPadLeft: number;
  40917. /**
  40918. * Gets the value of D-pad right
  40919. */
  40920. /**
  40921. * Sets the value of D-pad right
  40922. */
  40923. dPadRight: number;
  40924. /**
  40925. * Force the gamepad to synchronize with device values
  40926. */
  40927. update(): void;
  40928. /**
  40929. * Disposes the gamepad
  40930. */
  40931. dispose(): void;
  40932. }
  40933. }
  40934. declare module "babylonjs/Gamepads/gamepadManager" {
  40935. import { Observable } from "babylonjs/Misc/observable";
  40936. import { Nullable } from "babylonjs/types";
  40937. import { Scene } from "babylonjs/scene";
  40938. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40939. /**
  40940. * Manager for handling gamepads
  40941. */
  40942. export class GamepadManager {
  40943. private _scene?;
  40944. private _babylonGamepads;
  40945. private _oneGamepadConnected;
  40946. /** @hidden */
  40947. _isMonitoring: boolean;
  40948. private _gamepadEventSupported;
  40949. private _gamepadSupport;
  40950. /**
  40951. * observable to be triggered when the gamepad controller has been connected
  40952. */
  40953. onGamepadConnectedObservable: Observable<Gamepad>;
  40954. /**
  40955. * observable to be triggered when the gamepad controller has been disconnected
  40956. */
  40957. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40958. private _onGamepadConnectedEvent;
  40959. private _onGamepadDisconnectedEvent;
  40960. /**
  40961. * Initializes the gamepad manager
  40962. * @param _scene BabylonJS scene
  40963. */
  40964. constructor(_scene?: Scene | undefined);
  40965. /**
  40966. * The gamepads in the game pad manager
  40967. */
  40968. readonly gamepads: Gamepad[];
  40969. /**
  40970. * Get the gamepad controllers based on type
  40971. * @param type The type of gamepad controller
  40972. * @returns Nullable gamepad
  40973. */
  40974. getGamepadByType(type?: number): Nullable<Gamepad>;
  40975. /**
  40976. * Disposes the gamepad manager
  40977. */
  40978. dispose(): void;
  40979. private _addNewGamepad;
  40980. private _startMonitoringGamepads;
  40981. private _stopMonitoringGamepads;
  40982. /** @hidden */
  40983. _checkGamepadsStatus(): void;
  40984. private _updateGamepadObjects;
  40985. }
  40986. }
  40987. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40988. import { Nullable } from "babylonjs/types";
  40989. import { Scene } from "babylonjs/scene";
  40990. import { ISceneComponent } from "babylonjs/sceneComponent";
  40991. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40992. module "babylonjs/scene" {
  40993. interface Scene {
  40994. /** @hidden */
  40995. _gamepadManager: Nullable<GamepadManager>;
  40996. /**
  40997. * Gets the gamepad manager associated with the scene
  40998. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40999. */
  41000. gamepadManager: GamepadManager;
  41001. }
  41002. }
  41003. module "babylonjs/Cameras/freeCameraInputsManager" {
  41004. /**
  41005. * Interface representing a free camera inputs manager
  41006. */
  41007. interface FreeCameraInputsManager {
  41008. /**
  41009. * Adds gamepad input support to the FreeCameraInputsManager.
  41010. * @returns the FreeCameraInputsManager
  41011. */
  41012. addGamepad(): FreeCameraInputsManager;
  41013. }
  41014. }
  41015. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41016. /**
  41017. * Interface representing an arc rotate camera inputs manager
  41018. */
  41019. interface ArcRotateCameraInputsManager {
  41020. /**
  41021. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41022. * @returns the camera inputs manager
  41023. */
  41024. addGamepad(): ArcRotateCameraInputsManager;
  41025. }
  41026. }
  41027. /**
  41028. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41029. */
  41030. export class GamepadSystemSceneComponent implements ISceneComponent {
  41031. /**
  41032. * The component name helpfull to identify the component in the list of scene components.
  41033. */
  41034. readonly name: string;
  41035. /**
  41036. * The scene the component belongs to.
  41037. */
  41038. scene: Scene;
  41039. /**
  41040. * Creates a new instance of the component for the given scene
  41041. * @param scene Defines the scene to register the component in
  41042. */
  41043. constructor(scene: Scene);
  41044. /**
  41045. * Registers the component in a given scene
  41046. */
  41047. register(): void;
  41048. /**
  41049. * Rebuilds the elements related to this component in case of
  41050. * context lost for instance.
  41051. */
  41052. rebuild(): void;
  41053. /**
  41054. * Disposes the component and the associated ressources
  41055. */
  41056. dispose(): void;
  41057. private _beforeCameraUpdate;
  41058. }
  41059. }
  41060. declare module "babylonjs/Cameras/universalCamera" {
  41061. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  41062. import { Scene } from "babylonjs/scene";
  41063. import { Vector3 } from "babylonjs/Maths/math.vector";
  41064. import "babylonjs/Gamepads/gamepadSceneComponent";
  41065. /**
  41066. * 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,
  41067. * which still works and will still be found in many Playgrounds.
  41068. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41069. */
  41070. export class UniversalCamera extends TouchCamera {
  41071. /**
  41072. * Defines the gamepad rotation sensiblity.
  41073. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41074. */
  41075. gamepadAngularSensibility: number;
  41076. /**
  41077. * Defines the gamepad move sensiblity.
  41078. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41079. */
  41080. gamepadMoveSensibility: number;
  41081. /**
  41082. * 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,
  41083. * which still works and will still be found in many Playgrounds.
  41084. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41085. * @param name Define the name of the camera in the scene
  41086. * @param position Define the start position of the camera in the scene
  41087. * @param scene Define the scene the camera belongs to
  41088. */
  41089. constructor(name: string, position: Vector3, scene: Scene);
  41090. /**
  41091. * Gets the current object class name.
  41092. * @return the class name
  41093. */
  41094. getClassName(): string;
  41095. }
  41096. }
  41097. declare module "babylonjs/Cameras/gamepadCamera" {
  41098. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41099. import { Scene } from "babylonjs/scene";
  41100. import { Vector3 } from "babylonjs/Maths/math.vector";
  41101. /**
  41102. * This represents a FPS type of camera. This is only here for back compat purpose.
  41103. * Please use the UniversalCamera instead as both are identical.
  41104. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41105. */
  41106. export class GamepadCamera extends UniversalCamera {
  41107. /**
  41108. * Instantiates a new Gamepad Camera
  41109. * This represents a FPS type of camera. This is only here for back compat purpose.
  41110. * Please use the UniversalCamera instead as both are identical.
  41111. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41112. * @param name Define the name of the camera in the scene
  41113. * @param position Define the start position of the camera in the scene
  41114. * @param scene Define the scene the camera belongs to
  41115. */
  41116. constructor(name: string, position: Vector3, scene: Scene);
  41117. /**
  41118. * Gets the current object class name.
  41119. * @return the class name
  41120. */
  41121. getClassName(): string;
  41122. }
  41123. }
  41124. declare module "babylonjs/Shaders/pass.fragment" {
  41125. /** @hidden */
  41126. export var passPixelShader: {
  41127. name: string;
  41128. shader: string;
  41129. };
  41130. }
  41131. declare module "babylonjs/Shaders/passCube.fragment" {
  41132. /** @hidden */
  41133. export var passCubePixelShader: {
  41134. name: string;
  41135. shader: string;
  41136. };
  41137. }
  41138. declare module "babylonjs/PostProcesses/passPostProcess" {
  41139. import { Nullable } from "babylonjs/types";
  41140. import { Camera } from "babylonjs/Cameras/camera";
  41141. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41142. import { Engine } from "babylonjs/Engines/engine";
  41143. import "babylonjs/Shaders/pass.fragment";
  41144. import "babylonjs/Shaders/passCube.fragment";
  41145. /**
  41146. * PassPostProcess which produces an output the same as it's input
  41147. */
  41148. export class PassPostProcess extends PostProcess {
  41149. /**
  41150. * Creates the PassPostProcess
  41151. * @param name The name of the effect.
  41152. * @param options The required width/height ratio to downsize to before computing the render pass.
  41153. * @param camera The camera to apply the render pass to.
  41154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41155. * @param engine The engine which the post process will be applied. (default: current engine)
  41156. * @param reusable If the post process can be reused on the same frame. (default: false)
  41157. * @param textureType The type of texture to be used when performing the post processing.
  41158. * @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)
  41159. */
  41160. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41161. }
  41162. /**
  41163. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41164. */
  41165. export class PassCubePostProcess extends PostProcess {
  41166. private _face;
  41167. /**
  41168. * Gets or sets the cube face to display.
  41169. * * 0 is +X
  41170. * * 1 is -X
  41171. * * 2 is +Y
  41172. * * 3 is -Y
  41173. * * 4 is +Z
  41174. * * 5 is -Z
  41175. */
  41176. face: number;
  41177. /**
  41178. * Creates the PassCubePostProcess
  41179. * @param name The name of the effect.
  41180. * @param options The required width/height ratio to downsize to before computing the render pass.
  41181. * @param camera The camera to apply the render pass to.
  41182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41183. * @param engine The engine which the post process will be applied. (default: current engine)
  41184. * @param reusable If the post process can be reused on the same frame. (default: false)
  41185. * @param textureType The type of texture to be used when performing the post processing.
  41186. * @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)
  41187. */
  41188. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41189. }
  41190. }
  41191. declare module "babylonjs/Shaders/anaglyph.fragment" {
  41192. /** @hidden */
  41193. export var anaglyphPixelShader: {
  41194. name: string;
  41195. shader: string;
  41196. };
  41197. }
  41198. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41199. import { Engine } from "babylonjs/Engines/engine";
  41200. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41201. import { Camera } from "babylonjs/Cameras/camera";
  41202. import "babylonjs/Shaders/anaglyph.fragment";
  41203. /**
  41204. * Postprocess used to generate anaglyphic rendering
  41205. */
  41206. export class AnaglyphPostProcess extends PostProcess {
  41207. private _passedProcess;
  41208. /**
  41209. * Creates a new AnaglyphPostProcess
  41210. * @param name defines postprocess name
  41211. * @param options defines creation options or target ratio scale
  41212. * @param rigCameras defines cameras using this postprocess
  41213. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41214. * @param engine defines hosting engine
  41215. * @param reusable defines if the postprocess will be reused multiple times per frame
  41216. */
  41217. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41218. }
  41219. }
  41220. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41221. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41222. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41223. import { Scene } from "babylonjs/scene";
  41224. import { Vector3 } from "babylonjs/Maths/math.vector";
  41225. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41226. /**
  41227. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41228. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41229. */
  41230. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41231. /**
  41232. * Creates a new AnaglyphArcRotateCamera
  41233. * @param name defines camera name
  41234. * @param alpha defines alpha angle (in radians)
  41235. * @param beta defines beta angle (in radians)
  41236. * @param radius defines radius
  41237. * @param target defines camera target
  41238. * @param interaxialDistance defines distance between each color axis
  41239. * @param scene defines the hosting scene
  41240. */
  41241. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41242. /**
  41243. * Gets camera class name
  41244. * @returns AnaglyphArcRotateCamera
  41245. */
  41246. getClassName(): string;
  41247. }
  41248. }
  41249. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41250. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41251. import { Scene } from "babylonjs/scene";
  41252. import { Vector3 } from "babylonjs/Maths/math.vector";
  41253. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41254. /**
  41255. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41256. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41257. */
  41258. export class AnaglyphFreeCamera extends FreeCamera {
  41259. /**
  41260. * Creates a new AnaglyphFreeCamera
  41261. * @param name defines camera name
  41262. * @param position defines initial position
  41263. * @param interaxialDistance defines distance between each color axis
  41264. * @param scene defines the hosting scene
  41265. */
  41266. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41267. /**
  41268. * Gets camera class name
  41269. * @returns AnaglyphFreeCamera
  41270. */
  41271. getClassName(): string;
  41272. }
  41273. }
  41274. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41275. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41276. import { Scene } from "babylonjs/scene";
  41277. import { Vector3 } from "babylonjs/Maths/math.vector";
  41278. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41279. /**
  41280. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41281. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41282. */
  41283. export class AnaglyphGamepadCamera extends GamepadCamera {
  41284. /**
  41285. * Creates a new AnaglyphGamepadCamera
  41286. * @param name defines camera name
  41287. * @param position defines initial position
  41288. * @param interaxialDistance defines distance between each color axis
  41289. * @param scene defines the hosting scene
  41290. */
  41291. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41292. /**
  41293. * Gets camera class name
  41294. * @returns AnaglyphGamepadCamera
  41295. */
  41296. getClassName(): string;
  41297. }
  41298. }
  41299. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41300. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41301. import { Scene } from "babylonjs/scene";
  41302. import { Vector3 } from "babylonjs/Maths/math.vector";
  41303. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41304. /**
  41305. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41306. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41307. */
  41308. export class AnaglyphUniversalCamera extends UniversalCamera {
  41309. /**
  41310. * Creates a new AnaglyphUniversalCamera
  41311. * @param name defines camera name
  41312. * @param position defines initial position
  41313. * @param interaxialDistance defines distance between each color axis
  41314. * @param scene defines the hosting scene
  41315. */
  41316. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41317. /**
  41318. * Gets camera class name
  41319. * @returns AnaglyphUniversalCamera
  41320. */
  41321. getClassName(): string;
  41322. }
  41323. }
  41324. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41325. /** @hidden */
  41326. export var stereoscopicInterlacePixelShader: {
  41327. name: string;
  41328. shader: string;
  41329. };
  41330. }
  41331. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41332. import { Camera } from "babylonjs/Cameras/camera";
  41333. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41334. import { Engine } from "babylonjs/Engines/engine";
  41335. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41336. /**
  41337. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41338. */
  41339. export class StereoscopicInterlacePostProcess extends PostProcess {
  41340. private _stepSize;
  41341. private _passedProcess;
  41342. /**
  41343. * Initializes a StereoscopicInterlacePostProcess
  41344. * @param name The name of the effect.
  41345. * @param rigCameras The rig cameras to be appled to the post process
  41346. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41348. * @param engine The engine which the post process will be applied. (default: current engine)
  41349. * @param reusable If the post process can be reused on the same frame. (default: false)
  41350. */
  41351. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41352. }
  41353. }
  41354. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41355. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41356. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41357. import { Scene } from "babylonjs/scene";
  41358. import { Vector3 } from "babylonjs/Maths/math.vector";
  41359. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41360. /**
  41361. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41362. * @see http://doc.babylonjs.com/features/cameras
  41363. */
  41364. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41365. /**
  41366. * Creates a new StereoscopicArcRotateCamera
  41367. * @param name defines camera name
  41368. * @param alpha defines alpha angle (in radians)
  41369. * @param beta defines beta angle (in radians)
  41370. * @param radius defines radius
  41371. * @param target defines camera target
  41372. * @param interaxialDistance defines distance between each color axis
  41373. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41374. * @param scene defines the hosting scene
  41375. */
  41376. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41377. /**
  41378. * Gets camera class name
  41379. * @returns StereoscopicArcRotateCamera
  41380. */
  41381. getClassName(): string;
  41382. }
  41383. }
  41384. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41385. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41386. import { Scene } from "babylonjs/scene";
  41387. import { Vector3 } from "babylonjs/Maths/math.vector";
  41388. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41389. /**
  41390. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41391. * @see http://doc.babylonjs.com/features/cameras
  41392. */
  41393. export class StereoscopicFreeCamera extends FreeCamera {
  41394. /**
  41395. * Creates a new StereoscopicFreeCamera
  41396. * @param name defines camera name
  41397. * @param position defines initial position
  41398. * @param interaxialDistance defines distance between each color axis
  41399. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41400. * @param scene defines the hosting scene
  41401. */
  41402. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41403. /**
  41404. * Gets camera class name
  41405. * @returns StereoscopicFreeCamera
  41406. */
  41407. getClassName(): string;
  41408. }
  41409. }
  41410. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41411. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41412. import { Scene } from "babylonjs/scene";
  41413. import { Vector3 } from "babylonjs/Maths/math.vector";
  41414. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41415. /**
  41416. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41417. * @see http://doc.babylonjs.com/features/cameras
  41418. */
  41419. export class StereoscopicGamepadCamera extends GamepadCamera {
  41420. /**
  41421. * Creates a new StereoscopicGamepadCamera
  41422. * @param name defines camera name
  41423. * @param position defines initial position
  41424. * @param interaxialDistance defines distance between each color axis
  41425. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41426. * @param scene defines the hosting scene
  41427. */
  41428. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41429. /**
  41430. * Gets camera class name
  41431. * @returns StereoscopicGamepadCamera
  41432. */
  41433. getClassName(): string;
  41434. }
  41435. }
  41436. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41437. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41438. import { Scene } from "babylonjs/scene";
  41439. import { Vector3 } from "babylonjs/Maths/math.vector";
  41440. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41441. /**
  41442. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41443. * @see http://doc.babylonjs.com/features/cameras
  41444. */
  41445. export class StereoscopicUniversalCamera extends UniversalCamera {
  41446. /**
  41447. * Creates a new StereoscopicUniversalCamera
  41448. * @param name defines camera name
  41449. * @param position defines initial position
  41450. * @param interaxialDistance defines distance between each color axis
  41451. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41452. * @param scene defines the hosting scene
  41453. */
  41454. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41455. /**
  41456. * Gets camera class name
  41457. * @returns StereoscopicUniversalCamera
  41458. */
  41459. getClassName(): string;
  41460. }
  41461. }
  41462. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41463. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41464. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41465. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41466. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41467. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41468. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41469. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41470. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41471. }
  41472. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41473. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41474. import { Scene } from "babylonjs/scene";
  41475. import { Vector3 } from "babylonjs/Maths/math.vector";
  41476. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41477. /**
  41478. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41479. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41480. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41481. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41482. */
  41483. export class VirtualJoysticksCamera extends FreeCamera {
  41484. /**
  41485. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41486. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41487. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41488. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41489. * @param name Define the name of the camera in the scene
  41490. * @param position Define the start position of the camera in the scene
  41491. * @param scene Define the scene the camera belongs to
  41492. */
  41493. constructor(name: string, position: Vector3, scene: Scene);
  41494. /**
  41495. * Gets the current object class name.
  41496. * @return the class name
  41497. */
  41498. getClassName(): string;
  41499. }
  41500. }
  41501. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41502. import { Matrix } from "babylonjs/Maths/math.vector";
  41503. /**
  41504. * This represents all the required metrics to create a VR camera.
  41505. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41506. */
  41507. export class VRCameraMetrics {
  41508. /**
  41509. * Define the horizontal resolution off the screen.
  41510. */
  41511. hResolution: number;
  41512. /**
  41513. * Define the vertical resolution off the screen.
  41514. */
  41515. vResolution: number;
  41516. /**
  41517. * Define the horizontal screen size.
  41518. */
  41519. hScreenSize: number;
  41520. /**
  41521. * Define the vertical screen size.
  41522. */
  41523. vScreenSize: number;
  41524. /**
  41525. * Define the vertical screen center position.
  41526. */
  41527. vScreenCenter: number;
  41528. /**
  41529. * Define the distance of the eyes to the screen.
  41530. */
  41531. eyeToScreenDistance: number;
  41532. /**
  41533. * Define the distance between both lenses
  41534. */
  41535. lensSeparationDistance: number;
  41536. /**
  41537. * Define the distance between both viewer's eyes.
  41538. */
  41539. interpupillaryDistance: number;
  41540. /**
  41541. * Define the distortion factor of the VR postprocess.
  41542. * Please, touch with care.
  41543. */
  41544. distortionK: number[];
  41545. /**
  41546. * Define the chromatic aberration correction factors for the VR post process.
  41547. */
  41548. chromaAbCorrection: number[];
  41549. /**
  41550. * Define the scale factor of the post process.
  41551. * The smaller the better but the slower.
  41552. */
  41553. postProcessScaleFactor: number;
  41554. /**
  41555. * Define an offset for the lens center.
  41556. */
  41557. lensCenterOffset: number;
  41558. /**
  41559. * Define if the current vr camera should compensate the distortion of the lense or not.
  41560. */
  41561. compensateDistortion: boolean;
  41562. /**
  41563. * Defines if multiview should be enabled when rendering (Default: false)
  41564. */
  41565. multiviewEnabled: boolean;
  41566. /**
  41567. * Gets the rendering aspect ratio based on the provided resolutions.
  41568. */
  41569. readonly aspectRatio: number;
  41570. /**
  41571. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41572. */
  41573. readonly aspectRatioFov: number;
  41574. /**
  41575. * @hidden
  41576. */
  41577. readonly leftHMatrix: Matrix;
  41578. /**
  41579. * @hidden
  41580. */
  41581. readonly rightHMatrix: Matrix;
  41582. /**
  41583. * @hidden
  41584. */
  41585. readonly leftPreViewMatrix: Matrix;
  41586. /**
  41587. * @hidden
  41588. */
  41589. readonly rightPreViewMatrix: Matrix;
  41590. /**
  41591. * Get the default VRMetrics based on the most generic setup.
  41592. * @returns the default vr metrics
  41593. */
  41594. static GetDefault(): VRCameraMetrics;
  41595. }
  41596. }
  41597. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41598. /** @hidden */
  41599. export var vrDistortionCorrectionPixelShader: {
  41600. name: string;
  41601. shader: string;
  41602. };
  41603. }
  41604. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41605. import { Camera } from "babylonjs/Cameras/camera";
  41606. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41607. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41608. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41609. /**
  41610. * VRDistortionCorrectionPostProcess used for mobile VR
  41611. */
  41612. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41613. private _isRightEye;
  41614. private _distortionFactors;
  41615. private _postProcessScaleFactor;
  41616. private _lensCenterOffset;
  41617. private _scaleIn;
  41618. private _scaleFactor;
  41619. private _lensCenter;
  41620. /**
  41621. * Initializes the VRDistortionCorrectionPostProcess
  41622. * @param name The name of the effect.
  41623. * @param camera The camera to apply the render pass to.
  41624. * @param isRightEye If this is for the right eye distortion
  41625. * @param vrMetrics All the required metrics for the VR camera
  41626. */
  41627. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41628. }
  41629. }
  41630. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41631. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41632. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41633. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41634. import { Scene } from "babylonjs/scene";
  41635. import { Vector3 } from "babylonjs/Maths/math.vector";
  41636. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41637. import "babylonjs/Cameras/RigModes/vrRigMode";
  41638. /**
  41639. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41640. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41641. */
  41642. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41643. /**
  41644. * Creates a new VRDeviceOrientationArcRotateCamera
  41645. * @param name defines camera name
  41646. * @param alpha defines the camera rotation along the logitudinal axis
  41647. * @param beta defines the camera rotation along the latitudinal axis
  41648. * @param radius defines the camera distance from its target
  41649. * @param target defines the camera target
  41650. * @param scene defines the scene the camera belongs to
  41651. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41652. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41653. */
  41654. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41655. /**
  41656. * Gets camera class name
  41657. * @returns VRDeviceOrientationArcRotateCamera
  41658. */
  41659. getClassName(): string;
  41660. }
  41661. }
  41662. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41663. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41664. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41665. import { Scene } from "babylonjs/scene";
  41666. import { Vector3 } from "babylonjs/Maths/math.vector";
  41667. import "babylonjs/Cameras/RigModes/vrRigMode";
  41668. /**
  41669. * Camera used to simulate VR rendering (based on FreeCamera)
  41670. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41671. */
  41672. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41673. /**
  41674. * Creates a new VRDeviceOrientationFreeCamera
  41675. * @param name defines camera name
  41676. * @param position defines the start position of the camera
  41677. * @param scene defines the scene the camera belongs to
  41678. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41679. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41680. */
  41681. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41682. /**
  41683. * Gets camera class name
  41684. * @returns VRDeviceOrientationFreeCamera
  41685. */
  41686. getClassName(): string;
  41687. }
  41688. }
  41689. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41690. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41691. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41692. import { Scene } from "babylonjs/scene";
  41693. import { Vector3 } from "babylonjs/Maths/math.vector";
  41694. import "babylonjs/Gamepads/gamepadSceneComponent";
  41695. /**
  41696. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41697. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41698. */
  41699. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41700. /**
  41701. * Creates a new VRDeviceOrientationGamepadCamera
  41702. * @param name defines camera name
  41703. * @param position defines the start position of the camera
  41704. * @param scene defines the scene the camera belongs to
  41705. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41706. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41707. */
  41708. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41709. /**
  41710. * Gets camera class name
  41711. * @returns VRDeviceOrientationGamepadCamera
  41712. */
  41713. getClassName(): string;
  41714. }
  41715. }
  41716. declare module "babylonjs/Materials/pushMaterial" {
  41717. import { Nullable } from "babylonjs/types";
  41718. import { Scene } from "babylonjs/scene";
  41719. import { Matrix } from "babylonjs/Maths/math.vector";
  41720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41721. import { Mesh } from "babylonjs/Meshes/mesh";
  41722. import { Material } from "babylonjs/Materials/material";
  41723. import { Effect } from "babylonjs/Materials/effect";
  41724. /**
  41725. * Base class of materials working in push mode in babylon JS
  41726. * @hidden
  41727. */
  41728. export class PushMaterial extends Material {
  41729. protected _activeEffect: Effect;
  41730. protected _normalMatrix: Matrix;
  41731. /**
  41732. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41733. * This means that the material can keep using a previous shader while a new one is being compiled.
  41734. * This is mostly used when shader parallel compilation is supported (true by default)
  41735. */
  41736. allowShaderHotSwapping: boolean;
  41737. constructor(name: string, scene: Scene);
  41738. getEffect(): Effect;
  41739. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41740. /**
  41741. * Binds the given world matrix to the active effect
  41742. *
  41743. * @param world the matrix to bind
  41744. */
  41745. bindOnlyWorldMatrix(world: Matrix): void;
  41746. /**
  41747. * Binds the given normal matrix to the active effect
  41748. *
  41749. * @param normalMatrix the matrix to bind
  41750. */
  41751. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41752. bind(world: Matrix, mesh?: Mesh): void;
  41753. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41754. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41755. }
  41756. }
  41757. declare module "babylonjs/Materials/materialFlags" {
  41758. /**
  41759. * This groups all the flags used to control the materials channel.
  41760. */
  41761. export class MaterialFlags {
  41762. private static _DiffuseTextureEnabled;
  41763. /**
  41764. * Are diffuse textures enabled in the application.
  41765. */
  41766. static DiffuseTextureEnabled: boolean;
  41767. private static _AmbientTextureEnabled;
  41768. /**
  41769. * Are ambient textures enabled in the application.
  41770. */
  41771. static AmbientTextureEnabled: boolean;
  41772. private static _OpacityTextureEnabled;
  41773. /**
  41774. * Are opacity textures enabled in the application.
  41775. */
  41776. static OpacityTextureEnabled: boolean;
  41777. private static _ReflectionTextureEnabled;
  41778. /**
  41779. * Are reflection textures enabled in the application.
  41780. */
  41781. static ReflectionTextureEnabled: boolean;
  41782. private static _EmissiveTextureEnabled;
  41783. /**
  41784. * Are emissive textures enabled in the application.
  41785. */
  41786. static EmissiveTextureEnabled: boolean;
  41787. private static _SpecularTextureEnabled;
  41788. /**
  41789. * Are specular textures enabled in the application.
  41790. */
  41791. static SpecularTextureEnabled: boolean;
  41792. private static _BumpTextureEnabled;
  41793. /**
  41794. * Are bump textures enabled in the application.
  41795. */
  41796. static BumpTextureEnabled: boolean;
  41797. private static _LightmapTextureEnabled;
  41798. /**
  41799. * Are lightmap textures enabled in the application.
  41800. */
  41801. static LightmapTextureEnabled: boolean;
  41802. private static _RefractionTextureEnabled;
  41803. /**
  41804. * Are refraction textures enabled in the application.
  41805. */
  41806. static RefractionTextureEnabled: boolean;
  41807. private static _ColorGradingTextureEnabled;
  41808. /**
  41809. * Are color grading textures enabled in the application.
  41810. */
  41811. static ColorGradingTextureEnabled: boolean;
  41812. private static _FresnelEnabled;
  41813. /**
  41814. * Are fresnels enabled in the application.
  41815. */
  41816. static FresnelEnabled: boolean;
  41817. private static _ClearCoatTextureEnabled;
  41818. /**
  41819. * Are clear coat textures enabled in the application.
  41820. */
  41821. static ClearCoatTextureEnabled: boolean;
  41822. private static _ClearCoatBumpTextureEnabled;
  41823. /**
  41824. * Are clear coat bump textures enabled in the application.
  41825. */
  41826. static ClearCoatBumpTextureEnabled: boolean;
  41827. private static _ClearCoatTintTextureEnabled;
  41828. /**
  41829. * Are clear coat tint textures enabled in the application.
  41830. */
  41831. static ClearCoatTintTextureEnabled: boolean;
  41832. private static _SheenTextureEnabled;
  41833. /**
  41834. * Are sheen textures enabled in the application.
  41835. */
  41836. static SheenTextureEnabled: boolean;
  41837. private static _AnisotropicTextureEnabled;
  41838. /**
  41839. * Are anisotropic textures enabled in the application.
  41840. */
  41841. static AnisotropicTextureEnabled: boolean;
  41842. private static _ThicknessTextureEnabled;
  41843. /**
  41844. * Are thickness textures enabled in the application.
  41845. */
  41846. static ThicknessTextureEnabled: boolean;
  41847. }
  41848. }
  41849. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41850. /** @hidden */
  41851. export var defaultFragmentDeclaration: {
  41852. name: string;
  41853. shader: string;
  41854. };
  41855. }
  41856. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41857. /** @hidden */
  41858. export var defaultUboDeclaration: {
  41859. name: string;
  41860. shader: string;
  41861. };
  41862. }
  41863. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41864. /** @hidden */
  41865. export var lightFragmentDeclaration: {
  41866. name: string;
  41867. shader: string;
  41868. };
  41869. }
  41870. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41871. /** @hidden */
  41872. export var lightUboDeclaration: {
  41873. name: string;
  41874. shader: string;
  41875. };
  41876. }
  41877. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41878. /** @hidden */
  41879. export var lightsFragmentFunctions: {
  41880. name: string;
  41881. shader: string;
  41882. };
  41883. }
  41884. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41885. /** @hidden */
  41886. export var shadowsFragmentFunctions: {
  41887. name: string;
  41888. shader: string;
  41889. };
  41890. }
  41891. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41892. /** @hidden */
  41893. export var fresnelFunction: {
  41894. name: string;
  41895. shader: string;
  41896. };
  41897. }
  41898. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41899. /** @hidden */
  41900. export var reflectionFunction: {
  41901. name: string;
  41902. shader: string;
  41903. };
  41904. }
  41905. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41906. /** @hidden */
  41907. export var bumpFragmentFunctions: {
  41908. name: string;
  41909. shader: string;
  41910. };
  41911. }
  41912. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41913. /** @hidden */
  41914. export var logDepthDeclaration: {
  41915. name: string;
  41916. shader: string;
  41917. };
  41918. }
  41919. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41920. /** @hidden */
  41921. export var bumpFragment: {
  41922. name: string;
  41923. shader: string;
  41924. };
  41925. }
  41926. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41927. /** @hidden */
  41928. export var depthPrePass: {
  41929. name: string;
  41930. shader: string;
  41931. };
  41932. }
  41933. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41934. /** @hidden */
  41935. export var lightFragment: {
  41936. name: string;
  41937. shader: string;
  41938. };
  41939. }
  41940. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41941. /** @hidden */
  41942. export var logDepthFragment: {
  41943. name: string;
  41944. shader: string;
  41945. };
  41946. }
  41947. declare module "babylonjs/Shaders/default.fragment" {
  41948. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41949. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41950. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41951. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41952. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41953. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41954. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41955. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41956. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41957. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41958. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41959. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41960. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41961. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41962. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41963. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41964. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41965. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41966. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41967. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41968. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41969. /** @hidden */
  41970. export var defaultPixelShader: {
  41971. name: string;
  41972. shader: string;
  41973. };
  41974. }
  41975. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41976. /** @hidden */
  41977. export var defaultVertexDeclaration: {
  41978. name: string;
  41979. shader: string;
  41980. };
  41981. }
  41982. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41983. /** @hidden */
  41984. export var bumpVertexDeclaration: {
  41985. name: string;
  41986. shader: string;
  41987. };
  41988. }
  41989. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41990. /** @hidden */
  41991. export var bumpVertex: {
  41992. name: string;
  41993. shader: string;
  41994. };
  41995. }
  41996. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41997. /** @hidden */
  41998. export var fogVertex: {
  41999. name: string;
  42000. shader: string;
  42001. };
  42002. }
  42003. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  42004. /** @hidden */
  42005. export var shadowsVertex: {
  42006. name: string;
  42007. shader: string;
  42008. };
  42009. }
  42010. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  42011. /** @hidden */
  42012. export var pointCloudVertex: {
  42013. name: string;
  42014. shader: string;
  42015. };
  42016. }
  42017. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  42018. /** @hidden */
  42019. export var logDepthVertex: {
  42020. name: string;
  42021. shader: string;
  42022. };
  42023. }
  42024. declare module "babylonjs/Shaders/default.vertex" {
  42025. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  42026. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  42027. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42028. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  42029. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  42030. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  42031. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  42032. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  42033. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  42034. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  42035. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  42036. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  42037. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  42038. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  42039. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  42040. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  42041. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  42042. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  42043. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  42044. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  42045. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  42046. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  42047. /** @hidden */
  42048. export var defaultVertexShader: {
  42049. name: string;
  42050. shader: string;
  42051. };
  42052. }
  42053. declare module "babylonjs/Materials/standardMaterial" {
  42054. import { SmartArray } from "babylonjs/Misc/smartArray";
  42055. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  42056. import { Nullable } from "babylonjs/types";
  42057. import { Scene } from "babylonjs/scene";
  42058. import { Matrix } from "babylonjs/Maths/math.vector";
  42059. import { Color3 } from "babylonjs/Maths/math.color";
  42060. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42062. import { Mesh } from "babylonjs/Meshes/mesh";
  42063. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  42064. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42065. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  42066. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  42067. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  42068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42069. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42070. import "babylonjs/Shaders/default.fragment";
  42071. import "babylonjs/Shaders/default.vertex";
  42072. /** @hidden */
  42073. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  42074. MAINUV1: boolean;
  42075. MAINUV2: boolean;
  42076. DIFFUSE: boolean;
  42077. DIFFUSEDIRECTUV: number;
  42078. AMBIENT: boolean;
  42079. AMBIENTDIRECTUV: number;
  42080. OPACITY: boolean;
  42081. OPACITYDIRECTUV: number;
  42082. OPACITYRGB: boolean;
  42083. REFLECTION: boolean;
  42084. EMISSIVE: boolean;
  42085. EMISSIVEDIRECTUV: number;
  42086. SPECULAR: boolean;
  42087. SPECULARDIRECTUV: number;
  42088. BUMP: boolean;
  42089. BUMPDIRECTUV: number;
  42090. PARALLAX: boolean;
  42091. PARALLAXOCCLUSION: boolean;
  42092. SPECULAROVERALPHA: boolean;
  42093. CLIPPLANE: boolean;
  42094. CLIPPLANE2: boolean;
  42095. CLIPPLANE3: boolean;
  42096. CLIPPLANE4: boolean;
  42097. ALPHATEST: boolean;
  42098. DEPTHPREPASS: boolean;
  42099. ALPHAFROMDIFFUSE: boolean;
  42100. POINTSIZE: boolean;
  42101. FOG: boolean;
  42102. SPECULARTERM: boolean;
  42103. DIFFUSEFRESNEL: boolean;
  42104. OPACITYFRESNEL: boolean;
  42105. REFLECTIONFRESNEL: boolean;
  42106. REFRACTIONFRESNEL: boolean;
  42107. EMISSIVEFRESNEL: boolean;
  42108. FRESNEL: boolean;
  42109. NORMAL: boolean;
  42110. UV1: boolean;
  42111. UV2: boolean;
  42112. VERTEXCOLOR: boolean;
  42113. VERTEXALPHA: boolean;
  42114. NUM_BONE_INFLUENCERS: number;
  42115. BonesPerMesh: number;
  42116. BONETEXTURE: boolean;
  42117. INSTANCES: boolean;
  42118. GLOSSINESS: boolean;
  42119. ROUGHNESS: boolean;
  42120. EMISSIVEASILLUMINATION: boolean;
  42121. LINKEMISSIVEWITHDIFFUSE: boolean;
  42122. REFLECTIONFRESNELFROMSPECULAR: boolean;
  42123. LIGHTMAP: boolean;
  42124. LIGHTMAPDIRECTUV: number;
  42125. OBJECTSPACE_NORMALMAP: boolean;
  42126. USELIGHTMAPASSHADOWMAP: boolean;
  42127. REFLECTIONMAP_3D: boolean;
  42128. REFLECTIONMAP_SPHERICAL: boolean;
  42129. REFLECTIONMAP_PLANAR: boolean;
  42130. REFLECTIONMAP_CUBIC: boolean;
  42131. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  42132. REFLECTIONMAP_PROJECTION: boolean;
  42133. REFLECTIONMAP_SKYBOX: boolean;
  42134. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  42135. REFLECTIONMAP_EXPLICIT: boolean;
  42136. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  42137. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  42138. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  42139. INVERTCUBICMAP: boolean;
  42140. LOGARITHMICDEPTH: boolean;
  42141. REFRACTION: boolean;
  42142. REFRACTIONMAP_3D: boolean;
  42143. REFLECTIONOVERALPHA: boolean;
  42144. TWOSIDEDLIGHTING: boolean;
  42145. SHADOWFLOAT: boolean;
  42146. MORPHTARGETS: boolean;
  42147. MORPHTARGETS_NORMAL: boolean;
  42148. MORPHTARGETS_TANGENT: boolean;
  42149. MORPHTARGETS_UV: boolean;
  42150. NUM_MORPH_INFLUENCERS: number;
  42151. NONUNIFORMSCALING: boolean;
  42152. PREMULTIPLYALPHA: boolean;
  42153. IMAGEPROCESSING: boolean;
  42154. VIGNETTE: boolean;
  42155. VIGNETTEBLENDMODEMULTIPLY: boolean;
  42156. VIGNETTEBLENDMODEOPAQUE: boolean;
  42157. TONEMAPPING: boolean;
  42158. TONEMAPPING_ACES: boolean;
  42159. CONTRAST: boolean;
  42160. COLORCURVES: boolean;
  42161. COLORGRADING: boolean;
  42162. COLORGRADING3D: boolean;
  42163. SAMPLER3DGREENDEPTH: boolean;
  42164. SAMPLER3DBGRMAP: boolean;
  42165. IMAGEPROCESSINGPOSTPROCESS: boolean;
  42166. MULTIVIEW: boolean;
  42167. /**
  42168. * If the reflection texture on this material is in linear color space
  42169. * @hidden
  42170. */
  42171. IS_REFLECTION_LINEAR: boolean;
  42172. /**
  42173. * If the refraction texture on this material is in linear color space
  42174. * @hidden
  42175. */
  42176. IS_REFRACTION_LINEAR: boolean;
  42177. EXPOSURE: boolean;
  42178. constructor();
  42179. setReflectionMode(modeToEnable: string): void;
  42180. }
  42181. /**
  42182. * This is the default material used in Babylon. It is the best trade off between quality
  42183. * and performances.
  42184. * @see http://doc.babylonjs.com/babylon101/materials
  42185. */
  42186. export class StandardMaterial extends PushMaterial {
  42187. private _diffuseTexture;
  42188. /**
  42189. * The basic texture of the material as viewed under a light.
  42190. */
  42191. diffuseTexture: Nullable<BaseTexture>;
  42192. private _ambientTexture;
  42193. /**
  42194. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42195. */
  42196. ambientTexture: Nullable<BaseTexture>;
  42197. private _opacityTexture;
  42198. /**
  42199. * Define the transparency of the material from a texture.
  42200. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42201. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42202. */
  42203. opacityTexture: Nullable<BaseTexture>;
  42204. private _reflectionTexture;
  42205. /**
  42206. * Define the texture used to display the reflection.
  42207. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42208. */
  42209. reflectionTexture: Nullable<BaseTexture>;
  42210. private _emissiveTexture;
  42211. /**
  42212. * Define texture of the material as if self lit.
  42213. * This will be mixed in the final result even in the absence of light.
  42214. */
  42215. emissiveTexture: Nullable<BaseTexture>;
  42216. private _specularTexture;
  42217. /**
  42218. * Define how the color and intensity of the highlight given by the light in the material.
  42219. */
  42220. specularTexture: Nullable<BaseTexture>;
  42221. private _bumpTexture;
  42222. /**
  42223. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42224. * 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.
  42225. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42226. */
  42227. bumpTexture: Nullable<BaseTexture>;
  42228. private _lightmapTexture;
  42229. /**
  42230. * Complex lighting can be computationally expensive to compute at runtime.
  42231. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42232. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42233. */
  42234. lightmapTexture: Nullable<BaseTexture>;
  42235. private _refractionTexture;
  42236. /**
  42237. * Define the texture used to display the refraction.
  42238. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42239. */
  42240. refractionTexture: Nullable<BaseTexture>;
  42241. /**
  42242. * The color of the material lit by the environmental background lighting.
  42243. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42244. */
  42245. ambientColor: Color3;
  42246. /**
  42247. * The basic color of the material as viewed under a light.
  42248. */
  42249. diffuseColor: Color3;
  42250. /**
  42251. * Define how the color and intensity of the highlight given by the light in the material.
  42252. */
  42253. specularColor: Color3;
  42254. /**
  42255. * Define the color of the material as if self lit.
  42256. * This will be mixed in the final result even in the absence of light.
  42257. */
  42258. emissiveColor: Color3;
  42259. /**
  42260. * Defines how sharp are the highlights in the material.
  42261. * The bigger the value the sharper giving a more glossy feeling to the result.
  42262. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42263. */
  42264. specularPower: number;
  42265. private _useAlphaFromDiffuseTexture;
  42266. /**
  42267. * Does the transparency come from the diffuse texture alpha channel.
  42268. */
  42269. useAlphaFromDiffuseTexture: boolean;
  42270. private _useEmissiveAsIllumination;
  42271. /**
  42272. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42273. */
  42274. useEmissiveAsIllumination: boolean;
  42275. private _linkEmissiveWithDiffuse;
  42276. /**
  42277. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42278. * the emissive level when the final color is close to one.
  42279. */
  42280. linkEmissiveWithDiffuse: boolean;
  42281. private _useSpecularOverAlpha;
  42282. /**
  42283. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42284. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42285. */
  42286. useSpecularOverAlpha: boolean;
  42287. private _useReflectionOverAlpha;
  42288. /**
  42289. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42290. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42291. */
  42292. useReflectionOverAlpha: boolean;
  42293. private _disableLighting;
  42294. /**
  42295. * Does lights from the scene impacts this material.
  42296. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42297. */
  42298. disableLighting: boolean;
  42299. private _useObjectSpaceNormalMap;
  42300. /**
  42301. * Allows using an object space normal map (instead of tangent space).
  42302. */
  42303. useObjectSpaceNormalMap: boolean;
  42304. private _useParallax;
  42305. /**
  42306. * Is parallax enabled or not.
  42307. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42308. */
  42309. useParallax: boolean;
  42310. private _useParallaxOcclusion;
  42311. /**
  42312. * Is parallax occlusion enabled or not.
  42313. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42314. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42315. */
  42316. useParallaxOcclusion: boolean;
  42317. /**
  42318. * 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.
  42319. */
  42320. parallaxScaleBias: number;
  42321. private _roughness;
  42322. /**
  42323. * Helps to define how blurry the reflections should appears in the material.
  42324. */
  42325. roughness: number;
  42326. /**
  42327. * In case of refraction, define the value of the index of refraction.
  42328. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42329. */
  42330. indexOfRefraction: number;
  42331. /**
  42332. * Invert the refraction texture alongside the y axis.
  42333. * It can be useful with procedural textures or probe for instance.
  42334. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42335. */
  42336. invertRefractionY: boolean;
  42337. /**
  42338. * Defines the alpha limits in alpha test mode.
  42339. */
  42340. alphaCutOff: number;
  42341. private _useLightmapAsShadowmap;
  42342. /**
  42343. * In case of light mapping, define whether the map contains light or shadow informations.
  42344. */
  42345. useLightmapAsShadowmap: boolean;
  42346. private _diffuseFresnelParameters;
  42347. /**
  42348. * Define the diffuse fresnel parameters of the material.
  42349. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42350. */
  42351. diffuseFresnelParameters: FresnelParameters;
  42352. private _opacityFresnelParameters;
  42353. /**
  42354. * Define the opacity fresnel parameters of the material.
  42355. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42356. */
  42357. opacityFresnelParameters: FresnelParameters;
  42358. private _reflectionFresnelParameters;
  42359. /**
  42360. * Define the reflection fresnel parameters of the material.
  42361. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42362. */
  42363. reflectionFresnelParameters: FresnelParameters;
  42364. private _refractionFresnelParameters;
  42365. /**
  42366. * Define the refraction fresnel parameters of the material.
  42367. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42368. */
  42369. refractionFresnelParameters: FresnelParameters;
  42370. private _emissiveFresnelParameters;
  42371. /**
  42372. * Define the emissive fresnel parameters of the material.
  42373. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42374. */
  42375. emissiveFresnelParameters: FresnelParameters;
  42376. private _useReflectionFresnelFromSpecular;
  42377. /**
  42378. * If true automatically deducts the fresnels values from the material specularity.
  42379. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42380. */
  42381. useReflectionFresnelFromSpecular: boolean;
  42382. private _useGlossinessFromSpecularMapAlpha;
  42383. /**
  42384. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42385. */
  42386. useGlossinessFromSpecularMapAlpha: boolean;
  42387. private _maxSimultaneousLights;
  42388. /**
  42389. * Defines the maximum number of lights that can be used in the material
  42390. */
  42391. maxSimultaneousLights: number;
  42392. private _invertNormalMapX;
  42393. /**
  42394. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42395. */
  42396. invertNormalMapX: boolean;
  42397. private _invertNormalMapY;
  42398. /**
  42399. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42400. */
  42401. invertNormalMapY: boolean;
  42402. private _twoSidedLighting;
  42403. /**
  42404. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42405. */
  42406. twoSidedLighting: boolean;
  42407. /**
  42408. * Default configuration related to image processing available in the standard Material.
  42409. */
  42410. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42411. /**
  42412. * Gets the image processing configuration used either in this material.
  42413. */
  42414. /**
  42415. * Sets the Default image processing configuration used either in the this material.
  42416. *
  42417. * If sets to null, the scene one is in use.
  42418. */
  42419. imageProcessingConfiguration: ImageProcessingConfiguration;
  42420. /**
  42421. * Keep track of the image processing observer to allow dispose and replace.
  42422. */
  42423. private _imageProcessingObserver;
  42424. /**
  42425. * Attaches a new image processing configuration to the Standard Material.
  42426. * @param configuration
  42427. */
  42428. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42429. /**
  42430. * Gets wether the color curves effect is enabled.
  42431. */
  42432. /**
  42433. * Sets wether the color curves effect is enabled.
  42434. */
  42435. cameraColorCurvesEnabled: boolean;
  42436. /**
  42437. * Gets wether the color grading effect is enabled.
  42438. */
  42439. /**
  42440. * Gets wether the color grading effect is enabled.
  42441. */
  42442. cameraColorGradingEnabled: boolean;
  42443. /**
  42444. * Gets wether tonemapping is enabled or not.
  42445. */
  42446. /**
  42447. * Sets wether tonemapping is enabled or not
  42448. */
  42449. cameraToneMappingEnabled: boolean;
  42450. /**
  42451. * The camera exposure used on this material.
  42452. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42453. * This corresponds to a photographic exposure.
  42454. */
  42455. /**
  42456. * The camera exposure used on this material.
  42457. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42458. * This corresponds to a photographic exposure.
  42459. */
  42460. cameraExposure: number;
  42461. /**
  42462. * Gets The camera contrast used on this material.
  42463. */
  42464. /**
  42465. * Sets The camera contrast used on this material.
  42466. */
  42467. cameraContrast: number;
  42468. /**
  42469. * Gets the Color Grading 2D Lookup Texture.
  42470. */
  42471. /**
  42472. * Sets the Color Grading 2D Lookup Texture.
  42473. */
  42474. cameraColorGradingTexture: Nullable<BaseTexture>;
  42475. /**
  42476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42478. * 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;
  42479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42480. */
  42481. /**
  42482. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42483. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42484. * 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;
  42485. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42486. */
  42487. cameraColorCurves: Nullable<ColorCurves>;
  42488. /**
  42489. * Custom callback helping to override the default shader used in the material.
  42490. */
  42491. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42492. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42493. protected _worldViewProjectionMatrix: Matrix;
  42494. protected _globalAmbientColor: Color3;
  42495. protected _useLogarithmicDepth: boolean;
  42496. protected _rebuildInParallel: boolean;
  42497. /**
  42498. * Instantiates a new standard material.
  42499. * This is the default material used in Babylon. It is the best trade off between quality
  42500. * and performances.
  42501. * @see http://doc.babylonjs.com/babylon101/materials
  42502. * @param name Define the name of the material in the scene
  42503. * @param scene Define the scene the material belong to
  42504. */
  42505. constructor(name: string, scene: Scene);
  42506. /**
  42507. * Gets a boolean indicating that current material needs to register RTT
  42508. */
  42509. readonly hasRenderTargetTextures: boolean;
  42510. /**
  42511. * Gets the current class name of the material e.g. "StandardMaterial"
  42512. * Mainly use in serialization.
  42513. * @returns the class name
  42514. */
  42515. getClassName(): string;
  42516. /**
  42517. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42518. * You can try switching to logarithmic depth.
  42519. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42520. */
  42521. useLogarithmicDepth: boolean;
  42522. /**
  42523. * Specifies if the material will require alpha blending
  42524. * @returns a boolean specifying if alpha blending is needed
  42525. */
  42526. needAlphaBlending(): boolean;
  42527. /**
  42528. * Specifies if this material should be rendered in alpha test mode
  42529. * @returns a boolean specifying if an alpha test is needed.
  42530. */
  42531. needAlphaTesting(): boolean;
  42532. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42533. /**
  42534. * Get the texture used for alpha test purpose.
  42535. * @returns the diffuse texture in case of the standard material.
  42536. */
  42537. getAlphaTestTexture(): Nullable<BaseTexture>;
  42538. /**
  42539. * Get if the submesh is ready to be used and all its information available.
  42540. * Child classes can use it to update shaders
  42541. * @param mesh defines the mesh to check
  42542. * @param subMesh defines which submesh to check
  42543. * @param useInstances specifies that instances should be used
  42544. * @returns a boolean indicating that the submesh is ready or not
  42545. */
  42546. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42547. /**
  42548. * Builds the material UBO layouts.
  42549. * Used internally during the effect preparation.
  42550. */
  42551. buildUniformLayout(): void;
  42552. /**
  42553. * Unbinds the material from the mesh
  42554. */
  42555. unbind(): void;
  42556. /**
  42557. * Binds the submesh to this material by preparing the effect and shader to draw
  42558. * @param world defines the world transformation matrix
  42559. * @param mesh defines the mesh containing the submesh
  42560. * @param subMesh defines the submesh to bind the material to
  42561. */
  42562. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42563. /**
  42564. * Get the list of animatables in the material.
  42565. * @returns the list of animatables object used in the material
  42566. */
  42567. getAnimatables(): IAnimatable[];
  42568. /**
  42569. * Gets the active textures from the material
  42570. * @returns an array of textures
  42571. */
  42572. getActiveTextures(): BaseTexture[];
  42573. /**
  42574. * Specifies if the material uses a texture
  42575. * @param texture defines the texture to check against the material
  42576. * @returns a boolean specifying if the material uses the texture
  42577. */
  42578. hasTexture(texture: BaseTexture): boolean;
  42579. /**
  42580. * Disposes the material
  42581. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42582. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42583. */
  42584. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42585. /**
  42586. * Makes a duplicate of the material, and gives it a new name
  42587. * @param name defines the new name for the duplicated material
  42588. * @returns the cloned material
  42589. */
  42590. clone(name: string): StandardMaterial;
  42591. /**
  42592. * Serializes this material in a JSON representation
  42593. * @returns the serialized material object
  42594. */
  42595. serialize(): any;
  42596. /**
  42597. * Creates a standard material from parsed material data
  42598. * @param source defines the JSON representation of the material
  42599. * @param scene defines the hosting scene
  42600. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42601. * @returns a new standard material
  42602. */
  42603. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42604. /**
  42605. * Are diffuse textures enabled in the application.
  42606. */
  42607. static DiffuseTextureEnabled: boolean;
  42608. /**
  42609. * Are ambient textures enabled in the application.
  42610. */
  42611. static AmbientTextureEnabled: boolean;
  42612. /**
  42613. * Are opacity textures enabled in the application.
  42614. */
  42615. static OpacityTextureEnabled: boolean;
  42616. /**
  42617. * Are reflection textures enabled in the application.
  42618. */
  42619. static ReflectionTextureEnabled: boolean;
  42620. /**
  42621. * Are emissive textures enabled in the application.
  42622. */
  42623. static EmissiveTextureEnabled: boolean;
  42624. /**
  42625. * Are specular textures enabled in the application.
  42626. */
  42627. static SpecularTextureEnabled: boolean;
  42628. /**
  42629. * Are bump textures enabled in the application.
  42630. */
  42631. static BumpTextureEnabled: boolean;
  42632. /**
  42633. * Are lightmap textures enabled in the application.
  42634. */
  42635. static LightmapTextureEnabled: boolean;
  42636. /**
  42637. * Are refraction textures enabled in the application.
  42638. */
  42639. static RefractionTextureEnabled: boolean;
  42640. /**
  42641. * Are color grading textures enabled in the application.
  42642. */
  42643. static ColorGradingTextureEnabled: boolean;
  42644. /**
  42645. * Are fresnels enabled in the application.
  42646. */
  42647. static FresnelEnabled: boolean;
  42648. }
  42649. }
  42650. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42651. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42652. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42653. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42654. /** @hidden */
  42655. export var imageProcessingPixelShader: {
  42656. name: string;
  42657. shader: string;
  42658. };
  42659. }
  42660. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42661. import { Nullable } from "babylonjs/types";
  42662. import { Color4 } from "babylonjs/Maths/math.color";
  42663. import { Camera } from "babylonjs/Cameras/camera";
  42664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42665. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42666. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42667. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42668. import { Engine } from "babylonjs/Engines/engine";
  42669. import "babylonjs/Shaders/imageProcessing.fragment";
  42670. import "babylonjs/Shaders/postprocess.vertex";
  42671. /**
  42672. * ImageProcessingPostProcess
  42673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42674. */
  42675. export class ImageProcessingPostProcess extends PostProcess {
  42676. /**
  42677. * Default configuration related to image processing available in the PBR Material.
  42678. */
  42679. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42680. /**
  42681. * Gets the image processing configuration used either in this material.
  42682. */
  42683. /**
  42684. * Sets the Default image processing configuration used either in the this material.
  42685. *
  42686. * If sets to null, the scene one is in use.
  42687. */
  42688. imageProcessingConfiguration: ImageProcessingConfiguration;
  42689. /**
  42690. * Keep track of the image processing observer to allow dispose and replace.
  42691. */
  42692. private _imageProcessingObserver;
  42693. /**
  42694. * Attaches a new image processing configuration to the PBR Material.
  42695. * @param configuration
  42696. */
  42697. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42698. /**
  42699. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42700. */
  42701. /**
  42702. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42703. */
  42704. colorCurves: Nullable<ColorCurves>;
  42705. /**
  42706. * Gets wether the color curves effect is enabled.
  42707. */
  42708. /**
  42709. * Sets wether the color curves effect is enabled.
  42710. */
  42711. colorCurvesEnabled: boolean;
  42712. /**
  42713. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42714. */
  42715. /**
  42716. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42717. */
  42718. colorGradingTexture: Nullable<BaseTexture>;
  42719. /**
  42720. * Gets wether the color grading effect is enabled.
  42721. */
  42722. /**
  42723. * Gets wether the color grading effect is enabled.
  42724. */
  42725. colorGradingEnabled: boolean;
  42726. /**
  42727. * Gets exposure used in the effect.
  42728. */
  42729. /**
  42730. * Sets exposure used in the effect.
  42731. */
  42732. exposure: number;
  42733. /**
  42734. * Gets wether tonemapping is enabled or not.
  42735. */
  42736. /**
  42737. * Sets wether tonemapping is enabled or not
  42738. */
  42739. toneMappingEnabled: boolean;
  42740. /**
  42741. * Gets the type of tone mapping effect.
  42742. */
  42743. /**
  42744. * Sets the type of tone mapping effect.
  42745. */
  42746. toneMappingType: number;
  42747. /**
  42748. * Gets contrast used in the effect.
  42749. */
  42750. /**
  42751. * Sets contrast used in the effect.
  42752. */
  42753. contrast: number;
  42754. /**
  42755. * Gets Vignette stretch size.
  42756. */
  42757. /**
  42758. * Sets Vignette stretch size.
  42759. */
  42760. vignetteStretch: number;
  42761. /**
  42762. * Gets Vignette centre X Offset.
  42763. */
  42764. /**
  42765. * Sets Vignette centre X Offset.
  42766. */
  42767. vignetteCentreX: number;
  42768. /**
  42769. * Gets Vignette centre Y Offset.
  42770. */
  42771. /**
  42772. * Sets Vignette centre Y Offset.
  42773. */
  42774. vignetteCentreY: number;
  42775. /**
  42776. * Gets Vignette weight or intensity of the vignette effect.
  42777. */
  42778. /**
  42779. * Sets Vignette weight or intensity of the vignette effect.
  42780. */
  42781. vignetteWeight: number;
  42782. /**
  42783. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42784. * if vignetteEnabled is set to true.
  42785. */
  42786. /**
  42787. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42788. * if vignetteEnabled is set to true.
  42789. */
  42790. vignetteColor: Color4;
  42791. /**
  42792. * Gets Camera field of view used by the Vignette effect.
  42793. */
  42794. /**
  42795. * Sets Camera field of view used by the Vignette effect.
  42796. */
  42797. vignetteCameraFov: number;
  42798. /**
  42799. * Gets the vignette blend mode allowing different kind of effect.
  42800. */
  42801. /**
  42802. * Sets the vignette blend mode allowing different kind of effect.
  42803. */
  42804. vignetteBlendMode: number;
  42805. /**
  42806. * Gets wether the vignette effect is enabled.
  42807. */
  42808. /**
  42809. * Sets wether the vignette effect is enabled.
  42810. */
  42811. vignetteEnabled: boolean;
  42812. private _fromLinearSpace;
  42813. /**
  42814. * Gets wether the input of the processing is in Gamma or Linear Space.
  42815. */
  42816. /**
  42817. * Sets wether the input of the processing is in Gamma or Linear Space.
  42818. */
  42819. fromLinearSpace: boolean;
  42820. /**
  42821. * Defines cache preventing GC.
  42822. */
  42823. private _defines;
  42824. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42825. /**
  42826. * "ImageProcessingPostProcess"
  42827. * @returns "ImageProcessingPostProcess"
  42828. */
  42829. getClassName(): string;
  42830. protected _updateParameters(): void;
  42831. dispose(camera?: Camera): void;
  42832. }
  42833. }
  42834. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42835. import { Scene } from "babylonjs/scene";
  42836. import { Color3 } from "babylonjs/Maths/math.color";
  42837. import { Mesh } from "babylonjs/Meshes/mesh";
  42838. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42839. import { Nullable } from "babylonjs/types";
  42840. /**
  42841. * Class containing static functions to help procedurally build meshes
  42842. */
  42843. export class GroundBuilder {
  42844. /**
  42845. * Creates a ground mesh
  42846. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42847. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42849. * @param name defines the name of the mesh
  42850. * @param options defines the options used to create the mesh
  42851. * @param scene defines the hosting scene
  42852. * @returns the ground mesh
  42853. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42854. */
  42855. static CreateGround(name: string, options: {
  42856. width?: number;
  42857. height?: number;
  42858. subdivisions?: number;
  42859. subdivisionsX?: number;
  42860. subdivisionsY?: number;
  42861. updatable?: boolean;
  42862. }, scene: any): Mesh;
  42863. /**
  42864. * Creates a tiled ground mesh
  42865. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42866. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42867. * * 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
  42868. * * 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
  42869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42870. * @param name defines the name of the mesh
  42871. * @param options defines the options used to create the mesh
  42872. * @param scene defines the hosting scene
  42873. * @returns the tiled ground mesh
  42874. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42875. */
  42876. static CreateTiledGround(name: string, options: {
  42877. xmin: number;
  42878. zmin: number;
  42879. xmax: number;
  42880. zmax: number;
  42881. subdivisions?: {
  42882. w: number;
  42883. h: number;
  42884. };
  42885. precision?: {
  42886. w: number;
  42887. h: number;
  42888. };
  42889. updatable?: boolean;
  42890. }, scene?: Nullable<Scene>): Mesh;
  42891. /**
  42892. * Creates a ground mesh from a height map
  42893. * * The parameter `url` sets the URL of the height map image resource.
  42894. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42895. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42896. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42897. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42898. * * 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.
  42899. * * 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).
  42900. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42902. * @param name defines the name of the mesh
  42903. * @param url defines the url to the height map
  42904. * @param options defines the options used to create the mesh
  42905. * @param scene defines the hosting scene
  42906. * @returns the ground mesh
  42907. * @see https://doc.babylonjs.com/babylon101/height_map
  42908. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42909. */
  42910. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42911. width?: number;
  42912. height?: number;
  42913. subdivisions?: number;
  42914. minHeight?: number;
  42915. maxHeight?: number;
  42916. colorFilter?: Color3;
  42917. alphaFilter?: number;
  42918. updatable?: boolean;
  42919. onReady?: (mesh: GroundMesh) => void;
  42920. }, scene?: Nullable<Scene>): GroundMesh;
  42921. }
  42922. }
  42923. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42924. import { Vector4 } from "babylonjs/Maths/math.vector";
  42925. import { Mesh } from "babylonjs/Meshes/mesh";
  42926. /**
  42927. * Class containing static functions to help procedurally build meshes
  42928. */
  42929. export class TorusBuilder {
  42930. /**
  42931. * Creates a torus mesh
  42932. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42933. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42934. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42938. * @param name defines the name of the mesh
  42939. * @param options defines the options used to create the mesh
  42940. * @param scene defines the hosting scene
  42941. * @returns the torus mesh
  42942. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42943. */
  42944. static CreateTorus(name: string, options: {
  42945. diameter?: number;
  42946. thickness?: number;
  42947. tessellation?: number;
  42948. updatable?: boolean;
  42949. sideOrientation?: number;
  42950. frontUVs?: Vector4;
  42951. backUVs?: Vector4;
  42952. }, scene: any): Mesh;
  42953. }
  42954. }
  42955. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42956. import { Vector4 } from "babylonjs/Maths/math.vector";
  42957. import { Color4 } from "babylonjs/Maths/math.color";
  42958. import { Mesh } from "babylonjs/Meshes/mesh";
  42959. /**
  42960. * Class containing static functions to help procedurally build meshes
  42961. */
  42962. export class CylinderBuilder {
  42963. /**
  42964. * Creates a cylinder or a cone mesh
  42965. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42966. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42967. * * 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.
  42968. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42969. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42970. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42971. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42972. * * 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).
  42973. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42974. * * 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).
  42975. * * 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
  42976. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42977. * * 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
  42978. * * 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.
  42979. * * If `enclose` is false, a ring surface is one element.
  42980. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42981. * * 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
  42982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42985. * @param name defines the name of the mesh
  42986. * @param options defines the options used to create the mesh
  42987. * @param scene defines the hosting scene
  42988. * @returns the cylinder mesh
  42989. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42990. */
  42991. static CreateCylinder(name: string, options: {
  42992. height?: number;
  42993. diameterTop?: number;
  42994. diameterBottom?: number;
  42995. diameter?: number;
  42996. tessellation?: number;
  42997. subdivisions?: number;
  42998. arc?: number;
  42999. faceColors?: Color4[];
  43000. faceUV?: Vector4[];
  43001. updatable?: boolean;
  43002. hasRings?: boolean;
  43003. enclose?: boolean;
  43004. cap?: number;
  43005. sideOrientation?: number;
  43006. frontUVs?: Vector4;
  43007. backUVs?: Vector4;
  43008. }, scene: any): Mesh;
  43009. }
  43010. }
  43011. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43012. import { Nullable } from "babylonjs/types";
  43013. import { IDisposable } from "babylonjs/scene";
  43014. /**
  43015. * States of the webXR experience
  43016. */
  43017. export enum WebXRState {
  43018. /**
  43019. * Transitioning to being in XR mode
  43020. */
  43021. ENTERING_XR = 0,
  43022. /**
  43023. * Transitioning to non XR mode
  43024. */
  43025. EXITING_XR = 1,
  43026. /**
  43027. * In XR mode and presenting
  43028. */
  43029. IN_XR = 2,
  43030. /**
  43031. * Not entered XR mode
  43032. */
  43033. NOT_IN_XR = 3
  43034. }
  43035. /**
  43036. * Abstraction of the XR render target
  43037. */
  43038. export interface WebXRRenderTarget extends IDisposable {
  43039. /**
  43040. * xrpresent context of the canvas which can be used to display/mirror xr content
  43041. */
  43042. canvasContext: WebGLRenderingContext;
  43043. /**
  43044. * xr layer for the canvas
  43045. */
  43046. xrLayer: Nullable<XRWebGLLayer>;
  43047. /**
  43048. * Initializes the xr layer for the session
  43049. * @param xrSession xr session
  43050. * @returns a promise that will resolve once the XR Layer has been created
  43051. */
  43052. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43053. }
  43054. }
  43055. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43056. import { Nullable } from "babylonjs/types";
  43057. import { Observable } from "babylonjs/Misc/observable";
  43058. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43059. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43060. /**
  43061. * COnfiguration object for WebXR output canvas
  43062. */
  43063. export class WebXRManagedOutputCanvasOptions {
  43064. /**
  43065. * Options for this XR Layer output
  43066. */
  43067. canvasOptions: XRWebGLLayerOptions;
  43068. /**
  43069. * CSS styling for a newly created canvas (if not provided)
  43070. */
  43071. newCanvasCssStyle?: string;
  43072. /**
  43073. * Get the default values of the configuration object
  43074. * @returns default values of this configuration object
  43075. */
  43076. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43077. }
  43078. /**
  43079. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43080. */
  43081. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43082. private configuration;
  43083. private _engine;
  43084. private _canvas;
  43085. /**
  43086. * xrpresent context of the canvas which can be used to display/mirror xr content
  43087. */
  43088. canvasContext: WebGLRenderingContext;
  43089. /**
  43090. * xr layer for the canvas
  43091. */
  43092. xrLayer: Nullable<XRWebGLLayer>;
  43093. /**
  43094. * Initializes the xr layer for the session
  43095. * @param xrSession xr session
  43096. * @returns a promise that will resolve once the XR Layer has been created
  43097. */
  43098. initializeXRLayerAsync(xrSession: any): any;
  43099. /**
  43100. * Initializes the canvas to be added/removed upon entering/exiting xr
  43101. * @param engine the Babylon engine
  43102. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43103. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43104. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43105. */
  43106. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43107. /**
  43108. * Disposes of the object
  43109. */
  43110. dispose(): void;
  43111. private _setManagedOutputCanvas;
  43112. private _addCanvas;
  43113. private _removeCanvas;
  43114. }
  43115. }
  43116. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43117. import { Observable } from "babylonjs/Misc/observable";
  43118. import { Nullable } from "babylonjs/types";
  43119. import { IDisposable, Scene } from "babylonjs/scene";
  43120. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43121. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43122. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43123. /**
  43124. * Manages an XRSession to work with Babylon's engine
  43125. * @see https://doc.babylonjs.com/how_to/webxr
  43126. */
  43127. export class WebXRSessionManager implements IDisposable {
  43128. private scene;
  43129. /**
  43130. * Fires every time a new xrFrame arrives which can be used to update the camera
  43131. */
  43132. onXRFrameObservable: Observable<any>;
  43133. /**
  43134. * Fires when the xr session is ended either by the device or manually done
  43135. */
  43136. onXRSessionEnded: Observable<any>;
  43137. /**
  43138. * Underlying xr session
  43139. */
  43140. session: XRSession;
  43141. /**
  43142. * Type of reference space used when creating the session
  43143. */
  43144. referenceSpace: XRReferenceSpace;
  43145. /**
  43146. * Current XR frame
  43147. */
  43148. currentFrame: Nullable<XRFrame>;
  43149. private _xrNavigator;
  43150. private baseLayer;
  43151. private _rttProvider;
  43152. private _sessionEnded;
  43153. /**
  43154. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43155. * @param scene The scene which the session should be created for
  43156. */
  43157. constructor(scene: Scene);
  43158. /**
  43159. * Initializes the manager
  43160. * After initialization enterXR can be called to start an XR session
  43161. * @returns Promise which resolves after it is initialized
  43162. */
  43163. initializeAsync(): Promise<void>;
  43164. /**
  43165. * Initializes an xr session
  43166. * @param xrSessionMode mode to initialize
  43167. * @param optionalFeatures defines optional values to pass to the session builder
  43168. * @returns a promise which will resolve once the session has been initialized
  43169. */
  43170. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43171. /**
  43172. * Sets the reference space on the xr session
  43173. * @param referenceSpace space to set
  43174. * @returns a promise that will resolve once the reference space has been set
  43175. */
  43176. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43177. /**
  43178. * Updates the render state of the session
  43179. * @param state state to set
  43180. * @returns a promise that resolves once the render state has been updated
  43181. */
  43182. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43183. /**
  43184. * Starts rendering to the xr layer
  43185. * @returns a promise that will resolve once rendering has started
  43186. */
  43187. startRenderingToXRAsync(): Promise<void>;
  43188. /**
  43189. * Gets the correct render target texture to be rendered this frame for this eye
  43190. * @param eye the eye for which to get the render target
  43191. * @returns the render target for the specified eye
  43192. */
  43193. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43194. /**
  43195. * Stops the xrSession and restores the renderloop
  43196. * @returns Promise which resolves after it exits XR
  43197. */
  43198. exitXRAsync(): Promise<void>;
  43199. /**
  43200. * Checks if a session would be supported for the creation options specified
  43201. * @param sessionMode session mode to check if supported eg. immersive-vr
  43202. * @returns true if supported
  43203. */
  43204. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43205. /**
  43206. * Creates a WebXRRenderTarget object for the XR session
  43207. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43208. * @param options optional options to provide when creating a new render target
  43209. * @returns a WebXR render target to which the session can render
  43210. */
  43211. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43212. /**
  43213. * @hidden
  43214. * Converts the render layer of xrSession to a render target
  43215. * @param session session to create render target for
  43216. * @param scene scene the new render target should be created for
  43217. */
  43218. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43219. /**
  43220. * Disposes of the session manager
  43221. */
  43222. dispose(): void;
  43223. /**
  43224. * Gets a promise returning true when fullfiled if the given session mode is supported
  43225. * @param sessionMode defines the session to test
  43226. * @returns a promise
  43227. */
  43228. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43229. }
  43230. }
  43231. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43232. import { Scene } from "babylonjs/scene";
  43233. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43234. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43235. /**
  43236. * WebXR Camera which holds the views for the xrSession
  43237. * @see https://doc.babylonjs.com/how_to/webxr
  43238. */
  43239. export class WebXRCamera extends FreeCamera {
  43240. /**
  43241. * Is the camera in debug mode. Used when using an emulator
  43242. */
  43243. debugMode: boolean;
  43244. /**
  43245. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43246. * @param name the name of the camera
  43247. * @param scene the scene to add the camera to
  43248. */
  43249. constructor(name: string, scene: Scene);
  43250. private _updateNumberOfRigCameras;
  43251. /** @hidden */
  43252. _updateForDualEyeDebugging(): void;
  43253. /**
  43254. * Updates the cameras position from the current pose information of the XR session
  43255. * @param xrSessionManager the session containing pose information
  43256. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43257. */
  43258. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43259. }
  43260. }
  43261. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43262. import { Observable } from "babylonjs/Misc/observable";
  43263. import { IDisposable, Scene } from "babylonjs/scene";
  43264. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43266. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43267. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43268. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43269. /**
  43270. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43271. * @see https://doc.babylonjs.com/how_to/webxr
  43272. */
  43273. export class WebXRExperienceHelper implements IDisposable {
  43274. private scene;
  43275. /**
  43276. * 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
  43277. */
  43278. container: AbstractMesh;
  43279. /**
  43280. * Camera used to render xr content
  43281. */
  43282. camera: WebXRCamera;
  43283. /**
  43284. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43285. */
  43286. state: WebXRState;
  43287. private _setState;
  43288. private static _TmpVector;
  43289. /**
  43290. * Fires when the state of the experience helper has changed
  43291. */
  43292. onStateChangedObservable: Observable<WebXRState>;
  43293. /** Session manager used to keep track of xr session */
  43294. sessionManager: WebXRSessionManager;
  43295. private _nonVRCamera;
  43296. private _originalSceneAutoClear;
  43297. private _supported;
  43298. /**
  43299. * Creates the experience helper
  43300. * @param scene the scene to attach the experience helper to
  43301. * @returns a promise for the experience helper
  43302. */
  43303. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43304. /**
  43305. * Creates a WebXRExperienceHelper
  43306. * @param scene The scene the helper should be created in
  43307. */
  43308. private constructor();
  43309. /**
  43310. * Exits XR mode and returns the scene to its original state
  43311. * @returns promise that resolves after xr mode has exited
  43312. */
  43313. exitXRAsync(): Promise<void>;
  43314. /**
  43315. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43316. * @param sessionMode options for the XR session
  43317. * @param referenceSpaceType frame of reference of the XR session
  43318. * @param renderTarget the output canvas that will be used to enter XR mode
  43319. * @returns promise that resolves after xr mode has entered
  43320. */
  43321. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43322. /**
  43323. * Updates the global position of the camera by moving the camera's container
  43324. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43325. * @param position The desired global position of the camera
  43326. */
  43327. setPositionOfCameraUsingContainer(position: Vector3): void;
  43328. /**
  43329. * Rotates the xr camera by rotating the camera's container around the camera's position
  43330. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43331. * @param rotation the desired quaternion rotation to apply to the camera
  43332. */
  43333. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43334. /**
  43335. * Disposes of the experience helper
  43336. */
  43337. dispose(): void;
  43338. }
  43339. }
  43340. declare module "babylonjs/Cameras/XR/webXRController" {
  43341. import { Nullable } from "babylonjs/types";
  43342. import { Observable } from "babylonjs/Misc/observable";
  43343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43344. import { Ray } from "babylonjs/Culling/ray";
  43345. import { Scene } from "babylonjs/scene";
  43346. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43347. /**
  43348. * Represents an XR input
  43349. */
  43350. export class WebXRController {
  43351. private scene;
  43352. /** The underlying input source for the controller */
  43353. inputSource: XRInputSource;
  43354. private parentContainer;
  43355. /**
  43356. * 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
  43357. */
  43358. grip?: AbstractMesh;
  43359. /**
  43360. * Pointer which can be used to select objects or attach a visible laser to
  43361. */
  43362. pointer: AbstractMesh;
  43363. private _gamepadMode;
  43364. /**
  43365. * If available, this is the gamepad object related to this controller.
  43366. * Using this object it is possible to get click events and trackpad changes of the
  43367. * webxr controller that is currently being used.
  43368. */
  43369. gamepadController?: WebVRController;
  43370. /**
  43371. * Event that fires when the controller is removed/disposed
  43372. */
  43373. onDisposeObservable: Observable<{}>;
  43374. private _tmpMatrix;
  43375. private _tmpQuaternion;
  43376. private _tmpVector;
  43377. /**
  43378. * Creates the controller
  43379. * @see https://doc.babylonjs.com/how_to/webxr
  43380. * @param scene the scene which the controller should be associated to
  43381. * @param inputSource the underlying input source for the controller
  43382. * @param parentContainer parent that the controller meshes should be children of
  43383. */
  43384. constructor(scene: Scene,
  43385. /** The underlying input source for the controller */
  43386. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43387. /**
  43388. * Updates the controller pose based on the given XRFrame
  43389. * @param xrFrame xr frame to update the pose with
  43390. * @param referenceSpace reference space to use
  43391. */
  43392. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43393. /**
  43394. * Gets a world space ray coming from the controller
  43395. * @param result the resulting ray
  43396. */
  43397. getWorldPointerRayToRef(result: Ray): void;
  43398. /**
  43399. * Get the scene associated with this controller
  43400. * @returns the scene object
  43401. */
  43402. getScene(): Scene;
  43403. /**
  43404. * Disposes of the object
  43405. */
  43406. dispose(): void;
  43407. }
  43408. }
  43409. declare module "babylonjs/Cameras/XR/webXRInput" {
  43410. import { Observable } from "babylonjs/Misc/observable";
  43411. import { IDisposable } from "babylonjs/scene";
  43412. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43413. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43414. /**
  43415. * XR input used to track XR inputs such as controllers/rays
  43416. */
  43417. export class WebXRInput implements IDisposable {
  43418. /**
  43419. * Base experience the input listens to
  43420. */
  43421. baseExperience: WebXRExperienceHelper;
  43422. /**
  43423. * XR controllers being tracked
  43424. */
  43425. controllers: Array<WebXRController>;
  43426. private _frameObserver;
  43427. private _stateObserver;
  43428. /**
  43429. * Event when a controller has been connected/added
  43430. */
  43431. onControllerAddedObservable: Observable<WebXRController>;
  43432. /**
  43433. * Event when a controller has been removed/disconnected
  43434. */
  43435. onControllerRemovedObservable: Observable<WebXRController>;
  43436. /**
  43437. * Initializes the WebXRInput
  43438. * @param baseExperience experience helper which the input should be created for
  43439. */
  43440. constructor(
  43441. /**
  43442. * Base experience the input listens to
  43443. */
  43444. baseExperience: WebXRExperienceHelper);
  43445. private _onInputSourcesChange;
  43446. private _addAndRemoveControllers;
  43447. /**
  43448. * Disposes of the object
  43449. */
  43450. dispose(): void;
  43451. }
  43452. }
  43453. declare module "babylonjs/Loading/sceneLoader" {
  43454. import { Observable } from "babylonjs/Misc/observable";
  43455. import { Nullable } from "babylonjs/types";
  43456. import { Scene } from "babylonjs/scene";
  43457. import { Engine } from "babylonjs/Engines/engine";
  43458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43459. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43460. import { AssetContainer } from "babylonjs/assetContainer";
  43461. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43462. import { Skeleton } from "babylonjs/Bones/skeleton";
  43463. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43464. import { WebRequest } from "babylonjs/Misc/webRequest";
  43465. /**
  43466. * Class used to represent data loading progression
  43467. */
  43468. export class SceneLoaderProgressEvent {
  43469. /** defines if data length to load can be evaluated */
  43470. readonly lengthComputable: boolean;
  43471. /** defines the loaded data length */
  43472. readonly loaded: number;
  43473. /** defines the data length to load */
  43474. readonly total: number;
  43475. /**
  43476. * Create a new progress event
  43477. * @param lengthComputable defines if data length to load can be evaluated
  43478. * @param loaded defines the loaded data length
  43479. * @param total defines the data length to load
  43480. */
  43481. constructor(
  43482. /** defines if data length to load can be evaluated */
  43483. lengthComputable: boolean,
  43484. /** defines the loaded data length */
  43485. loaded: number,
  43486. /** defines the data length to load */
  43487. total: number);
  43488. /**
  43489. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43490. * @param event defines the source event
  43491. * @returns a new SceneLoaderProgressEvent
  43492. */
  43493. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43494. }
  43495. /**
  43496. * Interface used by SceneLoader plugins to define supported file extensions
  43497. */
  43498. export interface ISceneLoaderPluginExtensions {
  43499. /**
  43500. * Defines the list of supported extensions
  43501. */
  43502. [extension: string]: {
  43503. isBinary: boolean;
  43504. };
  43505. }
  43506. /**
  43507. * Interface used by SceneLoader plugin factory
  43508. */
  43509. export interface ISceneLoaderPluginFactory {
  43510. /**
  43511. * Defines the name of the factory
  43512. */
  43513. name: string;
  43514. /**
  43515. * Function called to create a new plugin
  43516. * @return the new plugin
  43517. */
  43518. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43519. /**
  43520. * The callback that returns true if the data can be directly loaded.
  43521. * @param data string containing the file data
  43522. * @returns if the data can be loaded directly
  43523. */
  43524. canDirectLoad?(data: string): boolean;
  43525. }
  43526. /**
  43527. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43528. */
  43529. export interface ISceneLoaderPluginBase {
  43530. /**
  43531. * The friendly name of this plugin.
  43532. */
  43533. name: string;
  43534. /**
  43535. * The file extensions supported by this plugin.
  43536. */
  43537. extensions: string | ISceneLoaderPluginExtensions;
  43538. /**
  43539. * The callback called when loading from a url.
  43540. * @param scene scene loading this url
  43541. * @param url url to load
  43542. * @param onSuccess callback called when the file successfully loads
  43543. * @param onProgress callback called while file is loading (if the server supports this mode)
  43544. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43545. * @param onError callback called when the file fails to load
  43546. * @returns a file request object
  43547. */
  43548. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43549. /**
  43550. * The callback called when loading from a file object.
  43551. * @param scene scene loading this file
  43552. * @param file defines the file to load
  43553. * @param onSuccess defines the callback to call when data is loaded
  43554. * @param onProgress defines the callback to call during loading process
  43555. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43556. * @param onError defines the callback to call when an error occurs
  43557. * @returns a file request object
  43558. */
  43559. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43560. /**
  43561. * The callback that returns true if the data can be directly loaded.
  43562. * @param data string containing the file data
  43563. * @returns if the data can be loaded directly
  43564. */
  43565. canDirectLoad?(data: string): boolean;
  43566. /**
  43567. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43568. * @param scene scene loading this data
  43569. * @param data string containing the data
  43570. * @returns data to pass to the plugin
  43571. */
  43572. directLoad?(scene: Scene, data: string): any;
  43573. /**
  43574. * The callback that allows custom handling of the root url based on the response url.
  43575. * @param rootUrl the original root url
  43576. * @param responseURL the response url if available
  43577. * @returns the new root url
  43578. */
  43579. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43580. }
  43581. /**
  43582. * Interface used to define a SceneLoader plugin
  43583. */
  43584. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43585. /**
  43586. * Import meshes into a scene.
  43587. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43588. * @param scene The scene to import into
  43589. * @param data The data to import
  43590. * @param rootUrl The root url for scene and resources
  43591. * @param meshes The meshes array to import into
  43592. * @param particleSystems The particle systems array to import into
  43593. * @param skeletons The skeletons array to import into
  43594. * @param onError The callback when import fails
  43595. * @returns True if successful or false otherwise
  43596. */
  43597. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43598. /**
  43599. * Load into a scene.
  43600. * @param scene The scene to load into
  43601. * @param data The data to import
  43602. * @param rootUrl The root url for scene and resources
  43603. * @param onError The callback when import fails
  43604. * @returns True if successful or false otherwise
  43605. */
  43606. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43607. /**
  43608. * Load into an asset container.
  43609. * @param scene The scene to load into
  43610. * @param data The data to import
  43611. * @param rootUrl The root url for scene and resources
  43612. * @param onError The callback when import fails
  43613. * @returns The loaded asset container
  43614. */
  43615. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43616. }
  43617. /**
  43618. * Interface used to define an async SceneLoader plugin
  43619. */
  43620. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43621. /**
  43622. * Import meshes into a scene.
  43623. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43624. * @param scene The scene to import into
  43625. * @param data The data to import
  43626. * @param rootUrl The root url for scene and resources
  43627. * @param onProgress The callback when the load progresses
  43628. * @param fileName Defines the name of the file to load
  43629. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43630. */
  43631. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43632. meshes: AbstractMesh[];
  43633. particleSystems: IParticleSystem[];
  43634. skeletons: Skeleton[];
  43635. animationGroups: AnimationGroup[];
  43636. }>;
  43637. /**
  43638. * Load into a scene.
  43639. * @param scene The scene to load into
  43640. * @param data The data to import
  43641. * @param rootUrl The root url for scene and resources
  43642. * @param onProgress The callback when the load progresses
  43643. * @param fileName Defines the name of the file to load
  43644. * @returns Nothing
  43645. */
  43646. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43647. /**
  43648. * Load into an asset container.
  43649. * @param scene The scene to load into
  43650. * @param data The data to import
  43651. * @param rootUrl The root url for scene and resources
  43652. * @param onProgress The callback when the load progresses
  43653. * @param fileName Defines the name of the file to load
  43654. * @returns The loaded asset container
  43655. */
  43656. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43657. }
  43658. /**
  43659. * Class used to load scene from various file formats using registered plugins
  43660. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43661. */
  43662. export class SceneLoader {
  43663. /**
  43664. * No logging while loading
  43665. */
  43666. static readonly NO_LOGGING: number;
  43667. /**
  43668. * Minimal logging while loading
  43669. */
  43670. static readonly MINIMAL_LOGGING: number;
  43671. /**
  43672. * Summary logging while loading
  43673. */
  43674. static readonly SUMMARY_LOGGING: number;
  43675. /**
  43676. * Detailled logging while loading
  43677. */
  43678. static readonly DETAILED_LOGGING: number;
  43679. /**
  43680. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43681. */
  43682. static ForceFullSceneLoadingForIncremental: boolean;
  43683. /**
  43684. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43685. */
  43686. static ShowLoadingScreen: boolean;
  43687. /**
  43688. * Defines the current logging level (while loading the scene)
  43689. * @ignorenaming
  43690. */
  43691. static loggingLevel: number;
  43692. /**
  43693. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43694. */
  43695. static CleanBoneMatrixWeights: boolean;
  43696. /**
  43697. * Event raised when a plugin is used to load a scene
  43698. */
  43699. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43700. private static _registeredPlugins;
  43701. private static _getDefaultPlugin;
  43702. private static _getPluginForExtension;
  43703. private static _getPluginForDirectLoad;
  43704. private static _getPluginForFilename;
  43705. private static _getDirectLoad;
  43706. private static _loadData;
  43707. private static _getFileInfo;
  43708. /**
  43709. * Gets a plugin that can load the given extension
  43710. * @param extension defines the extension to load
  43711. * @returns a plugin or null if none works
  43712. */
  43713. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43714. /**
  43715. * Gets a boolean indicating that the given extension can be loaded
  43716. * @param extension defines the extension to load
  43717. * @returns true if the extension is supported
  43718. */
  43719. static IsPluginForExtensionAvailable(extension: string): boolean;
  43720. /**
  43721. * Adds a new plugin to the list of registered plugins
  43722. * @param plugin defines the plugin to add
  43723. */
  43724. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43725. /**
  43726. * Import meshes into a scene
  43727. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43728. * @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)
  43729. * @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)
  43730. * @param scene the instance of BABYLON.Scene to append to
  43731. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43732. * @param onProgress a callback with a progress event for each file being loaded
  43733. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43734. * @param pluginExtension the extension used to determine the plugin
  43735. * @returns The loaded plugin
  43736. */
  43737. 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>;
  43738. /**
  43739. * Import meshes into a scene
  43740. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43741. * @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)
  43742. * @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)
  43743. * @param scene the instance of BABYLON.Scene to append to
  43744. * @param onProgress a callback with a progress event for each file being loaded
  43745. * @param pluginExtension the extension used to determine the plugin
  43746. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43747. */
  43748. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43749. meshes: AbstractMesh[];
  43750. particleSystems: IParticleSystem[];
  43751. skeletons: Skeleton[];
  43752. animationGroups: AnimationGroup[];
  43753. }>;
  43754. /**
  43755. * Load a scene
  43756. * @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)
  43757. * @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)
  43758. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43759. * @param onSuccess a callback with the scene when import succeeds
  43760. * @param onProgress a callback with a progress event for each file being loaded
  43761. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43762. * @param pluginExtension the extension used to determine the plugin
  43763. * @returns The loaded plugin
  43764. */
  43765. 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>;
  43766. /**
  43767. * Load a scene
  43768. * @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)
  43769. * @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)
  43770. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43771. * @param onProgress a callback with a progress event for each file being loaded
  43772. * @param pluginExtension the extension used to determine the plugin
  43773. * @returns The loaded scene
  43774. */
  43775. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43776. /**
  43777. * Append a scene
  43778. * @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)
  43779. * @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)
  43780. * @param scene is the instance of BABYLON.Scene to append to
  43781. * @param onSuccess a callback with the scene when import succeeds
  43782. * @param onProgress a callback with a progress event for each file being loaded
  43783. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43784. * @param pluginExtension the extension used to determine the plugin
  43785. * @returns The loaded plugin
  43786. */
  43787. 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>;
  43788. /**
  43789. * Append a scene
  43790. * @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)
  43791. * @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)
  43792. * @param scene is the instance of BABYLON.Scene to append to
  43793. * @param onProgress a callback with a progress event for each file being loaded
  43794. * @param pluginExtension the extension used to determine the plugin
  43795. * @returns The given scene
  43796. */
  43797. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43798. /**
  43799. * Load a scene into an asset container
  43800. * @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)
  43801. * @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)
  43802. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43803. * @param onSuccess a callback with the scene when import succeeds
  43804. * @param onProgress a callback with a progress event for each file being loaded
  43805. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43806. * @param pluginExtension the extension used to determine the plugin
  43807. * @returns The loaded plugin
  43808. */
  43809. 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>;
  43810. /**
  43811. * Load a scene into an asset container
  43812. * @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)
  43813. * @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)
  43814. * @param scene is the instance of Scene to append to
  43815. * @param onProgress a callback with a progress event for each file being loaded
  43816. * @param pluginExtension the extension used to determine the plugin
  43817. * @returns The loaded asset container
  43818. */
  43819. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43820. }
  43821. }
  43822. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43823. import { Scene } from "babylonjs/scene";
  43824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43825. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43826. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43827. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43828. /**
  43829. * Generic Controller
  43830. */
  43831. export class GenericController extends WebVRController {
  43832. /**
  43833. * Base Url for the controller model.
  43834. */
  43835. static readonly MODEL_BASE_URL: string;
  43836. /**
  43837. * File name for the controller model.
  43838. */
  43839. static readonly MODEL_FILENAME: string;
  43840. /**
  43841. * Creates a new GenericController from a gamepad
  43842. * @param vrGamepad the gamepad that the controller should be created from
  43843. */
  43844. constructor(vrGamepad: any);
  43845. /**
  43846. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43847. * @param scene scene in which to add meshes
  43848. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43849. */
  43850. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43851. /**
  43852. * Called once for each button that changed state since the last frame
  43853. * @param buttonIdx Which button index changed
  43854. * @param state New state of the button
  43855. * @param changes Which properties on the state changed since last frame
  43856. */
  43857. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43858. }
  43859. }
  43860. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43861. import { Observable } from "babylonjs/Misc/observable";
  43862. import { Scene } from "babylonjs/scene";
  43863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43864. import { Ray } from "babylonjs/Culling/ray";
  43865. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43866. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43867. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43868. /**
  43869. * Defines the WindowsMotionController object that the state of the windows motion controller
  43870. */
  43871. export class WindowsMotionController extends WebVRController {
  43872. /**
  43873. * The base url used to load the left and right controller models
  43874. */
  43875. static MODEL_BASE_URL: string;
  43876. /**
  43877. * The name of the left controller model file
  43878. */
  43879. static MODEL_LEFT_FILENAME: string;
  43880. /**
  43881. * The name of the right controller model file
  43882. */
  43883. static MODEL_RIGHT_FILENAME: string;
  43884. /**
  43885. * The controller name prefix for this controller type
  43886. */
  43887. static readonly GAMEPAD_ID_PREFIX: string;
  43888. /**
  43889. * The controller id pattern for this controller type
  43890. */
  43891. private static readonly GAMEPAD_ID_PATTERN;
  43892. private _loadedMeshInfo;
  43893. private readonly _mapping;
  43894. /**
  43895. * Fired when the trackpad on this controller is clicked
  43896. */
  43897. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43898. /**
  43899. * Fired when the trackpad on this controller is modified
  43900. */
  43901. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43902. /**
  43903. * The current x and y values of this controller's trackpad
  43904. */
  43905. trackpad: StickValues;
  43906. /**
  43907. * Creates a new WindowsMotionController from a gamepad
  43908. * @param vrGamepad the gamepad that the controller should be created from
  43909. */
  43910. constructor(vrGamepad: any);
  43911. /**
  43912. * Fired when the trigger on this controller is modified
  43913. */
  43914. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43915. /**
  43916. * Fired when the menu button on this controller is modified
  43917. */
  43918. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43919. /**
  43920. * Fired when the grip button on this controller is modified
  43921. */
  43922. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43923. /**
  43924. * Fired when the thumbstick button on this controller is modified
  43925. */
  43926. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43927. /**
  43928. * Fired when the touchpad button on this controller is modified
  43929. */
  43930. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43931. /**
  43932. * Fired when the touchpad values on this controller are modified
  43933. */
  43934. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43935. private _updateTrackpad;
  43936. /**
  43937. * Called once per frame by the engine.
  43938. */
  43939. update(): void;
  43940. /**
  43941. * Called once for each button that changed state since the last frame
  43942. * @param buttonIdx Which button index changed
  43943. * @param state New state of the button
  43944. * @param changes Which properties on the state changed since last frame
  43945. */
  43946. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43947. /**
  43948. * Moves the buttons on the controller mesh based on their current state
  43949. * @param buttonName the name of the button to move
  43950. * @param buttonValue the value of the button which determines the buttons new position
  43951. */
  43952. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43953. /**
  43954. * Moves the axis on the controller mesh based on its current state
  43955. * @param axis the index of the axis
  43956. * @param axisValue the value of the axis which determines the meshes new position
  43957. * @hidden
  43958. */
  43959. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43960. /**
  43961. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43962. * @param scene scene in which to add meshes
  43963. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43964. */
  43965. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43966. /**
  43967. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43968. * can be transformed by button presses and axes values, based on this._mapping.
  43969. *
  43970. * @param scene scene in which the meshes exist
  43971. * @param meshes list of meshes that make up the controller model to process
  43972. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43973. */
  43974. private processModel;
  43975. private createMeshInfo;
  43976. /**
  43977. * Gets the ray of the controller in the direction the controller is pointing
  43978. * @param length the length the resulting ray should be
  43979. * @returns a ray in the direction the controller is pointing
  43980. */
  43981. getForwardRay(length?: number): Ray;
  43982. /**
  43983. * Disposes of the controller
  43984. */
  43985. dispose(): void;
  43986. }
  43987. }
  43988. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43989. import { Observable } from "babylonjs/Misc/observable";
  43990. import { Scene } from "babylonjs/scene";
  43991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43992. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43993. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43994. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43995. /**
  43996. * Oculus Touch Controller
  43997. */
  43998. export class OculusTouchController extends WebVRController {
  43999. /**
  44000. * Base Url for the controller model.
  44001. */
  44002. static MODEL_BASE_URL: string;
  44003. /**
  44004. * File name for the left controller model.
  44005. */
  44006. static MODEL_LEFT_FILENAME: string;
  44007. /**
  44008. * File name for the right controller model.
  44009. */
  44010. static MODEL_RIGHT_FILENAME: string;
  44011. /**
  44012. * Base Url for the Quest controller model.
  44013. */
  44014. static QUEST_MODEL_BASE_URL: string;
  44015. /**
  44016. * @hidden
  44017. * If the controllers are running on a device that needs the updated Quest controller models
  44018. */
  44019. static _IsQuest: boolean;
  44020. /**
  44021. * Fired when the secondary trigger on this controller is modified
  44022. */
  44023. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44024. /**
  44025. * Fired when the thumb rest on this controller is modified
  44026. */
  44027. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44028. /**
  44029. * Creates a new OculusTouchController from a gamepad
  44030. * @param vrGamepad the gamepad that the controller should be created from
  44031. */
  44032. constructor(vrGamepad: any);
  44033. /**
  44034. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44035. * @param scene scene in which to add meshes
  44036. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44037. */
  44038. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44039. /**
  44040. * Fired when the A button on this controller is modified
  44041. */
  44042. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44043. /**
  44044. * Fired when the B button on this controller is modified
  44045. */
  44046. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44047. /**
  44048. * Fired when the X button on this controller is modified
  44049. */
  44050. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44051. /**
  44052. * Fired when the Y button on this controller is modified
  44053. */
  44054. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44055. /**
  44056. * Called once for each button that changed state since the last frame
  44057. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44058. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44059. * 2) secondary trigger (same)
  44060. * 3) A (right) X (left), touch, pressed = value
  44061. * 4) B / Y
  44062. * 5) thumb rest
  44063. * @param buttonIdx Which button index changed
  44064. * @param state New state of the button
  44065. * @param changes Which properties on the state changed since last frame
  44066. */
  44067. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44068. }
  44069. }
  44070. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44071. import { Scene } from "babylonjs/scene";
  44072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44073. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44074. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44075. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44076. import { Observable } from "babylonjs/Misc/observable";
  44077. /**
  44078. * Vive Controller
  44079. */
  44080. export class ViveController extends WebVRController {
  44081. /**
  44082. * Base Url for the controller model.
  44083. */
  44084. static MODEL_BASE_URL: string;
  44085. /**
  44086. * File name for the controller model.
  44087. */
  44088. static MODEL_FILENAME: string;
  44089. /**
  44090. * Creates a new ViveController from a gamepad
  44091. * @param vrGamepad the gamepad that the controller should be created from
  44092. */
  44093. constructor(vrGamepad: any);
  44094. /**
  44095. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44096. * @param scene scene in which to add meshes
  44097. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44098. */
  44099. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44100. /**
  44101. * Fired when the left button on this controller is modified
  44102. */
  44103. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44104. /**
  44105. * Fired when the right button on this controller is modified
  44106. */
  44107. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44108. /**
  44109. * Fired when the menu button on this controller is modified
  44110. */
  44111. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44112. /**
  44113. * Called once for each button that changed state since the last frame
  44114. * Vive mapping:
  44115. * 0: touchpad
  44116. * 1: trigger
  44117. * 2: left AND right buttons
  44118. * 3: menu button
  44119. * @param buttonIdx Which button index changed
  44120. * @param state New state of the button
  44121. * @param changes Which properties on the state changed since last frame
  44122. */
  44123. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44124. }
  44125. }
  44126. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44127. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44128. import { Observable } from "babylonjs/Misc/observable";
  44129. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44130. /**
  44131. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44132. */
  44133. export class WebXRControllerModelLoader {
  44134. /**
  44135. * an observable that triggers when a new model (the mesh itself) was initialized.
  44136. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44137. */
  44138. onControllerModelLoaded: Observable<WebXRController>;
  44139. /**
  44140. * Creates the WebXRControllerModelLoader
  44141. * @param input xr input that creates the controllers
  44142. */
  44143. constructor(input: WebXRInput);
  44144. }
  44145. }
  44146. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  44147. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44148. /**
  44149. * Handles pointer input automatically for the pointer of XR controllers
  44150. */
  44151. export class WebXRControllerPointerSelection {
  44152. private static _idCounter;
  44153. private _tmpRay;
  44154. /**
  44155. * Creates a WebXRControllerPointerSelection
  44156. * @param input input manager to setup pointer selection
  44157. */
  44158. constructor(input: WebXRInput);
  44159. private _convertNormalToDirectionOfRay;
  44160. private _updatePointerDistance;
  44161. }
  44162. }
  44163. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  44164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44165. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44166. /**
  44167. * Enables teleportation
  44168. */
  44169. export class WebXRControllerTeleportation {
  44170. private _teleportationFillColor;
  44171. private _teleportationBorderColor;
  44172. private _tmpRay;
  44173. private _tmpVector;
  44174. /**
  44175. * Creates a WebXRControllerTeleportation
  44176. * @param input input manager to add teleportation to
  44177. * @param floorMeshes floormeshes which can be teleported to
  44178. */
  44179. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  44180. }
  44181. }
  44182. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  44183. import { Nullable } from "babylonjs/types";
  44184. import { Observable } from "babylonjs/Misc/observable";
  44185. import { IDisposable, Scene } from "babylonjs/scene";
  44186. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44187. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44188. /**
  44189. * Button which can be used to enter a different mode of XR
  44190. */
  44191. export class WebXREnterExitUIButton {
  44192. /** button element */
  44193. element: HTMLElement;
  44194. /** XR initialization options for the button */
  44195. sessionMode: XRSessionMode;
  44196. /** Reference space type */
  44197. referenceSpaceType: XRReferenceSpaceType;
  44198. /**
  44199. * Creates a WebXREnterExitUIButton
  44200. * @param element button element
  44201. * @param sessionMode XR initialization session mode
  44202. * @param referenceSpaceType the type of reference space to be used
  44203. */
  44204. constructor(
  44205. /** button element */
  44206. element: HTMLElement,
  44207. /** XR initialization options for the button */
  44208. sessionMode: XRSessionMode,
  44209. /** Reference space type */
  44210. referenceSpaceType: XRReferenceSpaceType);
  44211. /**
  44212. * Overwritable function which can be used to update the button's visuals when the state changes
  44213. * @param activeButton the current active button in the UI
  44214. */
  44215. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44216. }
  44217. /**
  44218. * Options to create the webXR UI
  44219. */
  44220. export class WebXREnterExitUIOptions {
  44221. /**
  44222. * Context to enter xr with
  44223. */
  44224. renderTarget?: Nullable<WebXRRenderTarget>;
  44225. /**
  44226. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44227. */
  44228. customButtons?: Array<WebXREnterExitUIButton>;
  44229. /**
  44230. * A session mode to use when creating the default button.
  44231. * Default is immersive-vr
  44232. */
  44233. sessionMode?: XRSessionMode;
  44234. /**
  44235. * A reference space type to use when creating the default button.
  44236. * Default is local-floor
  44237. */
  44238. referenceSpaceType?: XRReferenceSpaceType;
  44239. }
  44240. /**
  44241. * UI to allow the user to enter/exit XR mode
  44242. */
  44243. export class WebXREnterExitUI implements IDisposable {
  44244. private scene;
  44245. private _overlay;
  44246. private _buttons;
  44247. private _activeButton;
  44248. /**
  44249. * Fired every time the active button is changed.
  44250. *
  44251. * When xr is entered via a button that launches xr that button will be the callback parameter
  44252. *
  44253. * When exiting xr the callback parameter will be null)
  44254. */
  44255. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44256. /**
  44257. * Creates UI to allow the user to enter/exit XR mode
  44258. * @param scene the scene to add the ui to
  44259. * @param helper the xr experience helper to enter/exit xr with
  44260. * @param options options to configure the UI
  44261. * @returns the created ui
  44262. */
  44263. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44264. private constructor();
  44265. private _updateButtons;
  44266. /**
  44267. * Disposes of the object
  44268. */
  44269. dispose(): void;
  44270. }
  44271. }
  44272. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44273. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44274. import { Scene } from "babylonjs/scene";
  44275. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44276. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44277. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44278. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44279. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44280. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44282. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44283. /**
  44284. * Options for the default xr helper
  44285. */
  44286. export class WebXRDefaultExperienceOptions {
  44287. /**
  44288. * Floor meshes that should be used for teleporting
  44289. */
  44290. floorMeshes: Array<AbstractMesh>;
  44291. /**
  44292. * Enable or disable default UI to enter XR
  44293. */
  44294. disableDefaultUI?: boolean;
  44295. /**
  44296. * optional configuration for the output canvas
  44297. */
  44298. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44299. }
  44300. /**
  44301. * Default experience which provides a similar setup to the previous webVRExperience
  44302. */
  44303. export class WebXRDefaultExperience {
  44304. /**
  44305. * Base experience
  44306. */
  44307. baseExperience: WebXRExperienceHelper;
  44308. /**
  44309. * Input experience extension
  44310. */
  44311. input: WebXRInput;
  44312. /**
  44313. * Loads the controller models
  44314. */
  44315. controllerModelLoader: WebXRControllerModelLoader;
  44316. /**
  44317. * Enables laser pointer and selection
  44318. */
  44319. pointerSelection: WebXRControllerPointerSelection;
  44320. /**
  44321. * Enables teleportation
  44322. */
  44323. teleportation: WebXRControllerTeleportation;
  44324. /**
  44325. * Enables ui for enetering/exiting xr
  44326. */
  44327. enterExitUI: WebXREnterExitUI;
  44328. /**
  44329. * Default target xr should render to
  44330. */
  44331. renderTarget: WebXRRenderTarget;
  44332. /**
  44333. * Creates the default xr experience
  44334. * @param scene scene
  44335. * @param options options for basic configuration
  44336. * @returns resulting WebXRDefaultExperience
  44337. */
  44338. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44339. private constructor();
  44340. /**
  44341. * DIsposes of the experience helper
  44342. */
  44343. dispose(): void;
  44344. }
  44345. }
  44346. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  44347. import { Observable } from "babylonjs/Misc/observable";
  44348. import { Nullable } from "babylonjs/types";
  44349. import { Camera } from "babylonjs/Cameras/camera";
  44350. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44351. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44352. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  44353. import { Scene } from "babylonjs/scene";
  44354. import { Vector3 } from "babylonjs/Maths/math.vector";
  44355. import { Color3 } from "babylonjs/Maths/math.color";
  44356. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44358. import { Mesh } from "babylonjs/Meshes/mesh";
  44359. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44360. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44361. import "babylonjs/Meshes/Builders/groundBuilder";
  44362. import "babylonjs/Meshes/Builders/torusBuilder";
  44363. import "babylonjs/Meshes/Builders/cylinderBuilder";
  44364. import "babylonjs/Gamepads/gamepadSceneComponent";
  44365. import "babylonjs/Animations/animatable";
  44366. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44367. /**
  44368. * Options to modify the vr teleportation behavior.
  44369. */
  44370. export interface VRTeleportationOptions {
  44371. /**
  44372. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44373. */
  44374. floorMeshName?: string;
  44375. /**
  44376. * A list of meshes to be used as the teleportation floor. (default: empty)
  44377. */
  44378. floorMeshes?: Mesh[];
  44379. /**
  44380. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44381. */
  44382. teleportationMode?: number;
  44383. /**
  44384. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44385. */
  44386. teleportationTime?: number;
  44387. /**
  44388. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44389. */
  44390. teleportationSpeed?: number;
  44391. }
  44392. /**
  44393. * Options to modify the vr experience helper's behavior.
  44394. */
  44395. export interface VRExperienceHelperOptions extends WebVROptions {
  44396. /**
  44397. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44398. */
  44399. createDeviceOrientationCamera?: boolean;
  44400. /**
  44401. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44402. */
  44403. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44404. /**
  44405. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44406. */
  44407. laserToggle?: boolean;
  44408. /**
  44409. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44410. */
  44411. floorMeshes?: Mesh[];
  44412. /**
  44413. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44414. */
  44415. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44416. /**
  44417. * Defines if WebXR should be used instead of WebVR (if available)
  44418. */
  44419. useXR?: boolean;
  44420. }
  44421. /**
  44422. * Event containing information after VR has been entered
  44423. */
  44424. export class OnAfterEnteringVRObservableEvent {
  44425. /**
  44426. * If entering vr was successful
  44427. */
  44428. success: boolean;
  44429. }
  44430. /**
  44431. * Helps to quickly add VR support to an existing scene.
  44432. * See http://doc.babylonjs.com/how_to/webvr_helper
  44433. */
  44434. export class VRExperienceHelper {
  44435. /** Options to modify the vr experience helper's behavior. */
  44436. webVROptions: VRExperienceHelperOptions;
  44437. private _scene;
  44438. private _position;
  44439. private _btnVR;
  44440. private _btnVRDisplayed;
  44441. private _webVRsupported;
  44442. private _webVRready;
  44443. private _webVRrequesting;
  44444. private _webVRpresenting;
  44445. private _hasEnteredVR;
  44446. private _fullscreenVRpresenting;
  44447. private _inputElement;
  44448. private _webVRCamera;
  44449. private _vrDeviceOrientationCamera;
  44450. private _deviceOrientationCamera;
  44451. private _existingCamera;
  44452. private _onKeyDown;
  44453. private _onVrDisplayPresentChange;
  44454. private _onVRDisplayChanged;
  44455. private _onVRRequestPresentStart;
  44456. private _onVRRequestPresentComplete;
  44457. /**
  44458. * 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)
  44459. */
  44460. enableGazeEvenWhenNoPointerLock: boolean;
  44461. /**
  44462. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44463. */
  44464. exitVROnDoubleTap: boolean;
  44465. /**
  44466. * Observable raised right before entering VR.
  44467. */
  44468. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44469. /**
  44470. * Observable raised when entering VR has completed.
  44471. */
  44472. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44473. /**
  44474. * Observable raised when exiting VR.
  44475. */
  44476. onExitingVRObservable: Observable<VRExperienceHelper>;
  44477. /**
  44478. * Observable raised when controller mesh is loaded.
  44479. */
  44480. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44481. /** Return this.onEnteringVRObservable
  44482. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44483. */
  44484. readonly onEnteringVR: Observable<VRExperienceHelper>;
  44485. /** Return this.onExitingVRObservable
  44486. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44487. */
  44488. readonly onExitingVR: Observable<VRExperienceHelper>;
  44489. /** Return this.onControllerMeshLoadedObservable
  44490. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44491. */
  44492. readonly onControllerMeshLoaded: Observable<WebVRController>;
  44493. private _rayLength;
  44494. private _useCustomVRButton;
  44495. private _teleportationRequested;
  44496. private _teleportActive;
  44497. private _floorMeshName;
  44498. private _floorMeshesCollection;
  44499. private _teleportationMode;
  44500. private _teleportationTime;
  44501. private _teleportationSpeed;
  44502. private _rotationAllowed;
  44503. private _teleportBackwardsVector;
  44504. private _teleportationTarget;
  44505. private _isDefaultTeleportationTarget;
  44506. private _postProcessMove;
  44507. private _teleportationFillColor;
  44508. private _teleportationBorderColor;
  44509. private _rotationAngle;
  44510. private _haloCenter;
  44511. private _cameraGazer;
  44512. private _padSensibilityUp;
  44513. private _padSensibilityDown;
  44514. private _leftController;
  44515. private _rightController;
  44516. /**
  44517. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44518. */
  44519. onNewMeshSelected: Observable<AbstractMesh>;
  44520. /**
  44521. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44522. * This observable will provide the mesh and the controller used to select the mesh
  44523. */
  44524. onMeshSelectedWithController: Observable<{
  44525. mesh: AbstractMesh;
  44526. controller: WebVRController;
  44527. }>;
  44528. /**
  44529. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44530. */
  44531. onNewMeshPicked: Observable<PickingInfo>;
  44532. private _circleEase;
  44533. /**
  44534. * Observable raised before camera teleportation
  44535. */
  44536. onBeforeCameraTeleport: Observable<Vector3>;
  44537. /**
  44538. * Observable raised after camera teleportation
  44539. */
  44540. onAfterCameraTeleport: Observable<Vector3>;
  44541. /**
  44542. * Observable raised when current selected mesh gets unselected
  44543. */
  44544. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44545. private _raySelectionPredicate;
  44546. /**
  44547. * To be optionaly changed by user to define custom ray selection
  44548. */
  44549. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44550. /**
  44551. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44552. */
  44553. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44554. /**
  44555. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44556. */
  44557. teleportationEnabled: boolean;
  44558. private _defaultHeight;
  44559. private _teleportationInitialized;
  44560. private _interactionsEnabled;
  44561. private _interactionsRequested;
  44562. private _displayGaze;
  44563. private _displayLaserPointer;
  44564. /**
  44565. * The mesh used to display where the user is going to teleport.
  44566. */
  44567. /**
  44568. * Sets the mesh to be used to display where the user is going to teleport.
  44569. */
  44570. teleportationTarget: Mesh;
  44571. /**
  44572. * 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
  44573. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44574. * See http://doc.babylonjs.com/resources/baking_transformations
  44575. */
  44576. gazeTrackerMesh: Mesh;
  44577. /**
  44578. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44579. */
  44580. updateGazeTrackerScale: boolean;
  44581. /**
  44582. * If the gaze trackers color should be updated when selecting meshes
  44583. */
  44584. updateGazeTrackerColor: boolean;
  44585. /**
  44586. * If the controller laser color should be updated when selecting meshes
  44587. */
  44588. updateControllerLaserColor: boolean;
  44589. /**
  44590. * The gaze tracking mesh corresponding to the left controller
  44591. */
  44592. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  44593. /**
  44594. * The gaze tracking mesh corresponding to the right controller
  44595. */
  44596. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  44597. /**
  44598. * If the ray of the gaze should be displayed.
  44599. */
  44600. /**
  44601. * Sets if the ray of the gaze should be displayed.
  44602. */
  44603. displayGaze: boolean;
  44604. /**
  44605. * If the ray of the LaserPointer should be displayed.
  44606. */
  44607. /**
  44608. * Sets if the ray of the LaserPointer should be displayed.
  44609. */
  44610. displayLaserPointer: boolean;
  44611. /**
  44612. * The deviceOrientationCamera used as the camera when not in VR.
  44613. */
  44614. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  44615. /**
  44616. * Based on the current WebVR support, returns the current VR camera used.
  44617. */
  44618. readonly currentVRCamera: Nullable<Camera>;
  44619. /**
  44620. * The webVRCamera which is used when in VR.
  44621. */
  44622. readonly webVRCamera: WebVRFreeCamera;
  44623. /**
  44624. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44625. */
  44626. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  44627. /**
  44628. * The html button that is used to trigger entering into VR.
  44629. */
  44630. readonly vrButton: Nullable<HTMLButtonElement>;
  44631. private readonly _teleportationRequestInitiated;
  44632. /**
  44633. * Defines wether or not Pointer lock should be requested when switching to
  44634. * full screen.
  44635. */
  44636. requestPointerLockOnFullScreen: boolean;
  44637. /**
  44638. * If asking to force XR, this will be populated with the default xr experience
  44639. */
  44640. xr: WebXRDefaultExperience;
  44641. /**
  44642. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44643. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44644. */
  44645. xrTestDone: boolean;
  44646. /**
  44647. * Instantiates a VRExperienceHelper.
  44648. * Helps to quickly add VR support to an existing scene.
  44649. * @param scene The scene the VRExperienceHelper belongs to.
  44650. * @param webVROptions Options to modify the vr experience helper's behavior.
  44651. */
  44652. constructor(scene: Scene,
  44653. /** Options to modify the vr experience helper's behavior. */
  44654. webVROptions?: VRExperienceHelperOptions);
  44655. private completeVRInit;
  44656. private _onDefaultMeshLoaded;
  44657. private _onResize;
  44658. private _onFullscreenChange;
  44659. /**
  44660. * Gets a value indicating if we are currently in VR mode.
  44661. */
  44662. readonly isInVRMode: boolean;
  44663. private onVrDisplayPresentChange;
  44664. private onVRDisplayChanged;
  44665. private moveButtonToBottomRight;
  44666. private displayVRButton;
  44667. private updateButtonVisibility;
  44668. private _cachedAngularSensibility;
  44669. /**
  44670. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44671. * Otherwise, will use the fullscreen API.
  44672. */
  44673. enterVR(): void;
  44674. /**
  44675. * Attempt to exit VR, or fullscreen.
  44676. */
  44677. exitVR(): void;
  44678. /**
  44679. * The position of the vr experience helper.
  44680. */
  44681. /**
  44682. * Sets the position of the vr experience helper.
  44683. */
  44684. position: Vector3;
  44685. /**
  44686. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44687. */
  44688. enableInteractions(): void;
  44689. private readonly _noControllerIsActive;
  44690. private beforeRender;
  44691. private _isTeleportationFloor;
  44692. /**
  44693. * Adds a floor mesh to be used for teleportation.
  44694. * @param floorMesh the mesh to be used for teleportation.
  44695. */
  44696. addFloorMesh(floorMesh: Mesh): void;
  44697. /**
  44698. * Removes a floor mesh from being used for teleportation.
  44699. * @param floorMesh the mesh to be removed.
  44700. */
  44701. removeFloorMesh(floorMesh: Mesh): void;
  44702. /**
  44703. * Enables interactions and teleportation using the VR controllers and gaze.
  44704. * @param vrTeleportationOptions options to modify teleportation behavior.
  44705. */
  44706. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44707. private _onNewGamepadConnected;
  44708. private _tryEnableInteractionOnController;
  44709. private _onNewGamepadDisconnected;
  44710. private _enableInteractionOnController;
  44711. private _checkTeleportWithRay;
  44712. private _checkRotate;
  44713. private _checkTeleportBackwards;
  44714. private _enableTeleportationOnController;
  44715. private _createTeleportationCircles;
  44716. private _displayTeleportationTarget;
  44717. private _hideTeleportationTarget;
  44718. private _rotateCamera;
  44719. private _moveTeleportationSelectorTo;
  44720. private _workingVector;
  44721. private _workingQuaternion;
  44722. private _workingMatrix;
  44723. /**
  44724. * Time Constant Teleportation Mode
  44725. */
  44726. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44727. /**
  44728. * Speed Constant Teleportation Mode
  44729. */
  44730. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44731. /**
  44732. * Teleports the users feet to the desired location
  44733. * @param location The location where the user's feet should be placed
  44734. */
  44735. teleportCamera(location: Vector3): void;
  44736. private _convertNormalToDirectionOfRay;
  44737. private _castRayAndSelectObject;
  44738. private _notifySelectedMeshUnselected;
  44739. /**
  44740. * Sets the color of the laser ray from the vr controllers.
  44741. * @param color new color for the ray.
  44742. */
  44743. changeLaserColor(color: Color3): void;
  44744. /**
  44745. * Sets the color of the ray from the vr headsets gaze.
  44746. * @param color new color for the ray.
  44747. */
  44748. changeGazeColor(color: Color3): void;
  44749. /**
  44750. * Exits VR and disposes of the vr experience helper
  44751. */
  44752. dispose(): void;
  44753. /**
  44754. * Gets the name of the VRExperienceHelper class
  44755. * @returns "VRExperienceHelper"
  44756. */
  44757. getClassName(): string;
  44758. }
  44759. }
  44760. declare module "babylonjs/Cameras/VR/index" {
  44761. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  44762. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  44763. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44764. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  44765. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  44766. export * from "babylonjs/Cameras/VR/webVRCamera";
  44767. }
  44768. declare module "babylonjs/Cameras/XR/index" {
  44769. export * from "babylonjs/Cameras/XR/webXRCamera";
  44770. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44771. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44772. export * from "babylonjs/Cameras/XR/webXRInput";
  44773. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44774. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44775. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44776. export * from "babylonjs/Cameras/XR/webXRController";
  44777. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44778. export * from "babylonjs/Cameras/XR/webXRTypes";
  44779. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44780. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44781. }
  44782. declare module "babylonjs/Cameras/RigModes/index" {
  44783. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44784. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44785. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44786. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44787. }
  44788. declare module "babylonjs/Cameras/index" {
  44789. export * from "babylonjs/Cameras/Inputs/index";
  44790. export * from "babylonjs/Cameras/cameraInputsManager";
  44791. export * from "babylonjs/Cameras/camera";
  44792. export * from "babylonjs/Cameras/targetCamera";
  44793. export * from "babylonjs/Cameras/freeCamera";
  44794. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44795. export * from "babylonjs/Cameras/touchCamera";
  44796. export * from "babylonjs/Cameras/arcRotateCamera";
  44797. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44798. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44799. export * from "babylonjs/Cameras/flyCamera";
  44800. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44801. export * from "babylonjs/Cameras/followCamera";
  44802. export * from "babylonjs/Cameras/followCameraInputsManager";
  44803. export * from "babylonjs/Cameras/gamepadCamera";
  44804. export * from "babylonjs/Cameras/Stereoscopic/index";
  44805. export * from "babylonjs/Cameras/universalCamera";
  44806. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44807. export * from "babylonjs/Cameras/VR/index";
  44808. export * from "babylonjs/Cameras/XR/index";
  44809. export * from "babylonjs/Cameras/RigModes/index";
  44810. }
  44811. declare module "babylonjs/Collisions/index" {
  44812. export * from "babylonjs/Collisions/collider";
  44813. export * from "babylonjs/Collisions/collisionCoordinator";
  44814. export * from "babylonjs/Collisions/pickingInfo";
  44815. export * from "babylonjs/Collisions/intersectionInfo";
  44816. export * from "babylonjs/Collisions/meshCollisionData";
  44817. }
  44818. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44819. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44820. import { Vector3 } from "babylonjs/Maths/math.vector";
  44821. import { Ray } from "babylonjs/Culling/ray";
  44822. import { Plane } from "babylonjs/Maths/math.plane";
  44823. /**
  44824. * Contains an array of blocks representing the octree
  44825. */
  44826. export interface IOctreeContainer<T> {
  44827. /**
  44828. * Blocks within the octree
  44829. */
  44830. blocks: Array<OctreeBlock<T>>;
  44831. }
  44832. /**
  44833. * Class used to store a cell in an octree
  44834. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44835. */
  44836. export class OctreeBlock<T> {
  44837. /**
  44838. * Gets the content of the current block
  44839. */
  44840. entries: T[];
  44841. /**
  44842. * Gets the list of block children
  44843. */
  44844. blocks: Array<OctreeBlock<T>>;
  44845. private _depth;
  44846. private _maxDepth;
  44847. private _capacity;
  44848. private _minPoint;
  44849. private _maxPoint;
  44850. private _boundingVectors;
  44851. private _creationFunc;
  44852. /**
  44853. * Creates a new block
  44854. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44855. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44856. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44857. * @param depth defines the current depth of this block in the octree
  44858. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44859. * @param creationFunc defines a callback to call when an element is added to the block
  44860. */
  44861. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44862. /**
  44863. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44864. */
  44865. readonly capacity: number;
  44866. /**
  44867. * Gets the minimum vector (in world space) of the block's bounding box
  44868. */
  44869. readonly minPoint: Vector3;
  44870. /**
  44871. * Gets the maximum vector (in world space) of the block's bounding box
  44872. */
  44873. readonly maxPoint: Vector3;
  44874. /**
  44875. * Add a new element to this block
  44876. * @param entry defines the element to add
  44877. */
  44878. addEntry(entry: T): void;
  44879. /**
  44880. * Remove an element from this block
  44881. * @param entry defines the element to remove
  44882. */
  44883. removeEntry(entry: T): void;
  44884. /**
  44885. * Add an array of elements to this block
  44886. * @param entries defines the array of elements to add
  44887. */
  44888. addEntries(entries: T[]): void;
  44889. /**
  44890. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44891. * @param frustumPlanes defines the frustum planes to test
  44892. * @param selection defines the array to store current content if selection is positive
  44893. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44894. */
  44895. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44896. /**
  44897. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44898. * @param sphereCenter defines the bounding sphere center
  44899. * @param sphereRadius defines the bounding sphere radius
  44900. * @param selection defines the array to store current content if selection is positive
  44901. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44902. */
  44903. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44904. /**
  44905. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44906. * @param ray defines the ray to test with
  44907. * @param selection defines the array to store current content if selection is positive
  44908. */
  44909. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44910. /**
  44911. * Subdivide the content into child blocks (this block will then be empty)
  44912. */
  44913. createInnerBlocks(): void;
  44914. /**
  44915. * @hidden
  44916. */
  44917. 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;
  44918. }
  44919. }
  44920. declare module "babylonjs/Culling/Octrees/octree" {
  44921. import { SmartArray } from "babylonjs/Misc/smartArray";
  44922. import { Vector3 } from "babylonjs/Maths/math.vector";
  44923. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44925. import { Ray } from "babylonjs/Culling/ray";
  44926. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44927. import { Plane } from "babylonjs/Maths/math.plane";
  44928. /**
  44929. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44930. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44931. */
  44932. export class Octree<T> {
  44933. /** 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.) */
  44934. maxDepth: number;
  44935. /**
  44936. * Blocks within the octree containing objects
  44937. */
  44938. blocks: Array<OctreeBlock<T>>;
  44939. /**
  44940. * Content stored in the octree
  44941. */
  44942. dynamicContent: T[];
  44943. private _maxBlockCapacity;
  44944. private _selectionContent;
  44945. private _creationFunc;
  44946. /**
  44947. * Creates a octree
  44948. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44949. * @param creationFunc function to be used to instatiate the octree
  44950. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44951. * @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.)
  44952. */
  44953. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44954. /** 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.) */
  44955. maxDepth?: number);
  44956. /**
  44957. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44958. * @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);
  44959. * @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);
  44960. * @param entries meshes to be added to the octree blocks
  44961. */
  44962. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44963. /**
  44964. * Adds a mesh to the octree
  44965. * @param entry Mesh to add to the octree
  44966. */
  44967. addMesh(entry: T): void;
  44968. /**
  44969. * Remove an element from the octree
  44970. * @param entry defines the element to remove
  44971. */
  44972. removeMesh(entry: T): void;
  44973. /**
  44974. * Selects an array of meshes within the frustum
  44975. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44976. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44977. * @returns array of meshes within the frustum
  44978. */
  44979. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44980. /**
  44981. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44982. * @param sphereCenter defines the bounding sphere center
  44983. * @param sphereRadius defines the bounding sphere radius
  44984. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44985. * @returns an array of objects that intersect the sphere
  44986. */
  44987. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44988. /**
  44989. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44990. * @param ray defines the ray to test with
  44991. * @returns array of intersected objects
  44992. */
  44993. intersectsRay(ray: Ray): SmartArray<T>;
  44994. /**
  44995. * Adds a mesh into the octree block if it intersects the block
  44996. */
  44997. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44998. /**
  44999. * Adds a submesh into the octree block if it intersects the block
  45000. */
  45001. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45002. }
  45003. }
  45004. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  45005. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  45006. import { Scene } from "babylonjs/scene";
  45007. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45009. import { Ray } from "babylonjs/Culling/ray";
  45010. import { Octree } from "babylonjs/Culling/Octrees/octree";
  45011. import { Collider } from "babylonjs/Collisions/collider";
  45012. module "babylonjs/scene" {
  45013. interface Scene {
  45014. /**
  45015. * @hidden
  45016. * Backing Filed
  45017. */
  45018. _selectionOctree: Octree<AbstractMesh>;
  45019. /**
  45020. * Gets the octree used to boost mesh selection (picking)
  45021. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45022. */
  45023. selectionOctree: Octree<AbstractMesh>;
  45024. /**
  45025. * Creates or updates the octree used to boost selection (picking)
  45026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45027. * @param maxCapacity defines the maximum capacity per leaf
  45028. * @param maxDepth defines the maximum depth of the octree
  45029. * @returns an octree of AbstractMesh
  45030. */
  45031. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45032. }
  45033. }
  45034. module "babylonjs/Meshes/abstractMesh" {
  45035. interface AbstractMesh {
  45036. /**
  45037. * @hidden
  45038. * Backing Field
  45039. */
  45040. _submeshesOctree: Octree<SubMesh>;
  45041. /**
  45042. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45043. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45044. * @param maxCapacity defines the maximum size of each block (64 by default)
  45045. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45046. * @returns the new octree
  45047. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45049. */
  45050. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45051. }
  45052. }
  45053. /**
  45054. * Defines the octree scene component responsible to manage any octrees
  45055. * in a given scene.
  45056. */
  45057. export class OctreeSceneComponent {
  45058. /**
  45059. * The component name help to identify the component in the list of scene components.
  45060. */
  45061. readonly name: string;
  45062. /**
  45063. * The scene the component belongs to.
  45064. */
  45065. scene: Scene;
  45066. /**
  45067. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45068. */
  45069. readonly checksIsEnabled: boolean;
  45070. /**
  45071. * Creates a new instance of the component for the given scene
  45072. * @param scene Defines the scene to register the component in
  45073. */
  45074. constructor(scene: Scene);
  45075. /**
  45076. * Registers the component in a given scene
  45077. */
  45078. register(): void;
  45079. /**
  45080. * Return the list of active meshes
  45081. * @returns the list of active meshes
  45082. */
  45083. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45084. /**
  45085. * Return the list of active sub meshes
  45086. * @param mesh The mesh to get the candidates sub meshes from
  45087. * @returns the list of active sub meshes
  45088. */
  45089. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45090. private _tempRay;
  45091. /**
  45092. * Return the list of sub meshes intersecting with a given local ray
  45093. * @param mesh defines the mesh to find the submesh for
  45094. * @param localRay defines the ray in local space
  45095. * @returns the list of intersecting sub meshes
  45096. */
  45097. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45098. /**
  45099. * Return the list of sub meshes colliding with a collider
  45100. * @param mesh defines the mesh to find the submesh for
  45101. * @param collider defines the collider to evaluate the collision against
  45102. * @returns the list of colliding sub meshes
  45103. */
  45104. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45105. /**
  45106. * Rebuilds the elements related to this component in case of
  45107. * context lost for instance.
  45108. */
  45109. rebuild(): void;
  45110. /**
  45111. * Disposes the component and the associated ressources.
  45112. */
  45113. dispose(): void;
  45114. }
  45115. }
  45116. declare module "babylonjs/Culling/Octrees/index" {
  45117. export * from "babylonjs/Culling/Octrees/octree";
  45118. export * from "babylonjs/Culling/Octrees/octreeBlock";
  45119. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  45120. }
  45121. declare module "babylonjs/Culling/index" {
  45122. export * from "babylonjs/Culling/boundingBox";
  45123. export * from "babylonjs/Culling/boundingInfo";
  45124. export * from "babylonjs/Culling/boundingSphere";
  45125. export * from "babylonjs/Culling/Octrees/index";
  45126. export * from "babylonjs/Culling/ray";
  45127. }
  45128. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45129. import { IDisposable, Scene } from "babylonjs/scene";
  45130. import { Nullable } from "babylonjs/types";
  45131. import { Observable } from "babylonjs/Misc/observable";
  45132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45133. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45134. import { Camera } from "babylonjs/Cameras/camera";
  45135. /**
  45136. * Renders a layer on top of an existing scene
  45137. */
  45138. export class UtilityLayerRenderer implements IDisposable {
  45139. /** the original scene that will be rendered on top of */
  45140. originalScene: Scene;
  45141. private _pointerCaptures;
  45142. private _lastPointerEvents;
  45143. private static _DefaultUtilityLayer;
  45144. private static _DefaultKeepDepthUtilityLayer;
  45145. private _sharedGizmoLight;
  45146. private _renderCamera;
  45147. /**
  45148. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45149. * @returns the camera that is used when rendering the utility layer
  45150. */
  45151. getRenderCamera(): Nullable<Camera>;
  45152. /**
  45153. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45154. * @param cam the camera that should be used when rendering the utility layer
  45155. */
  45156. setRenderCamera(cam: Nullable<Camera>): void;
  45157. /**
  45158. * @hidden
  45159. * Light which used by gizmos to get light shading
  45160. */
  45161. _getSharedGizmoLight(): HemisphericLight;
  45162. /**
  45163. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45164. */
  45165. pickUtilitySceneFirst: boolean;
  45166. /**
  45167. * 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)
  45168. */
  45169. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45170. /**
  45171. * 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)
  45172. */
  45173. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45174. /**
  45175. * The scene that is rendered on top of the original scene
  45176. */
  45177. utilityLayerScene: Scene;
  45178. /**
  45179. * If the utility layer should automatically be rendered on top of existing scene
  45180. */
  45181. shouldRender: boolean;
  45182. /**
  45183. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45184. */
  45185. onlyCheckPointerDownEvents: boolean;
  45186. /**
  45187. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45188. */
  45189. processAllEvents: boolean;
  45190. /**
  45191. * Observable raised when the pointer move from the utility layer scene to the main scene
  45192. */
  45193. onPointerOutObservable: Observable<number>;
  45194. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45195. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45196. private _afterRenderObserver;
  45197. private _sceneDisposeObserver;
  45198. private _originalPointerObserver;
  45199. /**
  45200. * Instantiates a UtilityLayerRenderer
  45201. * @param originalScene the original scene that will be rendered on top of
  45202. * @param handleEvents boolean indicating if the utility layer should handle events
  45203. */
  45204. constructor(
  45205. /** the original scene that will be rendered on top of */
  45206. originalScene: Scene, handleEvents?: boolean);
  45207. private _notifyObservers;
  45208. /**
  45209. * Renders the utility layers scene on top of the original scene
  45210. */
  45211. render(): void;
  45212. /**
  45213. * Disposes of the renderer
  45214. */
  45215. dispose(): void;
  45216. private _updateCamera;
  45217. }
  45218. }
  45219. declare module "babylonjs/Gizmos/gizmo" {
  45220. import { Nullable } from "babylonjs/types";
  45221. import { IDisposable } from "babylonjs/scene";
  45222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45223. import { Mesh } from "babylonjs/Meshes/mesh";
  45224. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45225. /**
  45226. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45227. */
  45228. export class Gizmo implements IDisposable {
  45229. /** The utility layer the gizmo will be added to */
  45230. gizmoLayer: UtilityLayerRenderer;
  45231. /**
  45232. * The root mesh of the gizmo
  45233. */
  45234. _rootMesh: Mesh;
  45235. private _attachedMesh;
  45236. /**
  45237. * Ratio for the scale of the gizmo (Default: 1)
  45238. */
  45239. scaleRatio: number;
  45240. /**
  45241. * If a custom mesh has been set (Default: false)
  45242. */
  45243. protected _customMeshSet: boolean;
  45244. /**
  45245. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45246. * * When set, interactions will be enabled
  45247. */
  45248. attachedMesh: Nullable<AbstractMesh>;
  45249. /**
  45250. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45251. * @param mesh The mesh to replace the default mesh of the gizmo
  45252. */
  45253. setCustomMesh(mesh: Mesh): void;
  45254. /**
  45255. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45256. */
  45257. updateGizmoRotationToMatchAttachedMesh: boolean;
  45258. /**
  45259. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45260. */
  45261. updateGizmoPositionToMatchAttachedMesh: boolean;
  45262. /**
  45263. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45264. */
  45265. updateScale: boolean;
  45266. protected _interactionsEnabled: boolean;
  45267. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45268. private _beforeRenderObserver;
  45269. private _tempVector;
  45270. /**
  45271. * Creates a gizmo
  45272. * @param gizmoLayer The utility layer the gizmo will be added to
  45273. */
  45274. constructor(
  45275. /** The utility layer the gizmo will be added to */
  45276. gizmoLayer?: UtilityLayerRenderer);
  45277. /**
  45278. * Updates the gizmo to match the attached mesh's position/rotation
  45279. */
  45280. protected _update(): void;
  45281. /**
  45282. * Disposes of the gizmo
  45283. */
  45284. dispose(): void;
  45285. }
  45286. }
  45287. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45288. import { Observable } from "babylonjs/Misc/observable";
  45289. import { Nullable } from "babylonjs/types";
  45290. import { Vector3 } from "babylonjs/Maths/math.vector";
  45291. import { Color3 } from "babylonjs/Maths/math.color";
  45292. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45294. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45295. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45296. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45297. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45298. import { Scene } from "babylonjs/scene";
  45299. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45300. /**
  45301. * Single plane drag gizmo
  45302. */
  45303. export class PlaneDragGizmo extends Gizmo {
  45304. /**
  45305. * Drag behavior responsible for the gizmos dragging interactions
  45306. */
  45307. dragBehavior: PointerDragBehavior;
  45308. private _pointerObserver;
  45309. /**
  45310. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45311. */
  45312. snapDistance: number;
  45313. /**
  45314. * Event that fires each time the gizmo snaps to a new location.
  45315. * * snapDistance is the the change in distance
  45316. */
  45317. onSnapObservable: Observable<{
  45318. snapDistance: number;
  45319. }>;
  45320. private _plane;
  45321. private _coloredMaterial;
  45322. private _hoverMaterial;
  45323. private _isEnabled;
  45324. private _parent;
  45325. /** @hidden */
  45326. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45327. /** @hidden */
  45328. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45329. /**
  45330. * Creates a PlaneDragGizmo
  45331. * @param gizmoLayer The utility layer the gizmo will be added to
  45332. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45333. * @param color The color of the gizmo
  45334. */
  45335. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45336. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45337. /**
  45338. * If the gizmo is enabled
  45339. */
  45340. isEnabled: boolean;
  45341. /**
  45342. * Disposes of the gizmo
  45343. */
  45344. dispose(): void;
  45345. }
  45346. }
  45347. declare module "babylonjs/Gizmos/positionGizmo" {
  45348. import { Observable } from "babylonjs/Misc/observable";
  45349. import { Nullable } from "babylonjs/types";
  45350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45351. import { Mesh } from "babylonjs/Meshes/mesh";
  45352. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45353. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45354. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45355. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45356. /**
  45357. * Gizmo that enables dragging a mesh along 3 axis
  45358. */
  45359. export class PositionGizmo extends Gizmo {
  45360. /**
  45361. * Internal gizmo used for interactions on the x axis
  45362. */
  45363. xGizmo: AxisDragGizmo;
  45364. /**
  45365. * Internal gizmo used for interactions on the y axis
  45366. */
  45367. yGizmo: AxisDragGizmo;
  45368. /**
  45369. * Internal gizmo used for interactions on the z axis
  45370. */
  45371. zGizmo: AxisDragGizmo;
  45372. /**
  45373. * Internal gizmo used for interactions on the yz plane
  45374. */
  45375. xPlaneGizmo: PlaneDragGizmo;
  45376. /**
  45377. * Internal gizmo used for interactions on the xz plane
  45378. */
  45379. yPlaneGizmo: PlaneDragGizmo;
  45380. /**
  45381. * Internal gizmo used for interactions on the xy plane
  45382. */
  45383. zPlaneGizmo: PlaneDragGizmo;
  45384. /**
  45385. * private variables
  45386. */
  45387. private _meshAttached;
  45388. private _updateGizmoRotationToMatchAttachedMesh;
  45389. private _snapDistance;
  45390. private _scaleRatio;
  45391. /** Fires an event when any of it's sub gizmos are dragged */
  45392. onDragStartObservable: Observable<unknown>;
  45393. /** Fires an event when any of it's sub gizmos are released from dragging */
  45394. onDragEndObservable: Observable<unknown>;
  45395. /**
  45396. * If set to true, planar drag is enabled
  45397. */
  45398. private _planarGizmoEnabled;
  45399. attachedMesh: Nullable<AbstractMesh>;
  45400. /**
  45401. * Creates a PositionGizmo
  45402. * @param gizmoLayer The utility layer the gizmo will be added to
  45403. */
  45404. constructor(gizmoLayer?: UtilityLayerRenderer);
  45405. /**
  45406. * If the planar drag gizmo is enabled
  45407. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45408. */
  45409. planarGizmoEnabled: boolean;
  45410. updateGizmoRotationToMatchAttachedMesh: boolean;
  45411. /**
  45412. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45413. */
  45414. snapDistance: number;
  45415. /**
  45416. * Ratio for the scale of the gizmo (Default: 1)
  45417. */
  45418. scaleRatio: number;
  45419. /**
  45420. * Disposes of the gizmo
  45421. */
  45422. dispose(): void;
  45423. /**
  45424. * CustomMeshes are not supported by this gizmo
  45425. * @param mesh The mesh to replace the default mesh of the gizmo
  45426. */
  45427. setCustomMesh(mesh: Mesh): void;
  45428. }
  45429. }
  45430. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45431. import { Observable } from "babylonjs/Misc/observable";
  45432. import { Nullable } from "babylonjs/types";
  45433. import { Vector3 } from "babylonjs/Maths/math.vector";
  45434. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45436. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45437. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45438. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45439. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45440. import { Scene } from "babylonjs/scene";
  45441. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45442. import { Color3 } from "babylonjs/Maths/math.color";
  45443. /**
  45444. * Single axis drag gizmo
  45445. */
  45446. export class AxisDragGizmo extends Gizmo {
  45447. /**
  45448. * Drag behavior responsible for the gizmos dragging interactions
  45449. */
  45450. dragBehavior: PointerDragBehavior;
  45451. private _pointerObserver;
  45452. /**
  45453. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45454. */
  45455. snapDistance: number;
  45456. /**
  45457. * Event that fires each time the gizmo snaps to a new location.
  45458. * * snapDistance is the the change in distance
  45459. */
  45460. onSnapObservable: Observable<{
  45461. snapDistance: number;
  45462. }>;
  45463. private _isEnabled;
  45464. private _parent;
  45465. private _arrow;
  45466. private _coloredMaterial;
  45467. private _hoverMaterial;
  45468. /** @hidden */
  45469. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45470. /** @hidden */
  45471. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45472. /**
  45473. * Creates an AxisDragGizmo
  45474. * @param gizmoLayer The utility layer the gizmo will be added to
  45475. * @param dragAxis The axis which the gizmo will be able to drag on
  45476. * @param color The color of the gizmo
  45477. */
  45478. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45479. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45480. /**
  45481. * If the gizmo is enabled
  45482. */
  45483. isEnabled: boolean;
  45484. /**
  45485. * Disposes of the gizmo
  45486. */
  45487. dispose(): void;
  45488. }
  45489. }
  45490. declare module "babylonjs/Debug/axesViewer" {
  45491. import { Vector3 } from "babylonjs/Maths/math.vector";
  45492. import { Nullable } from "babylonjs/types";
  45493. import { Scene } from "babylonjs/scene";
  45494. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45495. /**
  45496. * The Axes viewer will show 3 axes in a specific point in space
  45497. */
  45498. export class AxesViewer {
  45499. private _xAxis;
  45500. private _yAxis;
  45501. private _zAxis;
  45502. private _scaleLinesFactor;
  45503. private _instanced;
  45504. /**
  45505. * Gets the hosting scene
  45506. */
  45507. scene: Scene;
  45508. /**
  45509. * Gets or sets a number used to scale line length
  45510. */
  45511. scaleLines: number;
  45512. /** Gets the node hierarchy used to render x-axis */
  45513. readonly xAxis: TransformNode;
  45514. /** Gets the node hierarchy used to render y-axis */
  45515. readonly yAxis: TransformNode;
  45516. /** Gets the node hierarchy used to render z-axis */
  45517. readonly zAxis: TransformNode;
  45518. /**
  45519. * Creates a new AxesViewer
  45520. * @param scene defines the hosting scene
  45521. * @param scaleLines defines a number used to scale line length (1 by default)
  45522. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45523. * @param xAxis defines the node hierarchy used to render the x-axis
  45524. * @param yAxis defines the node hierarchy used to render the y-axis
  45525. * @param zAxis defines the node hierarchy used to render the z-axis
  45526. */
  45527. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45528. /**
  45529. * Force the viewer to update
  45530. * @param position defines the position of the viewer
  45531. * @param xaxis defines the x axis of the viewer
  45532. * @param yaxis defines the y axis of the viewer
  45533. * @param zaxis defines the z axis of the viewer
  45534. */
  45535. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45536. /**
  45537. * Creates an instance of this axes viewer.
  45538. * @returns a new axes viewer with instanced meshes
  45539. */
  45540. createInstance(): AxesViewer;
  45541. /** Releases resources */
  45542. dispose(): void;
  45543. private static _SetRenderingGroupId;
  45544. }
  45545. }
  45546. declare module "babylonjs/Debug/boneAxesViewer" {
  45547. import { Nullable } from "babylonjs/types";
  45548. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45549. import { Vector3 } from "babylonjs/Maths/math.vector";
  45550. import { Mesh } from "babylonjs/Meshes/mesh";
  45551. import { Bone } from "babylonjs/Bones/bone";
  45552. import { Scene } from "babylonjs/scene";
  45553. /**
  45554. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45555. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45556. */
  45557. export class BoneAxesViewer extends AxesViewer {
  45558. /**
  45559. * Gets or sets the target mesh where to display the axes viewer
  45560. */
  45561. mesh: Nullable<Mesh>;
  45562. /**
  45563. * Gets or sets the target bone where to display the axes viewer
  45564. */
  45565. bone: Nullable<Bone>;
  45566. /** Gets current position */
  45567. pos: Vector3;
  45568. /** Gets direction of X axis */
  45569. xaxis: Vector3;
  45570. /** Gets direction of Y axis */
  45571. yaxis: Vector3;
  45572. /** Gets direction of Z axis */
  45573. zaxis: Vector3;
  45574. /**
  45575. * Creates a new BoneAxesViewer
  45576. * @param scene defines the hosting scene
  45577. * @param bone defines the target bone
  45578. * @param mesh defines the target mesh
  45579. * @param scaleLines defines a scaling factor for line length (1 by default)
  45580. */
  45581. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45582. /**
  45583. * Force the viewer to update
  45584. */
  45585. update(): void;
  45586. /** Releases resources */
  45587. dispose(): void;
  45588. }
  45589. }
  45590. declare module "babylonjs/Debug/debugLayer" {
  45591. import { Scene } from "babylonjs/scene";
  45592. /**
  45593. * Interface used to define scene explorer extensibility option
  45594. */
  45595. export interface IExplorerExtensibilityOption {
  45596. /**
  45597. * Define the option label
  45598. */
  45599. label: string;
  45600. /**
  45601. * Defines the action to execute on click
  45602. */
  45603. action: (entity: any) => void;
  45604. }
  45605. /**
  45606. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45607. */
  45608. export interface IExplorerExtensibilityGroup {
  45609. /**
  45610. * Defines a predicate to test if a given type mut be extended
  45611. */
  45612. predicate: (entity: any) => boolean;
  45613. /**
  45614. * Gets the list of options added to a type
  45615. */
  45616. entries: IExplorerExtensibilityOption[];
  45617. }
  45618. /**
  45619. * Interface used to define the options to use to create the Inspector
  45620. */
  45621. export interface IInspectorOptions {
  45622. /**
  45623. * Display in overlay mode (default: false)
  45624. */
  45625. overlay?: boolean;
  45626. /**
  45627. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45628. */
  45629. globalRoot?: HTMLElement;
  45630. /**
  45631. * Display the Scene explorer
  45632. */
  45633. showExplorer?: boolean;
  45634. /**
  45635. * Display the property inspector
  45636. */
  45637. showInspector?: boolean;
  45638. /**
  45639. * Display in embed mode (both panes on the right)
  45640. */
  45641. embedMode?: boolean;
  45642. /**
  45643. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45644. */
  45645. handleResize?: boolean;
  45646. /**
  45647. * Allow the panes to popup (default: true)
  45648. */
  45649. enablePopup?: boolean;
  45650. /**
  45651. * Allow the panes to be closed by users (default: true)
  45652. */
  45653. enableClose?: boolean;
  45654. /**
  45655. * Optional list of extensibility entries
  45656. */
  45657. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45658. /**
  45659. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45660. */
  45661. inspectorURL?: string;
  45662. }
  45663. module "babylonjs/scene" {
  45664. interface Scene {
  45665. /**
  45666. * @hidden
  45667. * Backing field
  45668. */
  45669. _debugLayer: DebugLayer;
  45670. /**
  45671. * Gets the debug layer (aka Inspector) associated with the scene
  45672. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45673. */
  45674. debugLayer: DebugLayer;
  45675. }
  45676. }
  45677. /**
  45678. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45679. * what is happening in your scene
  45680. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45681. */
  45682. export class DebugLayer {
  45683. /**
  45684. * Define the url to get the inspector script from.
  45685. * By default it uses the babylonjs CDN.
  45686. * @ignoreNaming
  45687. */
  45688. static InspectorURL: string;
  45689. private _scene;
  45690. private BJSINSPECTOR;
  45691. private _onPropertyChangedObservable?;
  45692. /**
  45693. * Observable triggered when a property is changed through the inspector.
  45694. */
  45695. readonly onPropertyChangedObservable: any;
  45696. /**
  45697. * Instantiates a new debug layer.
  45698. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45699. * what is happening in your scene
  45700. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45701. * @param scene Defines the scene to inspect
  45702. */
  45703. constructor(scene: Scene);
  45704. /** Creates the inspector window. */
  45705. private _createInspector;
  45706. /**
  45707. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45708. * @param entity defines the entity to select
  45709. * @param lineContainerTitle defines the specific block to highlight
  45710. */
  45711. select(entity: any, lineContainerTitle?: string): void;
  45712. /** Get the inspector from bundle or global */
  45713. private _getGlobalInspector;
  45714. /**
  45715. * Get if the inspector is visible or not.
  45716. * @returns true if visible otherwise, false
  45717. */
  45718. isVisible(): boolean;
  45719. /**
  45720. * Hide the inspector and close its window.
  45721. */
  45722. hide(): void;
  45723. /**
  45724. * Launch the debugLayer.
  45725. * @param config Define the configuration of the inspector
  45726. * @return a promise fulfilled when the debug layer is visible
  45727. */
  45728. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45729. }
  45730. }
  45731. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45732. import { Nullable } from "babylonjs/types";
  45733. import { Scene } from "babylonjs/scene";
  45734. import { Vector4 } from "babylonjs/Maths/math.vector";
  45735. import { Color4 } from "babylonjs/Maths/math.color";
  45736. import { Mesh } from "babylonjs/Meshes/mesh";
  45737. /**
  45738. * Class containing static functions to help procedurally build meshes
  45739. */
  45740. export class BoxBuilder {
  45741. /**
  45742. * Creates a box mesh
  45743. * * The parameter `size` sets the size (float) of each box side (default 1)
  45744. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45745. * * 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)
  45746. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45750. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45751. * @param name defines the name of the mesh
  45752. * @param options defines the options used to create the mesh
  45753. * @param scene defines the hosting scene
  45754. * @returns the box mesh
  45755. */
  45756. static CreateBox(name: string, options: {
  45757. size?: number;
  45758. width?: number;
  45759. height?: number;
  45760. depth?: number;
  45761. faceUV?: Vector4[];
  45762. faceColors?: Color4[];
  45763. sideOrientation?: number;
  45764. frontUVs?: Vector4;
  45765. backUVs?: Vector4;
  45766. wrap?: boolean;
  45767. topBaseAt?: number;
  45768. bottomBaseAt?: number;
  45769. updatable?: boolean;
  45770. }, scene?: Nullable<Scene>): Mesh;
  45771. }
  45772. }
  45773. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45774. import { Vector4 } from "babylonjs/Maths/math.vector";
  45775. import { Mesh } from "babylonjs/Meshes/mesh";
  45776. import { Scene } from "babylonjs/scene";
  45777. import { Nullable } from "babylonjs/types";
  45778. /**
  45779. * Class containing static functions to help procedurally build meshes
  45780. */
  45781. export class SphereBuilder {
  45782. /**
  45783. * Creates a sphere mesh
  45784. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45785. * * 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`)
  45786. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45787. * * 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
  45788. * * 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)
  45789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45792. * @param name defines the name of the mesh
  45793. * @param options defines the options used to create the mesh
  45794. * @param scene defines the hosting scene
  45795. * @returns the sphere mesh
  45796. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45797. */
  45798. static CreateSphere(name: string, options: {
  45799. segments?: number;
  45800. diameter?: number;
  45801. diameterX?: number;
  45802. diameterY?: number;
  45803. diameterZ?: number;
  45804. arc?: number;
  45805. slice?: number;
  45806. sideOrientation?: number;
  45807. frontUVs?: Vector4;
  45808. backUVs?: Vector4;
  45809. updatable?: boolean;
  45810. }, scene?: Nullable<Scene>): Mesh;
  45811. }
  45812. }
  45813. declare module "babylonjs/Debug/physicsViewer" {
  45814. import { Nullable } from "babylonjs/types";
  45815. import { Scene } from "babylonjs/scene";
  45816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45817. import { Mesh } from "babylonjs/Meshes/mesh";
  45818. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45819. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45820. /**
  45821. * Used to show the physics impostor around the specific mesh
  45822. */
  45823. export class PhysicsViewer {
  45824. /** @hidden */
  45825. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45826. /** @hidden */
  45827. protected _meshes: Array<Nullable<AbstractMesh>>;
  45828. /** @hidden */
  45829. protected _scene: Nullable<Scene>;
  45830. /** @hidden */
  45831. protected _numMeshes: number;
  45832. /** @hidden */
  45833. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45834. private _renderFunction;
  45835. private _utilityLayer;
  45836. private _debugBoxMesh;
  45837. private _debugSphereMesh;
  45838. private _debugCylinderMesh;
  45839. private _debugMaterial;
  45840. private _debugMeshMeshes;
  45841. /**
  45842. * Creates a new PhysicsViewer
  45843. * @param scene defines the hosting scene
  45844. */
  45845. constructor(scene: Scene);
  45846. /** @hidden */
  45847. protected _updateDebugMeshes(): void;
  45848. /**
  45849. * Renders a specified physic impostor
  45850. * @param impostor defines the impostor to render
  45851. * @param targetMesh defines the mesh represented by the impostor
  45852. * @returns the new debug mesh used to render the impostor
  45853. */
  45854. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45855. /**
  45856. * Hides a specified physic impostor
  45857. * @param impostor defines the impostor to hide
  45858. */
  45859. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45860. private _getDebugMaterial;
  45861. private _getDebugBoxMesh;
  45862. private _getDebugSphereMesh;
  45863. private _getDebugCylinderMesh;
  45864. private _getDebugMeshMesh;
  45865. private _getDebugMesh;
  45866. /** Releases all resources */
  45867. dispose(): void;
  45868. }
  45869. }
  45870. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45871. import { Vector3 } from "babylonjs/Maths/math.vector";
  45872. import { Color4 } from "babylonjs/Maths/math.color";
  45873. import { Nullable } from "babylonjs/types";
  45874. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45875. import { Scene } from "babylonjs/scene";
  45876. /**
  45877. * Class containing static functions to help procedurally build meshes
  45878. */
  45879. export class LinesBuilder {
  45880. /**
  45881. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45882. * * 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
  45883. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45884. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45885. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45886. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45887. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45888. * * 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
  45889. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45892. * @param name defines the name of the new line system
  45893. * @param options defines the options used to create the line system
  45894. * @param scene defines the hosting scene
  45895. * @returns a new line system mesh
  45896. */
  45897. static CreateLineSystem(name: string, options: {
  45898. lines: Vector3[][];
  45899. updatable?: boolean;
  45900. instance?: Nullable<LinesMesh>;
  45901. colors?: Nullable<Color4[][]>;
  45902. useVertexAlpha?: boolean;
  45903. }, scene: Nullable<Scene>): LinesMesh;
  45904. /**
  45905. * Creates a line mesh
  45906. * 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
  45907. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45908. * * The parameter `points` is an array successive Vector3
  45909. * * 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
  45910. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45911. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45912. * * When updating an instance, remember that only point positions can change, not the number of points
  45913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45915. * @param name defines the name of the new line system
  45916. * @param options defines the options used to create the line system
  45917. * @param scene defines the hosting scene
  45918. * @returns a new line mesh
  45919. */
  45920. static CreateLines(name: string, options: {
  45921. points: Vector3[];
  45922. updatable?: boolean;
  45923. instance?: Nullable<LinesMesh>;
  45924. colors?: Color4[];
  45925. useVertexAlpha?: boolean;
  45926. }, scene?: Nullable<Scene>): LinesMesh;
  45927. /**
  45928. * Creates a dashed line mesh
  45929. * * 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
  45930. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45931. * * The parameter `points` is an array successive Vector3
  45932. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45933. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45934. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45935. * * 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
  45936. * * When updating an instance, remember that only point positions can change, not the number of points
  45937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45938. * @param name defines the name of the mesh
  45939. * @param options defines the options used to create the mesh
  45940. * @param scene defines the hosting scene
  45941. * @returns the dashed line mesh
  45942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45943. */
  45944. static CreateDashedLines(name: string, options: {
  45945. points: Vector3[];
  45946. dashSize?: number;
  45947. gapSize?: number;
  45948. dashNb?: number;
  45949. updatable?: boolean;
  45950. instance?: LinesMesh;
  45951. }, scene?: Nullable<Scene>): LinesMesh;
  45952. }
  45953. }
  45954. declare module "babylonjs/Debug/rayHelper" {
  45955. import { Nullable } from "babylonjs/types";
  45956. import { Ray } from "babylonjs/Culling/ray";
  45957. import { Vector3 } from "babylonjs/Maths/math.vector";
  45958. import { Color3 } from "babylonjs/Maths/math.color";
  45959. import { Scene } from "babylonjs/scene";
  45960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45961. import "babylonjs/Meshes/Builders/linesBuilder";
  45962. /**
  45963. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45964. * in order to better appreciate the issue one might have.
  45965. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45966. */
  45967. export class RayHelper {
  45968. /**
  45969. * Defines the ray we are currently tryin to visualize.
  45970. */
  45971. ray: Nullable<Ray>;
  45972. private _renderPoints;
  45973. private _renderLine;
  45974. private _renderFunction;
  45975. private _scene;
  45976. private _updateToMeshFunction;
  45977. private _attachedToMesh;
  45978. private _meshSpaceDirection;
  45979. private _meshSpaceOrigin;
  45980. /**
  45981. * Helper function to create a colored helper in a scene in one line.
  45982. * @param ray Defines the ray we are currently tryin to visualize
  45983. * @param scene Defines the scene the ray is used in
  45984. * @param color Defines the color we want to see the ray in
  45985. * @returns The newly created ray helper.
  45986. */
  45987. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45988. /**
  45989. * Instantiate a new ray helper.
  45990. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45991. * in order to better appreciate the issue one might have.
  45992. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45993. * @param ray Defines the ray we are currently tryin to visualize
  45994. */
  45995. constructor(ray: Ray);
  45996. /**
  45997. * Shows the ray we are willing to debug.
  45998. * @param scene Defines the scene the ray needs to be rendered in
  45999. * @param color Defines the color the ray needs to be rendered in
  46000. */
  46001. show(scene: Scene, color?: Color3): void;
  46002. /**
  46003. * Hides the ray we are debugging.
  46004. */
  46005. hide(): void;
  46006. private _render;
  46007. /**
  46008. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46009. * @param mesh Defines the mesh we want the helper attached to
  46010. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46011. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46012. * @param length Defines the length of the ray
  46013. */
  46014. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46015. /**
  46016. * Detach the ray helper from the mesh it has previously been attached to.
  46017. */
  46018. detachFromMesh(): void;
  46019. private _updateToMesh;
  46020. /**
  46021. * Dispose the helper and release its associated resources.
  46022. */
  46023. dispose(): void;
  46024. }
  46025. }
  46026. declare module "babylonjs/Debug/skeletonViewer" {
  46027. import { Color3 } from "babylonjs/Maths/math.color";
  46028. import { Scene } from "babylonjs/scene";
  46029. import { Nullable } from "babylonjs/types";
  46030. import { Skeleton } from "babylonjs/Bones/skeleton";
  46031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46032. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46033. /**
  46034. * Class used to render a debug view of a given skeleton
  46035. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46036. */
  46037. export class SkeletonViewer {
  46038. /** defines the skeleton to render */
  46039. skeleton: Skeleton;
  46040. /** defines the mesh attached to the skeleton */
  46041. mesh: AbstractMesh;
  46042. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46043. autoUpdateBonesMatrices: boolean;
  46044. /** defines the rendering group id to use with the viewer */
  46045. renderingGroupId: number;
  46046. /** Gets or sets the color used to render the skeleton */
  46047. color: Color3;
  46048. private _scene;
  46049. private _debugLines;
  46050. private _debugMesh;
  46051. private _isEnabled;
  46052. private _renderFunction;
  46053. private _utilityLayer;
  46054. /**
  46055. * Returns the mesh used to render the bones
  46056. */
  46057. readonly debugMesh: Nullable<LinesMesh>;
  46058. /**
  46059. * Creates a new SkeletonViewer
  46060. * @param skeleton defines the skeleton to render
  46061. * @param mesh defines the mesh attached to the skeleton
  46062. * @param scene defines the hosting scene
  46063. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46064. * @param renderingGroupId defines the rendering group id to use with the viewer
  46065. */
  46066. constructor(
  46067. /** defines the skeleton to render */
  46068. skeleton: Skeleton,
  46069. /** defines the mesh attached to the skeleton */
  46070. mesh: AbstractMesh, scene: Scene,
  46071. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46072. autoUpdateBonesMatrices?: boolean,
  46073. /** defines the rendering group id to use with the viewer */
  46074. renderingGroupId?: number);
  46075. /** Gets or sets a boolean indicating if the viewer is enabled */
  46076. isEnabled: boolean;
  46077. private _getBonePosition;
  46078. private _getLinesForBonesWithLength;
  46079. private _getLinesForBonesNoLength;
  46080. /** Update the viewer to sync with current skeleton state */
  46081. update(): void;
  46082. /** Release associated resources */
  46083. dispose(): void;
  46084. }
  46085. }
  46086. declare module "babylonjs/Debug/index" {
  46087. export * from "babylonjs/Debug/axesViewer";
  46088. export * from "babylonjs/Debug/boneAxesViewer";
  46089. export * from "babylonjs/Debug/debugLayer";
  46090. export * from "babylonjs/Debug/physicsViewer";
  46091. export * from "babylonjs/Debug/rayHelper";
  46092. export * from "babylonjs/Debug/skeletonViewer";
  46093. }
  46094. declare module "babylonjs/Engines/nullEngine" {
  46095. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  46096. import { Scene } from "babylonjs/scene";
  46097. import { Engine } from "babylonjs/Engines/engine";
  46098. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46099. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46100. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46101. import { Effect } from "babylonjs/Materials/effect";
  46102. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46103. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46104. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  46105. /**
  46106. * Options to create the null engine
  46107. */
  46108. export class NullEngineOptions {
  46109. /**
  46110. * Render width (Default: 512)
  46111. */
  46112. renderWidth: number;
  46113. /**
  46114. * Render height (Default: 256)
  46115. */
  46116. renderHeight: number;
  46117. /**
  46118. * Texture size (Default: 512)
  46119. */
  46120. textureSize: number;
  46121. /**
  46122. * If delta time between frames should be constant
  46123. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46124. */
  46125. deterministicLockstep: boolean;
  46126. /**
  46127. * Maximum about of steps between frames (Default: 4)
  46128. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46129. */
  46130. lockstepMaxSteps: number;
  46131. }
  46132. /**
  46133. * The null engine class provides support for headless version of babylon.js.
  46134. * This can be used in server side scenario or for testing purposes
  46135. */
  46136. export class NullEngine extends Engine {
  46137. private _options;
  46138. /**
  46139. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46140. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46141. * @returns true if engine is in deterministic lock step mode
  46142. */
  46143. isDeterministicLockStep(): boolean;
  46144. /**
  46145. * Gets the max steps when engine is running in deterministic lock step
  46146. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46147. * @returns the max steps
  46148. */
  46149. getLockstepMaxSteps(): number;
  46150. /**
  46151. * Gets the current hardware scaling level.
  46152. * By default the hardware scaling level is computed from the window device ratio.
  46153. * 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.
  46154. * @returns a number indicating the current hardware scaling level
  46155. */
  46156. getHardwareScalingLevel(): number;
  46157. constructor(options?: NullEngineOptions);
  46158. /**
  46159. * Creates a vertex buffer
  46160. * @param vertices the data for the vertex buffer
  46161. * @returns the new WebGL static buffer
  46162. */
  46163. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46164. /**
  46165. * Creates a new index buffer
  46166. * @param indices defines the content of the index buffer
  46167. * @param updatable defines if the index buffer must be updatable
  46168. * @returns a new webGL buffer
  46169. */
  46170. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46171. /**
  46172. * Clear the current render buffer or the current render target (if any is set up)
  46173. * @param color defines the color to use
  46174. * @param backBuffer defines if the back buffer must be cleared
  46175. * @param depth defines if the depth buffer must be cleared
  46176. * @param stencil defines if the stencil buffer must be cleared
  46177. */
  46178. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46179. /**
  46180. * Gets the current render width
  46181. * @param useScreen defines if screen size must be used (or the current render target if any)
  46182. * @returns a number defining the current render width
  46183. */
  46184. getRenderWidth(useScreen?: boolean): number;
  46185. /**
  46186. * Gets the current render height
  46187. * @param useScreen defines if screen size must be used (or the current render target if any)
  46188. * @returns a number defining the current render height
  46189. */
  46190. getRenderHeight(useScreen?: boolean): number;
  46191. /**
  46192. * Set the WebGL's viewport
  46193. * @param viewport defines the viewport element to be used
  46194. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46195. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46196. */
  46197. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46198. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46199. /**
  46200. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46201. * @param pipelineContext defines the pipeline context to use
  46202. * @param uniformsNames defines the list of uniform names
  46203. * @returns an array of webGL uniform locations
  46204. */
  46205. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46206. /**
  46207. * Gets the lsit of active attributes for a given webGL program
  46208. * @param pipelineContext defines the pipeline context to use
  46209. * @param attributesNames defines the list of attribute names to get
  46210. * @returns an array of indices indicating the offset of each attribute
  46211. */
  46212. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46213. /**
  46214. * Binds an effect to the webGL context
  46215. * @param effect defines the effect to bind
  46216. */
  46217. bindSamplers(effect: Effect): void;
  46218. /**
  46219. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46220. * @param effect defines the effect to activate
  46221. */
  46222. enableEffect(effect: Effect): void;
  46223. /**
  46224. * Set various states to the webGL context
  46225. * @param culling defines backface culling state
  46226. * @param zOffset defines the value to apply to zOffset (0 by default)
  46227. * @param force defines if states must be applied even if cache is up to date
  46228. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46229. */
  46230. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46231. /**
  46232. * Set the value of an uniform to an array of int32
  46233. * @param uniform defines the webGL uniform location where to store the value
  46234. * @param array defines the array of int32 to store
  46235. */
  46236. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46237. /**
  46238. * Set the value of an uniform to an array of int32 (stored as vec2)
  46239. * @param uniform defines the webGL uniform location where to store the value
  46240. * @param array defines the array of int32 to store
  46241. */
  46242. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46243. /**
  46244. * Set the value of an uniform to an array of int32 (stored as vec3)
  46245. * @param uniform defines the webGL uniform location where to store the value
  46246. * @param array defines the array of int32 to store
  46247. */
  46248. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46249. /**
  46250. * Set the value of an uniform to an array of int32 (stored as vec4)
  46251. * @param uniform defines the webGL uniform location where to store the value
  46252. * @param array defines the array of int32 to store
  46253. */
  46254. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46255. /**
  46256. * Set the value of an uniform to an array of float32
  46257. * @param uniform defines the webGL uniform location where to store the value
  46258. * @param array defines the array of float32 to store
  46259. */
  46260. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46261. /**
  46262. * Set the value of an uniform to an array of float32 (stored as vec2)
  46263. * @param uniform defines the webGL uniform location where to store the value
  46264. * @param array defines the array of float32 to store
  46265. */
  46266. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46267. /**
  46268. * Set the value of an uniform to an array of float32 (stored as vec3)
  46269. * @param uniform defines the webGL uniform location where to store the value
  46270. * @param array defines the array of float32 to store
  46271. */
  46272. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46273. /**
  46274. * Set the value of an uniform to an array of float32 (stored as vec4)
  46275. * @param uniform defines the webGL uniform location where to store the value
  46276. * @param array defines the array of float32 to store
  46277. */
  46278. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46279. /**
  46280. * Set the value of an uniform to an array of number
  46281. * @param uniform defines the webGL uniform location where to store the value
  46282. * @param array defines the array of number to store
  46283. */
  46284. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46285. /**
  46286. * Set the value of an uniform to an array of number (stored as vec2)
  46287. * @param uniform defines the webGL uniform location where to store the value
  46288. * @param array defines the array of number to store
  46289. */
  46290. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46291. /**
  46292. * Set the value of an uniform to an array of number (stored as vec3)
  46293. * @param uniform defines the webGL uniform location where to store the value
  46294. * @param array defines the array of number to store
  46295. */
  46296. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46297. /**
  46298. * Set the value of an uniform to an array of number (stored as vec4)
  46299. * @param uniform defines the webGL uniform location where to store the value
  46300. * @param array defines the array of number to store
  46301. */
  46302. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46303. /**
  46304. * Set the value of an uniform to an array of float32 (stored as matrices)
  46305. * @param uniform defines the webGL uniform location where to store the value
  46306. * @param matrices defines the array of float32 to store
  46307. */
  46308. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46309. /**
  46310. * Set the value of an uniform to a matrix (3x3)
  46311. * @param uniform defines the webGL uniform location where to store the value
  46312. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46313. */
  46314. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46315. /**
  46316. * Set the value of an uniform to a matrix (2x2)
  46317. * @param uniform defines the webGL uniform location where to store the value
  46318. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46319. */
  46320. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46321. /**
  46322. * Set the value of an uniform to a number (float)
  46323. * @param uniform defines the webGL uniform location where to store the value
  46324. * @param value defines the float number to store
  46325. */
  46326. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46327. /**
  46328. * Set the value of an uniform to a vec2
  46329. * @param uniform defines the webGL uniform location where to store the value
  46330. * @param x defines the 1st component of the value
  46331. * @param y defines the 2nd component of the value
  46332. */
  46333. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46334. /**
  46335. * Set the value of an uniform to a vec3
  46336. * @param uniform defines the webGL uniform location where to store the value
  46337. * @param x defines the 1st component of the value
  46338. * @param y defines the 2nd component of the value
  46339. * @param z defines the 3rd component of the value
  46340. */
  46341. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46342. /**
  46343. * Set the value of an uniform to a boolean
  46344. * @param uniform defines the webGL uniform location where to store the value
  46345. * @param bool defines the boolean to store
  46346. */
  46347. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46348. /**
  46349. * Set the value of an uniform to a vec4
  46350. * @param uniform defines the webGL uniform location where to store the value
  46351. * @param x defines the 1st component of the value
  46352. * @param y defines the 2nd component of the value
  46353. * @param z defines the 3rd component of the value
  46354. * @param w defines the 4th component of the value
  46355. */
  46356. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46357. /**
  46358. * Sets the current alpha mode
  46359. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46360. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46361. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46362. */
  46363. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46364. /**
  46365. * Bind webGl buffers directly to the webGL context
  46366. * @param vertexBuffers defines the vertex buffer to bind
  46367. * @param indexBuffer defines the index buffer to bind
  46368. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46369. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46370. * @param effect defines the effect associated with the vertex buffer
  46371. */
  46372. bindBuffers(vertexBuffers: {
  46373. [key: string]: VertexBuffer;
  46374. }, indexBuffer: DataBuffer, effect: Effect): void;
  46375. /**
  46376. * Force the entire cache to be cleared
  46377. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46378. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46379. */
  46380. wipeCaches(bruteForce?: boolean): void;
  46381. /**
  46382. * Send a draw order
  46383. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46384. * @param indexStart defines the starting index
  46385. * @param indexCount defines the number of index to draw
  46386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46387. */
  46388. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46389. /**
  46390. * Draw a list of indexed primitives
  46391. * @param fillMode defines the primitive to use
  46392. * @param indexStart defines the starting index
  46393. * @param indexCount defines the number of index to draw
  46394. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46395. */
  46396. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46397. /**
  46398. * Draw a list of unindexed primitives
  46399. * @param fillMode defines the primitive to use
  46400. * @param verticesStart defines the index of first vertex to draw
  46401. * @param verticesCount defines the count of vertices to draw
  46402. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46403. */
  46404. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46405. /** @hidden */
  46406. _createTexture(): WebGLTexture;
  46407. /** @hidden */
  46408. _releaseTexture(texture: InternalTexture): void;
  46409. /**
  46410. * Usually called from Texture.ts.
  46411. * Passed information to create a WebGLTexture
  46412. * @param urlArg defines a value which contains one of the following:
  46413. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46414. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46415. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46416. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46417. * @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)
  46418. * @param scene needed for loading to the correct scene
  46419. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46420. * @param onLoad optional callback to be called upon successful completion
  46421. * @param onError optional callback to be called upon failure
  46422. * @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
  46423. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46424. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46425. * @param forcedExtension defines the extension to use to pick the right loader
  46426. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46427. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46428. */
  46429. 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;
  46430. /**
  46431. * Creates a new render target texture
  46432. * @param size defines the size of the texture
  46433. * @param options defines the options used to create the texture
  46434. * @returns a new render target texture stored in an InternalTexture
  46435. */
  46436. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46437. /**
  46438. * Update the sampling mode of a given texture
  46439. * @param samplingMode defines the required sampling mode
  46440. * @param texture defines the texture to update
  46441. */
  46442. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46443. /**
  46444. * Binds the frame buffer to the specified texture.
  46445. * @param texture The texture to render to or null for the default canvas
  46446. * @param faceIndex The face of the texture to render to in case of cube texture
  46447. * @param requiredWidth The width of the target to render to
  46448. * @param requiredHeight The height of the target to render to
  46449. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46450. * @param depthStencilTexture The depth stencil texture to use to render
  46451. * @param lodLevel defines le lod level to bind to the frame buffer
  46452. */
  46453. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46454. /**
  46455. * Unbind the current render target texture from the webGL context
  46456. * @param texture defines the render target texture to unbind
  46457. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46458. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46459. */
  46460. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46461. /**
  46462. * Creates a dynamic vertex buffer
  46463. * @param vertices the data for the dynamic vertex buffer
  46464. * @returns the new WebGL dynamic buffer
  46465. */
  46466. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46467. /**
  46468. * Update the content of a dynamic texture
  46469. * @param texture defines the texture to update
  46470. * @param canvas defines the canvas containing the source
  46471. * @param invertY defines if data must be stored with Y axis inverted
  46472. * @param premulAlpha defines if alpha is stored as premultiplied
  46473. * @param format defines the format of the data
  46474. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46475. */
  46476. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46477. /**
  46478. * Gets a boolean indicating if all created effects are ready
  46479. * @returns true if all effects are ready
  46480. */
  46481. areAllEffectsReady(): boolean;
  46482. /**
  46483. * @hidden
  46484. * Get the current error code of the webGL context
  46485. * @returns the error code
  46486. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46487. */
  46488. getError(): number;
  46489. /** @hidden */
  46490. _getUnpackAlignement(): number;
  46491. /** @hidden */
  46492. _unpackFlipY(value: boolean): void;
  46493. /**
  46494. * Update a dynamic index buffer
  46495. * @param indexBuffer defines the target index buffer
  46496. * @param indices defines the data to update
  46497. * @param offset defines the offset in the target index buffer where update should start
  46498. */
  46499. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46500. /**
  46501. * Updates a dynamic vertex buffer.
  46502. * @param vertexBuffer the vertex buffer to update
  46503. * @param vertices the data used to update the vertex buffer
  46504. * @param byteOffset the byte offset of the data (optional)
  46505. * @param byteLength the byte length of the data (optional)
  46506. */
  46507. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46508. /** @hidden */
  46509. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46510. /** @hidden */
  46511. _bindTexture(channel: number, texture: InternalTexture): void;
  46512. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46513. /**
  46514. * 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
  46515. */
  46516. releaseEffects(): void;
  46517. displayLoadingUI(): void;
  46518. hideLoadingUI(): void;
  46519. /** @hidden */
  46520. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46521. /** @hidden */
  46522. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46523. /** @hidden */
  46524. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46525. /** @hidden */
  46526. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46527. }
  46528. }
  46529. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46530. import { Nullable, int } from "babylonjs/types";
  46531. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46532. /** @hidden */
  46533. export class _OcclusionDataStorage {
  46534. /** @hidden */
  46535. occlusionInternalRetryCounter: number;
  46536. /** @hidden */
  46537. isOcclusionQueryInProgress: boolean;
  46538. /** @hidden */
  46539. isOccluded: boolean;
  46540. /** @hidden */
  46541. occlusionRetryCount: number;
  46542. /** @hidden */
  46543. occlusionType: number;
  46544. /** @hidden */
  46545. occlusionQueryAlgorithmType: number;
  46546. }
  46547. module "babylonjs/Engines/engine" {
  46548. interface Engine {
  46549. /**
  46550. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46551. * @return the new query
  46552. */
  46553. createQuery(): WebGLQuery;
  46554. /**
  46555. * Delete and release a webGL query
  46556. * @param query defines the query to delete
  46557. * @return the current engine
  46558. */
  46559. deleteQuery(query: WebGLQuery): Engine;
  46560. /**
  46561. * Check if a given query has resolved and got its value
  46562. * @param query defines the query to check
  46563. * @returns true if the query got its value
  46564. */
  46565. isQueryResultAvailable(query: WebGLQuery): boolean;
  46566. /**
  46567. * Gets the value of a given query
  46568. * @param query defines the query to check
  46569. * @returns the value of the query
  46570. */
  46571. getQueryResult(query: WebGLQuery): number;
  46572. /**
  46573. * Initiates an occlusion query
  46574. * @param algorithmType defines the algorithm to use
  46575. * @param query defines the query to use
  46576. * @returns the current engine
  46577. * @see http://doc.babylonjs.com/features/occlusionquery
  46578. */
  46579. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46580. /**
  46581. * Ends an occlusion query
  46582. * @see http://doc.babylonjs.com/features/occlusionquery
  46583. * @param algorithmType defines the algorithm to use
  46584. * @returns the current engine
  46585. */
  46586. endOcclusionQuery(algorithmType: number): Engine;
  46587. /**
  46588. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46589. * Please note that only one query can be issued at a time
  46590. * @returns a time token used to track the time span
  46591. */
  46592. startTimeQuery(): Nullable<_TimeToken>;
  46593. /**
  46594. * Ends a time query
  46595. * @param token defines the token used to measure the time span
  46596. * @returns the time spent (in ns)
  46597. */
  46598. endTimeQuery(token: _TimeToken): int;
  46599. /** @hidden */
  46600. _currentNonTimestampToken: Nullable<_TimeToken>;
  46601. /** @hidden */
  46602. _createTimeQuery(): WebGLQuery;
  46603. /** @hidden */
  46604. _deleteTimeQuery(query: WebGLQuery): void;
  46605. /** @hidden */
  46606. _getGlAlgorithmType(algorithmType: number): number;
  46607. /** @hidden */
  46608. _getTimeQueryResult(query: WebGLQuery): any;
  46609. /** @hidden */
  46610. _getTimeQueryAvailability(query: WebGLQuery): any;
  46611. }
  46612. }
  46613. module "babylonjs/Meshes/abstractMesh" {
  46614. interface AbstractMesh {
  46615. /**
  46616. * Backing filed
  46617. * @hidden
  46618. */
  46619. __occlusionDataStorage: _OcclusionDataStorage;
  46620. /**
  46621. * Access property
  46622. * @hidden
  46623. */
  46624. _occlusionDataStorage: _OcclusionDataStorage;
  46625. /**
  46626. * 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.
  46627. * The default value is -1 which means don't break the query and wait till the result
  46628. * @see http://doc.babylonjs.com/features/occlusionquery
  46629. */
  46630. occlusionRetryCount: number;
  46631. /**
  46632. * 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:
  46633. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46634. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46635. * * 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.
  46636. * @see http://doc.babylonjs.com/features/occlusionquery
  46637. */
  46638. occlusionType: number;
  46639. /**
  46640. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46641. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46642. * * 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.
  46643. * @see http://doc.babylonjs.com/features/occlusionquery
  46644. */
  46645. occlusionQueryAlgorithmType: number;
  46646. /**
  46647. * 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
  46648. * @see http://doc.babylonjs.com/features/occlusionquery
  46649. */
  46650. isOccluded: boolean;
  46651. /**
  46652. * Flag to check the progress status of the query
  46653. * @see http://doc.babylonjs.com/features/occlusionquery
  46654. */
  46655. isOcclusionQueryInProgress: boolean;
  46656. }
  46657. }
  46658. }
  46659. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46660. import { Nullable } from "babylonjs/types";
  46661. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46662. /** @hidden */
  46663. export var _forceTransformFeedbackToBundle: boolean;
  46664. module "babylonjs/Engines/engine" {
  46665. interface Engine {
  46666. /**
  46667. * Creates a webGL transform feedback object
  46668. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46669. * @returns the webGL transform feedback object
  46670. */
  46671. createTransformFeedback(): WebGLTransformFeedback;
  46672. /**
  46673. * Delete a webGL transform feedback object
  46674. * @param value defines the webGL transform feedback object to delete
  46675. */
  46676. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46677. /**
  46678. * Bind a webGL transform feedback object to the webgl context
  46679. * @param value defines the webGL transform feedback object to bind
  46680. */
  46681. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46682. /**
  46683. * Begins a transform feedback operation
  46684. * @param usePoints defines if points or triangles must be used
  46685. */
  46686. beginTransformFeedback(usePoints: boolean): void;
  46687. /**
  46688. * Ends a transform feedback operation
  46689. */
  46690. endTransformFeedback(): void;
  46691. /**
  46692. * Specify the varyings to use with transform feedback
  46693. * @param program defines the associated webGL program
  46694. * @param value defines the list of strings representing the varying names
  46695. */
  46696. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46697. /**
  46698. * Bind a webGL buffer for a transform feedback operation
  46699. * @param value defines the webGL buffer to bind
  46700. */
  46701. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46702. }
  46703. }
  46704. }
  46705. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46706. import { Scene } from "babylonjs/scene";
  46707. import { Engine } from "babylonjs/Engines/engine";
  46708. import { Texture } from "babylonjs/Materials/Textures/texture";
  46709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46710. import "babylonjs/Engines/Extensions/engine.multiRender";
  46711. /**
  46712. * Creation options of the multi render target texture.
  46713. */
  46714. export interface IMultiRenderTargetOptions {
  46715. /**
  46716. * Define if the texture needs to create mip maps after render.
  46717. */
  46718. generateMipMaps?: boolean;
  46719. /**
  46720. * Define the types of all the draw buffers we want to create
  46721. */
  46722. types?: number[];
  46723. /**
  46724. * Define the sampling modes of all the draw buffers we want to create
  46725. */
  46726. samplingModes?: number[];
  46727. /**
  46728. * Define if a depth buffer is required
  46729. */
  46730. generateDepthBuffer?: boolean;
  46731. /**
  46732. * Define if a stencil buffer is required
  46733. */
  46734. generateStencilBuffer?: boolean;
  46735. /**
  46736. * Define if a depth texture is required instead of a depth buffer
  46737. */
  46738. generateDepthTexture?: boolean;
  46739. /**
  46740. * Define the number of desired draw buffers
  46741. */
  46742. textureCount?: number;
  46743. /**
  46744. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46745. */
  46746. doNotChangeAspectRatio?: boolean;
  46747. /**
  46748. * Define the default type of the buffers we are creating
  46749. */
  46750. defaultType?: number;
  46751. }
  46752. /**
  46753. * A multi render target, like a render target provides the ability to render to a texture.
  46754. * Unlike the render target, it can render to several draw buffers in one draw.
  46755. * This is specially interesting in deferred rendering or for any effects requiring more than
  46756. * just one color from a single pass.
  46757. */
  46758. export class MultiRenderTarget extends RenderTargetTexture {
  46759. private _internalTextures;
  46760. private _textures;
  46761. private _multiRenderTargetOptions;
  46762. /**
  46763. * Get if draw buffers are currently supported by the used hardware and browser.
  46764. */
  46765. readonly isSupported: boolean;
  46766. /**
  46767. * Get the list of textures generated by the multi render target.
  46768. */
  46769. readonly textures: Texture[];
  46770. /**
  46771. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46772. */
  46773. readonly depthTexture: Texture;
  46774. /**
  46775. * Set the wrapping mode on U of all the textures we are rendering to.
  46776. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46777. */
  46778. wrapU: number;
  46779. /**
  46780. * Set the wrapping mode on V of all the textures we are rendering to.
  46781. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46782. */
  46783. wrapV: number;
  46784. /**
  46785. * Instantiate a new multi render target texture.
  46786. * A multi render target, like a render target provides the ability to render to a texture.
  46787. * Unlike the render target, it can render to several draw buffers in one draw.
  46788. * This is specially interesting in deferred rendering or for any effects requiring more than
  46789. * just one color from a single pass.
  46790. * @param name Define the name of the texture
  46791. * @param size Define the size of the buffers to render to
  46792. * @param count Define the number of target we are rendering into
  46793. * @param scene Define the scene the texture belongs to
  46794. * @param options Define the options used to create the multi render target
  46795. */
  46796. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46797. /** @hidden */
  46798. _rebuild(): void;
  46799. private _createInternalTextures;
  46800. private _createTextures;
  46801. /**
  46802. * Define the number of samples used if MSAA is enabled.
  46803. */
  46804. samples: number;
  46805. /**
  46806. * Resize all the textures in the multi render target.
  46807. * Be carrefull as it will recreate all the data in the new texture.
  46808. * @param size Define the new size
  46809. */
  46810. resize(size: any): void;
  46811. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46812. /**
  46813. * Dispose the render targets and their associated resources
  46814. */
  46815. dispose(): void;
  46816. /**
  46817. * Release all the underlying texture used as draw buffers.
  46818. */
  46819. releaseInternalTextures(): void;
  46820. }
  46821. }
  46822. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46823. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46824. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46825. import { Nullable } from "babylonjs/types";
  46826. module "babylonjs/Engines/thinEngine" {
  46827. interface ThinEngine {
  46828. /**
  46829. * Unbind a list of render target textures from the webGL context
  46830. * This is used only when drawBuffer extension or webGL2 are active
  46831. * @param textures defines the render target textures to unbind
  46832. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46833. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46834. */
  46835. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46836. /**
  46837. * Create a multi render target texture
  46838. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46839. * @param size defines the size of the texture
  46840. * @param options defines the creation options
  46841. * @returns the cube texture as an InternalTexture
  46842. */
  46843. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46844. /**
  46845. * Update the sample count for a given multiple render target texture
  46846. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46847. * @param textures defines the textures to update
  46848. * @param samples defines the sample count to set
  46849. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46850. */
  46851. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46852. }
  46853. }
  46854. }
  46855. declare module "babylonjs/Engines/Extensions/engine.views" {
  46856. import { Camera } from "babylonjs/Cameras/camera";
  46857. import { Nullable } from "babylonjs/types";
  46858. /**
  46859. * Class used to define an additional view for the engine
  46860. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46861. */
  46862. export class EngineView {
  46863. /** Defines the canvas where to render the view */
  46864. target: HTMLCanvasElement;
  46865. /** Defines an optional camera used to render the view (will use active camera else) */
  46866. camera?: Camera;
  46867. }
  46868. module "babylonjs/Engines/engine" {
  46869. interface Engine {
  46870. /**
  46871. * Gets or sets the HTML element to use for attaching events
  46872. */
  46873. inputElement: Nullable<HTMLElement>;
  46874. /**
  46875. * Gets the current engine view
  46876. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46877. */
  46878. activeView: Nullable<EngineView>;
  46879. /** Gets or sets the list of views */
  46880. views: EngineView[];
  46881. /**
  46882. * Register a new child canvas
  46883. * @param canvas defines the canvas to register
  46884. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46885. * @returns the associated view
  46886. */
  46887. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46888. /**
  46889. * Remove a registered child canvas
  46890. * @param canvas defines the canvas to remove
  46891. * @returns the current engine
  46892. */
  46893. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46894. }
  46895. }
  46896. }
  46897. declare module "babylonjs/Engines/Extensions/index" {
  46898. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46899. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46900. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46901. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46902. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46903. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46904. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46905. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46906. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46907. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46908. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46909. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46910. export * from "babylonjs/Engines/Extensions/engine.views";
  46911. }
  46912. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46913. import { Nullable } from "babylonjs/types";
  46914. /**
  46915. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46916. */
  46917. export interface CubeMapInfo {
  46918. /**
  46919. * The pixel array for the front face.
  46920. * This is stored in format, left to right, up to down format.
  46921. */
  46922. front: Nullable<ArrayBufferView>;
  46923. /**
  46924. * The pixel array for the back face.
  46925. * This is stored in format, left to right, up to down format.
  46926. */
  46927. back: Nullable<ArrayBufferView>;
  46928. /**
  46929. * The pixel array for the left face.
  46930. * This is stored in format, left to right, up to down format.
  46931. */
  46932. left: Nullable<ArrayBufferView>;
  46933. /**
  46934. * The pixel array for the right face.
  46935. * This is stored in format, left to right, up to down format.
  46936. */
  46937. right: Nullable<ArrayBufferView>;
  46938. /**
  46939. * The pixel array for the up face.
  46940. * This is stored in format, left to right, up to down format.
  46941. */
  46942. up: Nullable<ArrayBufferView>;
  46943. /**
  46944. * The pixel array for the down face.
  46945. * This is stored in format, left to right, up to down format.
  46946. */
  46947. down: Nullable<ArrayBufferView>;
  46948. /**
  46949. * The size of the cubemap stored.
  46950. *
  46951. * Each faces will be size * size pixels.
  46952. */
  46953. size: number;
  46954. /**
  46955. * The format of the texture.
  46956. *
  46957. * RGBA, RGB.
  46958. */
  46959. format: number;
  46960. /**
  46961. * The type of the texture data.
  46962. *
  46963. * UNSIGNED_INT, FLOAT.
  46964. */
  46965. type: number;
  46966. /**
  46967. * Specifies whether the texture is in gamma space.
  46968. */
  46969. gammaSpace: boolean;
  46970. }
  46971. /**
  46972. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46973. */
  46974. export class PanoramaToCubeMapTools {
  46975. private static FACE_FRONT;
  46976. private static FACE_BACK;
  46977. private static FACE_RIGHT;
  46978. private static FACE_LEFT;
  46979. private static FACE_DOWN;
  46980. private static FACE_UP;
  46981. /**
  46982. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46983. *
  46984. * @param float32Array The source data.
  46985. * @param inputWidth The width of the input panorama.
  46986. * @param inputHeight The height of the input panorama.
  46987. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46988. * @return The cubemap data
  46989. */
  46990. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46991. private static CreateCubemapTexture;
  46992. private static CalcProjectionSpherical;
  46993. }
  46994. }
  46995. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46996. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46998. import { Nullable } from "babylonjs/types";
  46999. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47000. /**
  47001. * Helper class dealing with the extraction of spherical polynomial dataArray
  47002. * from a cube map.
  47003. */
  47004. export class CubeMapToSphericalPolynomialTools {
  47005. private static FileFaces;
  47006. /**
  47007. * Converts a texture to the according Spherical Polynomial data.
  47008. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47009. *
  47010. * @param texture The texture to extract the information from.
  47011. * @return The Spherical Polynomial data.
  47012. */
  47013. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47014. /**
  47015. * Converts a cubemap to the according Spherical Polynomial data.
  47016. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47017. *
  47018. * @param cubeInfo The Cube map to extract the information from.
  47019. * @return The Spherical Polynomial data.
  47020. */
  47021. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47022. }
  47023. }
  47024. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  47025. import { Nullable } from "babylonjs/types";
  47026. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47027. module "babylonjs/Materials/Textures/baseTexture" {
  47028. interface BaseTexture {
  47029. /**
  47030. * Get the polynomial representation of the texture data.
  47031. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47032. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47033. */
  47034. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47035. }
  47036. }
  47037. }
  47038. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47039. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47040. /** @hidden */
  47041. export var rgbdEncodePixelShader: {
  47042. name: string;
  47043. shader: string;
  47044. };
  47045. }
  47046. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47047. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47048. /** @hidden */
  47049. export var rgbdDecodePixelShader: {
  47050. name: string;
  47051. shader: string;
  47052. };
  47053. }
  47054. declare module "babylonjs/Misc/environmentTextureTools" {
  47055. import { Nullable } from "babylonjs/types";
  47056. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47058. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47059. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47060. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  47061. import "babylonjs/Shaders/rgbdEncode.fragment";
  47062. import "babylonjs/Shaders/rgbdDecode.fragment";
  47063. /**
  47064. * Raw texture data and descriptor sufficient for WebGL texture upload
  47065. */
  47066. export interface EnvironmentTextureInfo {
  47067. /**
  47068. * Version of the environment map
  47069. */
  47070. version: number;
  47071. /**
  47072. * Width of image
  47073. */
  47074. width: number;
  47075. /**
  47076. * Irradiance information stored in the file.
  47077. */
  47078. irradiance: any;
  47079. /**
  47080. * Specular information stored in the file.
  47081. */
  47082. specular: any;
  47083. }
  47084. /**
  47085. * Defines One Image in the file. It requires only the position in the file
  47086. * as well as the length.
  47087. */
  47088. interface BufferImageData {
  47089. /**
  47090. * Length of the image data.
  47091. */
  47092. length: number;
  47093. /**
  47094. * Position of the data from the null terminator delimiting the end of the JSON.
  47095. */
  47096. position: number;
  47097. }
  47098. /**
  47099. * Defines the specular data enclosed in the file.
  47100. * This corresponds to the version 1 of the data.
  47101. */
  47102. export interface EnvironmentTextureSpecularInfoV1 {
  47103. /**
  47104. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47105. */
  47106. specularDataPosition?: number;
  47107. /**
  47108. * This contains all the images data needed to reconstruct the cubemap.
  47109. */
  47110. mipmaps: Array<BufferImageData>;
  47111. /**
  47112. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47113. */
  47114. lodGenerationScale: number;
  47115. }
  47116. /**
  47117. * Sets of helpers addressing the serialization and deserialization of environment texture
  47118. * stored in a BabylonJS env file.
  47119. * Those files are usually stored as .env files.
  47120. */
  47121. export class EnvironmentTextureTools {
  47122. /**
  47123. * Magic number identifying the env file.
  47124. */
  47125. private static _MagicBytes;
  47126. /**
  47127. * Gets the environment info from an env file.
  47128. * @param data The array buffer containing the .env bytes.
  47129. * @returns the environment file info (the json header) if successfully parsed.
  47130. */
  47131. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47132. /**
  47133. * Creates an environment texture from a loaded cube texture.
  47134. * @param texture defines the cube texture to convert in env file
  47135. * @return a promise containing the environment data if succesfull.
  47136. */
  47137. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47138. /**
  47139. * Creates a JSON representation of the spherical data.
  47140. * @param texture defines the texture containing the polynomials
  47141. * @return the JSON representation of the spherical info
  47142. */
  47143. private static _CreateEnvTextureIrradiance;
  47144. /**
  47145. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47146. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47147. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47148. * @return the views described by info providing access to the underlying buffer
  47149. */
  47150. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47151. /**
  47152. * Uploads the texture info contained in the env file to the GPU.
  47153. * @param texture defines the internal texture to upload to
  47154. * @param arrayBuffer defines the buffer cotaining the data to load
  47155. * @param info defines the texture info retrieved through the GetEnvInfo method
  47156. * @returns a promise
  47157. */
  47158. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47159. private static _OnImageReadyAsync;
  47160. /**
  47161. * Uploads the levels of image data to the GPU.
  47162. * @param texture defines the internal texture to upload to
  47163. * @param imageData defines the array buffer views of image data [mipmap][face]
  47164. * @returns a promise
  47165. */
  47166. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47167. /**
  47168. * Uploads spherical polynomials information to the texture.
  47169. * @param texture defines the texture we are trying to upload the information to
  47170. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47171. */
  47172. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47173. /** @hidden */
  47174. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47175. }
  47176. }
  47177. declare module "babylonjs/Maths/math.vertexFormat" {
  47178. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47179. /**
  47180. * Contains position and normal vectors for a vertex
  47181. */
  47182. export class PositionNormalVertex {
  47183. /** the position of the vertex (defaut: 0,0,0) */
  47184. position: Vector3;
  47185. /** the normal of the vertex (defaut: 0,1,0) */
  47186. normal: Vector3;
  47187. /**
  47188. * Creates a PositionNormalVertex
  47189. * @param position the position of the vertex (defaut: 0,0,0)
  47190. * @param normal the normal of the vertex (defaut: 0,1,0)
  47191. */
  47192. constructor(
  47193. /** the position of the vertex (defaut: 0,0,0) */
  47194. position?: Vector3,
  47195. /** the normal of the vertex (defaut: 0,1,0) */
  47196. normal?: Vector3);
  47197. /**
  47198. * Clones the PositionNormalVertex
  47199. * @returns the cloned PositionNormalVertex
  47200. */
  47201. clone(): PositionNormalVertex;
  47202. }
  47203. /**
  47204. * Contains position, normal and uv vectors for a vertex
  47205. */
  47206. export class PositionNormalTextureVertex {
  47207. /** the position of the vertex (defaut: 0,0,0) */
  47208. position: Vector3;
  47209. /** the normal of the vertex (defaut: 0,1,0) */
  47210. normal: Vector3;
  47211. /** the uv of the vertex (default: 0,0) */
  47212. uv: Vector2;
  47213. /**
  47214. * Creates a PositionNormalTextureVertex
  47215. * @param position the position of the vertex (defaut: 0,0,0)
  47216. * @param normal the normal of the vertex (defaut: 0,1,0)
  47217. * @param uv the uv of the vertex (default: 0,0)
  47218. */
  47219. constructor(
  47220. /** the position of the vertex (defaut: 0,0,0) */
  47221. position?: Vector3,
  47222. /** the normal of the vertex (defaut: 0,1,0) */
  47223. normal?: Vector3,
  47224. /** the uv of the vertex (default: 0,0) */
  47225. uv?: Vector2);
  47226. /**
  47227. * Clones the PositionNormalTextureVertex
  47228. * @returns the cloned PositionNormalTextureVertex
  47229. */
  47230. clone(): PositionNormalTextureVertex;
  47231. }
  47232. }
  47233. declare module "babylonjs/Maths/math" {
  47234. export * from "babylonjs/Maths/math.axis";
  47235. export * from "babylonjs/Maths/math.color";
  47236. export * from "babylonjs/Maths/math.constants";
  47237. export * from "babylonjs/Maths/math.frustum";
  47238. export * from "babylonjs/Maths/math.path";
  47239. export * from "babylonjs/Maths/math.plane";
  47240. export * from "babylonjs/Maths/math.size";
  47241. export * from "babylonjs/Maths/math.vector";
  47242. export * from "babylonjs/Maths/math.vertexFormat";
  47243. export * from "babylonjs/Maths/math.viewport";
  47244. }
  47245. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47246. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47247. /** @hidden */
  47248. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47249. private _genericAttributeLocation;
  47250. private _varyingLocationCount;
  47251. private _varyingLocationMap;
  47252. private _replacements;
  47253. private _textureCount;
  47254. private _uniforms;
  47255. lineProcessor(line: string): string;
  47256. attributeProcessor(attribute: string): string;
  47257. varyingProcessor(varying: string, isFragment: boolean): string;
  47258. uniformProcessor(uniform: string): string;
  47259. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47260. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47261. }
  47262. }
  47263. declare module "babylonjs/Engines/nativeEngine" {
  47264. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47265. import { Engine } from "babylonjs/Engines/engine";
  47266. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47267. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47268. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47269. import { Effect } from "babylonjs/Materials/effect";
  47270. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47271. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47272. import { IColor4Like } from "babylonjs/Maths/math.like";
  47273. import { Scene } from "babylonjs/scene";
  47274. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47275. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47276. /**
  47277. * Container for accessors for natively-stored mesh data buffers.
  47278. */
  47279. class NativeDataBuffer extends DataBuffer {
  47280. /**
  47281. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47282. */
  47283. nativeIndexBuffer?: any;
  47284. /**
  47285. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47286. */
  47287. nativeVertexBuffer?: any;
  47288. }
  47289. /** @hidden */
  47290. class NativeTexture extends InternalTexture {
  47291. getInternalTexture(): InternalTexture;
  47292. getViewCount(): number;
  47293. }
  47294. /** @hidden */
  47295. export class NativeEngine extends Engine {
  47296. private readonly _native;
  47297. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47298. private readonly INVALID_HANDLE;
  47299. getHardwareScalingLevel(): number;
  47300. constructor();
  47301. /**
  47302. * Can be used to override the current requestAnimationFrame requester.
  47303. * @hidden
  47304. */
  47305. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47306. /**
  47307. * Override default engine behavior.
  47308. * @param color
  47309. * @param backBuffer
  47310. * @param depth
  47311. * @param stencil
  47312. */
  47313. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47314. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47315. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47316. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47317. recordVertexArrayObject(vertexBuffers: {
  47318. [key: string]: VertexBuffer;
  47319. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47320. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47321. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47322. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47323. /**
  47324. * Draw a list of indexed primitives
  47325. * @param fillMode defines the primitive to use
  47326. * @param indexStart defines the starting index
  47327. * @param indexCount defines the number of index to draw
  47328. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47329. */
  47330. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47331. /**
  47332. * Draw a list of unindexed primitives
  47333. * @param fillMode defines the primitive to use
  47334. * @param verticesStart defines the index of first vertex to draw
  47335. * @param verticesCount defines the count of vertices to draw
  47336. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47337. */
  47338. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47339. createPipelineContext(): IPipelineContext;
  47340. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47341. /** @hidden */
  47342. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47343. /** @hidden */
  47344. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47345. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47346. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47347. protected _setProgram(program: WebGLProgram): void;
  47348. _releaseEffect(effect: Effect): void;
  47349. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47350. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47351. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47352. bindSamplers(effect: Effect): void;
  47353. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47354. getRenderWidth(useScreen?: boolean): number;
  47355. getRenderHeight(useScreen?: boolean): number;
  47356. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47357. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47358. /**
  47359. * Set the z offset to apply to current rendering
  47360. * @param value defines the offset to apply
  47361. */
  47362. setZOffset(value: number): void;
  47363. /**
  47364. * Gets the current value of the zOffset
  47365. * @returns the current zOffset state
  47366. */
  47367. getZOffset(): number;
  47368. /**
  47369. * Enable or disable depth buffering
  47370. * @param enable defines the state to set
  47371. */
  47372. setDepthBuffer(enable: boolean): void;
  47373. /**
  47374. * Gets a boolean indicating if depth writing is enabled
  47375. * @returns the current depth writing state
  47376. */
  47377. getDepthWrite(): boolean;
  47378. /**
  47379. * Enable or disable depth writing
  47380. * @param enable defines the state to set
  47381. */
  47382. setDepthWrite(enable: boolean): void;
  47383. /**
  47384. * Enable or disable color writing
  47385. * @param enable defines the state to set
  47386. */
  47387. setColorWrite(enable: boolean): void;
  47388. /**
  47389. * Gets a boolean indicating if color writing is enabled
  47390. * @returns the current color writing state
  47391. */
  47392. getColorWrite(): boolean;
  47393. /**
  47394. * Sets alpha constants used by some alpha blending modes
  47395. * @param r defines the red component
  47396. * @param g defines the green component
  47397. * @param b defines the blue component
  47398. * @param a defines the alpha component
  47399. */
  47400. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47401. /**
  47402. * Sets the current alpha mode
  47403. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47404. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47405. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47406. */
  47407. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47408. /**
  47409. * Gets the current alpha mode
  47410. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47411. * @returns the current alpha mode
  47412. */
  47413. getAlphaMode(): number;
  47414. setInt(uniform: WebGLUniformLocation, int: number): void;
  47415. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47416. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47417. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47418. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47419. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47420. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47421. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47422. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47423. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47424. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47425. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47426. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47427. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47428. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47429. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47430. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47431. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47432. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47433. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47434. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47435. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47436. wipeCaches(bruteForce?: boolean): void;
  47437. _createTexture(): WebGLTexture;
  47438. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47439. /**
  47440. * Usually called from BABYLON.Texture.ts.
  47441. * Passed information to create a WebGLTexture
  47442. * @param urlArg defines a value which contains one of the following:
  47443. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47444. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47445. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47446. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47447. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47448. * @param scene needed for loading to the correct scene
  47449. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47450. * @param onLoad optional callback to be called upon successful completion
  47451. * @param onError optional callback to be called upon failure
  47452. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47453. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47454. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47455. * @param forcedExtension defines the extension to use to pick the right loader
  47456. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47457. */
  47458. 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;
  47459. /**
  47460. * Creates a cube texture
  47461. * @param rootUrl defines the url where the files to load is located
  47462. * @param scene defines the current scene
  47463. * @param files defines the list of files to load (1 per face)
  47464. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47465. * @param onLoad defines an optional callback raised when the texture is loaded
  47466. * @param onError defines an optional callback raised if there is an issue to load the texture
  47467. * @param format defines the format of the data
  47468. * @param forcedExtension defines the extension to use to pick the right loader
  47469. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47470. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47471. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47472. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47473. * @returns the cube texture as an InternalTexture
  47474. */
  47475. 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;
  47476. private _getSamplingFilter;
  47477. private static _GetNativeTextureFormat;
  47478. createRenderTargetTexture(size: number | {
  47479. width: number;
  47480. height: number;
  47481. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47482. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47483. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47484. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47485. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47486. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47487. /**
  47488. * Updates a dynamic vertex buffer.
  47489. * @param vertexBuffer the vertex buffer to update
  47490. * @param data the data used to update the vertex buffer
  47491. * @param byteOffset the byte offset of the data (optional)
  47492. * @param byteLength the byte length of the data (optional)
  47493. */
  47494. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47495. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47496. private _updateAnisotropicLevel;
  47497. private _getAddressMode;
  47498. /** @hidden */
  47499. _bindTexture(channel: number, texture: InternalTexture): void;
  47500. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47501. releaseEffects(): void;
  47502. /** @hidden */
  47503. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47504. /** @hidden */
  47505. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47506. /** @hidden */
  47507. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47508. /** @hidden */
  47509. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47510. }
  47511. }
  47512. declare module "babylonjs/Engines/index" {
  47513. export * from "babylonjs/Engines/constants";
  47514. export * from "babylonjs/Engines/engineCapabilities";
  47515. export * from "babylonjs/Engines/instancingAttributeInfo";
  47516. export * from "babylonjs/Engines/thinEngine";
  47517. export * from "babylonjs/Engines/engine";
  47518. export * from "babylonjs/Engines/engineStore";
  47519. export * from "babylonjs/Engines/nullEngine";
  47520. export * from "babylonjs/Engines/Extensions/index";
  47521. export * from "babylonjs/Engines/IPipelineContext";
  47522. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47523. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47524. export * from "babylonjs/Engines/nativeEngine";
  47525. }
  47526. declare module "babylonjs/Events/clipboardEvents" {
  47527. /**
  47528. * Gather the list of clipboard event types as constants.
  47529. */
  47530. export class ClipboardEventTypes {
  47531. /**
  47532. * The clipboard event is fired when a copy command is active (pressed).
  47533. */
  47534. static readonly COPY: number;
  47535. /**
  47536. * The clipboard event is fired when a cut command is active (pressed).
  47537. */
  47538. static readonly CUT: number;
  47539. /**
  47540. * The clipboard event is fired when a paste command is active (pressed).
  47541. */
  47542. static readonly PASTE: number;
  47543. }
  47544. /**
  47545. * This class is used to store clipboard related info for the onClipboardObservable event.
  47546. */
  47547. export class ClipboardInfo {
  47548. /**
  47549. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47550. */
  47551. type: number;
  47552. /**
  47553. * Defines the related dom event
  47554. */
  47555. event: ClipboardEvent;
  47556. /**
  47557. *Creates an instance of ClipboardInfo.
  47558. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47559. * @param event Defines the related dom event
  47560. */
  47561. constructor(
  47562. /**
  47563. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47564. */
  47565. type: number,
  47566. /**
  47567. * Defines the related dom event
  47568. */
  47569. event: ClipboardEvent);
  47570. /**
  47571. * Get the clipboard event's type from the keycode.
  47572. * @param keyCode Defines the keyCode for the current keyboard event.
  47573. * @return {number}
  47574. */
  47575. static GetTypeFromCharacter(keyCode: number): number;
  47576. }
  47577. }
  47578. declare module "babylonjs/Events/index" {
  47579. export * from "babylonjs/Events/keyboardEvents";
  47580. export * from "babylonjs/Events/pointerEvents";
  47581. export * from "babylonjs/Events/clipboardEvents";
  47582. }
  47583. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47584. import { Scene } from "babylonjs/scene";
  47585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47586. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47587. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47588. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47589. /**
  47590. * Google Daydream controller
  47591. */
  47592. export class DaydreamController extends WebVRController {
  47593. /**
  47594. * Base Url for the controller model.
  47595. */
  47596. static MODEL_BASE_URL: string;
  47597. /**
  47598. * File name for the controller model.
  47599. */
  47600. static MODEL_FILENAME: string;
  47601. /**
  47602. * Gamepad Id prefix used to identify Daydream Controller.
  47603. */
  47604. static readonly GAMEPAD_ID_PREFIX: string;
  47605. /**
  47606. * Creates a new DaydreamController from a gamepad
  47607. * @param vrGamepad the gamepad that the controller should be created from
  47608. */
  47609. constructor(vrGamepad: any);
  47610. /**
  47611. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47612. * @param scene scene in which to add meshes
  47613. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47614. */
  47615. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47616. /**
  47617. * Called once for each button that changed state since the last frame
  47618. * @param buttonIdx Which button index changed
  47619. * @param state New state of the button
  47620. * @param changes Which properties on the state changed since last frame
  47621. */
  47622. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47623. }
  47624. }
  47625. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47626. import { Scene } from "babylonjs/scene";
  47627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47628. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47629. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47630. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47631. /**
  47632. * Gear VR Controller
  47633. */
  47634. export class GearVRController extends WebVRController {
  47635. /**
  47636. * Base Url for the controller model.
  47637. */
  47638. static MODEL_BASE_URL: string;
  47639. /**
  47640. * File name for the controller model.
  47641. */
  47642. static MODEL_FILENAME: string;
  47643. /**
  47644. * Gamepad Id prefix used to identify this controller.
  47645. */
  47646. static readonly GAMEPAD_ID_PREFIX: string;
  47647. private readonly _buttonIndexToObservableNameMap;
  47648. /**
  47649. * Creates a new GearVRController from a gamepad
  47650. * @param vrGamepad the gamepad that the controller should be created from
  47651. */
  47652. constructor(vrGamepad: any);
  47653. /**
  47654. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47655. * @param scene scene in which to add meshes
  47656. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47657. */
  47658. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47659. /**
  47660. * Called once for each button that changed state since the last frame
  47661. * @param buttonIdx Which button index changed
  47662. * @param state New state of the button
  47663. * @param changes Which properties on the state changed since last frame
  47664. */
  47665. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47666. }
  47667. }
  47668. declare module "babylonjs/Gamepads/Controllers/index" {
  47669. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47670. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47671. export * from "babylonjs/Gamepads/Controllers/genericController";
  47672. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47673. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47674. export * from "babylonjs/Gamepads/Controllers/viveController";
  47675. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47676. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47677. }
  47678. declare module "babylonjs/Gamepads/index" {
  47679. export * from "babylonjs/Gamepads/Controllers/index";
  47680. export * from "babylonjs/Gamepads/gamepad";
  47681. export * from "babylonjs/Gamepads/gamepadManager";
  47682. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47683. export * from "babylonjs/Gamepads/xboxGamepad";
  47684. export * from "babylonjs/Gamepads/dualShockGamepad";
  47685. }
  47686. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47687. import { Scene } from "babylonjs/scene";
  47688. import { Vector4 } from "babylonjs/Maths/math.vector";
  47689. import { Color4 } from "babylonjs/Maths/math.color";
  47690. import { Mesh } from "babylonjs/Meshes/mesh";
  47691. import { Nullable } from "babylonjs/types";
  47692. /**
  47693. * Class containing static functions to help procedurally build meshes
  47694. */
  47695. export class PolyhedronBuilder {
  47696. /**
  47697. * Creates a polyhedron mesh
  47698. * * 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
  47699. * * The parameter `size` (positive float, default 1) sets the polygon size
  47700. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47701. * * 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`
  47702. * * 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
  47703. * * 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)`)
  47704. * * 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
  47705. * * 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
  47706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47709. * @param name defines the name of the mesh
  47710. * @param options defines the options used to create the mesh
  47711. * @param scene defines the hosting scene
  47712. * @returns the polyhedron mesh
  47713. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47714. */
  47715. static CreatePolyhedron(name: string, options: {
  47716. type?: number;
  47717. size?: number;
  47718. sizeX?: number;
  47719. sizeY?: number;
  47720. sizeZ?: number;
  47721. custom?: any;
  47722. faceUV?: Vector4[];
  47723. faceColors?: Color4[];
  47724. flat?: boolean;
  47725. updatable?: boolean;
  47726. sideOrientation?: number;
  47727. frontUVs?: Vector4;
  47728. backUVs?: Vector4;
  47729. }, scene?: Nullable<Scene>): Mesh;
  47730. }
  47731. }
  47732. declare module "babylonjs/Gizmos/scaleGizmo" {
  47733. import { Observable } from "babylonjs/Misc/observable";
  47734. import { Nullable } from "babylonjs/types";
  47735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47736. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47737. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47738. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47739. /**
  47740. * Gizmo that enables scaling a mesh along 3 axis
  47741. */
  47742. export class ScaleGizmo extends Gizmo {
  47743. /**
  47744. * Internal gizmo used for interactions on the x axis
  47745. */
  47746. xGizmo: AxisScaleGizmo;
  47747. /**
  47748. * Internal gizmo used for interactions on the y axis
  47749. */
  47750. yGizmo: AxisScaleGizmo;
  47751. /**
  47752. * Internal gizmo used for interactions on the z axis
  47753. */
  47754. zGizmo: AxisScaleGizmo;
  47755. /**
  47756. * Internal gizmo used to scale all axis equally
  47757. */
  47758. uniformScaleGizmo: AxisScaleGizmo;
  47759. private _meshAttached;
  47760. private _updateGizmoRotationToMatchAttachedMesh;
  47761. private _snapDistance;
  47762. private _scaleRatio;
  47763. private _uniformScalingMesh;
  47764. private _octahedron;
  47765. private _sensitivity;
  47766. /** Fires an event when any of it's sub gizmos are dragged */
  47767. onDragStartObservable: Observable<unknown>;
  47768. /** Fires an event when any of it's sub gizmos are released from dragging */
  47769. onDragEndObservable: Observable<unknown>;
  47770. attachedMesh: Nullable<AbstractMesh>;
  47771. /**
  47772. * Creates a ScaleGizmo
  47773. * @param gizmoLayer The utility layer the gizmo will be added to
  47774. */
  47775. constructor(gizmoLayer?: UtilityLayerRenderer);
  47776. updateGizmoRotationToMatchAttachedMesh: boolean;
  47777. /**
  47778. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47779. */
  47780. snapDistance: number;
  47781. /**
  47782. * Ratio for the scale of the gizmo (Default: 1)
  47783. */
  47784. scaleRatio: number;
  47785. /**
  47786. * Sensitivity factor for dragging (Default: 1)
  47787. */
  47788. sensitivity: number;
  47789. /**
  47790. * Disposes of the gizmo
  47791. */
  47792. dispose(): void;
  47793. }
  47794. }
  47795. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47796. import { Observable } from "babylonjs/Misc/observable";
  47797. import { Nullable } from "babylonjs/types";
  47798. import { Vector3 } from "babylonjs/Maths/math.vector";
  47799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47800. import { Mesh } from "babylonjs/Meshes/mesh";
  47801. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47802. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47803. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47804. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47805. import { Color3 } from "babylonjs/Maths/math.color";
  47806. /**
  47807. * Single axis scale gizmo
  47808. */
  47809. export class AxisScaleGizmo extends Gizmo {
  47810. /**
  47811. * Drag behavior responsible for the gizmos dragging interactions
  47812. */
  47813. dragBehavior: PointerDragBehavior;
  47814. private _pointerObserver;
  47815. /**
  47816. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47817. */
  47818. snapDistance: number;
  47819. /**
  47820. * Event that fires each time the gizmo snaps to a new location.
  47821. * * snapDistance is the the change in distance
  47822. */
  47823. onSnapObservable: Observable<{
  47824. snapDistance: number;
  47825. }>;
  47826. /**
  47827. * If the scaling operation should be done on all axis (default: false)
  47828. */
  47829. uniformScaling: boolean;
  47830. /**
  47831. * Custom sensitivity value for the drag strength
  47832. */
  47833. sensitivity: number;
  47834. private _isEnabled;
  47835. private _parent;
  47836. private _arrow;
  47837. private _coloredMaterial;
  47838. private _hoverMaterial;
  47839. /**
  47840. * Creates an AxisScaleGizmo
  47841. * @param gizmoLayer The utility layer the gizmo will be added to
  47842. * @param dragAxis The axis which the gizmo will be able to scale on
  47843. * @param color The color of the gizmo
  47844. */
  47845. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47846. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47847. /**
  47848. * If the gizmo is enabled
  47849. */
  47850. isEnabled: boolean;
  47851. /**
  47852. * Disposes of the gizmo
  47853. */
  47854. dispose(): void;
  47855. /**
  47856. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47857. * @param mesh The mesh to replace the default mesh of the gizmo
  47858. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47859. */
  47860. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47861. }
  47862. }
  47863. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47864. import { Observable } from "babylonjs/Misc/observable";
  47865. import { Nullable } from "babylonjs/types";
  47866. import { Vector3 } from "babylonjs/Maths/math.vector";
  47867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47868. import { Mesh } from "babylonjs/Meshes/mesh";
  47869. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47870. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47871. import { Color3 } from "babylonjs/Maths/math.color";
  47872. import "babylonjs/Meshes/Builders/boxBuilder";
  47873. /**
  47874. * Bounding box gizmo
  47875. */
  47876. export class BoundingBoxGizmo extends Gizmo {
  47877. private _lineBoundingBox;
  47878. private _rotateSpheresParent;
  47879. private _scaleBoxesParent;
  47880. private _boundingDimensions;
  47881. private _renderObserver;
  47882. private _pointerObserver;
  47883. private _scaleDragSpeed;
  47884. private _tmpQuaternion;
  47885. private _tmpVector;
  47886. private _tmpRotationMatrix;
  47887. /**
  47888. * 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)
  47889. */
  47890. ignoreChildren: boolean;
  47891. /**
  47892. * 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)
  47893. */
  47894. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47895. /**
  47896. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47897. */
  47898. rotationSphereSize: number;
  47899. /**
  47900. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47901. */
  47902. scaleBoxSize: number;
  47903. /**
  47904. * 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)
  47905. */
  47906. fixedDragMeshScreenSize: boolean;
  47907. /**
  47908. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47909. */
  47910. fixedDragMeshScreenSizeDistanceFactor: number;
  47911. /**
  47912. * Fired when a rotation sphere or scale box is dragged
  47913. */
  47914. onDragStartObservable: Observable<{}>;
  47915. /**
  47916. * Fired when a scale box is dragged
  47917. */
  47918. onScaleBoxDragObservable: Observable<{}>;
  47919. /**
  47920. * Fired when a scale box drag is ended
  47921. */
  47922. onScaleBoxDragEndObservable: Observable<{}>;
  47923. /**
  47924. * Fired when a rotation sphere is dragged
  47925. */
  47926. onRotationSphereDragObservable: Observable<{}>;
  47927. /**
  47928. * Fired when a rotation sphere drag is ended
  47929. */
  47930. onRotationSphereDragEndObservable: Observable<{}>;
  47931. /**
  47932. * 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)
  47933. */
  47934. scalePivot: Nullable<Vector3>;
  47935. /**
  47936. * Mesh used as a pivot to rotate the attached mesh
  47937. */
  47938. private _anchorMesh;
  47939. private _existingMeshScale;
  47940. private _dragMesh;
  47941. private pointerDragBehavior;
  47942. private coloredMaterial;
  47943. private hoverColoredMaterial;
  47944. /**
  47945. * Sets the color of the bounding box gizmo
  47946. * @param color the color to set
  47947. */
  47948. setColor(color: Color3): void;
  47949. /**
  47950. * Creates an BoundingBoxGizmo
  47951. * @param gizmoLayer The utility layer the gizmo will be added to
  47952. * @param color The color of the gizmo
  47953. */
  47954. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47955. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47956. private _selectNode;
  47957. /**
  47958. * Updates the bounding box information for the Gizmo
  47959. */
  47960. updateBoundingBox(): void;
  47961. private _updateRotationSpheres;
  47962. private _updateScaleBoxes;
  47963. /**
  47964. * Enables rotation on the specified axis and disables rotation on the others
  47965. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47966. */
  47967. setEnabledRotationAxis(axis: string): void;
  47968. /**
  47969. * Enables/disables scaling
  47970. * @param enable if scaling should be enabled
  47971. */
  47972. setEnabledScaling(enable: boolean): void;
  47973. private _updateDummy;
  47974. /**
  47975. * Enables a pointer drag behavior on the bounding box of the gizmo
  47976. */
  47977. enableDragBehavior(): void;
  47978. /**
  47979. * Disposes of the gizmo
  47980. */
  47981. dispose(): void;
  47982. /**
  47983. * 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)
  47984. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47985. * @returns the bounding box mesh with the passed in mesh as a child
  47986. */
  47987. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47988. /**
  47989. * CustomMeshes are not supported by this gizmo
  47990. * @param mesh The mesh to replace the default mesh of the gizmo
  47991. */
  47992. setCustomMesh(mesh: Mesh): void;
  47993. }
  47994. }
  47995. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47996. import { Observable } from "babylonjs/Misc/observable";
  47997. import { Nullable } from "babylonjs/types";
  47998. import { Vector3 } from "babylonjs/Maths/math.vector";
  47999. import { Color3 } from "babylonjs/Maths/math.color";
  48000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48001. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48002. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48003. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48004. import "babylonjs/Meshes/Builders/linesBuilder";
  48005. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48006. /**
  48007. * Single plane rotation gizmo
  48008. */
  48009. export class PlaneRotationGizmo extends Gizmo {
  48010. /**
  48011. * Drag behavior responsible for the gizmos dragging interactions
  48012. */
  48013. dragBehavior: PointerDragBehavior;
  48014. private _pointerObserver;
  48015. /**
  48016. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48017. */
  48018. snapDistance: number;
  48019. /**
  48020. * Event that fires each time the gizmo snaps to a new location.
  48021. * * snapDistance is the the change in distance
  48022. */
  48023. onSnapObservable: Observable<{
  48024. snapDistance: number;
  48025. }>;
  48026. private _isEnabled;
  48027. private _parent;
  48028. /**
  48029. * Creates a PlaneRotationGizmo
  48030. * @param gizmoLayer The utility layer the gizmo will be added to
  48031. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48032. * @param color The color of the gizmo
  48033. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48034. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48035. */
  48036. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48037. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48038. /**
  48039. * If the gizmo is enabled
  48040. */
  48041. isEnabled: boolean;
  48042. /**
  48043. * Disposes of the gizmo
  48044. */
  48045. dispose(): void;
  48046. }
  48047. }
  48048. declare module "babylonjs/Gizmos/rotationGizmo" {
  48049. import { Observable } from "babylonjs/Misc/observable";
  48050. import { Nullable } from "babylonjs/types";
  48051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48052. import { Mesh } from "babylonjs/Meshes/mesh";
  48053. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48054. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  48055. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48056. /**
  48057. * Gizmo that enables rotating a mesh along 3 axis
  48058. */
  48059. export class RotationGizmo extends Gizmo {
  48060. /**
  48061. * Internal gizmo used for interactions on the x axis
  48062. */
  48063. xGizmo: PlaneRotationGizmo;
  48064. /**
  48065. * Internal gizmo used for interactions on the y axis
  48066. */
  48067. yGizmo: PlaneRotationGizmo;
  48068. /**
  48069. * Internal gizmo used for interactions on the z axis
  48070. */
  48071. zGizmo: PlaneRotationGizmo;
  48072. /** Fires an event when any of it's sub gizmos are dragged */
  48073. onDragStartObservable: Observable<unknown>;
  48074. /** Fires an event when any of it's sub gizmos are released from dragging */
  48075. onDragEndObservable: Observable<unknown>;
  48076. private _meshAttached;
  48077. attachedMesh: Nullable<AbstractMesh>;
  48078. /**
  48079. * Creates a RotationGizmo
  48080. * @param gizmoLayer The utility layer the gizmo will be added to
  48081. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48082. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48083. */
  48084. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48085. updateGizmoRotationToMatchAttachedMesh: boolean;
  48086. /**
  48087. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48088. */
  48089. snapDistance: number;
  48090. /**
  48091. * Ratio for the scale of the gizmo (Default: 1)
  48092. */
  48093. scaleRatio: number;
  48094. /**
  48095. * Disposes of the gizmo
  48096. */
  48097. dispose(): void;
  48098. /**
  48099. * CustomMeshes are not supported by this gizmo
  48100. * @param mesh The mesh to replace the default mesh of the gizmo
  48101. */
  48102. setCustomMesh(mesh: Mesh): void;
  48103. }
  48104. }
  48105. declare module "babylonjs/Gizmos/gizmoManager" {
  48106. import { Observable } from "babylonjs/Misc/observable";
  48107. import { Nullable } from "babylonjs/types";
  48108. import { Scene, IDisposable } from "babylonjs/scene";
  48109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48110. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48111. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48112. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48113. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48114. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48115. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  48116. /**
  48117. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48118. */
  48119. export class GizmoManager implements IDisposable {
  48120. private scene;
  48121. /**
  48122. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48123. */
  48124. gizmos: {
  48125. positionGizmo: Nullable<PositionGizmo>;
  48126. rotationGizmo: Nullable<RotationGizmo>;
  48127. scaleGizmo: Nullable<ScaleGizmo>;
  48128. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48129. };
  48130. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48131. clearGizmoOnEmptyPointerEvent: boolean;
  48132. /** Fires an event when the manager is attached to a mesh */
  48133. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48134. private _gizmosEnabled;
  48135. private _pointerObserver;
  48136. private _attachedMesh;
  48137. private _boundingBoxColor;
  48138. private _defaultUtilityLayer;
  48139. private _defaultKeepDepthUtilityLayer;
  48140. /**
  48141. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48142. */
  48143. boundingBoxDragBehavior: SixDofDragBehavior;
  48144. /**
  48145. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48146. */
  48147. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48148. /**
  48149. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48150. */
  48151. usePointerToAttachGizmos: boolean;
  48152. /**
  48153. * Utility layer that the bounding box gizmo belongs to
  48154. */
  48155. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48156. /**
  48157. * Utility layer that all gizmos besides bounding box belong to
  48158. */
  48159. readonly utilityLayer: UtilityLayerRenderer;
  48160. /**
  48161. * Instatiates a gizmo manager
  48162. * @param scene the scene to overlay the gizmos on top of
  48163. */
  48164. constructor(scene: Scene);
  48165. /**
  48166. * Attaches a set of gizmos to the specified mesh
  48167. * @param mesh The mesh the gizmo's should be attached to
  48168. */
  48169. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48170. /**
  48171. * If the position gizmo is enabled
  48172. */
  48173. positionGizmoEnabled: boolean;
  48174. /**
  48175. * If the rotation gizmo is enabled
  48176. */
  48177. rotationGizmoEnabled: boolean;
  48178. /**
  48179. * If the scale gizmo is enabled
  48180. */
  48181. scaleGizmoEnabled: boolean;
  48182. /**
  48183. * If the boundingBox gizmo is enabled
  48184. */
  48185. boundingBoxGizmoEnabled: boolean;
  48186. /**
  48187. * Disposes of the gizmo manager
  48188. */
  48189. dispose(): void;
  48190. }
  48191. }
  48192. declare module "babylonjs/Lights/directionalLight" {
  48193. import { Camera } from "babylonjs/Cameras/camera";
  48194. import { Scene } from "babylonjs/scene";
  48195. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48197. import { Light } from "babylonjs/Lights/light";
  48198. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48199. import { Effect } from "babylonjs/Materials/effect";
  48200. /**
  48201. * A directional light is defined by a direction (what a surprise!).
  48202. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48203. * 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.
  48204. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48205. */
  48206. export class DirectionalLight extends ShadowLight {
  48207. private _shadowFrustumSize;
  48208. /**
  48209. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48210. */
  48211. /**
  48212. * Specifies a fix frustum size for the shadow generation.
  48213. */
  48214. shadowFrustumSize: number;
  48215. private _shadowOrthoScale;
  48216. /**
  48217. * Gets the shadow projection scale against the optimal computed one.
  48218. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48219. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48220. */
  48221. /**
  48222. * Sets the shadow projection scale against the optimal computed one.
  48223. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48224. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48225. */
  48226. shadowOrthoScale: number;
  48227. /**
  48228. * Automatically compute the projection matrix to best fit (including all the casters)
  48229. * on each frame.
  48230. */
  48231. autoUpdateExtends: boolean;
  48232. private _orthoLeft;
  48233. private _orthoRight;
  48234. private _orthoTop;
  48235. private _orthoBottom;
  48236. /**
  48237. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48238. * The directional light is emitted from everywhere in the given direction.
  48239. * It can cast shadows.
  48240. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48241. * @param name The friendly name of the light
  48242. * @param direction The direction of the light
  48243. * @param scene The scene the light belongs to
  48244. */
  48245. constructor(name: string, direction: Vector3, scene: Scene);
  48246. /**
  48247. * Returns the string "DirectionalLight".
  48248. * @return The class name
  48249. */
  48250. getClassName(): string;
  48251. /**
  48252. * Returns the integer 1.
  48253. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48254. */
  48255. getTypeID(): number;
  48256. /**
  48257. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48258. * Returns the DirectionalLight Shadow projection matrix.
  48259. */
  48260. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48261. /**
  48262. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48263. * Returns the DirectionalLight Shadow projection matrix.
  48264. */
  48265. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48266. /**
  48267. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48268. * Returns the DirectionalLight Shadow projection matrix.
  48269. */
  48270. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48271. protected _buildUniformLayout(): void;
  48272. /**
  48273. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48274. * @param effect The effect to update
  48275. * @param lightIndex The index of the light in the effect to update
  48276. * @returns The directional light
  48277. */
  48278. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48279. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48280. /**
  48281. * Gets the minZ used for shadow according to both the scene and the light.
  48282. *
  48283. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48284. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48285. * @param activeCamera The camera we are returning the min for
  48286. * @returns the depth min z
  48287. */
  48288. getDepthMinZ(activeCamera: Camera): number;
  48289. /**
  48290. * Gets the maxZ used for shadow according to both the scene and the light.
  48291. *
  48292. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48293. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48294. * @param activeCamera The camera we are returning the max for
  48295. * @returns the depth max z
  48296. */
  48297. getDepthMaxZ(activeCamera: Camera): number;
  48298. /**
  48299. * Prepares the list of defines specific to the light type.
  48300. * @param defines the list of defines
  48301. * @param lightIndex defines the index of the light for the effect
  48302. */
  48303. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48304. }
  48305. }
  48306. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48307. import { Mesh } from "babylonjs/Meshes/mesh";
  48308. /**
  48309. * Class containing static functions to help procedurally build meshes
  48310. */
  48311. export class HemisphereBuilder {
  48312. /**
  48313. * Creates a hemisphere mesh
  48314. * @param name defines the name of the mesh
  48315. * @param options defines the options used to create the mesh
  48316. * @param scene defines the hosting scene
  48317. * @returns the hemisphere mesh
  48318. */
  48319. static CreateHemisphere(name: string, options: {
  48320. segments?: number;
  48321. diameter?: number;
  48322. sideOrientation?: number;
  48323. }, scene: any): Mesh;
  48324. }
  48325. }
  48326. declare module "babylonjs/Lights/spotLight" {
  48327. import { Nullable } from "babylonjs/types";
  48328. import { Scene } from "babylonjs/scene";
  48329. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48331. import { Effect } from "babylonjs/Materials/effect";
  48332. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48333. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48334. /**
  48335. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48336. * These values define a cone of light starting from the position, emitting toward the direction.
  48337. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48338. * and the exponent defines the speed of the decay of the light with distance (reach).
  48339. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48340. */
  48341. export class SpotLight extends ShadowLight {
  48342. private _angle;
  48343. private _innerAngle;
  48344. private _cosHalfAngle;
  48345. private _lightAngleScale;
  48346. private _lightAngleOffset;
  48347. /**
  48348. * Gets the cone angle of the spot light in Radians.
  48349. */
  48350. /**
  48351. * Sets the cone angle of the spot light in Radians.
  48352. */
  48353. angle: number;
  48354. /**
  48355. * Only used in gltf falloff mode, this defines the angle where
  48356. * the directional falloff will start before cutting at angle which could be seen
  48357. * as outer angle.
  48358. */
  48359. /**
  48360. * Only used in gltf falloff mode, this defines the angle where
  48361. * the directional falloff will start before cutting at angle which could be seen
  48362. * as outer angle.
  48363. */
  48364. innerAngle: number;
  48365. private _shadowAngleScale;
  48366. /**
  48367. * Allows scaling the angle of the light for shadow generation only.
  48368. */
  48369. /**
  48370. * Allows scaling the angle of the light for shadow generation only.
  48371. */
  48372. shadowAngleScale: number;
  48373. /**
  48374. * The light decay speed with the distance from the emission spot.
  48375. */
  48376. exponent: number;
  48377. private _projectionTextureMatrix;
  48378. /**
  48379. * Allows reading the projecton texture
  48380. */
  48381. readonly projectionTextureMatrix: Matrix;
  48382. protected _projectionTextureLightNear: number;
  48383. /**
  48384. * Gets the near clip of the Spotlight for texture projection.
  48385. */
  48386. /**
  48387. * Sets the near clip of the Spotlight for texture projection.
  48388. */
  48389. projectionTextureLightNear: number;
  48390. protected _projectionTextureLightFar: number;
  48391. /**
  48392. * Gets the far clip of the Spotlight for texture projection.
  48393. */
  48394. /**
  48395. * Sets the far clip of the Spotlight for texture projection.
  48396. */
  48397. projectionTextureLightFar: number;
  48398. protected _projectionTextureUpDirection: Vector3;
  48399. /**
  48400. * Gets the Up vector of the Spotlight for texture projection.
  48401. */
  48402. /**
  48403. * Sets the Up vector of the Spotlight for texture projection.
  48404. */
  48405. projectionTextureUpDirection: Vector3;
  48406. private _projectionTexture;
  48407. /**
  48408. * Gets the projection texture of the light.
  48409. */
  48410. /**
  48411. * Sets the projection texture of the light.
  48412. */
  48413. projectionTexture: Nullable<BaseTexture>;
  48414. private _projectionTextureViewLightDirty;
  48415. private _projectionTextureProjectionLightDirty;
  48416. private _projectionTextureDirty;
  48417. private _projectionTextureViewTargetVector;
  48418. private _projectionTextureViewLightMatrix;
  48419. private _projectionTextureProjectionLightMatrix;
  48420. private _projectionTextureScalingMatrix;
  48421. /**
  48422. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48423. * It can cast shadows.
  48424. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48425. * @param name The light friendly name
  48426. * @param position The position of the spot light in the scene
  48427. * @param direction The direction of the light in the scene
  48428. * @param angle The cone angle of the light in Radians
  48429. * @param exponent The light decay speed with the distance from the emission spot
  48430. * @param scene The scene the lights belongs to
  48431. */
  48432. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48433. /**
  48434. * Returns the string "SpotLight".
  48435. * @returns the class name
  48436. */
  48437. getClassName(): string;
  48438. /**
  48439. * Returns the integer 2.
  48440. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48441. */
  48442. getTypeID(): number;
  48443. /**
  48444. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48445. */
  48446. protected _setDirection(value: Vector3): void;
  48447. /**
  48448. * Overrides the position setter to recompute the projection texture view light Matrix.
  48449. */
  48450. protected _setPosition(value: Vector3): void;
  48451. /**
  48452. * 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.
  48453. * Returns the SpotLight.
  48454. */
  48455. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48456. protected _computeProjectionTextureViewLightMatrix(): void;
  48457. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48458. /**
  48459. * Main function for light texture projection matrix computing.
  48460. */
  48461. protected _computeProjectionTextureMatrix(): void;
  48462. protected _buildUniformLayout(): void;
  48463. private _computeAngleValues;
  48464. /**
  48465. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48466. * @param effect The effect to update
  48467. * @param lightIndex The index of the light in the effect to update
  48468. * @returns The spot light
  48469. */
  48470. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48471. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48472. /**
  48473. * Disposes the light and the associated resources.
  48474. */
  48475. dispose(): void;
  48476. /**
  48477. * Prepares the list of defines specific to the light type.
  48478. * @param defines the list of defines
  48479. * @param lightIndex defines the index of the light for the effect
  48480. */
  48481. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48482. }
  48483. }
  48484. declare module "babylonjs/Gizmos/lightGizmo" {
  48485. import { Nullable } from "babylonjs/types";
  48486. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48487. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48488. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48489. import { Light } from "babylonjs/Lights/light";
  48490. /**
  48491. * Gizmo that enables viewing a light
  48492. */
  48493. export class LightGizmo extends Gizmo {
  48494. private _lightMesh;
  48495. private _material;
  48496. private _cachedPosition;
  48497. private _cachedForward;
  48498. private _attachedMeshParent;
  48499. /**
  48500. * Creates a LightGizmo
  48501. * @param gizmoLayer The utility layer the gizmo will be added to
  48502. */
  48503. constructor(gizmoLayer?: UtilityLayerRenderer);
  48504. private _light;
  48505. /**
  48506. * The light that the gizmo is attached to
  48507. */
  48508. light: Nullable<Light>;
  48509. /**
  48510. * Gets the material used to render the light gizmo
  48511. */
  48512. readonly material: StandardMaterial;
  48513. /**
  48514. * @hidden
  48515. * Updates the gizmo to match the attached mesh's position/rotation
  48516. */
  48517. protected _update(): void;
  48518. private static _Scale;
  48519. /**
  48520. * Creates the lines for a light mesh
  48521. */
  48522. private static _CreateLightLines;
  48523. /**
  48524. * Disposes of the light gizmo
  48525. */
  48526. dispose(): void;
  48527. private static _CreateHemisphericLightMesh;
  48528. private static _CreatePointLightMesh;
  48529. private static _CreateSpotLightMesh;
  48530. private static _CreateDirectionalLightMesh;
  48531. }
  48532. }
  48533. declare module "babylonjs/Gizmos/index" {
  48534. export * from "babylonjs/Gizmos/axisDragGizmo";
  48535. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48536. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48537. export * from "babylonjs/Gizmos/gizmo";
  48538. export * from "babylonjs/Gizmos/gizmoManager";
  48539. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48540. export * from "babylonjs/Gizmos/positionGizmo";
  48541. export * from "babylonjs/Gizmos/rotationGizmo";
  48542. export * from "babylonjs/Gizmos/scaleGizmo";
  48543. export * from "babylonjs/Gizmos/lightGizmo";
  48544. export * from "babylonjs/Gizmos/planeDragGizmo";
  48545. }
  48546. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48547. /** @hidden */
  48548. export var backgroundFragmentDeclaration: {
  48549. name: string;
  48550. shader: string;
  48551. };
  48552. }
  48553. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48554. /** @hidden */
  48555. export var backgroundUboDeclaration: {
  48556. name: string;
  48557. shader: string;
  48558. };
  48559. }
  48560. declare module "babylonjs/Shaders/background.fragment" {
  48561. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48562. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48563. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48564. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48565. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48566. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48568. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48569. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48570. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48571. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48572. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48573. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48574. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48575. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48576. /** @hidden */
  48577. export var backgroundPixelShader: {
  48578. name: string;
  48579. shader: string;
  48580. };
  48581. }
  48582. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48583. /** @hidden */
  48584. export var backgroundVertexDeclaration: {
  48585. name: string;
  48586. shader: string;
  48587. };
  48588. }
  48589. declare module "babylonjs/Shaders/background.vertex" {
  48590. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48591. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48592. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48593. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48594. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48595. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48596. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48597. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48598. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48599. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48600. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48601. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48602. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48603. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48604. /** @hidden */
  48605. export var backgroundVertexShader: {
  48606. name: string;
  48607. shader: string;
  48608. };
  48609. }
  48610. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48611. import { Nullable, int, float } from "babylonjs/types";
  48612. import { Scene } from "babylonjs/scene";
  48613. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48614. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48616. import { Mesh } from "babylonjs/Meshes/mesh";
  48617. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48618. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48619. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48621. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48622. import { Color3 } from "babylonjs/Maths/math.color";
  48623. import "babylonjs/Shaders/background.fragment";
  48624. import "babylonjs/Shaders/background.vertex";
  48625. /**
  48626. * Background material used to create an efficient environement around your scene.
  48627. */
  48628. export class BackgroundMaterial extends PushMaterial {
  48629. /**
  48630. * Standard reflectance value at parallel view angle.
  48631. */
  48632. static StandardReflectance0: number;
  48633. /**
  48634. * Standard reflectance value at grazing angle.
  48635. */
  48636. static StandardReflectance90: number;
  48637. protected _primaryColor: Color3;
  48638. /**
  48639. * Key light Color (multiply against the environement texture)
  48640. */
  48641. primaryColor: Color3;
  48642. protected __perceptualColor: Nullable<Color3>;
  48643. /**
  48644. * Experimental Internal Use Only.
  48645. *
  48646. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48647. * This acts as a helper to set the primary color to a more "human friendly" value.
  48648. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48649. * output color as close as possible from the chosen value.
  48650. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48651. * part of lighting setup.)
  48652. */
  48653. _perceptualColor: Nullable<Color3>;
  48654. protected _primaryColorShadowLevel: float;
  48655. /**
  48656. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48657. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48658. */
  48659. primaryColorShadowLevel: float;
  48660. protected _primaryColorHighlightLevel: float;
  48661. /**
  48662. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48663. * The primary color is used at the level chosen to define what the white area would look.
  48664. */
  48665. primaryColorHighlightLevel: float;
  48666. protected _reflectionTexture: Nullable<BaseTexture>;
  48667. /**
  48668. * Reflection Texture used in the material.
  48669. * Should be author in a specific way for the best result (refer to the documentation).
  48670. */
  48671. reflectionTexture: Nullable<BaseTexture>;
  48672. protected _reflectionBlur: float;
  48673. /**
  48674. * Reflection Texture level of blur.
  48675. *
  48676. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48677. * texture twice.
  48678. */
  48679. reflectionBlur: float;
  48680. protected _diffuseTexture: Nullable<BaseTexture>;
  48681. /**
  48682. * Diffuse Texture used in the material.
  48683. * Should be author in a specific way for the best result (refer to the documentation).
  48684. */
  48685. diffuseTexture: Nullable<BaseTexture>;
  48686. protected _shadowLights: Nullable<IShadowLight[]>;
  48687. /**
  48688. * Specify the list of lights casting shadow on the material.
  48689. * All scene shadow lights will be included if null.
  48690. */
  48691. shadowLights: Nullable<IShadowLight[]>;
  48692. protected _shadowLevel: float;
  48693. /**
  48694. * Helps adjusting the shadow to a softer level if required.
  48695. * 0 means black shadows and 1 means no shadows.
  48696. */
  48697. shadowLevel: float;
  48698. protected _sceneCenter: Vector3;
  48699. /**
  48700. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48701. * It is usually zero but might be interesting to modify according to your setup.
  48702. */
  48703. sceneCenter: Vector3;
  48704. protected _opacityFresnel: boolean;
  48705. /**
  48706. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48707. * This helps ensuring a nice transition when the camera goes under the ground.
  48708. */
  48709. opacityFresnel: boolean;
  48710. protected _reflectionFresnel: boolean;
  48711. /**
  48712. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48713. * This helps adding a mirror texture on the ground.
  48714. */
  48715. reflectionFresnel: boolean;
  48716. protected _reflectionFalloffDistance: number;
  48717. /**
  48718. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48719. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48720. */
  48721. reflectionFalloffDistance: number;
  48722. protected _reflectionAmount: number;
  48723. /**
  48724. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48725. */
  48726. reflectionAmount: number;
  48727. protected _reflectionReflectance0: number;
  48728. /**
  48729. * This specifies the weight of the reflection at grazing angle.
  48730. */
  48731. reflectionReflectance0: number;
  48732. protected _reflectionReflectance90: number;
  48733. /**
  48734. * This specifies the weight of the reflection at a perpendicular point of view.
  48735. */
  48736. reflectionReflectance90: number;
  48737. /**
  48738. * Sets the reflection reflectance fresnel values according to the default standard
  48739. * empirically know to work well :-)
  48740. */
  48741. reflectionStandardFresnelWeight: number;
  48742. protected _useRGBColor: boolean;
  48743. /**
  48744. * Helps to directly use the maps channels instead of their level.
  48745. */
  48746. useRGBColor: boolean;
  48747. protected _enableNoise: boolean;
  48748. /**
  48749. * This helps reducing the banding effect that could occur on the background.
  48750. */
  48751. enableNoise: boolean;
  48752. /**
  48753. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48754. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48755. * Recommended to be keep at 1.0 except for special cases.
  48756. */
  48757. fovMultiplier: number;
  48758. private _fovMultiplier;
  48759. /**
  48760. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48761. */
  48762. useEquirectangularFOV: boolean;
  48763. private _maxSimultaneousLights;
  48764. /**
  48765. * Number of Simultaneous lights allowed on the material.
  48766. */
  48767. maxSimultaneousLights: int;
  48768. /**
  48769. * Default configuration related to image processing available in the Background Material.
  48770. */
  48771. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48772. /**
  48773. * Keep track of the image processing observer to allow dispose and replace.
  48774. */
  48775. private _imageProcessingObserver;
  48776. /**
  48777. * Attaches a new image processing configuration to the PBR Material.
  48778. * @param configuration (if null the scene configuration will be use)
  48779. */
  48780. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48781. /**
  48782. * Gets the image processing configuration used either in this material.
  48783. */
  48784. /**
  48785. * Sets the Default image processing configuration used either in the this material.
  48786. *
  48787. * If sets to null, the scene one is in use.
  48788. */
  48789. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48790. /**
  48791. * Gets wether the color curves effect is enabled.
  48792. */
  48793. /**
  48794. * Sets wether the color curves effect is enabled.
  48795. */
  48796. cameraColorCurvesEnabled: boolean;
  48797. /**
  48798. * Gets wether the color grading effect is enabled.
  48799. */
  48800. /**
  48801. * Gets wether the color grading effect is enabled.
  48802. */
  48803. cameraColorGradingEnabled: boolean;
  48804. /**
  48805. * Gets wether tonemapping is enabled or not.
  48806. */
  48807. /**
  48808. * Sets wether tonemapping is enabled or not
  48809. */
  48810. cameraToneMappingEnabled: boolean;
  48811. /**
  48812. * The camera exposure used on this material.
  48813. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48814. * This corresponds to a photographic exposure.
  48815. */
  48816. /**
  48817. * The camera exposure used on this material.
  48818. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48819. * This corresponds to a photographic exposure.
  48820. */
  48821. cameraExposure: float;
  48822. /**
  48823. * Gets The camera contrast used on this material.
  48824. */
  48825. /**
  48826. * Sets The camera contrast used on this material.
  48827. */
  48828. cameraContrast: float;
  48829. /**
  48830. * Gets the Color Grading 2D Lookup Texture.
  48831. */
  48832. /**
  48833. * Sets the Color Grading 2D Lookup Texture.
  48834. */
  48835. cameraColorGradingTexture: Nullable<BaseTexture>;
  48836. /**
  48837. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48838. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48839. * 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;
  48840. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48841. */
  48842. /**
  48843. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48844. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48845. * 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;
  48846. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48847. */
  48848. cameraColorCurves: Nullable<ColorCurves>;
  48849. /**
  48850. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48851. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48852. */
  48853. switchToBGR: boolean;
  48854. private _renderTargets;
  48855. private _reflectionControls;
  48856. private _white;
  48857. private _primaryShadowColor;
  48858. private _primaryHighlightColor;
  48859. /**
  48860. * Instantiates a Background Material in the given scene
  48861. * @param name The friendly name of the material
  48862. * @param scene The scene to add the material to
  48863. */
  48864. constructor(name: string, scene: Scene);
  48865. /**
  48866. * Gets a boolean indicating that current material needs to register RTT
  48867. */
  48868. readonly hasRenderTargetTextures: boolean;
  48869. /**
  48870. * The entire material has been created in order to prevent overdraw.
  48871. * @returns false
  48872. */
  48873. needAlphaTesting(): boolean;
  48874. /**
  48875. * The entire material has been created in order to prevent overdraw.
  48876. * @returns true if blending is enable
  48877. */
  48878. needAlphaBlending(): boolean;
  48879. /**
  48880. * Checks wether the material is ready to be rendered for a given mesh.
  48881. * @param mesh The mesh to render
  48882. * @param subMesh The submesh to check against
  48883. * @param useInstances Specify wether or not the material is used with instances
  48884. * @returns true if all the dependencies are ready (Textures, Effects...)
  48885. */
  48886. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48887. /**
  48888. * Compute the primary color according to the chosen perceptual color.
  48889. */
  48890. private _computePrimaryColorFromPerceptualColor;
  48891. /**
  48892. * Compute the highlights and shadow colors according to their chosen levels.
  48893. */
  48894. private _computePrimaryColors;
  48895. /**
  48896. * Build the uniform buffer used in the material.
  48897. */
  48898. buildUniformLayout(): void;
  48899. /**
  48900. * Unbind the material.
  48901. */
  48902. unbind(): void;
  48903. /**
  48904. * Bind only the world matrix to the material.
  48905. * @param world The world matrix to bind.
  48906. */
  48907. bindOnlyWorldMatrix(world: Matrix): void;
  48908. /**
  48909. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48910. * @param world The world matrix to bind.
  48911. * @param subMesh The submesh to bind for.
  48912. */
  48913. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48914. /**
  48915. * Checks to see if a texture is used in the material.
  48916. * @param texture - Base texture to use.
  48917. * @returns - Boolean specifying if a texture is used in the material.
  48918. */
  48919. hasTexture(texture: BaseTexture): boolean;
  48920. /**
  48921. * Dispose the material.
  48922. * @param forceDisposeEffect Force disposal of the associated effect.
  48923. * @param forceDisposeTextures Force disposal of the associated textures.
  48924. */
  48925. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48926. /**
  48927. * Clones the material.
  48928. * @param name The cloned name.
  48929. * @returns The cloned material.
  48930. */
  48931. clone(name: string): BackgroundMaterial;
  48932. /**
  48933. * Serializes the current material to its JSON representation.
  48934. * @returns The JSON representation.
  48935. */
  48936. serialize(): any;
  48937. /**
  48938. * Gets the class name of the material
  48939. * @returns "BackgroundMaterial"
  48940. */
  48941. getClassName(): string;
  48942. /**
  48943. * Parse a JSON input to create back a background material.
  48944. * @param source The JSON data to parse
  48945. * @param scene The scene to create the parsed material in
  48946. * @param rootUrl The root url of the assets the material depends upon
  48947. * @returns the instantiated BackgroundMaterial.
  48948. */
  48949. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48950. }
  48951. }
  48952. declare module "babylonjs/Helpers/environmentHelper" {
  48953. import { Observable } from "babylonjs/Misc/observable";
  48954. import { Nullable } from "babylonjs/types";
  48955. import { Scene } from "babylonjs/scene";
  48956. import { Vector3 } from "babylonjs/Maths/math.vector";
  48957. import { Color3 } from "babylonjs/Maths/math.color";
  48958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48959. import { Mesh } from "babylonjs/Meshes/mesh";
  48960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48961. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48962. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48963. import "babylonjs/Meshes/Builders/planeBuilder";
  48964. import "babylonjs/Meshes/Builders/boxBuilder";
  48965. /**
  48966. * Represents the different options available during the creation of
  48967. * a Environment helper.
  48968. *
  48969. * This can control the default ground, skybox and image processing setup of your scene.
  48970. */
  48971. export interface IEnvironmentHelperOptions {
  48972. /**
  48973. * Specifies wether or not to create a ground.
  48974. * True by default.
  48975. */
  48976. createGround: boolean;
  48977. /**
  48978. * Specifies the ground size.
  48979. * 15 by default.
  48980. */
  48981. groundSize: number;
  48982. /**
  48983. * The texture used on the ground for the main color.
  48984. * Comes from the BabylonJS CDN by default.
  48985. *
  48986. * Remarks: Can be either a texture or a url.
  48987. */
  48988. groundTexture: string | BaseTexture;
  48989. /**
  48990. * The color mixed in the ground texture by default.
  48991. * BabylonJS clearColor by default.
  48992. */
  48993. groundColor: Color3;
  48994. /**
  48995. * Specifies the ground opacity.
  48996. * 1 by default.
  48997. */
  48998. groundOpacity: number;
  48999. /**
  49000. * Enables the ground to receive shadows.
  49001. * True by default.
  49002. */
  49003. enableGroundShadow: boolean;
  49004. /**
  49005. * Helps preventing the shadow to be fully black on the ground.
  49006. * 0.5 by default.
  49007. */
  49008. groundShadowLevel: number;
  49009. /**
  49010. * Creates a mirror texture attach to the ground.
  49011. * false by default.
  49012. */
  49013. enableGroundMirror: boolean;
  49014. /**
  49015. * Specifies the ground mirror size ratio.
  49016. * 0.3 by default as the default kernel is 64.
  49017. */
  49018. groundMirrorSizeRatio: number;
  49019. /**
  49020. * Specifies the ground mirror blur kernel size.
  49021. * 64 by default.
  49022. */
  49023. groundMirrorBlurKernel: number;
  49024. /**
  49025. * Specifies the ground mirror visibility amount.
  49026. * 1 by default
  49027. */
  49028. groundMirrorAmount: number;
  49029. /**
  49030. * Specifies the ground mirror reflectance weight.
  49031. * This uses the standard weight of the background material to setup the fresnel effect
  49032. * of the mirror.
  49033. * 1 by default.
  49034. */
  49035. groundMirrorFresnelWeight: number;
  49036. /**
  49037. * Specifies the ground mirror Falloff distance.
  49038. * This can helps reducing the size of the reflection.
  49039. * 0 by Default.
  49040. */
  49041. groundMirrorFallOffDistance: number;
  49042. /**
  49043. * Specifies the ground mirror texture type.
  49044. * Unsigned Int by Default.
  49045. */
  49046. groundMirrorTextureType: number;
  49047. /**
  49048. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49049. * the shown objects.
  49050. */
  49051. groundYBias: number;
  49052. /**
  49053. * Specifies wether or not to create a skybox.
  49054. * True by default.
  49055. */
  49056. createSkybox: boolean;
  49057. /**
  49058. * Specifies the skybox size.
  49059. * 20 by default.
  49060. */
  49061. skyboxSize: number;
  49062. /**
  49063. * The texture used on the skybox for the main color.
  49064. * Comes from the BabylonJS CDN by default.
  49065. *
  49066. * Remarks: Can be either a texture or a url.
  49067. */
  49068. skyboxTexture: string | BaseTexture;
  49069. /**
  49070. * The color mixed in the skybox texture by default.
  49071. * BabylonJS clearColor by default.
  49072. */
  49073. skyboxColor: Color3;
  49074. /**
  49075. * The background rotation around the Y axis of the scene.
  49076. * This helps aligning the key lights of your scene with the background.
  49077. * 0 by default.
  49078. */
  49079. backgroundYRotation: number;
  49080. /**
  49081. * Compute automatically the size of the elements to best fit with the scene.
  49082. */
  49083. sizeAuto: boolean;
  49084. /**
  49085. * Default position of the rootMesh if autoSize is not true.
  49086. */
  49087. rootPosition: Vector3;
  49088. /**
  49089. * Sets up the image processing in the scene.
  49090. * true by default.
  49091. */
  49092. setupImageProcessing: boolean;
  49093. /**
  49094. * The texture used as your environment texture in the scene.
  49095. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49096. *
  49097. * Remarks: Can be either a texture or a url.
  49098. */
  49099. environmentTexture: string | BaseTexture;
  49100. /**
  49101. * The value of the exposure to apply to the scene.
  49102. * 0.6 by default if setupImageProcessing is true.
  49103. */
  49104. cameraExposure: number;
  49105. /**
  49106. * The value of the contrast to apply to the scene.
  49107. * 1.6 by default if setupImageProcessing is true.
  49108. */
  49109. cameraContrast: number;
  49110. /**
  49111. * Specifies wether or not tonemapping should be enabled in the scene.
  49112. * true by default if setupImageProcessing is true.
  49113. */
  49114. toneMappingEnabled: boolean;
  49115. }
  49116. /**
  49117. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49118. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49119. * It also helps with the default setup of your imageProcessing configuration.
  49120. */
  49121. export class EnvironmentHelper {
  49122. /**
  49123. * Default ground texture URL.
  49124. */
  49125. private static _groundTextureCDNUrl;
  49126. /**
  49127. * Default skybox texture URL.
  49128. */
  49129. private static _skyboxTextureCDNUrl;
  49130. /**
  49131. * Default environment texture URL.
  49132. */
  49133. private static _environmentTextureCDNUrl;
  49134. /**
  49135. * Creates the default options for the helper.
  49136. */
  49137. private static _getDefaultOptions;
  49138. private _rootMesh;
  49139. /**
  49140. * Gets the root mesh created by the helper.
  49141. */
  49142. readonly rootMesh: Mesh;
  49143. private _skybox;
  49144. /**
  49145. * Gets the skybox created by the helper.
  49146. */
  49147. readonly skybox: Nullable<Mesh>;
  49148. private _skyboxTexture;
  49149. /**
  49150. * Gets the skybox texture created by the helper.
  49151. */
  49152. readonly skyboxTexture: Nullable<BaseTexture>;
  49153. private _skyboxMaterial;
  49154. /**
  49155. * Gets the skybox material created by the helper.
  49156. */
  49157. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49158. private _ground;
  49159. /**
  49160. * Gets the ground mesh created by the helper.
  49161. */
  49162. readonly ground: Nullable<Mesh>;
  49163. private _groundTexture;
  49164. /**
  49165. * Gets the ground texture created by the helper.
  49166. */
  49167. readonly groundTexture: Nullable<BaseTexture>;
  49168. private _groundMirror;
  49169. /**
  49170. * Gets the ground mirror created by the helper.
  49171. */
  49172. readonly groundMirror: Nullable<MirrorTexture>;
  49173. /**
  49174. * Gets the ground mirror render list to helps pushing the meshes
  49175. * you wish in the ground reflection.
  49176. */
  49177. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49178. private _groundMaterial;
  49179. /**
  49180. * Gets the ground material created by the helper.
  49181. */
  49182. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49183. /**
  49184. * Stores the creation options.
  49185. */
  49186. private readonly _scene;
  49187. private _options;
  49188. /**
  49189. * This observable will be notified with any error during the creation of the environment,
  49190. * mainly texture creation errors.
  49191. */
  49192. onErrorObservable: Observable<{
  49193. message?: string;
  49194. exception?: any;
  49195. }>;
  49196. /**
  49197. * constructor
  49198. * @param options Defines the options we want to customize the helper
  49199. * @param scene The scene to add the material to
  49200. */
  49201. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49202. /**
  49203. * Updates the background according to the new options
  49204. * @param options
  49205. */
  49206. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49207. /**
  49208. * Sets the primary color of all the available elements.
  49209. * @param color the main color to affect to the ground and the background
  49210. */
  49211. setMainColor(color: Color3): void;
  49212. /**
  49213. * Setup the image processing according to the specified options.
  49214. */
  49215. private _setupImageProcessing;
  49216. /**
  49217. * Setup the environment texture according to the specified options.
  49218. */
  49219. private _setupEnvironmentTexture;
  49220. /**
  49221. * Setup the background according to the specified options.
  49222. */
  49223. private _setupBackground;
  49224. /**
  49225. * Get the scene sizes according to the setup.
  49226. */
  49227. private _getSceneSize;
  49228. /**
  49229. * Setup the ground according to the specified options.
  49230. */
  49231. private _setupGround;
  49232. /**
  49233. * Setup the ground material according to the specified options.
  49234. */
  49235. private _setupGroundMaterial;
  49236. /**
  49237. * Setup the ground diffuse texture according to the specified options.
  49238. */
  49239. private _setupGroundDiffuseTexture;
  49240. /**
  49241. * Setup the ground mirror texture according to the specified options.
  49242. */
  49243. private _setupGroundMirrorTexture;
  49244. /**
  49245. * Setup the ground to receive the mirror texture.
  49246. */
  49247. private _setupMirrorInGroundMaterial;
  49248. /**
  49249. * Setup the skybox according to the specified options.
  49250. */
  49251. private _setupSkybox;
  49252. /**
  49253. * Setup the skybox material according to the specified options.
  49254. */
  49255. private _setupSkyboxMaterial;
  49256. /**
  49257. * Setup the skybox reflection texture according to the specified options.
  49258. */
  49259. private _setupSkyboxReflectionTexture;
  49260. private _errorHandler;
  49261. /**
  49262. * Dispose all the elements created by the Helper.
  49263. */
  49264. dispose(): void;
  49265. }
  49266. }
  49267. declare module "babylonjs/Helpers/photoDome" {
  49268. import { Observable } from "babylonjs/Misc/observable";
  49269. import { Nullable } from "babylonjs/types";
  49270. import { Scene } from "babylonjs/scene";
  49271. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49272. import { Mesh } from "babylonjs/Meshes/mesh";
  49273. import { Texture } from "babylonjs/Materials/Textures/texture";
  49274. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49275. import "babylonjs/Meshes/Builders/sphereBuilder";
  49276. /**
  49277. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49278. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49279. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49280. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49281. */
  49282. export class PhotoDome extends TransformNode {
  49283. /**
  49284. * Define the image as a Monoscopic panoramic 360 image.
  49285. */
  49286. static readonly MODE_MONOSCOPIC: number;
  49287. /**
  49288. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49289. */
  49290. static readonly MODE_TOPBOTTOM: number;
  49291. /**
  49292. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49293. */
  49294. static readonly MODE_SIDEBYSIDE: number;
  49295. private _useDirectMapping;
  49296. /**
  49297. * The texture being displayed on the sphere
  49298. */
  49299. protected _photoTexture: Texture;
  49300. /**
  49301. * Gets or sets the texture being displayed on the sphere
  49302. */
  49303. photoTexture: Texture;
  49304. /**
  49305. * Observable raised when an error occured while loading the 360 image
  49306. */
  49307. onLoadErrorObservable: Observable<string>;
  49308. /**
  49309. * The skybox material
  49310. */
  49311. protected _material: BackgroundMaterial;
  49312. /**
  49313. * The surface used for the skybox
  49314. */
  49315. protected _mesh: Mesh;
  49316. /**
  49317. * Gets the mesh used for the skybox.
  49318. */
  49319. readonly mesh: Mesh;
  49320. /**
  49321. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49322. * Also see the options.resolution property.
  49323. */
  49324. fovMultiplier: number;
  49325. private _imageMode;
  49326. /**
  49327. * Gets or set the current video mode for the video. It can be:
  49328. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49329. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49330. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49331. */
  49332. imageMode: number;
  49333. /**
  49334. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49335. * @param name Element's name, child elements will append suffixes for their own names.
  49336. * @param urlsOfPhoto defines the url of the photo to display
  49337. * @param options defines an object containing optional or exposed sub element properties
  49338. * @param onError defines a callback called when an error occured while loading the texture
  49339. */
  49340. constructor(name: string, urlOfPhoto: string, options: {
  49341. resolution?: number;
  49342. size?: number;
  49343. useDirectMapping?: boolean;
  49344. faceForward?: boolean;
  49345. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49346. private _onBeforeCameraRenderObserver;
  49347. private _changeImageMode;
  49348. /**
  49349. * Releases resources associated with this node.
  49350. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49351. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49352. */
  49353. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49354. }
  49355. }
  49356. declare module "babylonjs/Misc/rgbdTextureTools" {
  49357. import "babylonjs/Shaders/rgbdDecode.fragment";
  49358. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49359. import { Texture } from "babylonjs/Materials/Textures/texture";
  49360. /**
  49361. * Class used to host RGBD texture specific utilities
  49362. */
  49363. export class RGBDTextureTools {
  49364. /**
  49365. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49366. * @param texture the texture to expand.
  49367. */
  49368. static ExpandRGBDTexture(texture: Texture): void;
  49369. }
  49370. }
  49371. declare module "babylonjs/Misc/brdfTextureTools" {
  49372. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49373. import { Scene } from "babylonjs/scene";
  49374. /**
  49375. * Class used to host texture specific utilities
  49376. */
  49377. export class BRDFTextureTools {
  49378. /**
  49379. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49380. * @param scene defines the hosting scene
  49381. * @returns the environment BRDF texture
  49382. */
  49383. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49384. private static _environmentBRDFBase64Texture;
  49385. }
  49386. }
  49387. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49388. import { Nullable } from "babylonjs/types";
  49389. import { Color3 } from "babylonjs/Maths/math.color";
  49390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49391. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49392. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49393. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49394. import { Engine } from "babylonjs/Engines/engine";
  49395. import { Scene } from "babylonjs/scene";
  49396. /**
  49397. * @hidden
  49398. */
  49399. export interface IMaterialClearCoatDefines {
  49400. CLEARCOAT: boolean;
  49401. CLEARCOAT_DEFAULTIOR: boolean;
  49402. CLEARCOAT_TEXTURE: boolean;
  49403. CLEARCOAT_TEXTUREDIRECTUV: number;
  49404. CLEARCOAT_BUMP: boolean;
  49405. CLEARCOAT_BUMPDIRECTUV: number;
  49406. CLEARCOAT_TINT: boolean;
  49407. CLEARCOAT_TINT_TEXTURE: boolean;
  49408. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49409. /** @hidden */
  49410. _areTexturesDirty: boolean;
  49411. }
  49412. /**
  49413. * Define the code related to the clear coat parameters of the pbr material.
  49414. */
  49415. export class PBRClearCoatConfiguration {
  49416. /**
  49417. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49418. * The default fits with a polyurethane material.
  49419. */
  49420. private static readonly _DefaultIndexOfRefraction;
  49421. private _isEnabled;
  49422. /**
  49423. * Defines if the clear coat is enabled in the material.
  49424. */
  49425. isEnabled: boolean;
  49426. /**
  49427. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49428. */
  49429. intensity: number;
  49430. /**
  49431. * Defines the clear coat layer roughness.
  49432. */
  49433. roughness: number;
  49434. private _indexOfRefraction;
  49435. /**
  49436. * Defines the index of refraction of the clear coat.
  49437. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49438. * The default fits with a polyurethane material.
  49439. * Changing the default value is more performance intensive.
  49440. */
  49441. indexOfRefraction: number;
  49442. private _texture;
  49443. /**
  49444. * Stores the clear coat values in a texture.
  49445. */
  49446. texture: Nullable<BaseTexture>;
  49447. private _bumpTexture;
  49448. /**
  49449. * Define the clear coat specific bump texture.
  49450. */
  49451. bumpTexture: Nullable<BaseTexture>;
  49452. private _isTintEnabled;
  49453. /**
  49454. * Defines if the clear coat tint is enabled in the material.
  49455. */
  49456. isTintEnabled: boolean;
  49457. /**
  49458. * Defines the clear coat tint of the material.
  49459. * This is only use if tint is enabled
  49460. */
  49461. tintColor: Color3;
  49462. /**
  49463. * Defines the distance at which the tint color should be found in the
  49464. * clear coat media.
  49465. * This is only use if tint is enabled
  49466. */
  49467. tintColorAtDistance: number;
  49468. /**
  49469. * Defines the clear coat layer thickness.
  49470. * This is only use if tint is enabled
  49471. */
  49472. tintThickness: number;
  49473. private _tintTexture;
  49474. /**
  49475. * Stores the clear tint values in a texture.
  49476. * rgb is tint
  49477. * a is a thickness factor
  49478. */
  49479. tintTexture: Nullable<BaseTexture>;
  49480. /** @hidden */
  49481. private _internalMarkAllSubMeshesAsTexturesDirty;
  49482. /** @hidden */
  49483. _markAllSubMeshesAsTexturesDirty(): void;
  49484. /**
  49485. * Instantiate a new istance of clear coat configuration.
  49486. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49487. */
  49488. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49489. /**
  49490. * Gets wehter the submesh is ready to be used or not.
  49491. * @param defines the list of "defines" to update.
  49492. * @param scene defines the scene the material belongs to.
  49493. * @param engine defines the engine the material belongs to.
  49494. * @param disableBumpMap defines wether the material disables bump or not.
  49495. * @returns - boolean indicating that the submesh is ready or not.
  49496. */
  49497. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49498. /**
  49499. * Checks to see if a texture is used in the material.
  49500. * @param defines the list of "defines" to update.
  49501. * @param scene defines the scene to the material belongs to.
  49502. */
  49503. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49504. /**
  49505. * Binds the material data.
  49506. * @param uniformBuffer defines the Uniform buffer to fill in.
  49507. * @param scene defines the scene the material belongs to.
  49508. * @param engine defines the engine the material belongs to.
  49509. * @param disableBumpMap defines wether the material disables bump or not.
  49510. * @param isFrozen defines wether the material is frozen or not.
  49511. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49512. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49513. */
  49514. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49515. /**
  49516. * Checks to see if a texture is used in the material.
  49517. * @param texture - Base texture to use.
  49518. * @returns - Boolean specifying if a texture is used in the material.
  49519. */
  49520. hasTexture(texture: BaseTexture): boolean;
  49521. /**
  49522. * Returns an array of the actively used textures.
  49523. * @param activeTextures Array of BaseTextures
  49524. */
  49525. getActiveTextures(activeTextures: BaseTexture[]): void;
  49526. /**
  49527. * Returns the animatable textures.
  49528. * @param animatables Array of animatable textures.
  49529. */
  49530. getAnimatables(animatables: IAnimatable[]): void;
  49531. /**
  49532. * Disposes the resources of the material.
  49533. * @param forceDisposeTextures - Forces the disposal of all textures.
  49534. */
  49535. dispose(forceDisposeTextures?: boolean): void;
  49536. /**
  49537. * Get the current class name of the texture useful for serialization or dynamic coding.
  49538. * @returns "PBRClearCoatConfiguration"
  49539. */
  49540. getClassName(): string;
  49541. /**
  49542. * Add fallbacks to the effect fallbacks list.
  49543. * @param defines defines the Base texture to use.
  49544. * @param fallbacks defines the current fallback list.
  49545. * @param currentRank defines the current fallback rank.
  49546. * @returns the new fallback rank.
  49547. */
  49548. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49549. /**
  49550. * Add the required uniforms to the current list.
  49551. * @param uniforms defines the current uniform list.
  49552. */
  49553. static AddUniforms(uniforms: string[]): void;
  49554. /**
  49555. * Add the required samplers to the current list.
  49556. * @param samplers defines the current sampler list.
  49557. */
  49558. static AddSamplers(samplers: string[]): void;
  49559. /**
  49560. * Add the required uniforms to the current buffer.
  49561. * @param uniformBuffer defines the current uniform buffer.
  49562. */
  49563. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49564. /**
  49565. * Makes a duplicate of the current configuration into another one.
  49566. * @param clearCoatConfiguration define the config where to copy the info
  49567. */
  49568. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49569. /**
  49570. * Serializes this clear coat configuration.
  49571. * @returns - An object with the serialized config.
  49572. */
  49573. serialize(): any;
  49574. /**
  49575. * Parses a anisotropy Configuration from a serialized object.
  49576. * @param source - Serialized object.
  49577. * @param scene Defines the scene we are parsing for
  49578. * @param rootUrl Defines the rootUrl to load from
  49579. */
  49580. parse(source: any, scene: Scene, rootUrl: string): void;
  49581. }
  49582. }
  49583. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49584. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49586. import { Vector2 } from "babylonjs/Maths/math.vector";
  49587. import { Scene } from "babylonjs/scene";
  49588. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49589. import { Nullable } from "babylonjs/types";
  49590. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49591. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49592. /**
  49593. * @hidden
  49594. */
  49595. export interface IMaterialAnisotropicDefines {
  49596. ANISOTROPIC: boolean;
  49597. ANISOTROPIC_TEXTURE: boolean;
  49598. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49599. MAINUV1: boolean;
  49600. _areTexturesDirty: boolean;
  49601. _needUVs: boolean;
  49602. }
  49603. /**
  49604. * Define the code related to the anisotropic parameters of the pbr material.
  49605. */
  49606. export class PBRAnisotropicConfiguration {
  49607. private _isEnabled;
  49608. /**
  49609. * Defines if the anisotropy is enabled in the material.
  49610. */
  49611. isEnabled: boolean;
  49612. /**
  49613. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49614. */
  49615. intensity: number;
  49616. /**
  49617. * Defines if the effect is along the tangents, bitangents or in between.
  49618. * By default, the effect is "strectching" the highlights along the tangents.
  49619. */
  49620. direction: Vector2;
  49621. private _texture;
  49622. /**
  49623. * Stores the anisotropy values in a texture.
  49624. * rg is direction (like normal from -1 to 1)
  49625. * b is a intensity
  49626. */
  49627. texture: Nullable<BaseTexture>;
  49628. /** @hidden */
  49629. private _internalMarkAllSubMeshesAsTexturesDirty;
  49630. /** @hidden */
  49631. _markAllSubMeshesAsTexturesDirty(): void;
  49632. /**
  49633. * Instantiate a new istance of anisotropy configuration.
  49634. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49635. */
  49636. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49637. /**
  49638. * Specifies that the submesh is ready to be used.
  49639. * @param defines the list of "defines" to update.
  49640. * @param scene defines the scene the material belongs to.
  49641. * @returns - boolean indicating that the submesh is ready or not.
  49642. */
  49643. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49644. /**
  49645. * Checks to see if a texture is used in the material.
  49646. * @param defines the list of "defines" to update.
  49647. * @param mesh the mesh we are preparing the defines for.
  49648. * @param scene defines the scene the material belongs to.
  49649. */
  49650. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49651. /**
  49652. * Binds the material data.
  49653. * @param uniformBuffer defines the Uniform buffer to fill in.
  49654. * @param scene defines the scene the material belongs to.
  49655. * @param isFrozen defines wether the material is frozen or not.
  49656. */
  49657. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49658. /**
  49659. * Checks to see if a texture is used in the material.
  49660. * @param texture - Base texture to use.
  49661. * @returns - Boolean specifying if a texture is used in the material.
  49662. */
  49663. hasTexture(texture: BaseTexture): boolean;
  49664. /**
  49665. * Returns an array of the actively used textures.
  49666. * @param activeTextures Array of BaseTextures
  49667. */
  49668. getActiveTextures(activeTextures: BaseTexture[]): void;
  49669. /**
  49670. * Returns the animatable textures.
  49671. * @param animatables Array of animatable textures.
  49672. */
  49673. getAnimatables(animatables: IAnimatable[]): void;
  49674. /**
  49675. * Disposes the resources of the material.
  49676. * @param forceDisposeTextures - Forces the disposal of all textures.
  49677. */
  49678. dispose(forceDisposeTextures?: boolean): void;
  49679. /**
  49680. * Get the current class name of the texture useful for serialization or dynamic coding.
  49681. * @returns "PBRAnisotropicConfiguration"
  49682. */
  49683. getClassName(): string;
  49684. /**
  49685. * Add fallbacks to the effect fallbacks list.
  49686. * @param defines defines the Base texture to use.
  49687. * @param fallbacks defines the current fallback list.
  49688. * @param currentRank defines the current fallback rank.
  49689. * @returns the new fallback rank.
  49690. */
  49691. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49692. /**
  49693. * Add the required uniforms to the current list.
  49694. * @param uniforms defines the current uniform list.
  49695. */
  49696. static AddUniforms(uniforms: string[]): void;
  49697. /**
  49698. * Add the required uniforms to the current buffer.
  49699. * @param uniformBuffer defines the current uniform buffer.
  49700. */
  49701. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49702. /**
  49703. * Add the required samplers to the current list.
  49704. * @param samplers defines the current sampler list.
  49705. */
  49706. static AddSamplers(samplers: string[]): void;
  49707. /**
  49708. * Makes a duplicate of the current configuration into another one.
  49709. * @param anisotropicConfiguration define the config where to copy the info
  49710. */
  49711. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49712. /**
  49713. * Serializes this anisotropy configuration.
  49714. * @returns - An object with the serialized config.
  49715. */
  49716. serialize(): any;
  49717. /**
  49718. * Parses a anisotropy Configuration from a serialized object.
  49719. * @param source - Serialized object.
  49720. * @param scene Defines the scene we are parsing for
  49721. * @param rootUrl Defines the rootUrl to load from
  49722. */
  49723. parse(source: any, scene: Scene, rootUrl: string): void;
  49724. }
  49725. }
  49726. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49727. import { Scene } from "babylonjs/scene";
  49728. /**
  49729. * @hidden
  49730. */
  49731. export interface IMaterialBRDFDefines {
  49732. BRDF_V_HEIGHT_CORRELATED: boolean;
  49733. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49734. SPHERICAL_HARMONICS: boolean;
  49735. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49736. /** @hidden */
  49737. _areMiscDirty: boolean;
  49738. }
  49739. /**
  49740. * Define the code related to the BRDF parameters of the pbr material.
  49741. */
  49742. export class PBRBRDFConfiguration {
  49743. /**
  49744. * Default value used for the energy conservation.
  49745. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49746. */
  49747. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49748. /**
  49749. * Default value used for the Smith Visibility Height Correlated mode.
  49750. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49751. */
  49752. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49753. /**
  49754. * Default value used for the IBL diffuse part.
  49755. * This can help switching back to the polynomials mode globally which is a tiny bit
  49756. * less GPU intensive at the drawback of a lower quality.
  49757. */
  49758. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49759. /**
  49760. * Default value used for activating energy conservation for the specular workflow.
  49761. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49762. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49763. */
  49764. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49765. private _useEnergyConservation;
  49766. /**
  49767. * Defines if the material uses energy conservation.
  49768. */
  49769. useEnergyConservation: boolean;
  49770. private _useSmithVisibilityHeightCorrelated;
  49771. /**
  49772. * LEGACY Mode set to false
  49773. * Defines if the material uses height smith correlated visibility term.
  49774. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49775. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49776. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49777. * Not relying on height correlated will also disable energy conservation.
  49778. */
  49779. useSmithVisibilityHeightCorrelated: boolean;
  49780. private _useSphericalHarmonics;
  49781. /**
  49782. * LEGACY Mode set to false
  49783. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49784. * diffuse part of the IBL.
  49785. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49786. * to the ground truth.
  49787. */
  49788. useSphericalHarmonics: boolean;
  49789. private _useSpecularGlossinessInputEnergyConservation;
  49790. /**
  49791. * Defines if the material uses energy conservation, when the specular workflow is active.
  49792. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49793. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49794. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49795. */
  49796. useSpecularGlossinessInputEnergyConservation: boolean;
  49797. /** @hidden */
  49798. private _internalMarkAllSubMeshesAsMiscDirty;
  49799. /** @hidden */
  49800. _markAllSubMeshesAsMiscDirty(): void;
  49801. /**
  49802. * Instantiate a new istance of clear coat configuration.
  49803. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49804. */
  49805. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49806. /**
  49807. * Checks to see if a texture is used in the material.
  49808. * @param defines the list of "defines" to update.
  49809. */
  49810. prepareDefines(defines: IMaterialBRDFDefines): void;
  49811. /**
  49812. * Get the current class name of the texture useful for serialization or dynamic coding.
  49813. * @returns "PBRClearCoatConfiguration"
  49814. */
  49815. getClassName(): string;
  49816. /**
  49817. * Makes a duplicate of the current configuration into another one.
  49818. * @param brdfConfiguration define the config where to copy the info
  49819. */
  49820. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49821. /**
  49822. * Serializes this BRDF configuration.
  49823. * @returns - An object with the serialized config.
  49824. */
  49825. serialize(): any;
  49826. /**
  49827. * Parses a anisotropy Configuration from a serialized object.
  49828. * @param source - Serialized object.
  49829. * @param scene Defines the scene we are parsing for
  49830. * @param rootUrl Defines the rootUrl to load from
  49831. */
  49832. parse(source: any, scene: Scene, rootUrl: string): void;
  49833. }
  49834. }
  49835. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49836. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49837. import { Color3 } from "babylonjs/Maths/math.color";
  49838. import { Scene } from "babylonjs/scene";
  49839. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49840. import { Nullable } from "babylonjs/types";
  49841. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49842. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49843. /**
  49844. * @hidden
  49845. */
  49846. export interface IMaterialSheenDefines {
  49847. SHEEN: boolean;
  49848. SHEEN_TEXTURE: boolean;
  49849. SHEEN_TEXTUREDIRECTUV: number;
  49850. SHEEN_LINKWITHALBEDO: boolean;
  49851. /** @hidden */
  49852. _areTexturesDirty: boolean;
  49853. }
  49854. /**
  49855. * Define the code related to the Sheen parameters of the pbr material.
  49856. */
  49857. export class PBRSheenConfiguration {
  49858. private _isEnabled;
  49859. /**
  49860. * Defines if the material uses sheen.
  49861. */
  49862. isEnabled: boolean;
  49863. private _linkSheenWithAlbedo;
  49864. /**
  49865. * Defines if the sheen is linked to the sheen color.
  49866. */
  49867. linkSheenWithAlbedo: boolean;
  49868. /**
  49869. * Defines the sheen intensity.
  49870. */
  49871. intensity: number;
  49872. /**
  49873. * Defines the sheen color.
  49874. */
  49875. color: Color3;
  49876. private _texture;
  49877. /**
  49878. * Stores the sheen tint values in a texture.
  49879. * rgb is tint
  49880. * a is a intensity
  49881. */
  49882. texture: Nullable<BaseTexture>;
  49883. /** @hidden */
  49884. private _internalMarkAllSubMeshesAsTexturesDirty;
  49885. /** @hidden */
  49886. _markAllSubMeshesAsTexturesDirty(): void;
  49887. /**
  49888. * Instantiate a new istance of clear coat configuration.
  49889. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49890. */
  49891. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49892. /**
  49893. * Specifies that the submesh is ready to be used.
  49894. * @param defines the list of "defines" to update.
  49895. * @param scene defines the scene the material belongs to.
  49896. * @returns - boolean indicating that the submesh is ready or not.
  49897. */
  49898. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49899. /**
  49900. * Checks to see if a texture is used in the material.
  49901. * @param defines the list of "defines" to update.
  49902. * @param scene defines the scene the material belongs to.
  49903. */
  49904. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49905. /**
  49906. * Binds the material data.
  49907. * @param uniformBuffer defines the Uniform buffer to fill in.
  49908. * @param scene defines the scene the material belongs to.
  49909. * @param isFrozen defines wether the material is frozen or not.
  49910. */
  49911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49912. /**
  49913. * Checks to see if a texture is used in the material.
  49914. * @param texture - Base texture to use.
  49915. * @returns - Boolean specifying if a texture is used in the material.
  49916. */
  49917. hasTexture(texture: BaseTexture): boolean;
  49918. /**
  49919. * Returns an array of the actively used textures.
  49920. * @param activeTextures Array of BaseTextures
  49921. */
  49922. getActiveTextures(activeTextures: BaseTexture[]): void;
  49923. /**
  49924. * Returns the animatable textures.
  49925. * @param animatables Array of animatable textures.
  49926. */
  49927. getAnimatables(animatables: IAnimatable[]): void;
  49928. /**
  49929. * Disposes the resources of the material.
  49930. * @param forceDisposeTextures - Forces the disposal of all textures.
  49931. */
  49932. dispose(forceDisposeTextures?: boolean): void;
  49933. /**
  49934. * Get the current class name of the texture useful for serialization or dynamic coding.
  49935. * @returns "PBRSheenConfiguration"
  49936. */
  49937. getClassName(): string;
  49938. /**
  49939. * Add fallbacks to the effect fallbacks list.
  49940. * @param defines defines the Base texture to use.
  49941. * @param fallbacks defines the current fallback list.
  49942. * @param currentRank defines the current fallback rank.
  49943. * @returns the new fallback rank.
  49944. */
  49945. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49946. /**
  49947. * Add the required uniforms to the current list.
  49948. * @param uniforms defines the current uniform list.
  49949. */
  49950. static AddUniforms(uniforms: string[]): void;
  49951. /**
  49952. * Add the required uniforms to the current buffer.
  49953. * @param uniformBuffer defines the current uniform buffer.
  49954. */
  49955. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49956. /**
  49957. * Add the required samplers to the current list.
  49958. * @param samplers defines the current sampler list.
  49959. */
  49960. static AddSamplers(samplers: string[]): void;
  49961. /**
  49962. * Makes a duplicate of the current configuration into another one.
  49963. * @param sheenConfiguration define the config where to copy the info
  49964. */
  49965. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49966. /**
  49967. * Serializes this BRDF configuration.
  49968. * @returns - An object with the serialized config.
  49969. */
  49970. serialize(): any;
  49971. /**
  49972. * Parses a anisotropy Configuration from a serialized object.
  49973. * @param source - Serialized object.
  49974. * @param scene Defines the scene we are parsing for
  49975. * @param rootUrl Defines the rootUrl to load from
  49976. */
  49977. parse(source: any, scene: Scene, rootUrl: string): void;
  49978. }
  49979. }
  49980. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49981. import { Nullable } from "babylonjs/types";
  49982. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49983. import { Color3 } from "babylonjs/Maths/math.color";
  49984. import { SmartArray } from "babylonjs/Misc/smartArray";
  49985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49986. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49987. import { Effect } from "babylonjs/Materials/effect";
  49988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49989. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49990. import { Engine } from "babylonjs/Engines/engine";
  49991. import { Scene } from "babylonjs/scene";
  49992. /**
  49993. * @hidden
  49994. */
  49995. export interface IMaterialSubSurfaceDefines {
  49996. SUBSURFACE: boolean;
  49997. SS_REFRACTION: boolean;
  49998. SS_TRANSLUCENCY: boolean;
  49999. SS_SCATERRING: boolean;
  50000. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50001. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50002. SS_REFRACTIONMAP_3D: boolean;
  50003. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50004. SS_LODINREFRACTIONALPHA: boolean;
  50005. SS_GAMMAREFRACTION: boolean;
  50006. SS_RGBDREFRACTION: boolean;
  50007. SS_LINEARSPECULARREFRACTION: boolean;
  50008. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50009. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50010. /** @hidden */
  50011. _areTexturesDirty: boolean;
  50012. }
  50013. /**
  50014. * Define the code related to the sub surface parameters of the pbr material.
  50015. */
  50016. export class PBRSubSurfaceConfiguration {
  50017. private _isRefractionEnabled;
  50018. /**
  50019. * Defines if the refraction is enabled in the material.
  50020. */
  50021. isRefractionEnabled: boolean;
  50022. private _isTranslucencyEnabled;
  50023. /**
  50024. * Defines if the translucency is enabled in the material.
  50025. */
  50026. isTranslucencyEnabled: boolean;
  50027. private _isScatteringEnabled;
  50028. /**
  50029. * Defines the refraction intensity of the material.
  50030. * The refraction when enabled replaces the Diffuse part of the material.
  50031. * The intensity helps transitionning between diffuse and refraction.
  50032. */
  50033. refractionIntensity: number;
  50034. /**
  50035. * Defines the translucency intensity of the material.
  50036. * When translucency has been enabled, this defines how much of the "translucency"
  50037. * is addded to the diffuse part of the material.
  50038. */
  50039. translucencyIntensity: number;
  50040. /**
  50041. * Defines the scattering intensity of the material.
  50042. * When scattering has been enabled, this defines how much of the "scattered light"
  50043. * is addded to the diffuse part of the material.
  50044. */
  50045. scatteringIntensity: number;
  50046. private _thicknessTexture;
  50047. /**
  50048. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50049. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50050. * 0 would mean minimumThickness
  50051. * 1 would mean maximumThickness
  50052. * The other channels might be use as a mask to vary the different effects intensity.
  50053. */
  50054. thicknessTexture: Nullable<BaseTexture>;
  50055. private _refractionTexture;
  50056. /**
  50057. * Defines the texture to use for refraction.
  50058. */
  50059. refractionTexture: Nullable<BaseTexture>;
  50060. private _indexOfRefraction;
  50061. /**
  50062. * Defines the index of refraction used in the material.
  50063. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50064. */
  50065. indexOfRefraction: number;
  50066. private _invertRefractionY;
  50067. /**
  50068. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50069. */
  50070. invertRefractionY: boolean;
  50071. private _linkRefractionWithTransparency;
  50072. /**
  50073. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50074. * Materials half opaque for instance using refraction could benefit from this control.
  50075. */
  50076. linkRefractionWithTransparency: boolean;
  50077. /**
  50078. * Defines the minimum thickness stored in the thickness map.
  50079. * If no thickness map is defined, this value will be used to simulate thickness.
  50080. */
  50081. minimumThickness: number;
  50082. /**
  50083. * Defines the maximum thickness stored in the thickness map.
  50084. */
  50085. maximumThickness: number;
  50086. /**
  50087. * Defines the volume tint of the material.
  50088. * This is used for both translucency and scattering.
  50089. */
  50090. tintColor: Color3;
  50091. /**
  50092. * Defines the distance at which the tint color should be found in the media.
  50093. * This is used for refraction only.
  50094. */
  50095. tintColorAtDistance: number;
  50096. /**
  50097. * Defines how far each channel transmit through the media.
  50098. * It is defined as a color to simplify it selection.
  50099. */
  50100. diffusionDistance: Color3;
  50101. private _useMaskFromThicknessTexture;
  50102. /**
  50103. * Stores the intensity of the different subsurface effects in the thickness texture.
  50104. * * the green channel is the translucency intensity.
  50105. * * the blue channel is the scattering intensity.
  50106. * * the alpha channel is the refraction intensity.
  50107. */
  50108. useMaskFromThicknessTexture: boolean;
  50109. /** @hidden */
  50110. private _internalMarkAllSubMeshesAsTexturesDirty;
  50111. /** @hidden */
  50112. _markAllSubMeshesAsTexturesDirty(): void;
  50113. /**
  50114. * Instantiate a new istance of sub surface configuration.
  50115. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50116. */
  50117. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50118. /**
  50119. * Gets wehter the submesh is ready to be used or not.
  50120. * @param defines the list of "defines" to update.
  50121. * @param scene defines the scene the material belongs to.
  50122. * @returns - boolean indicating that the submesh is ready or not.
  50123. */
  50124. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50125. /**
  50126. * Checks to see if a texture is used in the material.
  50127. * @param defines the list of "defines" to update.
  50128. * @param scene defines the scene to the material belongs to.
  50129. */
  50130. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50131. /**
  50132. * Binds the material data.
  50133. * @param uniformBuffer defines the Uniform buffer to fill in.
  50134. * @param scene defines the scene the material belongs to.
  50135. * @param engine defines the engine the material belongs to.
  50136. * @param isFrozen defines wether the material is frozen or not.
  50137. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50138. */
  50139. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50140. /**
  50141. * Unbinds the material from the mesh.
  50142. * @param activeEffect defines the effect that should be unbound from.
  50143. * @returns true if unbound, otherwise false
  50144. */
  50145. unbind(activeEffect: Effect): boolean;
  50146. /**
  50147. * Returns the texture used for refraction or null if none is used.
  50148. * @param scene defines the scene the material belongs to.
  50149. * @returns - Refraction texture if present. If no refraction texture and refraction
  50150. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50151. */
  50152. private _getRefractionTexture;
  50153. /**
  50154. * Returns true if alpha blending should be disabled.
  50155. */
  50156. readonly disableAlphaBlending: boolean;
  50157. /**
  50158. * Fills the list of render target textures.
  50159. * @param renderTargets the list of render targets to update
  50160. */
  50161. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50162. /**
  50163. * Checks to see if a texture is used in the material.
  50164. * @param texture - Base texture to use.
  50165. * @returns - Boolean specifying if a texture is used in the material.
  50166. */
  50167. hasTexture(texture: BaseTexture): boolean;
  50168. /**
  50169. * Gets a boolean indicating that current material needs to register RTT
  50170. * @returns true if this uses a render target otherwise false.
  50171. */
  50172. hasRenderTargetTextures(): boolean;
  50173. /**
  50174. * Returns an array of the actively used textures.
  50175. * @param activeTextures Array of BaseTextures
  50176. */
  50177. getActiveTextures(activeTextures: BaseTexture[]): void;
  50178. /**
  50179. * Returns the animatable textures.
  50180. * @param animatables Array of animatable textures.
  50181. */
  50182. getAnimatables(animatables: IAnimatable[]): void;
  50183. /**
  50184. * Disposes the resources of the material.
  50185. * @param forceDisposeTextures - Forces the disposal of all textures.
  50186. */
  50187. dispose(forceDisposeTextures?: boolean): void;
  50188. /**
  50189. * Get the current class name of the texture useful for serialization or dynamic coding.
  50190. * @returns "PBRSubSurfaceConfiguration"
  50191. */
  50192. getClassName(): string;
  50193. /**
  50194. * Add fallbacks to the effect fallbacks list.
  50195. * @param defines defines the Base texture to use.
  50196. * @param fallbacks defines the current fallback list.
  50197. * @param currentRank defines the current fallback rank.
  50198. * @returns the new fallback rank.
  50199. */
  50200. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50201. /**
  50202. * Add the required uniforms to the current list.
  50203. * @param uniforms defines the current uniform list.
  50204. */
  50205. static AddUniforms(uniforms: string[]): void;
  50206. /**
  50207. * Add the required samplers to the current list.
  50208. * @param samplers defines the current sampler list.
  50209. */
  50210. static AddSamplers(samplers: string[]): void;
  50211. /**
  50212. * Add the required uniforms to the current buffer.
  50213. * @param uniformBuffer defines the current uniform buffer.
  50214. */
  50215. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50216. /**
  50217. * Makes a duplicate of the current configuration into another one.
  50218. * @param configuration define the config where to copy the info
  50219. */
  50220. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50221. /**
  50222. * Serializes this Sub Surface configuration.
  50223. * @returns - An object with the serialized config.
  50224. */
  50225. serialize(): any;
  50226. /**
  50227. * Parses a anisotropy Configuration from a serialized object.
  50228. * @param source - Serialized object.
  50229. * @param scene Defines the scene we are parsing for
  50230. * @param rootUrl Defines the rootUrl to load from
  50231. */
  50232. parse(source: any, scene: Scene, rootUrl: string): void;
  50233. }
  50234. }
  50235. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50236. /** @hidden */
  50237. export var pbrFragmentDeclaration: {
  50238. name: string;
  50239. shader: string;
  50240. };
  50241. }
  50242. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50243. /** @hidden */
  50244. export var pbrUboDeclaration: {
  50245. name: string;
  50246. shader: string;
  50247. };
  50248. }
  50249. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50250. /** @hidden */
  50251. export var pbrFragmentExtraDeclaration: {
  50252. name: string;
  50253. shader: string;
  50254. };
  50255. }
  50256. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50257. /** @hidden */
  50258. export var pbrFragmentSamplersDeclaration: {
  50259. name: string;
  50260. shader: string;
  50261. };
  50262. }
  50263. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50264. /** @hidden */
  50265. export var pbrHelperFunctions: {
  50266. name: string;
  50267. shader: string;
  50268. };
  50269. }
  50270. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50271. /** @hidden */
  50272. export var harmonicsFunctions: {
  50273. name: string;
  50274. shader: string;
  50275. };
  50276. }
  50277. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50278. /** @hidden */
  50279. export var pbrDirectLightingSetupFunctions: {
  50280. name: string;
  50281. shader: string;
  50282. };
  50283. }
  50284. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50285. /** @hidden */
  50286. export var pbrDirectLightingFalloffFunctions: {
  50287. name: string;
  50288. shader: string;
  50289. };
  50290. }
  50291. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50292. /** @hidden */
  50293. export var pbrBRDFFunctions: {
  50294. name: string;
  50295. shader: string;
  50296. };
  50297. }
  50298. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50299. /** @hidden */
  50300. export var pbrDirectLightingFunctions: {
  50301. name: string;
  50302. shader: string;
  50303. };
  50304. }
  50305. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50306. /** @hidden */
  50307. export var pbrIBLFunctions: {
  50308. name: string;
  50309. shader: string;
  50310. };
  50311. }
  50312. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50313. /** @hidden */
  50314. export var pbrDebug: {
  50315. name: string;
  50316. shader: string;
  50317. };
  50318. }
  50319. declare module "babylonjs/Shaders/pbr.fragment" {
  50320. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50321. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50322. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50323. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50324. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50325. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50326. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50327. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50328. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50329. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50330. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50331. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50332. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50333. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50334. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50335. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50336. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50337. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50338. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50339. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50340. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50341. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50342. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50343. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50344. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50345. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50346. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50347. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50348. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50349. /** @hidden */
  50350. export var pbrPixelShader: {
  50351. name: string;
  50352. shader: string;
  50353. };
  50354. }
  50355. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50356. /** @hidden */
  50357. export var pbrVertexDeclaration: {
  50358. name: string;
  50359. shader: string;
  50360. };
  50361. }
  50362. declare module "babylonjs/Shaders/pbr.vertex" {
  50363. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50364. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50365. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50366. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50367. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50368. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50369. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50370. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50371. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50372. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50373. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50374. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50376. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50377. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50378. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50379. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50380. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50381. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50382. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50383. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50384. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50385. /** @hidden */
  50386. export var pbrVertexShader: {
  50387. name: string;
  50388. shader: string;
  50389. };
  50390. }
  50391. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50392. import { Nullable } from "babylonjs/types";
  50393. import { Scene } from "babylonjs/scene";
  50394. import { Matrix } from "babylonjs/Maths/math.vector";
  50395. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50397. import { Mesh } from "babylonjs/Meshes/mesh";
  50398. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50399. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50400. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50401. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50402. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50403. import { Color3 } from "babylonjs/Maths/math.color";
  50404. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50405. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50406. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50407. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50409. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50410. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50411. import "babylonjs/Shaders/pbr.fragment";
  50412. import "babylonjs/Shaders/pbr.vertex";
  50413. /**
  50414. * Manages the defines for the PBR Material.
  50415. * @hidden
  50416. */
  50417. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50418. PBR: boolean;
  50419. MAINUV1: boolean;
  50420. MAINUV2: boolean;
  50421. UV1: boolean;
  50422. UV2: boolean;
  50423. ALBEDO: boolean;
  50424. ALBEDODIRECTUV: number;
  50425. VERTEXCOLOR: boolean;
  50426. AMBIENT: boolean;
  50427. AMBIENTDIRECTUV: number;
  50428. AMBIENTINGRAYSCALE: boolean;
  50429. OPACITY: boolean;
  50430. VERTEXALPHA: boolean;
  50431. OPACITYDIRECTUV: number;
  50432. OPACITYRGB: boolean;
  50433. ALPHATEST: boolean;
  50434. DEPTHPREPASS: boolean;
  50435. ALPHABLEND: boolean;
  50436. ALPHAFROMALBEDO: boolean;
  50437. ALPHATESTVALUE: string;
  50438. SPECULAROVERALPHA: boolean;
  50439. RADIANCEOVERALPHA: boolean;
  50440. ALPHAFRESNEL: boolean;
  50441. LINEARALPHAFRESNEL: boolean;
  50442. PREMULTIPLYALPHA: boolean;
  50443. EMISSIVE: boolean;
  50444. EMISSIVEDIRECTUV: number;
  50445. REFLECTIVITY: boolean;
  50446. REFLECTIVITYDIRECTUV: number;
  50447. SPECULARTERM: boolean;
  50448. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50449. MICROSURFACEAUTOMATIC: boolean;
  50450. LODBASEDMICROSFURACE: boolean;
  50451. MICROSURFACEMAP: boolean;
  50452. MICROSURFACEMAPDIRECTUV: number;
  50453. METALLICWORKFLOW: boolean;
  50454. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50455. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50456. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50457. AOSTOREINMETALMAPRED: boolean;
  50458. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50459. ENVIRONMENTBRDF: boolean;
  50460. ENVIRONMENTBRDF_RGBD: boolean;
  50461. NORMAL: boolean;
  50462. TANGENT: boolean;
  50463. BUMP: boolean;
  50464. BUMPDIRECTUV: number;
  50465. OBJECTSPACE_NORMALMAP: boolean;
  50466. PARALLAX: boolean;
  50467. PARALLAXOCCLUSION: boolean;
  50468. NORMALXYSCALE: boolean;
  50469. LIGHTMAP: boolean;
  50470. LIGHTMAPDIRECTUV: number;
  50471. USELIGHTMAPASSHADOWMAP: boolean;
  50472. GAMMALIGHTMAP: boolean;
  50473. RGBDLIGHTMAP: boolean;
  50474. REFLECTION: boolean;
  50475. REFLECTIONMAP_3D: boolean;
  50476. REFLECTIONMAP_SPHERICAL: boolean;
  50477. REFLECTIONMAP_PLANAR: boolean;
  50478. REFLECTIONMAP_CUBIC: boolean;
  50479. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50480. REFLECTIONMAP_PROJECTION: boolean;
  50481. REFLECTIONMAP_SKYBOX: boolean;
  50482. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50483. REFLECTIONMAP_EXPLICIT: boolean;
  50484. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50485. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50486. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50487. INVERTCUBICMAP: boolean;
  50488. USESPHERICALFROMREFLECTIONMAP: boolean;
  50489. USEIRRADIANCEMAP: boolean;
  50490. SPHERICAL_HARMONICS: boolean;
  50491. USESPHERICALINVERTEX: boolean;
  50492. REFLECTIONMAP_OPPOSITEZ: boolean;
  50493. LODINREFLECTIONALPHA: boolean;
  50494. GAMMAREFLECTION: boolean;
  50495. RGBDREFLECTION: boolean;
  50496. LINEARSPECULARREFLECTION: boolean;
  50497. RADIANCEOCCLUSION: boolean;
  50498. HORIZONOCCLUSION: boolean;
  50499. INSTANCES: boolean;
  50500. NUM_BONE_INFLUENCERS: number;
  50501. BonesPerMesh: number;
  50502. BONETEXTURE: boolean;
  50503. NONUNIFORMSCALING: boolean;
  50504. MORPHTARGETS: boolean;
  50505. MORPHTARGETS_NORMAL: boolean;
  50506. MORPHTARGETS_TANGENT: boolean;
  50507. MORPHTARGETS_UV: boolean;
  50508. NUM_MORPH_INFLUENCERS: number;
  50509. IMAGEPROCESSING: boolean;
  50510. VIGNETTE: boolean;
  50511. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50512. VIGNETTEBLENDMODEOPAQUE: boolean;
  50513. TONEMAPPING: boolean;
  50514. TONEMAPPING_ACES: boolean;
  50515. CONTRAST: boolean;
  50516. COLORCURVES: boolean;
  50517. COLORGRADING: boolean;
  50518. COLORGRADING3D: boolean;
  50519. SAMPLER3DGREENDEPTH: boolean;
  50520. SAMPLER3DBGRMAP: boolean;
  50521. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50522. EXPOSURE: boolean;
  50523. MULTIVIEW: boolean;
  50524. USEPHYSICALLIGHTFALLOFF: boolean;
  50525. USEGLTFLIGHTFALLOFF: boolean;
  50526. TWOSIDEDLIGHTING: boolean;
  50527. SHADOWFLOAT: boolean;
  50528. CLIPPLANE: boolean;
  50529. CLIPPLANE2: boolean;
  50530. CLIPPLANE3: boolean;
  50531. CLIPPLANE4: boolean;
  50532. POINTSIZE: boolean;
  50533. FOG: boolean;
  50534. LOGARITHMICDEPTH: boolean;
  50535. FORCENORMALFORWARD: boolean;
  50536. SPECULARAA: boolean;
  50537. CLEARCOAT: boolean;
  50538. CLEARCOAT_DEFAULTIOR: boolean;
  50539. CLEARCOAT_TEXTURE: boolean;
  50540. CLEARCOAT_TEXTUREDIRECTUV: number;
  50541. CLEARCOAT_BUMP: boolean;
  50542. CLEARCOAT_BUMPDIRECTUV: number;
  50543. CLEARCOAT_TINT: boolean;
  50544. CLEARCOAT_TINT_TEXTURE: boolean;
  50545. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50546. ANISOTROPIC: boolean;
  50547. ANISOTROPIC_TEXTURE: boolean;
  50548. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50549. BRDF_V_HEIGHT_CORRELATED: boolean;
  50550. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50551. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50552. SHEEN: boolean;
  50553. SHEEN_TEXTURE: boolean;
  50554. SHEEN_TEXTUREDIRECTUV: number;
  50555. SHEEN_LINKWITHALBEDO: boolean;
  50556. SUBSURFACE: boolean;
  50557. SS_REFRACTION: boolean;
  50558. SS_TRANSLUCENCY: boolean;
  50559. SS_SCATERRING: boolean;
  50560. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50561. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50562. SS_REFRACTIONMAP_3D: boolean;
  50563. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50564. SS_LODINREFRACTIONALPHA: boolean;
  50565. SS_GAMMAREFRACTION: boolean;
  50566. SS_RGBDREFRACTION: boolean;
  50567. SS_LINEARSPECULARREFRACTION: boolean;
  50568. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50569. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50570. UNLIT: boolean;
  50571. DEBUGMODE: number;
  50572. /**
  50573. * Initializes the PBR Material defines.
  50574. */
  50575. constructor();
  50576. /**
  50577. * Resets the PBR Material defines.
  50578. */
  50579. reset(): void;
  50580. }
  50581. /**
  50582. * The Physically based material base class of BJS.
  50583. *
  50584. * This offers the main features of a standard PBR material.
  50585. * For more information, please refer to the documentation :
  50586. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50587. */
  50588. export abstract class PBRBaseMaterial extends PushMaterial {
  50589. /**
  50590. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50591. */
  50592. static readonly PBRMATERIAL_OPAQUE: number;
  50593. /**
  50594. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50595. */
  50596. static readonly PBRMATERIAL_ALPHATEST: number;
  50597. /**
  50598. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50599. */
  50600. static readonly PBRMATERIAL_ALPHABLEND: number;
  50601. /**
  50602. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50603. * They are also discarded below the alpha cutoff threshold to improve performances.
  50604. */
  50605. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50606. /**
  50607. * Defines the default value of how much AO map is occluding the analytical lights
  50608. * (point spot...).
  50609. */
  50610. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50611. /**
  50612. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50613. */
  50614. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50615. /**
  50616. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50617. * to enhance interoperability with other engines.
  50618. */
  50619. static readonly LIGHTFALLOFF_GLTF: number;
  50620. /**
  50621. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50622. * to enhance interoperability with other materials.
  50623. */
  50624. static readonly LIGHTFALLOFF_STANDARD: number;
  50625. /**
  50626. * Intensity of the direct lights e.g. the four lights available in your scene.
  50627. * This impacts both the direct diffuse and specular highlights.
  50628. */
  50629. protected _directIntensity: number;
  50630. /**
  50631. * Intensity of the emissive part of the material.
  50632. * This helps controlling the emissive effect without modifying the emissive color.
  50633. */
  50634. protected _emissiveIntensity: number;
  50635. /**
  50636. * Intensity of the environment e.g. how much the environment will light the object
  50637. * either through harmonics for rough material or through the refelction for shiny ones.
  50638. */
  50639. protected _environmentIntensity: number;
  50640. /**
  50641. * This is a special control allowing the reduction of the specular highlights coming from the
  50642. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50643. */
  50644. protected _specularIntensity: number;
  50645. /**
  50646. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50647. */
  50648. private _lightingInfos;
  50649. /**
  50650. * Debug Control allowing disabling the bump map on this material.
  50651. */
  50652. protected _disableBumpMap: boolean;
  50653. /**
  50654. * AKA Diffuse Texture in standard nomenclature.
  50655. */
  50656. protected _albedoTexture: Nullable<BaseTexture>;
  50657. /**
  50658. * AKA Occlusion Texture in other nomenclature.
  50659. */
  50660. protected _ambientTexture: Nullable<BaseTexture>;
  50661. /**
  50662. * AKA Occlusion Texture Intensity in other nomenclature.
  50663. */
  50664. protected _ambientTextureStrength: number;
  50665. /**
  50666. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50667. * 1 means it completely occludes it
  50668. * 0 mean it has no impact
  50669. */
  50670. protected _ambientTextureImpactOnAnalyticalLights: number;
  50671. /**
  50672. * Stores the alpha values in a texture.
  50673. */
  50674. protected _opacityTexture: Nullable<BaseTexture>;
  50675. /**
  50676. * Stores the reflection values in a texture.
  50677. */
  50678. protected _reflectionTexture: Nullable<BaseTexture>;
  50679. /**
  50680. * Stores the emissive values in a texture.
  50681. */
  50682. protected _emissiveTexture: Nullable<BaseTexture>;
  50683. /**
  50684. * AKA Specular texture in other nomenclature.
  50685. */
  50686. protected _reflectivityTexture: Nullable<BaseTexture>;
  50687. /**
  50688. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50689. */
  50690. protected _metallicTexture: Nullable<BaseTexture>;
  50691. /**
  50692. * Specifies the metallic scalar of the metallic/roughness workflow.
  50693. * Can also be used to scale the metalness values of the metallic texture.
  50694. */
  50695. protected _metallic: Nullable<number>;
  50696. /**
  50697. * Specifies the roughness scalar of the metallic/roughness workflow.
  50698. * Can also be used to scale the roughness values of the metallic texture.
  50699. */
  50700. protected _roughness: Nullable<number>;
  50701. /**
  50702. * Specifies the an F0 factor to help configuring the material F0.
  50703. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50704. * to 0.5 the previously hard coded value stays the same.
  50705. * Can also be used to scale the F0 values of the metallic texture.
  50706. */
  50707. protected _metallicF0Factor: number;
  50708. /**
  50709. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50710. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50711. * your expectation as it multiplies with the texture data.
  50712. */
  50713. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50714. /**
  50715. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50716. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50717. */
  50718. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50719. /**
  50720. * Stores surface normal data used to displace a mesh in a texture.
  50721. */
  50722. protected _bumpTexture: Nullable<BaseTexture>;
  50723. /**
  50724. * Stores the pre-calculated light information of a mesh in a texture.
  50725. */
  50726. protected _lightmapTexture: Nullable<BaseTexture>;
  50727. /**
  50728. * The color of a material in ambient lighting.
  50729. */
  50730. protected _ambientColor: Color3;
  50731. /**
  50732. * AKA Diffuse Color in other nomenclature.
  50733. */
  50734. protected _albedoColor: Color3;
  50735. /**
  50736. * AKA Specular Color in other nomenclature.
  50737. */
  50738. protected _reflectivityColor: Color3;
  50739. /**
  50740. * The color applied when light is reflected from a material.
  50741. */
  50742. protected _reflectionColor: Color3;
  50743. /**
  50744. * The color applied when light is emitted from a material.
  50745. */
  50746. protected _emissiveColor: Color3;
  50747. /**
  50748. * AKA Glossiness in other nomenclature.
  50749. */
  50750. protected _microSurface: number;
  50751. /**
  50752. * Specifies that the material will use the light map as a show map.
  50753. */
  50754. protected _useLightmapAsShadowmap: boolean;
  50755. /**
  50756. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50757. * makes the reflect vector face the model (under horizon).
  50758. */
  50759. protected _useHorizonOcclusion: boolean;
  50760. /**
  50761. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50762. * too much the area relying on ambient texture to define their ambient occlusion.
  50763. */
  50764. protected _useRadianceOcclusion: boolean;
  50765. /**
  50766. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50767. */
  50768. protected _useAlphaFromAlbedoTexture: boolean;
  50769. /**
  50770. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50771. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50772. */
  50773. protected _useSpecularOverAlpha: boolean;
  50774. /**
  50775. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50776. */
  50777. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50778. /**
  50779. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50780. */
  50781. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50782. /**
  50783. * Specifies if the metallic texture contains the roughness information in its green channel.
  50784. */
  50785. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50786. /**
  50787. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50788. */
  50789. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50790. /**
  50791. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50792. */
  50793. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50794. /**
  50795. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50796. */
  50797. protected _useAmbientInGrayScale: boolean;
  50798. /**
  50799. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50800. * The material will try to infer what glossiness each pixel should be.
  50801. */
  50802. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50803. /**
  50804. * Defines the falloff type used in this material.
  50805. * It by default is Physical.
  50806. */
  50807. protected _lightFalloff: number;
  50808. /**
  50809. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50810. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50811. */
  50812. protected _useRadianceOverAlpha: boolean;
  50813. /**
  50814. * Allows using an object space normal map (instead of tangent space).
  50815. */
  50816. protected _useObjectSpaceNormalMap: boolean;
  50817. /**
  50818. * Allows using the bump map in parallax mode.
  50819. */
  50820. protected _useParallax: boolean;
  50821. /**
  50822. * Allows using the bump map in parallax occlusion mode.
  50823. */
  50824. protected _useParallaxOcclusion: boolean;
  50825. /**
  50826. * Controls the scale bias of the parallax mode.
  50827. */
  50828. protected _parallaxScaleBias: number;
  50829. /**
  50830. * If sets to true, disables all the lights affecting the material.
  50831. */
  50832. protected _disableLighting: boolean;
  50833. /**
  50834. * Number of Simultaneous lights allowed on the material.
  50835. */
  50836. protected _maxSimultaneousLights: number;
  50837. /**
  50838. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50839. */
  50840. protected _invertNormalMapX: boolean;
  50841. /**
  50842. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50843. */
  50844. protected _invertNormalMapY: boolean;
  50845. /**
  50846. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50847. */
  50848. protected _twoSidedLighting: boolean;
  50849. /**
  50850. * Defines the alpha limits in alpha test mode.
  50851. */
  50852. protected _alphaCutOff: number;
  50853. /**
  50854. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50855. */
  50856. protected _forceAlphaTest: boolean;
  50857. /**
  50858. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50859. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50860. */
  50861. protected _useAlphaFresnel: boolean;
  50862. /**
  50863. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50864. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50865. */
  50866. protected _useLinearAlphaFresnel: boolean;
  50867. /**
  50868. * The transparency mode of the material.
  50869. */
  50870. protected _transparencyMode: Nullable<number>;
  50871. /**
  50872. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50873. * from cos thetav and roughness:
  50874. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50875. */
  50876. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50877. /**
  50878. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50879. */
  50880. protected _forceIrradianceInFragment: boolean;
  50881. /**
  50882. * Force normal to face away from face.
  50883. */
  50884. protected _forceNormalForward: boolean;
  50885. /**
  50886. * Enables specular anti aliasing in the PBR shader.
  50887. * It will both interacts on the Geometry for analytical and IBL lighting.
  50888. * It also prefilter the roughness map based on the bump values.
  50889. */
  50890. protected _enableSpecularAntiAliasing: boolean;
  50891. /**
  50892. * Default configuration related to image processing available in the PBR Material.
  50893. */
  50894. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50895. /**
  50896. * Keep track of the image processing observer to allow dispose and replace.
  50897. */
  50898. private _imageProcessingObserver;
  50899. /**
  50900. * Attaches a new image processing configuration to the PBR Material.
  50901. * @param configuration
  50902. */
  50903. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50904. /**
  50905. * Stores the available render targets.
  50906. */
  50907. private _renderTargets;
  50908. /**
  50909. * Sets the global ambient color for the material used in lighting calculations.
  50910. */
  50911. private _globalAmbientColor;
  50912. /**
  50913. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50914. */
  50915. private _useLogarithmicDepth;
  50916. /**
  50917. * If set to true, no lighting calculations will be applied.
  50918. */
  50919. private _unlit;
  50920. private _debugMode;
  50921. /**
  50922. * @hidden
  50923. * This is reserved for the inspector.
  50924. * Defines the material debug mode.
  50925. * It helps seeing only some components of the material while troubleshooting.
  50926. */
  50927. debugMode: number;
  50928. /**
  50929. * @hidden
  50930. * This is reserved for the inspector.
  50931. * Specify from where on screen the debug mode should start.
  50932. * The value goes from -1 (full screen) to 1 (not visible)
  50933. * It helps with side by side comparison against the final render
  50934. * This defaults to -1
  50935. */
  50936. private debugLimit;
  50937. /**
  50938. * @hidden
  50939. * This is reserved for the inspector.
  50940. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50941. * You can use the factor to better multiply the final value.
  50942. */
  50943. private debugFactor;
  50944. /**
  50945. * Defines the clear coat layer parameters for the material.
  50946. */
  50947. readonly clearCoat: PBRClearCoatConfiguration;
  50948. /**
  50949. * Defines the anisotropic parameters for the material.
  50950. */
  50951. readonly anisotropy: PBRAnisotropicConfiguration;
  50952. /**
  50953. * Defines the BRDF parameters for the material.
  50954. */
  50955. readonly brdf: PBRBRDFConfiguration;
  50956. /**
  50957. * Defines the Sheen parameters for the material.
  50958. */
  50959. readonly sheen: PBRSheenConfiguration;
  50960. /**
  50961. * Defines the SubSurface parameters for the material.
  50962. */
  50963. readonly subSurface: PBRSubSurfaceConfiguration;
  50964. /**
  50965. * Custom callback helping to override the default shader used in the material.
  50966. */
  50967. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50968. protected _rebuildInParallel: boolean;
  50969. /**
  50970. * Instantiates a new PBRMaterial instance.
  50971. *
  50972. * @param name The material name
  50973. * @param scene The scene the material will be use in.
  50974. */
  50975. constructor(name: string, scene: Scene);
  50976. /**
  50977. * Gets a boolean indicating that current material needs to register RTT
  50978. */
  50979. readonly hasRenderTargetTextures: boolean;
  50980. /**
  50981. * Gets the name of the material class.
  50982. */
  50983. getClassName(): string;
  50984. /**
  50985. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50986. */
  50987. /**
  50988. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50989. */
  50990. useLogarithmicDepth: boolean;
  50991. /**
  50992. * Gets the current transparency mode.
  50993. */
  50994. /**
  50995. * Sets the transparency mode of the material.
  50996. *
  50997. * | Value | Type | Description |
  50998. * | ----- | ----------------------------------- | ----------- |
  50999. * | 0 | OPAQUE | |
  51000. * | 1 | ALPHATEST | |
  51001. * | 2 | ALPHABLEND | |
  51002. * | 3 | ALPHATESTANDBLEND | |
  51003. *
  51004. */
  51005. transparencyMode: Nullable<number>;
  51006. /**
  51007. * Returns true if alpha blending should be disabled.
  51008. */
  51009. private readonly _disableAlphaBlending;
  51010. /**
  51011. * Specifies whether or not this material should be rendered in alpha blend mode.
  51012. */
  51013. needAlphaBlending(): boolean;
  51014. /**
  51015. * Specifies if the mesh will require alpha blending.
  51016. * @param mesh - BJS mesh.
  51017. */
  51018. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51019. /**
  51020. * Specifies whether or not this material should be rendered in alpha test mode.
  51021. */
  51022. needAlphaTesting(): boolean;
  51023. /**
  51024. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51025. */
  51026. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51027. /**
  51028. * Gets the texture used for the alpha test.
  51029. */
  51030. getAlphaTestTexture(): Nullable<BaseTexture>;
  51031. /**
  51032. * Specifies that the submesh is ready to be used.
  51033. * @param mesh - BJS mesh.
  51034. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51035. * @param useInstances - Specifies that instances should be used.
  51036. * @returns - boolean indicating that the submesh is ready or not.
  51037. */
  51038. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51039. /**
  51040. * Specifies if the material uses metallic roughness workflow.
  51041. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51042. */
  51043. isMetallicWorkflow(): boolean;
  51044. private _prepareEffect;
  51045. private _prepareDefines;
  51046. /**
  51047. * Force shader compilation
  51048. */
  51049. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51050. /**
  51051. * Initializes the uniform buffer layout for the shader.
  51052. */
  51053. buildUniformLayout(): void;
  51054. /**
  51055. * Unbinds the material from the mesh
  51056. */
  51057. unbind(): void;
  51058. /**
  51059. * Binds the submesh data.
  51060. * @param world - The world matrix.
  51061. * @param mesh - The BJS mesh.
  51062. * @param subMesh - A submesh of the BJS mesh.
  51063. */
  51064. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51065. /**
  51066. * Returns the animatable textures.
  51067. * @returns - Array of animatable textures.
  51068. */
  51069. getAnimatables(): IAnimatable[];
  51070. /**
  51071. * Returns the texture used for reflections.
  51072. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51073. */
  51074. private _getReflectionTexture;
  51075. /**
  51076. * Returns an array of the actively used textures.
  51077. * @returns - Array of BaseTextures
  51078. */
  51079. getActiveTextures(): BaseTexture[];
  51080. /**
  51081. * Checks to see if a texture is used in the material.
  51082. * @param texture - Base texture to use.
  51083. * @returns - Boolean specifying if a texture is used in the material.
  51084. */
  51085. hasTexture(texture: BaseTexture): boolean;
  51086. /**
  51087. * Disposes the resources of the material.
  51088. * @param forceDisposeEffect - Forces the disposal of effects.
  51089. * @param forceDisposeTextures - Forces the disposal of all textures.
  51090. */
  51091. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51092. }
  51093. }
  51094. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  51095. import { Nullable } from "babylonjs/types";
  51096. import { Scene } from "babylonjs/scene";
  51097. import { Color3 } from "babylonjs/Maths/math.color";
  51098. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51099. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51100. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51101. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51102. /**
  51103. * The Physically based material of BJS.
  51104. *
  51105. * This offers the main features of a standard PBR material.
  51106. * For more information, please refer to the documentation :
  51107. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51108. */
  51109. export class PBRMaterial extends PBRBaseMaterial {
  51110. /**
  51111. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51112. */
  51113. static readonly PBRMATERIAL_OPAQUE: number;
  51114. /**
  51115. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51116. */
  51117. static readonly PBRMATERIAL_ALPHATEST: number;
  51118. /**
  51119. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51120. */
  51121. static readonly PBRMATERIAL_ALPHABLEND: number;
  51122. /**
  51123. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51124. * They are also discarded below the alpha cutoff threshold to improve performances.
  51125. */
  51126. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51127. /**
  51128. * Defines the default value of how much AO map is occluding the analytical lights
  51129. * (point spot...).
  51130. */
  51131. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51132. /**
  51133. * Intensity of the direct lights e.g. the four lights available in your scene.
  51134. * This impacts both the direct diffuse and specular highlights.
  51135. */
  51136. directIntensity: number;
  51137. /**
  51138. * Intensity of the emissive part of the material.
  51139. * This helps controlling the emissive effect without modifying the emissive color.
  51140. */
  51141. emissiveIntensity: number;
  51142. /**
  51143. * Intensity of the environment e.g. how much the environment will light the object
  51144. * either through harmonics for rough material or through the refelction for shiny ones.
  51145. */
  51146. environmentIntensity: number;
  51147. /**
  51148. * This is a special control allowing the reduction of the specular highlights coming from the
  51149. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51150. */
  51151. specularIntensity: number;
  51152. /**
  51153. * Debug Control allowing disabling the bump map on this material.
  51154. */
  51155. disableBumpMap: boolean;
  51156. /**
  51157. * AKA Diffuse Texture in standard nomenclature.
  51158. */
  51159. albedoTexture: BaseTexture;
  51160. /**
  51161. * AKA Occlusion Texture in other nomenclature.
  51162. */
  51163. ambientTexture: BaseTexture;
  51164. /**
  51165. * AKA Occlusion Texture Intensity in other nomenclature.
  51166. */
  51167. ambientTextureStrength: number;
  51168. /**
  51169. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51170. * 1 means it completely occludes it
  51171. * 0 mean it has no impact
  51172. */
  51173. ambientTextureImpactOnAnalyticalLights: number;
  51174. /**
  51175. * Stores the alpha values in a texture.
  51176. */
  51177. opacityTexture: BaseTexture;
  51178. /**
  51179. * Stores the reflection values in a texture.
  51180. */
  51181. reflectionTexture: Nullable<BaseTexture>;
  51182. /**
  51183. * Stores the emissive values in a texture.
  51184. */
  51185. emissiveTexture: BaseTexture;
  51186. /**
  51187. * AKA Specular texture in other nomenclature.
  51188. */
  51189. reflectivityTexture: BaseTexture;
  51190. /**
  51191. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51192. */
  51193. metallicTexture: BaseTexture;
  51194. /**
  51195. * Specifies the metallic scalar of the metallic/roughness workflow.
  51196. * Can also be used to scale the metalness values of the metallic texture.
  51197. */
  51198. metallic: Nullable<number>;
  51199. /**
  51200. * Specifies the roughness scalar of the metallic/roughness workflow.
  51201. * Can also be used to scale the roughness values of the metallic texture.
  51202. */
  51203. roughness: Nullable<number>;
  51204. /**
  51205. * Specifies the an F0 factor to help configuring the material F0.
  51206. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51207. * to 0.5 the previously hard coded value stays the same.
  51208. * Can also be used to scale the F0 values of the metallic texture.
  51209. */
  51210. metallicF0Factor: number;
  51211. /**
  51212. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51213. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51214. * your expectation as it multiplies with the texture data.
  51215. */
  51216. useMetallicF0FactorFromMetallicTexture: boolean;
  51217. /**
  51218. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51219. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51220. */
  51221. microSurfaceTexture: BaseTexture;
  51222. /**
  51223. * Stores surface normal data used to displace a mesh in a texture.
  51224. */
  51225. bumpTexture: BaseTexture;
  51226. /**
  51227. * Stores the pre-calculated light information of a mesh in a texture.
  51228. */
  51229. lightmapTexture: BaseTexture;
  51230. /**
  51231. * Stores the refracted light information in a texture.
  51232. */
  51233. refractionTexture: Nullable<BaseTexture>;
  51234. /**
  51235. * The color of a material in ambient lighting.
  51236. */
  51237. ambientColor: Color3;
  51238. /**
  51239. * AKA Diffuse Color in other nomenclature.
  51240. */
  51241. albedoColor: Color3;
  51242. /**
  51243. * AKA Specular Color in other nomenclature.
  51244. */
  51245. reflectivityColor: Color3;
  51246. /**
  51247. * The color reflected from the material.
  51248. */
  51249. reflectionColor: Color3;
  51250. /**
  51251. * The color emitted from the material.
  51252. */
  51253. emissiveColor: Color3;
  51254. /**
  51255. * AKA Glossiness in other nomenclature.
  51256. */
  51257. microSurface: number;
  51258. /**
  51259. * source material index of refraction (IOR)' / 'destination material IOR.
  51260. */
  51261. indexOfRefraction: number;
  51262. /**
  51263. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51264. */
  51265. invertRefractionY: boolean;
  51266. /**
  51267. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51268. * Materials half opaque for instance using refraction could benefit from this control.
  51269. */
  51270. linkRefractionWithTransparency: boolean;
  51271. /**
  51272. * If true, the light map contains occlusion information instead of lighting info.
  51273. */
  51274. useLightmapAsShadowmap: boolean;
  51275. /**
  51276. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51277. */
  51278. useAlphaFromAlbedoTexture: boolean;
  51279. /**
  51280. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51281. */
  51282. forceAlphaTest: boolean;
  51283. /**
  51284. * Defines the alpha limits in alpha test mode.
  51285. */
  51286. alphaCutOff: number;
  51287. /**
  51288. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51289. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51290. */
  51291. useSpecularOverAlpha: boolean;
  51292. /**
  51293. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51294. */
  51295. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51296. /**
  51297. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51298. */
  51299. useRoughnessFromMetallicTextureAlpha: boolean;
  51300. /**
  51301. * Specifies if the metallic texture contains the roughness information in its green channel.
  51302. */
  51303. useRoughnessFromMetallicTextureGreen: boolean;
  51304. /**
  51305. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51306. */
  51307. useMetallnessFromMetallicTextureBlue: boolean;
  51308. /**
  51309. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51310. */
  51311. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51312. /**
  51313. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51314. */
  51315. useAmbientInGrayScale: boolean;
  51316. /**
  51317. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51318. * The material will try to infer what glossiness each pixel should be.
  51319. */
  51320. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51321. /**
  51322. * BJS is using an harcoded light falloff based on a manually sets up range.
  51323. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51324. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51325. */
  51326. /**
  51327. * BJS is using an harcoded light falloff based on a manually sets up range.
  51328. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51329. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51330. */
  51331. usePhysicalLightFalloff: boolean;
  51332. /**
  51333. * In order to support the falloff compatibility with gltf, a special mode has been added
  51334. * to reproduce the gltf light falloff.
  51335. */
  51336. /**
  51337. * In order to support the falloff compatibility with gltf, a special mode has been added
  51338. * to reproduce the gltf light falloff.
  51339. */
  51340. useGLTFLightFalloff: boolean;
  51341. /**
  51342. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51343. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51344. */
  51345. useRadianceOverAlpha: boolean;
  51346. /**
  51347. * Allows using an object space normal map (instead of tangent space).
  51348. */
  51349. useObjectSpaceNormalMap: boolean;
  51350. /**
  51351. * Allows using the bump map in parallax mode.
  51352. */
  51353. useParallax: boolean;
  51354. /**
  51355. * Allows using the bump map in parallax occlusion mode.
  51356. */
  51357. useParallaxOcclusion: boolean;
  51358. /**
  51359. * Controls the scale bias of the parallax mode.
  51360. */
  51361. parallaxScaleBias: number;
  51362. /**
  51363. * If sets to true, disables all the lights affecting the material.
  51364. */
  51365. disableLighting: boolean;
  51366. /**
  51367. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51368. */
  51369. forceIrradianceInFragment: boolean;
  51370. /**
  51371. * Number of Simultaneous lights allowed on the material.
  51372. */
  51373. maxSimultaneousLights: number;
  51374. /**
  51375. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51376. */
  51377. invertNormalMapX: boolean;
  51378. /**
  51379. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51380. */
  51381. invertNormalMapY: boolean;
  51382. /**
  51383. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51384. */
  51385. twoSidedLighting: boolean;
  51386. /**
  51387. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51388. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51389. */
  51390. useAlphaFresnel: boolean;
  51391. /**
  51392. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51393. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51394. */
  51395. useLinearAlphaFresnel: boolean;
  51396. /**
  51397. * Let user defines the brdf lookup texture used for IBL.
  51398. * A default 8bit version is embedded but you could point at :
  51399. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51400. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51401. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51402. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51403. */
  51404. environmentBRDFTexture: Nullable<BaseTexture>;
  51405. /**
  51406. * Force normal to face away from face.
  51407. */
  51408. forceNormalForward: boolean;
  51409. /**
  51410. * Enables specular anti aliasing in the PBR shader.
  51411. * It will both interacts on the Geometry for analytical and IBL lighting.
  51412. * It also prefilter the roughness map based on the bump values.
  51413. */
  51414. enableSpecularAntiAliasing: boolean;
  51415. /**
  51416. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51417. * makes the reflect vector face the model (under horizon).
  51418. */
  51419. useHorizonOcclusion: boolean;
  51420. /**
  51421. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51422. * too much the area relying on ambient texture to define their ambient occlusion.
  51423. */
  51424. useRadianceOcclusion: boolean;
  51425. /**
  51426. * If set to true, no lighting calculations will be applied.
  51427. */
  51428. unlit: boolean;
  51429. /**
  51430. * Gets the image processing configuration used either in this material.
  51431. */
  51432. /**
  51433. * Sets the Default image processing configuration used either in the this material.
  51434. *
  51435. * If sets to null, the scene one is in use.
  51436. */
  51437. imageProcessingConfiguration: ImageProcessingConfiguration;
  51438. /**
  51439. * Gets wether the color curves effect is enabled.
  51440. */
  51441. /**
  51442. * Sets wether the color curves effect is enabled.
  51443. */
  51444. cameraColorCurvesEnabled: boolean;
  51445. /**
  51446. * Gets wether the color grading effect is enabled.
  51447. */
  51448. /**
  51449. * Gets wether the color grading effect is enabled.
  51450. */
  51451. cameraColorGradingEnabled: boolean;
  51452. /**
  51453. * Gets wether tonemapping is enabled or not.
  51454. */
  51455. /**
  51456. * Sets wether tonemapping is enabled or not
  51457. */
  51458. cameraToneMappingEnabled: boolean;
  51459. /**
  51460. * The camera exposure used on this material.
  51461. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51462. * This corresponds to a photographic exposure.
  51463. */
  51464. /**
  51465. * The camera exposure used on this material.
  51466. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51467. * This corresponds to a photographic exposure.
  51468. */
  51469. cameraExposure: number;
  51470. /**
  51471. * Gets The camera contrast used on this material.
  51472. */
  51473. /**
  51474. * Sets The camera contrast used on this material.
  51475. */
  51476. cameraContrast: number;
  51477. /**
  51478. * Gets the Color Grading 2D Lookup Texture.
  51479. */
  51480. /**
  51481. * Sets the Color Grading 2D Lookup Texture.
  51482. */
  51483. cameraColorGradingTexture: Nullable<BaseTexture>;
  51484. /**
  51485. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51486. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51487. * 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;
  51488. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51489. */
  51490. /**
  51491. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51492. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51493. * 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;
  51494. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51495. */
  51496. cameraColorCurves: Nullable<ColorCurves>;
  51497. /**
  51498. * Instantiates a new PBRMaterial instance.
  51499. *
  51500. * @param name The material name
  51501. * @param scene The scene the material will be use in.
  51502. */
  51503. constructor(name: string, scene: Scene);
  51504. /**
  51505. * Returns the name of this material class.
  51506. */
  51507. getClassName(): string;
  51508. /**
  51509. * Makes a duplicate of the current material.
  51510. * @param name - name to use for the new material.
  51511. */
  51512. clone(name: string): PBRMaterial;
  51513. /**
  51514. * Serializes this PBR Material.
  51515. * @returns - An object with the serialized material.
  51516. */
  51517. serialize(): any;
  51518. /**
  51519. * Parses a PBR Material from a serialized object.
  51520. * @param source - Serialized object.
  51521. * @param scene - BJS scene instance.
  51522. * @param rootUrl - url for the scene object
  51523. * @returns - PBRMaterial
  51524. */
  51525. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51526. }
  51527. }
  51528. declare module "babylonjs/Misc/dds" {
  51529. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51530. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51531. import { Nullable } from "babylonjs/types";
  51532. import { Scene } from "babylonjs/scene";
  51533. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51534. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51535. /**
  51536. * Direct draw surface info
  51537. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51538. */
  51539. export interface DDSInfo {
  51540. /**
  51541. * Width of the texture
  51542. */
  51543. width: number;
  51544. /**
  51545. * Width of the texture
  51546. */
  51547. height: number;
  51548. /**
  51549. * Number of Mipmaps for the texture
  51550. * @see https://en.wikipedia.org/wiki/Mipmap
  51551. */
  51552. mipmapCount: number;
  51553. /**
  51554. * If the textures format is a known fourCC format
  51555. * @see https://www.fourcc.org/
  51556. */
  51557. isFourCC: boolean;
  51558. /**
  51559. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51560. */
  51561. isRGB: boolean;
  51562. /**
  51563. * If the texture is a lumincance format
  51564. */
  51565. isLuminance: boolean;
  51566. /**
  51567. * If this is a cube texture
  51568. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51569. */
  51570. isCube: boolean;
  51571. /**
  51572. * If the texture is a compressed format eg. FOURCC_DXT1
  51573. */
  51574. isCompressed: boolean;
  51575. /**
  51576. * The dxgiFormat of the texture
  51577. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51578. */
  51579. dxgiFormat: number;
  51580. /**
  51581. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51582. */
  51583. textureType: number;
  51584. /**
  51585. * Sphericle polynomial created for the dds texture
  51586. */
  51587. sphericalPolynomial?: SphericalPolynomial;
  51588. }
  51589. /**
  51590. * Class used to provide DDS decompression tools
  51591. */
  51592. export class DDSTools {
  51593. /**
  51594. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51595. */
  51596. static StoreLODInAlphaChannel: boolean;
  51597. /**
  51598. * Gets DDS information from an array buffer
  51599. * @param arrayBuffer defines the array buffer to read data from
  51600. * @returns the DDS information
  51601. */
  51602. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51603. private static _FloatView;
  51604. private static _Int32View;
  51605. private static _ToHalfFloat;
  51606. private static _FromHalfFloat;
  51607. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51608. private static _GetHalfFloatRGBAArrayBuffer;
  51609. private static _GetFloatRGBAArrayBuffer;
  51610. private static _GetFloatAsUIntRGBAArrayBuffer;
  51611. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51612. private static _GetRGBAArrayBuffer;
  51613. private static _ExtractLongWordOrder;
  51614. private static _GetRGBArrayBuffer;
  51615. private static _GetLuminanceArrayBuffer;
  51616. /**
  51617. * Uploads DDS Levels to a Babylon Texture
  51618. * @hidden
  51619. */
  51620. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51621. }
  51622. module "babylonjs/Engines/thinEngine" {
  51623. interface ThinEngine {
  51624. /**
  51625. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51626. * @param rootUrl defines the url where the file to load is located
  51627. * @param scene defines the current scene
  51628. * @param lodScale defines scale to apply to the mip map selection
  51629. * @param lodOffset defines offset to apply to the mip map selection
  51630. * @param onLoad defines an optional callback raised when the texture is loaded
  51631. * @param onError defines an optional callback raised if there is an issue to load the texture
  51632. * @param format defines the format of the data
  51633. * @param forcedExtension defines the extension to use to pick the right loader
  51634. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51635. * @returns the cube texture as an InternalTexture
  51636. */
  51637. 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;
  51638. }
  51639. }
  51640. }
  51641. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51642. import { Nullable } from "babylonjs/types";
  51643. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51644. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51645. /**
  51646. * Implementation of the DDS Texture Loader.
  51647. * @hidden
  51648. */
  51649. export class _DDSTextureLoader implements IInternalTextureLoader {
  51650. /**
  51651. * Defines wether the loader supports cascade loading the different faces.
  51652. */
  51653. readonly supportCascades: boolean;
  51654. /**
  51655. * This returns if the loader support the current file information.
  51656. * @param extension defines the file extension of the file being loaded
  51657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51658. * @param fallback defines the fallback internal texture if any
  51659. * @param isBase64 defines whether the texture is encoded as a base64
  51660. * @param isBuffer defines whether the texture data are stored as a buffer
  51661. * @returns true if the loader can load the specified file
  51662. */
  51663. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51664. /**
  51665. * Transform the url before loading if required.
  51666. * @param rootUrl the url of the texture
  51667. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51668. * @returns the transformed texture
  51669. */
  51670. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51671. /**
  51672. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51673. * @param rootUrl the url of the texture
  51674. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51675. * @returns the fallback texture
  51676. */
  51677. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51678. /**
  51679. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51680. * @param data contains the texture data
  51681. * @param texture defines the BabylonJS internal texture
  51682. * @param createPolynomials will be true if polynomials have been requested
  51683. * @param onLoad defines the callback to trigger once the texture is ready
  51684. * @param onError defines the callback to trigger in case of error
  51685. */
  51686. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51687. /**
  51688. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51689. * @param data contains the texture data
  51690. * @param texture defines the BabylonJS internal texture
  51691. * @param callback defines the method to call once ready to upload
  51692. */
  51693. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51694. }
  51695. }
  51696. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51697. import { Nullable } from "babylonjs/types";
  51698. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51699. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51700. /**
  51701. * Implementation of the ENV Texture Loader.
  51702. * @hidden
  51703. */
  51704. export class _ENVTextureLoader implements IInternalTextureLoader {
  51705. /**
  51706. * Defines wether the loader supports cascade loading the different faces.
  51707. */
  51708. readonly supportCascades: boolean;
  51709. /**
  51710. * This returns if the loader support the current file information.
  51711. * @param extension defines the file extension of the file being loaded
  51712. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51713. * @param fallback defines the fallback internal texture if any
  51714. * @param isBase64 defines whether the texture is encoded as a base64
  51715. * @param isBuffer defines whether the texture data are stored as a buffer
  51716. * @returns true if the loader can load the specified file
  51717. */
  51718. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51719. /**
  51720. * Transform the url before loading if required.
  51721. * @param rootUrl the url of the texture
  51722. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51723. * @returns the transformed texture
  51724. */
  51725. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51726. /**
  51727. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51728. * @param rootUrl the url of the texture
  51729. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51730. * @returns the fallback texture
  51731. */
  51732. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51733. /**
  51734. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51735. * @param data contains the texture data
  51736. * @param texture defines the BabylonJS internal texture
  51737. * @param createPolynomials will be true if polynomials have been requested
  51738. * @param onLoad defines the callback to trigger once the texture is ready
  51739. * @param onError defines the callback to trigger in case of error
  51740. */
  51741. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51742. /**
  51743. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51744. * @param data contains the texture data
  51745. * @param texture defines the BabylonJS internal texture
  51746. * @param callback defines the method to call once ready to upload
  51747. */
  51748. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51749. }
  51750. }
  51751. declare module "babylonjs/Misc/khronosTextureContainer" {
  51752. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51753. /**
  51754. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51755. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51756. */
  51757. export class KhronosTextureContainer {
  51758. /** contents of the KTX container file */
  51759. arrayBuffer: any;
  51760. private static HEADER_LEN;
  51761. private static COMPRESSED_2D;
  51762. private static COMPRESSED_3D;
  51763. private static TEX_2D;
  51764. private static TEX_3D;
  51765. /**
  51766. * Gets the openGL type
  51767. */
  51768. glType: number;
  51769. /**
  51770. * Gets the openGL type size
  51771. */
  51772. glTypeSize: number;
  51773. /**
  51774. * Gets the openGL format
  51775. */
  51776. glFormat: number;
  51777. /**
  51778. * Gets the openGL internal format
  51779. */
  51780. glInternalFormat: number;
  51781. /**
  51782. * Gets the base internal format
  51783. */
  51784. glBaseInternalFormat: number;
  51785. /**
  51786. * Gets image width in pixel
  51787. */
  51788. pixelWidth: number;
  51789. /**
  51790. * Gets image height in pixel
  51791. */
  51792. pixelHeight: number;
  51793. /**
  51794. * Gets image depth in pixels
  51795. */
  51796. pixelDepth: number;
  51797. /**
  51798. * Gets the number of array elements
  51799. */
  51800. numberOfArrayElements: number;
  51801. /**
  51802. * Gets the number of faces
  51803. */
  51804. numberOfFaces: number;
  51805. /**
  51806. * Gets the number of mipmap levels
  51807. */
  51808. numberOfMipmapLevels: number;
  51809. /**
  51810. * Gets the bytes of key value data
  51811. */
  51812. bytesOfKeyValueData: number;
  51813. /**
  51814. * Gets the load type
  51815. */
  51816. loadType: number;
  51817. /**
  51818. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51819. */
  51820. isInvalid: boolean;
  51821. /**
  51822. * Creates a new KhronosTextureContainer
  51823. * @param arrayBuffer contents of the KTX container file
  51824. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51825. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51826. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51827. */
  51828. constructor(
  51829. /** contents of the KTX container file */
  51830. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51831. /**
  51832. * Uploads KTX content to a Babylon Texture.
  51833. * It is assumed that the texture has already been created & is currently bound
  51834. * @hidden
  51835. */
  51836. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51837. private _upload2DCompressedLevels;
  51838. }
  51839. }
  51840. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51841. import { Nullable } from "babylonjs/types";
  51842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51843. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51844. /**
  51845. * Implementation of the KTX Texture Loader.
  51846. * @hidden
  51847. */
  51848. export class _KTXTextureLoader implements IInternalTextureLoader {
  51849. /**
  51850. * Defines wether the loader supports cascade loading the different faces.
  51851. */
  51852. readonly supportCascades: boolean;
  51853. /**
  51854. * This returns if the loader support the current file information.
  51855. * @param extension defines the file extension of the file being loaded
  51856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51857. * @param fallback defines the fallback internal texture if any
  51858. * @param isBase64 defines whether the texture is encoded as a base64
  51859. * @param isBuffer defines whether the texture data are stored as a buffer
  51860. * @returns true if the loader can load the specified file
  51861. */
  51862. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51863. /**
  51864. * Transform the url before loading if required.
  51865. * @param rootUrl the url of the texture
  51866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51867. * @returns the transformed texture
  51868. */
  51869. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51870. /**
  51871. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51872. * @param rootUrl the url of the texture
  51873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51874. * @returns the fallback texture
  51875. */
  51876. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51877. /**
  51878. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51879. * @param data contains the texture data
  51880. * @param texture defines the BabylonJS internal texture
  51881. * @param createPolynomials will be true if polynomials have been requested
  51882. * @param onLoad defines the callback to trigger once the texture is ready
  51883. * @param onError defines the callback to trigger in case of error
  51884. */
  51885. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51886. /**
  51887. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51888. * @param data contains the texture data
  51889. * @param texture defines the BabylonJS internal texture
  51890. * @param callback defines the method to call once ready to upload
  51891. */
  51892. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51893. }
  51894. }
  51895. declare module "babylonjs/Helpers/sceneHelpers" {
  51896. import { Nullable } from "babylonjs/types";
  51897. import { Mesh } from "babylonjs/Meshes/mesh";
  51898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51899. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51900. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51901. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51902. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51903. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51904. import "babylonjs/Meshes/Builders/boxBuilder";
  51905. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51906. /** @hidden */
  51907. export var _forceSceneHelpersToBundle: boolean;
  51908. module "babylonjs/scene" {
  51909. interface Scene {
  51910. /**
  51911. * Creates a default light for the scene.
  51912. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51913. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51914. */
  51915. createDefaultLight(replace?: boolean): void;
  51916. /**
  51917. * Creates a default camera for the scene.
  51918. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51919. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51920. * @param replace has default false, when true replaces the active camera in the scene
  51921. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51922. */
  51923. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51924. /**
  51925. * Creates a default camera and a default light.
  51926. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51927. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51928. * @param replace has the default false, when true replaces the active camera/light in the scene
  51929. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51930. */
  51931. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51932. /**
  51933. * Creates a new sky box
  51934. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51935. * @param environmentTexture defines the texture to use as environment texture
  51936. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51937. * @param scale defines the overall scale of the skybox
  51938. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51939. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51940. * @returns a new mesh holding the sky box
  51941. */
  51942. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51943. /**
  51944. * Creates a new environment
  51945. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51946. * @param options defines the options you can use to configure the environment
  51947. * @returns the new EnvironmentHelper
  51948. */
  51949. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51950. /**
  51951. * Creates a new VREXperienceHelper
  51952. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51953. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51954. * @returns a new VREXperienceHelper
  51955. */
  51956. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51957. /**
  51958. * Creates a new WebXRDefaultExperience
  51959. * @see http://doc.babylonjs.com/how_to/webxr
  51960. * @param options experience options
  51961. * @returns a promise for a new WebXRDefaultExperience
  51962. */
  51963. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51964. }
  51965. }
  51966. }
  51967. declare module "babylonjs/Helpers/videoDome" {
  51968. import { Scene } from "babylonjs/scene";
  51969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51970. import { Mesh } from "babylonjs/Meshes/mesh";
  51971. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51972. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51973. import "babylonjs/Meshes/Builders/sphereBuilder";
  51974. /**
  51975. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51976. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51977. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51978. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51979. */
  51980. export class VideoDome extends TransformNode {
  51981. /**
  51982. * Define the video source as a Monoscopic panoramic 360 video.
  51983. */
  51984. static readonly MODE_MONOSCOPIC: number;
  51985. /**
  51986. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51987. */
  51988. static readonly MODE_TOPBOTTOM: number;
  51989. /**
  51990. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51991. */
  51992. static readonly MODE_SIDEBYSIDE: number;
  51993. private _halfDome;
  51994. private _useDirectMapping;
  51995. /**
  51996. * The video texture being displayed on the sphere
  51997. */
  51998. protected _videoTexture: VideoTexture;
  51999. /**
  52000. * Gets the video texture being displayed on the sphere
  52001. */
  52002. readonly videoTexture: VideoTexture;
  52003. /**
  52004. * The skybox material
  52005. */
  52006. protected _material: BackgroundMaterial;
  52007. /**
  52008. * The surface used for the skybox
  52009. */
  52010. protected _mesh: Mesh;
  52011. /**
  52012. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52013. */
  52014. private _halfDomeMask;
  52015. /**
  52016. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52017. * Also see the options.resolution property.
  52018. */
  52019. fovMultiplier: number;
  52020. private _videoMode;
  52021. /**
  52022. * Gets or set the current video mode for the video. It can be:
  52023. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52024. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52025. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52026. */
  52027. videoMode: number;
  52028. /**
  52029. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52030. *
  52031. */
  52032. /**
  52033. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52034. */
  52035. halfDome: boolean;
  52036. /**
  52037. * Oberserver used in Stereoscopic VR Mode.
  52038. */
  52039. private _onBeforeCameraRenderObserver;
  52040. /**
  52041. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52042. * @param name Element's name, child elements will append suffixes for their own names.
  52043. * @param urlsOrVideo defines the url(s) or the video element to use
  52044. * @param options An object containing optional or exposed sub element properties
  52045. */
  52046. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52047. resolution?: number;
  52048. clickToPlay?: boolean;
  52049. autoPlay?: boolean;
  52050. loop?: boolean;
  52051. size?: number;
  52052. poster?: string;
  52053. faceForward?: boolean;
  52054. useDirectMapping?: boolean;
  52055. halfDomeMode?: boolean;
  52056. }, scene: Scene);
  52057. private _changeVideoMode;
  52058. /**
  52059. * Releases resources associated with this node.
  52060. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52061. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52062. */
  52063. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52064. }
  52065. }
  52066. declare module "babylonjs/Helpers/index" {
  52067. export * from "babylonjs/Helpers/environmentHelper";
  52068. export * from "babylonjs/Helpers/photoDome";
  52069. export * from "babylonjs/Helpers/sceneHelpers";
  52070. export * from "babylonjs/Helpers/videoDome";
  52071. }
  52072. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  52073. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52074. import { IDisposable } from "babylonjs/scene";
  52075. import { Engine } from "babylonjs/Engines/engine";
  52076. /**
  52077. * This class can be used to get instrumentation data from a Babylon engine
  52078. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52079. */
  52080. export class EngineInstrumentation implements IDisposable {
  52081. /**
  52082. * Define the instrumented engine.
  52083. */
  52084. engine: Engine;
  52085. private _captureGPUFrameTime;
  52086. private _gpuFrameTimeToken;
  52087. private _gpuFrameTime;
  52088. private _captureShaderCompilationTime;
  52089. private _shaderCompilationTime;
  52090. private _onBeginFrameObserver;
  52091. private _onEndFrameObserver;
  52092. private _onBeforeShaderCompilationObserver;
  52093. private _onAfterShaderCompilationObserver;
  52094. /**
  52095. * Gets the perf counter used for GPU frame time
  52096. */
  52097. readonly gpuFrameTimeCounter: PerfCounter;
  52098. /**
  52099. * Gets the GPU frame time capture status
  52100. */
  52101. /**
  52102. * Enable or disable the GPU frame time capture
  52103. */
  52104. captureGPUFrameTime: boolean;
  52105. /**
  52106. * Gets the perf counter used for shader compilation time
  52107. */
  52108. readonly shaderCompilationTimeCounter: PerfCounter;
  52109. /**
  52110. * Gets the shader compilation time capture status
  52111. */
  52112. /**
  52113. * Enable or disable the shader compilation time capture
  52114. */
  52115. captureShaderCompilationTime: boolean;
  52116. /**
  52117. * Instantiates a new engine instrumentation.
  52118. * This class can be used to get instrumentation data from a Babylon engine
  52119. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52120. * @param engine Defines the engine to instrument
  52121. */
  52122. constructor(
  52123. /**
  52124. * Define the instrumented engine.
  52125. */
  52126. engine: Engine);
  52127. /**
  52128. * Dispose and release associated resources.
  52129. */
  52130. dispose(): void;
  52131. }
  52132. }
  52133. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  52134. import { Scene, IDisposable } from "babylonjs/scene";
  52135. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52136. /**
  52137. * This class can be used to get instrumentation data from a Babylon engine
  52138. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52139. */
  52140. export class SceneInstrumentation implements IDisposable {
  52141. /**
  52142. * Defines the scene to instrument
  52143. */
  52144. scene: Scene;
  52145. private _captureActiveMeshesEvaluationTime;
  52146. private _activeMeshesEvaluationTime;
  52147. private _captureRenderTargetsRenderTime;
  52148. private _renderTargetsRenderTime;
  52149. private _captureFrameTime;
  52150. private _frameTime;
  52151. private _captureRenderTime;
  52152. private _renderTime;
  52153. private _captureInterFrameTime;
  52154. private _interFrameTime;
  52155. private _captureParticlesRenderTime;
  52156. private _particlesRenderTime;
  52157. private _captureSpritesRenderTime;
  52158. private _spritesRenderTime;
  52159. private _capturePhysicsTime;
  52160. private _physicsTime;
  52161. private _captureAnimationsTime;
  52162. private _animationsTime;
  52163. private _captureCameraRenderTime;
  52164. private _cameraRenderTime;
  52165. private _onBeforeActiveMeshesEvaluationObserver;
  52166. private _onAfterActiveMeshesEvaluationObserver;
  52167. private _onBeforeRenderTargetsRenderObserver;
  52168. private _onAfterRenderTargetsRenderObserver;
  52169. private _onAfterRenderObserver;
  52170. private _onBeforeDrawPhaseObserver;
  52171. private _onAfterDrawPhaseObserver;
  52172. private _onBeforeAnimationsObserver;
  52173. private _onBeforeParticlesRenderingObserver;
  52174. private _onAfterParticlesRenderingObserver;
  52175. private _onBeforeSpritesRenderingObserver;
  52176. private _onAfterSpritesRenderingObserver;
  52177. private _onBeforePhysicsObserver;
  52178. private _onAfterPhysicsObserver;
  52179. private _onAfterAnimationsObserver;
  52180. private _onBeforeCameraRenderObserver;
  52181. private _onAfterCameraRenderObserver;
  52182. /**
  52183. * Gets the perf counter used for active meshes evaluation time
  52184. */
  52185. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52186. /**
  52187. * Gets the active meshes evaluation time capture status
  52188. */
  52189. /**
  52190. * Enable or disable the active meshes evaluation time capture
  52191. */
  52192. captureActiveMeshesEvaluationTime: boolean;
  52193. /**
  52194. * Gets the perf counter used for render targets render time
  52195. */
  52196. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52197. /**
  52198. * Gets the render targets render time capture status
  52199. */
  52200. /**
  52201. * Enable or disable the render targets render time capture
  52202. */
  52203. captureRenderTargetsRenderTime: boolean;
  52204. /**
  52205. * Gets the perf counter used for particles render time
  52206. */
  52207. readonly particlesRenderTimeCounter: PerfCounter;
  52208. /**
  52209. * Gets the particles render time capture status
  52210. */
  52211. /**
  52212. * Enable or disable the particles render time capture
  52213. */
  52214. captureParticlesRenderTime: boolean;
  52215. /**
  52216. * Gets the perf counter used for sprites render time
  52217. */
  52218. readonly spritesRenderTimeCounter: PerfCounter;
  52219. /**
  52220. * Gets the sprites render time capture status
  52221. */
  52222. /**
  52223. * Enable or disable the sprites render time capture
  52224. */
  52225. captureSpritesRenderTime: boolean;
  52226. /**
  52227. * Gets the perf counter used for physics time
  52228. */
  52229. readonly physicsTimeCounter: PerfCounter;
  52230. /**
  52231. * Gets the physics time capture status
  52232. */
  52233. /**
  52234. * Enable or disable the physics time capture
  52235. */
  52236. capturePhysicsTime: boolean;
  52237. /**
  52238. * Gets the perf counter used for animations time
  52239. */
  52240. readonly animationsTimeCounter: PerfCounter;
  52241. /**
  52242. * Gets the animations time capture status
  52243. */
  52244. /**
  52245. * Enable or disable the animations time capture
  52246. */
  52247. captureAnimationsTime: boolean;
  52248. /**
  52249. * Gets the perf counter used for frame time capture
  52250. */
  52251. readonly frameTimeCounter: PerfCounter;
  52252. /**
  52253. * Gets the frame time capture status
  52254. */
  52255. /**
  52256. * Enable or disable the frame time capture
  52257. */
  52258. captureFrameTime: boolean;
  52259. /**
  52260. * Gets the perf counter used for inter-frames time capture
  52261. */
  52262. readonly interFrameTimeCounter: PerfCounter;
  52263. /**
  52264. * Gets the inter-frames time capture status
  52265. */
  52266. /**
  52267. * Enable or disable the inter-frames time capture
  52268. */
  52269. captureInterFrameTime: boolean;
  52270. /**
  52271. * Gets the perf counter used for render time capture
  52272. */
  52273. readonly renderTimeCounter: PerfCounter;
  52274. /**
  52275. * Gets the render time capture status
  52276. */
  52277. /**
  52278. * Enable or disable the render time capture
  52279. */
  52280. captureRenderTime: boolean;
  52281. /**
  52282. * Gets the perf counter used for camera render time capture
  52283. */
  52284. readonly cameraRenderTimeCounter: PerfCounter;
  52285. /**
  52286. * Gets the camera render time capture status
  52287. */
  52288. /**
  52289. * Enable or disable the camera render time capture
  52290. */
  52291. captureCameraRenderTime: boolean;
  52292. /**
  52293. * Gets the perf counter used for draw calls
  52294. */
  52295. readonly drawCallsCounter: PerfCounter;
  52296. /**
  52297. * Instantiates a new scene instrumentation.
  52298. * This class can be used to get instrumentation data from a Babylon engine
  52299. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52300. * @param scene Defines the scene to instrument
  52301. */
  52302. constructor(
  52303. /**
  52304. * Defines the scene to instrument
  52305. */
  52306. scene: Scene);
  52307. /**
  52308. * Dispose and release associated resources.
  52309. */
  52310. dispose(): void;
  52311. }
  52312. }
  52313. declare module "babylonjs/Instrumentation/index" {
  52314. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52315. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52316. export * from "babylonjs/Instrumentation/timeToken";
  52317. }
  52318. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52319. /** @hidden */
  52320. export var glowMapGenerationPixelShader: {
  52321. name: string;
  52322. shader: string;
  52323. };
  52324. }
  52325. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52326. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52328. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52329. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52330. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52331. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52332. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52333. /** @hidden */
  52334. export var glowMapGenerationVertexShader: {
  52335. name: string;
  52336. shader: string;
  52337. };
  52338. }
  52339. declare module "babylonjs/Layers/effectLayer" {
  52340. import { Observable } from "babylonjs/Misc/observable";
  52341. import { Nullable } from "babylonjs/types";
  52342. import { Camera } from "babylonjs/Cameras/camera";
  52343. import { Scene } from "babylonjs/scene";
  52344. import { ISize } from "babylonjs/Maths/math.size";
  52345. import { Color4 } from "babylonjs/Maths/math.color";
  52346. import { Engine } from "babylonjs/Engines/engine";
  52347. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52349. import { Mesh } from "babylonjs/Meshes/mesh";
  52350. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52351. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52352. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52353. import { Effect } from "babylonjs/Materials/effect";
  52354. import { Material } from "babylonjs/Materials/material";
  52355. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52356. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52357. /**
  52358. * Effect layer options. This helps customizing the behaviour
  52359. * of the effect layer.
  52360. */
  52361. export interface IEffectLayerOptions {
  52362. /**
  52363. * Multiplication factor apply to the canvas size to compute the render target size
  52364. * used to generated the objects (the smaller the faster).
  52365. */
  52366. mainTextureRatio: number;
  52367. /**
  52368. * Enforces a fixed size texture to ensure effect stability across devices.
  52369. */
  52370. mainTextureFixedSize?: number;
  52371. /**
  52372. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52373. */
  52374. alphaBlendingMode: number;
  52375. /**
  52376. * The camera attached to the layer.
  52377. */
  52378. camera: Nullable<Camera>;
  52379. /**
  52380. * The rendering group to draw the layer in.
  52381. */
  52382. renderingGroupId: number;
  52383. }
  52384. /**
  52385. * The effect layer Helps adding post process effect blended with the main pass.
  52386. *
  52387. * This can be for instance use to generate glow or higlight effects on the scene.
  52388. *
  52389. * The effect layer class can not be used directly and is intented to inherited from to be
  52390. * customized per effects.
  52391. */
  52392. export abstract class EffectLayer {
  52393. private _vertexBuffers;
  52394. private _indexBuffer;
  52395. private _cachedDefines;
  52396. private _effectLayerMapGenerationEffect;
  52397. private _effectLayerOptions;
  52398. private _mergeEffect;
  52399. protected _scene: Scene;
  52400. protected _engine: Engine;
  52401. protected _maxSize: number;
  52402. protected _mainTextureDesiredSize: ISize;
  52403. protected _mainTexture: RenderTargetTexture;
  52404. protected _shouldRender: boolean;
  52405. protected _postProcesses: PostProcess[];
  52406. protected _textures: BaseTexture[];
  52407. protected _emissiveTextureAndColor: {
  52408. texture: Nullable<BaseTexture>;
  52409. color: Color4;
  52410. };
  52411. /**
  52412. * The name of the layer
  52413. */
  52414. name: string;
  52415. /**
  52416. * The clear color of the texture used to generate the glow map.
  52417. */
  52418. neutralColor: Color4;
  52419. /**
  52420. * Specifies wether the highlight layer is enabled or not.
  52421. */
  52422. isEnabled: boolean;
  52423. /**
  52424. * Gets the camera attached to the layer.
  52425. */
  52426. readonly camera: Nullable<Camera>;
  52427. /**
  52428. * Gets the rendering group id the layer should render in.
  52429. */
  52430. renderingGroupId: number;
  52431. /**
  52432. * An event triggered when the effect layer has been disposed.
  52433. */
  52434. onDisposeObservable: Observable<EffectLayer>;
  52435. /**
  52436. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52437. */
  52438. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52439. /**
  52440. * An event triggered when the generated texture is being merged in the scene.
  52441. */
  52442. onBeforeComposeObservable: Observable<EffectLayer>;
  52443. /**
  52444. * An event triggered when the mesh is rendered into the effect render target.
  52445. */
  52446. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52447. /**
  52448. * An event triggered after the mesh has been rendered into the effect render target.
  52449. */
  52450. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52451. /**
  52452. * An event triggered when the generated texture has been merged in the scene.
  52453. */
  52454. onAfterComposeObservable: Observable<EffectLayer>;
  52455. /**
  52456. * An event triggered when the efffect layer changes its size.
  52457. */
  52458. onSizeChangedObservable: Observable<EffectLayer>;
  52459. /** @hidden */
  52460. static _SceneComponentInitialization: (scene: Scene) => void;
  52461. /**
  52462. * Instantiates a new effect Layer and references it in the scene.
  52463. * @param name The name of the layer
  52464. * @param scene The scene to use the layer in
  52465. */
  52466. constructor(
  52467. /** The Friendly of the effect in the scene */
  52468. name: string, scene: Scene);
  52469. /**
  52470. * Get the effect name of the layer.
  52471. * @return The effect name
  52472. */
  52473. abstract getEffectName(): string;
  52474. /**
  52475. * Checks for the readiness of the element composing the layer.
  52476. * @param subMesh the mesh to check for
  52477. * @param useInstances specify wether or not to use instances to render the mesh
  52478. * @return true if ready otherwise, false
  52479. */
  52480. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52481. /**
  52482. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52483. * @returns true if the effect requires stencil during the main canvas render pass.
  52484. */
  52485. abstract needStencil(): boolean;
  52486. /**
  52487. * Create the merge effect. This is the shader use to blit the information back
  52488. * to the main canvas at the end of the scene rendering.
  52489. * @returns The effect containing the shader used to merge the effect on the main canvas
  52490. */
  52491. protected abstract _createMergeEffect(): Effect;
  52492. /**
  52493. * Creates the render target textures and post processes used in the effect layer.
  52494. */
  52495. protected abstract _createTextureAndPostProcesses(): void;
  52496. /**
  52497. * Implementation specific of rendering the generating effect on the main canvas.
  52498. * @param effect The effect used to render through
  52499. */
  52500. protected abstract _internalRender(effect: Effect): void;
  52501. /**
  52502. * Sets the required values for both the emissive texture and and the main color.
  52503. */
  52504. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52505. /**
  52506. * Free any resources and references associated to a mesh.
  52507. * Internal use
  52508. * @param mesh The mesh to free.
  52509. */
  52510. abstract _disposeMesh(mesh: Mesh): void;
  52511. /**
  52512. * Serializes this layer (Glow or Highlight for example)
  52513. * @returns a serialized layer object
  52514. */
  52515. abstract serialize?(): any;
  52516. /**
  52517. * Initializes the effect layer with the required options.
  52518. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52519. */
  52520. protected _init(options: Partial<IEffectLayerOptions>): void;
  52521. /**
  52522. * Generates the index buffer of the full screen quad blending to the main canvas.
  52523. */
  52524. private _generateIndexBuffer;
  52525. /**
  52526. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52527. */
  52528. private _generateVertexBuffer;
  52529. /**
  52530. * Sets the main texture desired size which is the closest power of two
  52531. * of the engine canvas size.
  52532. */
  52533. private _setMainTextureSize;
  52534. /**
  52535. * Creates the main texture for the effect layer.
  52536. */
  52537. protected _createMainTexture(): void;
  52538. /**
  52539. * Adds specific effects defines.
  52540. * @param defines The defines to add specifics to.
  52541. */
  52542. protected _addCustomEffectDefines(defines: string[]): void;
  52543. /**
  52544. * Checks for the readiness of the element composing the layer.
  52545. * @param subMesh the mesh to check for
  52546. * @param useInstances specify wether or not to use instances to render the mesh
  52547. * @param emissiveTexture the associated emissive texture used to generate the glow
  52548. * @return true if ready otherwise, false
  52549. */
  52550. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52551. /**
  52552. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52553. */
  52554. render(): void;
  52555. /**
  52556. * Determine if a given mesh will be used in the current effect.
  52557. * @param mesh mesh to test
  52558. * @returns true if the mesh will be used
  52559. */
  52560. hasMesh(mesh: AbstractMesh): boolean;
  52561. /**
  52562. * Returns true if the layer contains information to display, otherwise false.
  52563. * @returns true if the glow layer should be rendered
  52564. */
  52565. shouldRender(): boolean;
  52566. /**
  52567. * Returns true if the mesh should render, otherwise false.
  52568. * @param mesh The mesh to render
  52569. * @returns true if it should render otherwise false
  52570. */
  52571. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52572. /**
  52573. * Returns true if the mesh can be rendered, otherwise false.
  52574. * @param mesh The mesh to render
  52575. * @param material The material used on the mesh
  52576. * @returns true if it can be rendered otherwise false
  52577. */
  52578. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52579. /**
  52580. * Returns true if the mesh should render, otherwise false.
  52581. * @param mesh The mesh to render
  52582. * @returns true if it should render otherwise false
  52583. */
  52584. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52585. /**
  52586. * Renders the submesh passed in parameter to the generation map.
  52587. */
  52588. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52589. /**
  52590. * Defines wether the current material of the mesh should be use to render the effect.
  52591. * @param mesh defines the current mesh to render
  52592. */
  52593. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52594. /**
  52595. * Rebuild the required buffers.
  52596. * @hidden Internal use only.
  52597. */
  52598. _rebuild(): void;
  52599. /**
  52600. * Dispose only the render target textures and post process.
  52601. */
  52602. private _disposeTextureAndPostProcesses;
  52603. /**
  52604. * Dispose the highlight layer and free resources.
  52605. */
  52606. dispose(): void;
  52607. /**
  52608. * Gets the class name of the effect layer
  52609. * @returns the string with the class name of the effect layer
  52610. */
  52611. getClassName(): string;
  52612. /**
  52613. * Creates an effect layer from parsed effect layer data
  52614. * @param parsedEffectLayer defines effect layer data
  52615. * @param scene defines the current scene
  52616. * @param rootUrl defines the root URL containing the effect layer information
  52617. * @returns a parsed effect Layer
  52618. */
  52619. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52620. }
  52621. }
  52622. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52623. import { Scene } from "babylonjs/scene";
  52624. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52625. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52626. import { AbstractScene } from "babylonjs/abstractScene";
  52627. module "babylonjs/abstractScene" {
  52628. interface AbstractScene {
  52629. /**
  52630. * The list of effect layers (highlights/glow) added to the scene
  52631. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52632. * @see http://doc.babylonjs.com/how_to/glow_layer
  52633. */
  52634. effectLayers: Array<EffectLayer>;
  52635. /**
  52636. * Removes the given effect layer from this scene.
  52637. * @param toRemove defines the effect layer to remove
  52638. * @returns the index of the removed effect layer
  52639. */
  52640. removeEffectLayer(toRemove: EffectLayer): number;
  52641. /**
  52642. * Adds the given effect layer to this scene
  52643. * @param newEffectLayer defines the effect layer to add
  52644. */
  52645. addEffectLayer(newEffectLayer: EffectLayer): void;
  52646. }
  52647. }
  52648. /**
  52649. * Defines the layer scene component responsible to manage any effect layers
  52650. * in a given scene.
  52651. */
  52652. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52653. /**
  52654. * The component name helpfull to identify the component in the list of scene components.
  52655. */
  52656. readonly name: string;
  52657. /**
  52658. * The scene the component belongs to.
  52659. */
  52660. scene: Scene;
  52661. private _engine;
  52662. private _renderEffects;
  52663. private _needStencil;
  52664. private _previousStencilState;
  52665. /**
  52666. * Creates a new instance of the component for the given scene
  52667. * @param scene Defines the scene to register the component in
  52668. */
  52669. constructor(scene: Scene);
  52670. /**
  52671. * Registers the component in a given scene
  52672. */
  52673. register(): void;
  52674. /**
  52675. * Rebuilds the elements related to this component in case of
  52676. * context lost for instance.
  52677. */
  52678. rebuild(): void;
  52679. /**
  52680. * Serializes the component data to the specified json object
  52681. * @param serializationObject The object to serialize to
  52682. */
  52683. serialize(serializationObject: any): void;
  52684. /**
  52685. * Adds all the elements from the container to the scene
  52686. * @param container the container holding the elements
  52687. */
  52688. addFromContainer(container: AbstractScene): void;
  52689. /**
  52690. * Removes all the elements in the container from the scene
  52691. * @param container contains the elements to remove
  52692. * @param dispose if the removed element should be disposed (default: false)
  52693. */
  52694. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52695. /**
  52696. * Disposes the component and the associated ressources.
  52697. */
  52698. dispose(): void;
  52699. private _isReadyForMesh;
  52700. private _renderMainTexture;
  52701. private _setStencil;
  52702. private _setStencilBack;
  52703. private _draw;
  52704. private _drawCamera;
  52705. private _drawRenderingGroup;
  52706. }
  52707. }
  52708. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52709. /** @hidden */
  52710. export var glowMapMergePixelShader: {
  52711. name: string;
  52712. shader: string;
  52713. };
  52714. }
  52715. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52716. /** @hidden */
  52717. export var glowMapMergeVertexShader: {
  52718. name: string;
  52719. shader: string;
  52720. };
  52721. }
  52722. declare module "babylonjs/Layers/glowLayer" {
  52723. import { Nullable } from "babylonjs/types";
  52724. import { Camera } from "babylonjs/Cameras/camera";
  52725. import { Scene } from "babylonjs/scene";
  52726. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52728. import { Mesh } from "babylonjs/Meshes/mesh";
  52729. import { Texture } from "babylonjs/Materials/Textures/texture";
  52730. import { Effect } from "babylonjs/Materials/effect";
  52731. import { Material } from "babylonjs/Materials/material";
  52732. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52733. import { Color4 } from "babylonjs/Maths/math.color";
  52734. import "babylonjs/Shaders/glowMapMerge.fragment";
  52735. import "babylonjs/Shaders/glowMapMerge.vertex";
  52736. import "babylonjs/Layers/effectLayerSceneComponent";
  52737. module "babylonjs/abstractScene" {
  52738. interface AbstractScene {
  52739. /**
  52740. * Return a the first highlight layer of the scene with a given name.
  52741. * @param name The name of the highlight layer to look for.
  52742. * @return The highlight layer if found otherwise null.
  52743. */
  52744. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52745. }
  52746. }
  52747. /**
  52748. * Glow layer options. This helps customizing the behaviour
  52749. * of the glow layer.
  52750. */
  52751. export interface IGlowLayerOptions {
  52752. /**
  52753. * Multiplication factor apply to the canvas size to compute the render target size
  52754. * used to generated the glowing objects (the smaller the faster).
  52755. */
  52756. mainTextureRatio: number;
  52757. /**
  52758. * Enforces a fixed size texture to ensure resize independant blur.
  52759. */
  52760. mainTextureFixedSize?: number;
  52761. /**
  52762. * How big is the kernel of the blur texture.
  52763. */
  52764. blurKernelSize: number;
  52765. /**
  52766. * The camera attached to the layer.
  52767. */
  52768. camera: Nullable<Camera>;
  52769. /**
  52770. * Enable MSAA by chosing the number of samples.
  52771. */
  52772. mainTextureSamples?: number;
  52773. /**
  52774. * The rendering group to draw the layer in.
  52775. */
  52776. renderingGroupId: number;
  52777. }
  52778. /**
  52779. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52780. *
  52781. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52782. *
  52783. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52784. */
  52785. export class GlowLayer extends EffectLayer {
  52786. /**
  52787. * Effect Name of the layer.
  52788. */
  52789. static readonly EffectName: string;
  52790. /**
  52791. * The default blur kernel size used for the glow.
  52792. */
  52793. static DefaultBlurKernelSize: number;
  52794. /**
  52795. * The default texture size ratio used for the glow.
  52796. */
  52797. static DefaultTextureRatio: number;
  52798. /**
  52799. * Sets the kernel size of the blur.
  52800. */
  52801. /**
  52802. * Gets the kernel size of the blur.
  52803. */
  52804. blurKernelSize: number;
  52805. /**
  52806. * Sets the glow intensity.
  52807. */
  52808. /**
  52809. * Gets the glow intensity.
  52810. */
  52811. intensity: number;
  52812. private _options;
  52813. private _intensity;
  52814. private _horizontalBlurPostprocess1;
  52815. private _verticalBlurPostprocess1;
  52816. private _horizontalBlurPostprocess2;
  52817. private _verticalBlurPostprocess2;
  52818. private _blurTexture1;
  52819. private _blurTexture2;
  52820. private _postProcesses1;
  52821. private _postProcesses2;
  52822. private _includedOnlyMeshes;
  52823. private _excludedMeshes;
  52824. private _meshesUsingTheirOwnMaterials;
  52825. /**
  52826. * Callback used to let the user override the color selection on a per mesh basis
  52827. */
  52828. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52829. /**
  52830. * Callback used to let the user override the texture selection on a per mesh basis
  52831. */
  52832. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52833. /**
  52834. * Instantiates a new glow Layer and references it to the scene.
  52835. * @param name The name of the layer
  52836. * @param scene The scene to use the layer in
  52837. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52838. */
  52839. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52840. /**
  52841. * Get the effect name of the layer.
  52842. * @return The effect name
  52843. */
  52844. getEffectName(): string;
  52845. /**
  52846. * Create the merge effect. This is the shader use to blit the information back
  52847. * to the main canvas at the end of the scene rendering.
  52848. */
  52849. protected _createMergeEffect(): Effect;
  52850. /**
  52851. * Creates the render target textures and post processes used in the glow layer.
  52852. */
  52853. protected _createTextureAndPostProcesses(): void;
  52854. /**
  52855. * Checks for the readiness of the element composing the layer.
  52856. * @param subMesh the mesh to check for
  52857. * @param useInstances specify wether or not to use instances to render the mesh
  52858. * @param emissiveTexture the associated emissive texture used to generate the glow
  52859. * @return true if ready otherwise, false
  52860. */
  52861. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52862. /**
  52863. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52864. */
  52865. needStencil(): boolean;
  52866. /**
  52867. * Returns true if the mesh can be rendered, otherwise false.
  52868. * @param mesh The mesh to render
  52869. * @param material The material used on the mesh
  52870. * @returns true if it can be rendered otherwise false
  52871. */
  52872. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52873. /**
  52874. * Implementation specific of rendering the generating effect on the main canvas.
  52875. * @param effect The effect used to render through
  52876. */
  52877. protected _internalRender(effect: Effect): void;
  52878. /**
  52879. * Sets the required values for both the emissive texture and and the main color.
  52880. */
  52881. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52882. /**
  52883. * Returns true if the mesh should render, otherwise false.
  52884. * @param mesh The mesh to render
  52885. * @returns true if it should render otherwise false
  52886. */
  52887. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52888. /**
  52889. * Adds specific effects defines.
  52890. * @param defines The defines to add specifics to.
  52891. */
  52892. protected _addCustomEffectDefines(defines: string[]): void;
  52893. /**
  52894. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52895. * @param mesh The mesh to exclude from the glow layer
  52896. */
  52897. addExcludedMesh(mesh: Mesh): void;
  52898. /**
  52899. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52900. * @param mesh The mesh to remove
  52901. */
  52902. removeExcludedMesh(mesh: Mesh): void;
  52903. /**
  52904. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52905. * @param mesh The mesh to include in the glow layer
  52906. */
  52907. addIncludedOnlyMesh(mesh: Mesh): void;
  52908. /**
  52909. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52910. * @param mesh The mesh to remove
  52911. */
  52912. removeIncludedOnlyMesh(mesh: Mesh): void;
  52913. /**
  52914. * Determine if a given mesh will be used in the glow layer
  52915. * @param mesh The mesh to test
  52916. * @returns true if the mesh will be highlighted by the current glow layer
  52917. */
  52918. hasMesh(mesh: AbstractMesh): boolean;
  52919. /**
  52920. * Defines wether the current material of the mesh should be use to render the effect.
  52921. * @param mesh defines the current mesh to render
  52922. */
  52923. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52924. /**
  52925. * Add a mesh to be rendered through its own material and not with emissive only.
  52926. * @param mesh The mesh for which we need to use its material
  52927. */
  52928. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52929. /**
  52930. * Remove a mesh from being rendered through its own material and not with emissive only.
  52931. * @param mesh The mesh for which we need to not use its material
  52932. */
  52933. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52934. /**
  52935. * Free any resources and references associated to a mesh.
  52936. * Internal use
  52937. * @param mesh The mesh to free.
  52938. * @hidden
  52939. */
  52940. _disposeMesh(mesh: Mesh): void;
  52941. /**
  52942. * Gets the class name of the effect layer
  52943. * @returns the string with the class name of the effect layer
  52944. */
  52945. getClassName(): string;
  52946. /**
  52947. * Serializes this glow layer
  52948. * @returns a serialized glow layer object
  52949. */
  52950. serialize(): any;
  52951. /**
  52952. * Creates a Glow Layer from parsed glow layer data
  52953. * @param parsedGlowLayer defines glow layer data
  52954. * @param scene defines the current scene
  52955. * @param rootUrl defines the root URL containing the glow layer information
  52956. * @returns a parsed Glow Layer
  52957. */
  52958. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52959. }
  52960. }
  52961. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52962. /** @hidden */
  52963. export var glowBlurPostProcessPixelShader: {
  52964. name: string;
  52965. shader: string;
  52966. };
  52967. }
  52968. declare module "babylonjs/Layers/highlightLayer" {
  52969. import { Observable } from "babylonjs/Misc/observable";
  52970. import { Nullable } from "babylonjs/types";
  52971. import { Camera } from "babylonjs/Cameras/camera";
  52972. import { Scene } from "babylonjs/scene";
  52973. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52975. import { Mesh } from "babylonjs/Meshes/mesh";
  52976. import { Effect } from "babylonjs/Materials/effect";
  52977. import { Material } from "babylonjs/Materials/material";
  52978. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52979. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52980. import "babylonjs/Shaders/glowMapMerge.fragment";
  52981. import "babylonjs/Shaders/glowMapMerge.vertex";
  52982. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52983. module "babylonjs/abstractScene" {
  52984. interface AbstractScene {
  52985. /**
  52986. * Return a the first highlight layer of the scene with a given name.
  52987. * @param name The name of the highlight layer to look for.
  52988. * @return The highlight layer if found otherwise null.
  52989. */
  52990. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52991. }
  52992. }
  52993. /**
  52994. * Highlight layer options. This helps customizing the behaviour
  52995. * of the highlight layer.
  52996. */
  52997. export interface IHighlightLayerOptions {
  52998. /**
  52999. * Multiplication factor apply to the canvas size to compute the render target size
  53000. * used to generated the glowing objects (the smaller the faster).
  53001. */
  53002. mainTextureRatio: number;
  53003. /**
  53004. * Enforces a fixed size texture to ensure resize independant blur.
  53005. */
  53006. mainTextureFixedSize?: number;
  53007. /**
  53008. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53009. * of the picture to blur (the smaller the faster).
  53010. */
  53011. blurTextureSizeRatio: number;
  53012. /**
  53013. * How big in texel of the blur texture is the vertical blur.
  53014. */
  53015. blurVerticalSize: number;
  53016. /**
  53017. * How big in texel of the blur texture is the horizontal blur.
  53018. */
  53019. blurHorizontalSize: number;
  53020. /**
  53021. * Alpha blending mode used to apply the blur. Default is combine.
  53022. */
  53023. alphaBlendingMode: number;
  53024. /**
  53025. * The camera attached to the layer.
  53026. */
  53027. camera: Nullable<Camera>;
  53028. /**
  53029. * Should we display highlight as a solid stroke?
  53030. */
  53031. isStroke?: boolean;
  53032. /**
  53033. * The rendering group to draw the layer in.
  53034. */
  53035. renderingGroupId: number;
  53036. }
  53037. /**
  53038. * The highlight layer Helps adding a glow effect around a mesh.
  53039. *
  53040. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53041. * glowy meshes to your scene.
  53042. *
  53043. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53044. */
  53045. export class HighlightLayer extends EffectLayer {
  53046. name: string;
  53047. /**
  53048. * Effect Name of the highlight layer.
  53049. */
  53050. static readonly EffectName: string;
  53051. /**
  53052. * The neutral color used during the preparation of the glow effect.
  53053. * This is black by default as the blend operation is a blend operation.
  53054. */
  53055. static NeutralColor: Color4;
  53056. /**
  53057. * Stencil value used for glowing meshes.
  53058. */
  53059. static GlowingMeshStencilReference: number;
  53060. /**
  53061. * Stencil value used for the other meshes in the scene.
  53062. */
  53063. static NormalMeshStencilReference: number;
  53064. /**
  53065. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53066. */
  53067. innerGlow: boolean;
  53068. /**
  53069. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53070. */
  53071. outerGlow: boolean;
  53072. /**
  53073. * Specifies the horizontal size of the blur.
  53074. */
  53075. /**
  53076. * Gets the horizontal size of the blur.
  53077. */
  53078. blurHorizontalSize: number;
  53079. /**
  53080. * Specifies the vertical size of the blur.
  53081. */
  53082. /**
  53083. * Gets the vertical size of the blur.
  53084. */
  53085. blurVerticalSize: number;
  53086. /**
  53087. * An event triggered when the highlight layer is being blurred.
  53088. */
  53089. onBeforeBlurObservable: Observable<HighlightLayer>;
  53090. /**
  53091. * An event triggered when the highlight layer has been blurred.
  53092. */
  53093. onAfterBlurObservable: Observable<HighlightLayer>;
  53094. private _instanceGlowingMeshStencilReference;
  53095. private _options;
  53096. private _downSamplePostprocess;
  53097. private _horizontalBlurPostprocess;
  53098. private _verticalBlurPostprocess;
  53099. private _blurTexture;
  53100. private _meshes;
  53101. private _excludedMeshes;
  53102. /**
  53103. * Instantiates a new highlight Layer and references it to the scene..
  53104. * @param name The name of the layer
  53105. * @param scene The scene to use the layer in
  53106. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53107. */
  53108. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53109. /**
  53110. * Get the effect name of the layer.
  53111. * @return The effect name
  53112. */
  53113. getEffectName(): string;
  53114. /**
  53115. * Create the merge effect. This is the shader use to blit the information back
  53116. * to the main canvas at the end of the scene rendering.
  53117. */
  53118. protected _createMergeEffect(): Effect;
  53119. /**
  53120. * Creates the render target textures and post processes used in the highlight layer.
  53121. */
  53122. protected _createTextureAndPostProcesses(): void;
  53123. /**
  53124. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53125. */
  53126. needStencil(): boolean;
  53127. /**
  53128. * Checks for the readiness of the element composing the layer.
  53129. * @param subMesh the mesh to check for
  53130. * @param useInstances specify wether or not to use instances to render the mesh
  53131. * @param emissiveTexture the associated emissive texture used to generate the glow
  53132. * @return true if ready otherwise, false
  53133. */
  53134. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53135. /**
  53136. * Implementation specific of rendering the generating effect on the main canvas.
  53137. * @param effect The effect used to render through
  53138. */
  53139. protected _internalRender(effect: Effect): void;
  53140. /**
  53141. * Returns true if the layer contains information to display, otherwise false.
  53142. */
  53143. shouldRender(): boolean;
  53144. /**
  53145. * Returns true if the mesh should render, otherwise false.
  53146. * @param mesh The mesh to render
  53147. * @returns true if it should render otherwise false
  53148. */
  53149. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53150. /**
  53151. * Sets the required values for both the emissive texture and and the main color.
  53152. */
  53153. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53154. /**
  53155. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53156. * @param mesh The mesh to exclude from the highlight layer
  53157. */
  53158. addExcludedMesh(mesh: Mesh): void;
  53159. /**
  53160. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53161. * @param mesh The mesh to highlight
  53162. */
  53163. removeExcludedMesh(mesh: Mesh): void;
  53164. /**
  53165. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53166. * @param mesh mesh to test
  53167. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53168. */
  53169. hasMesh(mesh: AbstractMesh): boolean;
  53170. /**
  53171. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53172. * @param mesh The mesh to highlight
  53173. * @param color The color of the highlight
  53174. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53175. */
  53176. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53177. /**
  53178. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53179. * @param mesh The mesh to highlight
  53180. */
  53181. removeMesh(mesh: Mesh): void;
  53182. /**
  53183. * Force the stencil to the normal expected value for none glowing parts
  53184. */
  53185. private _defaultStencilReference;
  53186. /**
  53187. * Free any resources and references associated to a mesh.
  53188. * Internal use
  53189. * @param mesh The mesh to free.
  53190. * @hidden
  53191. */
  53192. _disposeMesh(mesh: Mesh): void;
  53193. /**
  53194. * Dispose the highlight layer and free resources.
  53195. */
  53196. dispose(): void;
  53197. /**
  53198. * Gets the class name of the effect layer
  53199. * @returns the string with the class name of the effect layer
  53200. */
  53201. getClassName(): string;
  53202. /**
  53203. * Serializes this Highlight layer
  53204. * @returns a serialized Highlight layer object
  53205. */
  53206. serialize(): any;
  53207. /**
  53208. * Creates a Highlight layer from parsed Highlight layer data
  53209. * @param parsedHightlightLayer defines the Highlight layer data
  53210. * @param scene defines the current scene
  53211. * @param rootUrl defines the root URL containing the Highlight layer information
  53212. * @returns a parsed Highlight layer
  53213. */
  53214. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53215. }
  53216. }
  53217. declare module "babylonjs/Layers/layerSceneComponent" {
  53218. import { Scene } from "babylonjs/scene";
  53219. import { ISceneComponent } from "babylonjs/sceneComponent";
  53220. import { Layer } from "babylonjs/Layers/layer";
  53221. import { AbstractScene } from "babylonjs/abstractScene";
  53222. module "babylonjs/abstractScene" {
  53223. interface AbstractScene {
  53224. /**
  53225. * The list of layers (background and foreground) of the scene
  53226. */
  53227. layers: Array<Layer>;
  53228. }
  53229. }
  53230. /**
  53231. * Defines the layer scene component responsible to manage any layers
  53232. * in a given scene.
  53233. */
  53234. export class LayerSceneComponent implements ISceneComponent {
  53235. /**
  53236. * The component name helpfull to identify the component in the list of scene components.
  53237. */
  53238. readonly name: string;
  53239. /**
  53240. * The scene the component belongs to.
  53241. */
  53242. scene: Scene;
  53243. private _engine;
  53244. /**
  53245. * Creates a new instance of the component for the given scene
  53246. * @param scene Defines the scene to register the component in
  53247. */
  53248. constructor(scene: Scene);
  53249. /**
  53250. * Registers the component in a given scene
  53251. */
  53252. register(): void;
  53253. /**
  53254. * Rebuilds the elements related to this component in case of
  53255. * context lost for instance.
  53256. */
  53257. rebuild(): void;
  53258. /**
  53259. * Disposes the component and the associated ressources.
  53260. */
  53261. dispose(): void;
  53262. private _draw;
  53263. private _drawCameraPredicate;
  53264. private _drawCameraBackground;
  53265. private _drawCameraForeground;
  53266. private _drawRenderTargetPredicate;
  53267. private _drawRenderTargetBackground;
  53268. private _drawRenderTargetForeground;
  53269. /**
  53270. * Adds all the elements from the container to the scene
  53271. * @param container the container holding the elements
  53272. */
  53273. addFromContainer(container: AbstractScene): void;
  53274. /**
  53275. * Removes all the elements in the container from the scene
  53276. * @param container contains the elements to remove
  53277. * @param dispose if the removed element should be disposed (default: false)
  53278. */
  53279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53280. }
  53281. }
  53282. declare module "babylonjs/Shaders/layer.fragment" {
  53283. /** @hidden */
  53284. export var layerPixelShader: {
  53285. name: string;
  53286. shader: string;
  53287. };
  53288. }
  53289. declare module "babylonjs/Shaders/layer.vertex" {
  53290. /** @hidden */
  53291. export var layerVertexShader: {
  53292. name: string;
  53293. shader: string;
  53294. };
  53295. }
  53296. declare module "babylonjs/Layers/layer" {
  53297. import { Observable } from "babylonjs/Misc/observable";
  53298. import { Nullable } from "babylonjs/types";
  53299. import { Scene } from "babylonjs/scene";
  53300. import { Vector2 } from "babylonjs/Maths/math.vector";
  53301. import { Color4 } from "babylonjs/Maths/math.color";
  53302. import { Texture } from "babylonjs/Materials/Textures/texture";
  53303. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53304. import "babylonjs/Shaders/layer.fragment";
  53305. import "babylonjs/Shaders/layer.vertex";
  53306. /**
  53307. * This represents a full screen 2d layer.
  53308. * This can be useful to display a picture in the background of your scene for instance.
  53309. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53310. */
  53311. export class Layer {
  53312. /**
  53313. * Define the name of the layer.
  53314. */
  53315. name: string;
  53316. /**
  53317. * Define the texture the layer should display.
  53318. */
  53319. texture: Nullable<Texture>;
  53320. /**
  53321. * Is the layer in background or foreground.
  53322. */
  53323. isBackground: boolean;
  53324. /**
  53325. * Define the color of the layer (instead of texture).
  53326. */
  53327. color: Color4;
  53328. /**
  53329. * Define the scale of the layer in order to zoom in out of the texture.
  53330. */
  53331. scale: Vector2;
  53332. /**
  53333. * Define an offset for the layer in order to shift the texture.
  53334. */
  53335. offset: Vector2;
  53336. /**
  53337. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53338. */
  53339. alphaBlendingMode: number;
  53340. /**
  53341. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53342. * Alpha test will not mix with the background color in case of transparency.
  53343. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53344. */
  53345. alphaTest: boolean;
  53346. /**
  53347. * Define a mask to restrict the layer to only some of the scene cameras.
  53348. */
  53349. layerMask: number;
  53350. /**
  53351. * Define the list of render target the layer is visible into.
  53352. */
  53353. renderTargetTextures: RenderTargetTexture[];
  53354. /**
  53355. * Define if the layer is only used in renderTarget or if it also
  53356. * renders in the main frame buffer of the canvas.
  53357. */
  53358. renderOnlyInRenderTargetTextures: boolean;
  53359. private _scene;
  53360. private _vertexBuffers;
  53361. private _indexBuffer;
  53362. private _effect;
  53363. private _alphaTestEffect;
  53364. /**
  53365. * An event triggered when the layer is disposed.
  53366. */
  53367. onDisposeObservable: Observable<Layer>;
  53368. private _onDisposeObserver;
  53369. /**
  53370. * Back compatibility with callback before the onDisposeObservable existed.
  53371. * The set callback will be triggered when the layer has been disposed.
  53372. */
  53373. onDispose: () => void;
  53374. /**
  53375. * An event triggered before rendering the scene
  53376. */
  53377. onBeforeRenderObservable: Observable<Layer>;
  53378. private _onBeforeRenderObserver;
  53379. /**
  53380. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53381. * The set callback will be triggered just before rendering the layer.
  53382. */
  53383. onBeforeRender: () => void;
  53384. /**
  53385. * An event triggered after rendering the scene
  53386. */
  53387. onAfterRenderObservable: Observable<Layer>;
  53388. private _onAfterRenderObserver;
  53389. /**
  53390. * Back compatibility with callback before the onAfterRenderObservable existed.
  53391. * The set callback will be triggered just after rendering the layer.
  53392. */
  53393. onAfterRender: () => void;
  53394. /**
  53395. * Instantiates a new layer.
  53396. * This represents a full screen 2d layer.
  53397. * This can be useful to display a picture in the background of your scene for instance.
  53398. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53399. * @param name Define the name of the layer in the scene
  53400. * @param imgUrl Define the url of the texture to display in the layer
  53401. * @param scene Define the scene the layer belongs to
  53402. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53403. * @param color Defines a color for the layer
  53404. */
  53405. constructor(
  53406. /**
  53407. * Define the name of the layer.
  53408. */
  53409. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53410. private _createIndexBuffer;
  53411. /** @hidden */
  53412. _rebuild(): void;
  53413. /**
  53414. * Renders the layer in the scene.
  53415. */
  53416. render(): void;
  53417. /**
  53418. * Disposes and releases the associated ressources.
  53419. */
  53420. dispose(): void;
  53421. }
  53422. }
  53423. declare module "babylonjs/Layers/index" {
  53424. export * from "babylonjs/Layers/effectLayer";
  53425. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53426. export * from "babylonjs/Layers/glowLayer";
  53427. export * from "babylonjs/Layers/highlightLayer";
  53428. export * from "babylonjs/Layers/layer";
  53429. export * from "babylonjs/Layers/layerSceneComponent";
  53430. }
  53431. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53432. /** @hidden */
  53433. export var lensFlarePixelShader: {
  53434. name: string;
  53435. shader: string;
  53436. };
  53437. }
  53438. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53439. /** @hidden */
  53440. export var lensFlareVertexShader: {
  53441. name: string;
  53442. shader: string;
  53443. };
  53444. }
  53445. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53446. import { Scene } from "babylonjs/scene";
  53447. import { Vector3 } from "babylonjs/Maths/math.vector";
  53448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53449. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53450. import "babylonjs/Shaders/lensFlare.fragment";
  53451. import "babylonjs/Shaders/lensFlare.vertex";
  53452. import { Viewport } from "babylonjs/Maths/math.viewport";
  53453. /**
  53454. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53455. * It is usually composed of several `lensFlare`.
  53456. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53457. */
  53458. export class LensFlareSystem {
  53459. /**
  53460. * Define the name of the lens flare system
  53461. */
  53462. name: string;
  53463. /**
  53464. * List of lens flares used in this system.
  53465. */
  53466. lensFlares: LensFlare[];
  53467. /**
  53468. * Define a limit from the border the lens flare can be visible.
  53469. */
  53470. borderLimit: number;
  53471. /**
  53472. * Define a viewport border we do not want to see the lens flare in.
  53473. */
  53474. viewportBorder: number;
  53475. /**
  53476. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53477. */
  53478. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53479. /**
  53480. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53481. */
  53482. layerMask: number;
  53483. /**
  53484. * Define the id of the lens flare system in the scene.
  53485. * (equal to name by default)
  53486. */
  53487. id: string;
  53488. private _scene;
  53489. private _emitter;
  53490. private _vertexBuffers;
  53491. private _indexBuffer;
  53492. private _effect;
  53493. private _positionX;
  53494. private _positionY;
  53495. private _isEnabled;
  53496. /** @hidden */
  53497. static _SceneComponentInitialization: (scene: Scene) => void;
  53498. /**
  53499. * Instantiates a lens flare system.
  53500. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53501. * It is usually composed of several `lensFlare`.
  53502. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53503. * @param name Define the name of the lens flare system in the scene
  53504. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53505. * @param scene Define the scene the lens flare system belongs to
  53506. */
  53507. constructor(
  53508. /**
  53509. * Define the name of the lens flare system
  53510. */
  53511. name: string, emitter: any, scene: Scene);
  53512. /**
  53513. * Define if the lens flare system is enabled.
  53514. */
  53515. isEnabled: boolean;
  53516. /**
  53517. * Get the scene the effects belongs to.
  53518. * @returns the scene holding the lens flare system
  53519. */
  53520. getScene(): Scene;
  53521. /**
  53522. * Get the emitter of the lens flare system.
  53523. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53524. * @returns the emitter of the lens flare system
  53525. */
  53526. getEmitter(): any;
  53527. /**
  53528. * Set the emitter of the lens flare system.
  53529. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53530. * @param newEmitter Define the new emitter of the system
  53531. */
  53532. setEmitter(newEmitter: any): void;
  53533. /**
  53534. * Get the lens flare system emitter position.
  53535. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53536. * @returns the position
  53537. */
  53538. getEmitterPosition(): Vector3;
  53539. /**
  53540. * @hidden
  53541. */
  53542. computeEffectivePosition(globalViewport: Viewport): boolean;
  53543. /** @hidden */
  53544. _isVisible(): boolean;
  53545. /**
  53546. * @hidden
  53547. */
  53548. render(): boolean;
  53549. /**
  53550. * Dispose and release the lens flare with its associated resources.
  53551. */
  53552. dispose(): void;
  53553. /**
  53554. * Parse a lens flare system from a JSON repressentation
  53555. * @param parsedLensFlareSystem Define the JSON to parse
  53556. * @param scene Define the scene the parsed system should be instantiated in
  53557. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53558. * @returns the parsed system
  53559. */
  53560. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53561. /**
  53562. * Serialize the current Lens Flare System into a JSON representation.
  53563. * @returns the serialized JSON
  53564. */
  53565. serialize(): any;
  53566. }
  53567. }
  53568. declare module "babylonjs/LensFlares/lensFlare" {
  53569. import { Nullable } from "babylonjs/types";
  53570. import { Color3 } from "babylonjs/Maths/math.color";
  53571. import { Texture } from "babylonjs/Materials/Textures/texture";
  53572. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53573. /**
  53574. * This represents one of the lens effect in a `lensFlareSystem`.
  53575. * It controls one of the indiviual texture used in the effect.
  53576. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53577. */
  53578. export class LensFlare {
  53579. /**
  53580. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53581. */
  53582. size: number;
  53583. /**
  53584. * 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.
  53585. */
  53586. position: number;
  53587. /**
  53588. * Define the lens color.
  53589. */
  53590. color: Color3;
  53591. /**
  53592. * Define the lens texture.
  53593. */
  53594. texture: Nullable<Texture>;
  53595. /**
  53596. * Define the alpha mode to render this particular lens.
  53597. */
  53598. alphaMode: number;
  53599. private _system;
  53600. /**
  53601. * Creates a new Lens Flare.
  53602. * This represents one of the lens effect in a `lensFlareSystem`.
  53603. * It controls one of the indiviual texture used in the effect.
  53604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53605. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53606. * @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.
  53607. * @param color Define the lens color
  53608. * @param imgUrl Define the lens texture url
  53609. * @param system Define the `lensFlareSystem` this flare is part of
  53610. * @returns The newly created Lens Flare
  53611. */
  53612. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53613. /**
  53614. * Instantiates a new Lens Flare.
  53615. * This represents one of the lens effect in a `lensFlareSystem`.
  53616. * It controls one of the indiviual texture used in the effect.
  53617. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53618. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53619. * @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.
  53620. * @param color Define the lens color
  53621. * @param imgUrl Define the lens texture url
  53622. * @param system Define the `lensFlareSystem` this flare is part of
  53623. */
  53624. constructor(
  53625. /**
  53626. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53627. */
  53628. size: number,
  53629. /**
  53630. * 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.
  53631. */
  53632. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53633. /**
  53634. * Dispose and release the lens flare with its associated resources.
  53635. */
  53636. dispose(): void;
  53637. }
  53638. }
  53639. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53640. import { Nullable } from "babylonjs/types";
  53641. import { Scene } from "babylonjs/scene";
  53642. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53643. import { AbstractScene } from "babylonjs/abstractScene";
  53644. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53645. module "babylonjs/abstractScene" {
  53646. interface AbstractScene {
  53647. /**
  53648. * The list of lens flare system added to the scene
  53649. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53650. */
  53651. lensFlareSystems: Array<LensFlareSystem>;
  53652. /**
  53653. * Removes the given lens flare system from this scene.
  53654. * @param toRemove The lens flare system to remove
  53655. * @returns The index of the removed lens flare system
  53656. */
  53657. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53658. /**
  53659. * Adds the given lens flare system to this scene
  53660. * @param newLensFlareSystem The lens flare system to add
  53661. */
  53662. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53663. /**
  53664. * Gets a lens flare system using its name
  53665. * @param name defines the name to look for
  53666. * @returns the lens flare system or null if not found
  53667. */
  53668. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53669. /**
  53670. * Gets a lens flare system using its id
  53671. * @param id defines the id to look for
  53672. * @returns the lens flare system or null if not found
  53673. */
  53674. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53675. }
  53676. }
  53677. /**
  53678. * Defines the lens flare scene component responsible to manage any lens flares
  53679. * in a given scene.
  53680. */
  53681. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53682. /**
  53683. * The component name helpfull to identify the component in the list of scene components.
  53684. */
  53685. readonly name: string;
  53686. /**
  53687. * The scene the component belongs to.
  53688. */
  53689. scene: Scene;
  53690. /**
  53691. * Creates a new instance of the component for the given scene
  53692. * @param scene Defines the scene to register the component in
  53693. */
  53694. constructor(scene: Scene);
  53695. /**
  53696. * Registers the component in a given scene
  53697. */
  53698. register(): void;
  53699. /**
  53700. * Rebuilds the elements related to this component in case of
  53701. * context lost for instance.
  53702. */
  53703. rebuild(): void;
  53704. /**
  53705. * Adds all the elements from the container to the scene
  53706. * @param container the container holding the elements
  53707. */
  53708. addFromContainer(container: AbstractScene): void;
  53709. /**
  53710. * Removes all the elements in the container from the scene
  53711. * @param container contains the elements to remove
  53712. * @param dispose if the removed element should be disposed (default: false)
  53713. */
  53714. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53715. /**
  53716. * Serializes the component data to the specified json object
  53717. * @param serializationObject The object to serialize to
  53718. */
  53719. serialize(serializationObject: any): void;
  53720. /**
  53721. * Disposes the component and the associated ressources.
  53722. */
  53723. dispose(): void;
  53724. private _draw;
  53725. }
  53726. }
  53727. declare module "babylonjs/LensFlares/index" {
  53728. export * from "babylonjs/LensFlares/lensFlare";
  53729. export * from "babylonjs/LensFlares/lensFlareSystem";
  53730. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53731. }
  53732. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53733. import { Scene } from "babylonjs/scene";
  53734. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53735. import { AbstractScene } from "babylonjs/abstractScene";
  53736. /**
  53737. * Defines the shadow generator component responsible to manage any shadow generators
  53738. * in a given scene.
  53739. */
  53740. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53741. /**
  53742. * The component name helpfull to identify the component in the list of scene components.
  53743. */
  53744. readonly name: string;
  53745. /**
  53746. * The scene the component belongs to.
  53747. */
  53748. scene: Scene;
  53749. /**
  53750. * Creates a new instance of the component for the given scene
  53751. * @param scene Defines the scene to register the component in
  53752. */
  53753. constructor(scene: Scene);
  53754. /**
  53755. * Registers the component in a given scene
  53756. */
  53757. register(): void;
  53758. /**
  53759. * Rebuilds the elements related to this component in case of
  53760. * context lost for instance.
  53761. */
  53762. rebuild(): void;
  53763. /**
  53764. * Serializes the component data to the specified json object
  53765. * @param serializationObject The object to serialize to
  53766. */
  53767. serialize(serializationObject: any): void;
  53768. /**
  53769. * Adds all the elements from the container to the scene
  53770. * @param container the container holding the elements
  53771. */
  53772. addFromContainer(container: AbstractScene): void;
  53773. /**
  53774. * Removes all the elements in the container from the scene
  53775. * @param container contains the elements to remove
  53776. * @param dispose if the removed element should be disposed (default: false)
  53777. */
  53778. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53779. /**
  53780. * Rebuilds the elements related to this component in case of
  53781. * context lost for instance.
  53782. */
  53783. dispose(): void;
  53784. private _gatherRenderTargets;
  53785. }
  53786. }
  53787. declare module "babylonjs/Lights/Shadows/index" {
  53788. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53789. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53790. }
  53791. declare module "babylonjs/Lights/pointLight" {
  53792. import { Scene } from "babylonjs/scene";
  53793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53795. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53796. import { Effect } from "babylonjs/Materials/effect";
  53797. /**
  53798. * A point light is a light defined by an unique point in world space.
  53799. * The light is emitted in every direction from this point.
  53800. * A good example of a point light is a standard light bulb.
  53801. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53802. */
  53803. export class PointLight extends ShadowLight {
  53804. private _shadowAngle;
  53805. /**
  53806. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53807. * This specifies what angle the shadow will use to be created.
  53808. *
  53809. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53810. */
  53811. /**
  53812. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53813. * This specifies what angle the shadow will use to be created.
  53814. *
  53815. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53816. */
  53817. shadowAngle: number;
  53818. /**
  53819. * Gets the direction if it has been set.
  53820. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53821. */
  53822. /**
  53823. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53824. */
  53825. direction: Vector3;
  53826. /**
  53827. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53828. * A PointLight emits the light in every direction.
  53829. * It can cast shadows.
  53830. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53831. * ```javascript
  53832. * var pointLight = new PointLight("pl", camera.position, scene);
  53833. * ```
  53834. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53835. * @param name The light friendly name
  53836. * @param position The position of the point light in the scene
  53837. * @param scene The scene the lights belongs to
  53838. */
  53839. constructor(name: string, position: Vector3, scene: Scene);
  53840. /**
  53841. * Returns the string "PointLight"
  53842. * @returns the class name
  53843. */
  53844. getClassName(): string;
  53845. /**
  53846. * Returns the integer 0.
  53847. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53848. */
  53849. getTypeID(): number;
  53850. /**
  53851. * Specifies wether or not the shadowmap should be a cube texture.
  53852. * @returns true if the shadowmap needs to be a cube texture.
  53853. */
  53854. needCube(): boolean;
  53855. /**
  53856. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53857. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53858. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53859. */
  53860. getShadowDirection(faceIndex?: number): Vector3;
  53861. /**
  53862. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53863. * - fov = PI / 2
  53864. * - aspect ratio : 1.0
  53865. * - z-near and far equal to the active camera minZ and maxZ.
  53866. * Returns the PointLight.
  53867. */
  53868. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53869. protected _buildUniformLayout(): void;
  53870. /**
  53871. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53872. * @param effect The effect to update
  53873. * @param lightIndex The index of the light in the effect to update
  53874. * @returns The point light
  53875. */
  53876. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53877. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53878. /**
  53879. * Prepares the list of defines specific to the light type.
  53880. * @param defines the list of defines
  53881. * @param lightIndex defines the index of the light for the effect
  53882. */
  53883. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53884. }
  53885. }
  53886. declare module "babylonjs/Lights/index" {
  53887. export * from "babylonjs/Lights/light";
  53888. export * from "babylonjs/Lights/shadowLight";
  53889. export * from "babylonjs/Lights/Shadows/index";
  53890. export * from "babylonjs/Lights/directionalLight";
  53891. export * from "babylonjs/Lights/hemisphericLight";
  53892. export * from "babylonjs/Lights/pointLight";
  53893. export * from "babylonjs/Lights/spotLight";
  53894. }
  53895. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53896. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53897. /**
  53898. * Header information of HDR texture files.
  53899. */
  53900. export interface HDRInfo {
  53901. /**
  53902. * The height of the texture in pixels.
  53903. */
  53904. height: number;
  53905. /**
  53906. * The width of the texture in pixels.
  53907. */
  53908. width: number;
  53909. /**
  53910. * The index of the beginning of the data in the binary file.
  53911. */
  53912. dataPosition: number;
  53913. }
  53914. /**
  53915. * This groups tools to convert HDR texture to native colors array.
  53916. */
  53917. export class HDRTools {
  53918. private static Ldexp;
  53919. private static Rgbe2float;
  53920. private static readStringLine;
  53921. /**
  53922. * Reads header information from an RGBE texture stored in a native array.
  53923. * More information on this format are available here:
  53924. * https://en.wikipedia.org/wiki/RGBE_image_format
  53925. *
  53926. * @param uint8array The binary file stored in native array.
  53927. * @return The header information.
  53928. */
  53929. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53930. /**
  53931. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53932. * This RGBE texture needs to store the information as a panorama.
  53933. *
  53934. * More information on this format are available here:
  53935. * https://en.wikipedia.org/wiki/RGBE_image_format
  53936. *
  53937. * @param buffer The binary file stored in an array buffer.
  53938. * @param size The expected size of the extracted cubemap.
  53939. * @return The Cube Map information.
  53940. */
  53941. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53942. /**
  53943. * Returns the pixels data extracted from an RGBE texture.
  53944. * This pixels will be stored left to right up to down in the R G B order in one array.
  53945. *
  53946. * More information on this format are available here:
  53947. * https://en.wikipedia.org/wiki/RGBE_image_format
  53948. *
  53949. * @param uint8array The binary file stored in an array buffer.
  53950. * @param hdrInfo The header information of the file.
  53951. * @return The pixels data in RGB right to left up to down order.
  53952. */
  53953. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53954. private static RGBE_ReadPixels_RLE;
  53955. }
  53956. }
  53957. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53958. import { Nullable } from "babylonjs/types";
  53959. import { Scene } from "babylonjs/scene";
  53960. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53962. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53963. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53964. /**
  53965. * This represents a texture coming from an HDR input.
  53966. *
  53967. * The only supported format is currently panorama picture stored in RGBE format.
  53968. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53969. */
  53970. export class HDRCubeTexture extends BaseTexture {
  53971. private static _facesMapping;
  53972. private _generateHarmonics;
  53973. private _noMipmap;
  53974. private _textureMatrix;
  53975. private _size;
  53976. private _onLoad;
  53977. private _onError;
  53978. /**
  53979. * The texture URL.
  53980. */
  53981. url: string;
  53982. /**
  53983. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53984. */
  53985. coordinatesMode: number;
  53986. protected _isBlocking: boolean;
  53987. /**
  53988. * Sets wether or not the texture is blocking during loading.
  53989. */
  53990. /**
  53991. * Gets wether or not the texture is blocking during loading.
  53992. */
  53993. isBlocking: boolean;
  53994. protected _rotationY: number;
  53995. /**
  53996. * Sets texture matrix rotation angle around Y axis in radians.
  53997. */
  53998. /**
  53999. * Gets texture matrix rotation angle around Y axis radians.
  54000. */
  54001. rotationY: number;
  54002. /**
  54003. * Gets or sets the center of the bounding box associated with the cube texture
  54004. * It must define where the camera used to render the texture was set
  54005. */
  54006. boundingBoxPosition: Vector3;
  54007. private _boundingBoxSize;
  54008. /**
  54009. * Gets or sets the size of the bounding box associated with the cube texture
  54010. * When defined, the cubemap will switch to local mode
  54011. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54012. * @example https://www.babylonjs-playground.com/#RNASML
  54013. */
  54014. boundingBoxSize: Vector3;
  54015. /**
  54016. * Instantiates an HDRTexture from the following parameters.
  54017. *
  54018. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54019. * @param scene The scene the texture will be used in
  54020. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54021. * @param noMipmap Forces to not generate the mipmap if true
  54022. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54023. * @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)
  54024. * @param reserved Reserved flag for internal use.
  54025. */
  54026. 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>);
  54027. /**
  54028. * Get the current class name of the texture useful for serialization or dynamic coding.
  54029. * @returns "HDRCubeTexture"
  54030. */
  54031. getClassName(): string;
  54032. /**
  54033. * Occurs when the file is raw .hdr file.
  54034. */
  54035. private loadTexture;
  54036. clone(): HDRCubeTexture;
  54037. delayLoad(): void;
  54038. /**
  54039. * Get the texture reflection matrix used to rotate/transform the reflection.
  54040. * @returns the reflection matrix
  54041. */
  54042. getReflectionTextureMatrix(): Matrix;
  54043. /**
  54044. * Set the texture reflection matrix used to rotate/transform the reflection.
  54045. * @param value Define the reflection matrix to set
  54046. */
  54047. setReflectionTextureMatrix(value: Matrix): void;
  54048. /**
  54049. * Parses a JSON representation of an HDR Texture in order to create the texture
  54050. * @param parsedTexture Define the JSON representation
  54051. * @param scene Define the scene the texture should be created in
  54052. * @param rootUrl Define the root url in case we need to load relative dependencies
  54053. * @returns the newly created texture after parsing
  54054. */
  54055. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54056. serialize(): any;
  54057. }
  54058. }
  54059. declare module "babylonjs/Physics/physicsEngine" {
  54060. import { Nullable } from "babylonjs/types";
  54061. import { Vector3 } from "babylonjs/Maths/math.vector";
  54062. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54063. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  54064. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  54065. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54066. /**
  54067. * Class used to control physics engine
  54068. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54069. */
  54070. export class PhysicsEngine implements IPhysicsEngine {
  54071. private _physicsPlugin;
  54072. /**
  54073. * Global value used to control the smallest number supported by the simulation
  54074. */
  54075. static Epsilon: number;
  54076. private _impostors;
  54077. private _joints;
  54078. /**
  54079. * Gets the gravity vector used by the simulation
  54080. */
  54081. gravity: Vector3;
  54082. /**
  54083. * Factory used to create the default physics plugin.
  54084. * @returns The default physics plugin
  54085. */
  54086. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54087. /**
  54088. * Creates a new Physics Engine
  54089. * @param gravity defines the gravity vector used by the simulation
  54090. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54091. */
  54092. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54093. /**
  54094. * Sets the gravity vector used by the simulation
  54095. * @param gravity defines the gravity vector to use
  54096. */
  54097. setGravity(gravity: Vector3): void;
  54098. /**
  54099. * Set the time step of the physics engine.
  54100. * Default is 1/60.
  54101. * To slow it down, enter 1/600 for example.
  54102. * To speed it up, 1/30
  54103. * @param newTimeStep defines the new timestep to apply to this world.
  54104. */
  54105. setTimeStep(newTimeStep?: number): void;
  54106. /**
  54107. * Get the time step of the physics engine.
  54108. * @returns the current time step
  54109. */
  54110. getTimeStep(): number;
  54111. /**
  54112. * Release all resources
  54113. */
  54114. dispose(): void;
  54115. /**
  54116. * Gets the name of the current physics plugin
  54117. * @returns the name of the plugin
  54118. */
  54119. getPhysicsPluginName(): string;
  54120. /**
  54121. * Adding a new impostor for the impostor tracking.
  54122. * This will be done by the impostor itself.
  54123. * @param impostor the impostor to add
  54124. */
  54125. addImpostor(impostor: PhysicsImpostor): void;
  54126. /**
  54127. * Remove an impostor from the engine.
  54128. * This impostor and its mesh will not longer be updated by the physics engine.
  54129. * @param impostor the impostor to remove
  54130. */
  54131. removeImpostor(impostor: PhysicsImpostor): void;
  54132. /**
  54133. * Add a joint to the physics engine
  54134. * @param mainImpostor defines the main impostor to which the joint is added.
  54135. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54136. * @param joint defines the joint that will connect both impostors.
  54137. */
  54138. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54139. /**
  54140. * Removes a joint from the simulation
  54141. * @param mainImpostor defines the impostor used with the joint
  54142. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54143. * @param joint defines the joint to remove
  54144. */
  54145. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54146. /**
  54147. * Called by the scene. No need to call it.
  54148. * @param delta defines the timespam between frames
  54149. */
  54150. _step(delta: number): void;
  54151. /**
  54152. * Gets the current plugin used to run the simulation
  54153. * @returns current plugin
  54154. */
  54155. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54156. /**
  54157. * Gets the list of physic impostors
  54158. * @returns an array of PhysicsImpostor
  54159. */
  54160. getImpostors(): Array<PhysicsImpostor>;
  54161. /**
  54162. * Gets the impostor for a physics enabled object
  54163. * @param object defines the object impersonated by the impostor
  54164. * @returns the PhysicsImpostor or null if not found
  54165. */
  54166. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54167. /**
  54168. * Gets the impostor for a physics body object
  54169. * @param body defines physics body used by the impostor
  54170. * @returns the PhysicsImpostor or null if not found
  54171. */
  54172. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54173. /**
  54174. * Does a raycast in the physics world
  54175. * @param from when should the ray start?
  54176. * @param to when should the ray end?
  54177. * @returns PhysicsRaycastResult
  54178. */
  54179. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54180. }
  54181. }
  54182. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54183. import { Nullable } from "babylonjs/types";
  54184. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54186. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54187. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54188. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54189. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54190. /** @hidden */
  54191. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54192. private _useDeltaForWorldStep;
  54193. world: any;
  54194. name: string;
  54195. private _physicsMaterials;
  54196. private _fixedTimeStep;
  54197. private _cannonRaycastResult;
  54198. private _raycastResult;
  54199. private _physicsBodysToRemoveAfterStep;
  54200. BJSCANNON: any;
  54201. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54202. setGravity(gravity: Vector3): void;
  54203. setTimeStep(timeStep: number): void;
  54204. getTimeStep(): number;
  54205. executeStep(delta: number): void;
  54206. private _removeMarkedPhysicsBodiesFromWorld;
  54207. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54208. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54209. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54210. private _processChildMeshes;
  54211. removePhysicsBody(impostor: PhysicsImpostor): void;
  54212. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54213. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54214. private _addMaterial;
  54215. private _checkWithEpsilon;
  54216. private _createShape;
  54217. private _createHeightmap;
  54218. private _minus90X;
  54219. private _plus90X;
  54220. private _tmpPosition;
  54221. private _tmpDeltaPosition;
  54222. private _tmpUnityRotation;
  54223. private _updatePhysicsBodyTransformation;
  54224. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54225. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54226. isSupported(): boolean;
  54227. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54228. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54229. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54230. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54231. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54232. getBodyMass(impostor: PhysicsImpostor): number;
  54233. getBodyFriction(impostor: PhysicsImpostor): number;
  54234. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54235. getBodyRestitution(impostor: PhysicsImpostor): number;
  54236. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54237. sleepBody(impostor: PhysicsImpostor): void;
  54238. wakeUpBody(impostor: PhysicsImpostor): void;
  54239. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54240. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54241. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54242. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54243. getRadius(impostor: PhysicsImpostor): number;
  54244. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54245. dispose(): void;
  54246. private _extendNamespace;
  54247. /**
  54248. * Does a raycast in the physics world
  54249. * @param from when should the ray start?
  54250. * @param to when should the ray end?
  54251. * @returns PhysicsRaycastResult
  54252. */
  54253. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54254. }
  54255. }
  54256. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54257. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54258. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54259. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54261. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54262. import { Nullable } from "babylonjs/types";
  54263. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54264. /** @hidden */
  54265. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54266. world: any;
  54267. name: string;
  54268. BJSOIMO: any;
  54269. private _raycastResult;
  54270. constructor(iterations?: number, oimoInjection?: any);
  54271. setGravity(gravity: Vector3): void;
  54272. setTimeStep(timeStep: number): void;
  54273. getTimeStep(): number;
  54274. private _tmpImpostorsArray;
  54275. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54276. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54277. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54278. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54279. private _tmpPositionVector;
  54280. removePhysicsBody(impostor: PhysicsImpostor): void;
  54281. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54282. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54283. isSupported(): boolean;
  54284. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54285. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54286. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54287. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54288. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54289. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54290. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54291. getBodyMass(impostor: PhysicsImpostor): number;
  54292. getBodyFriction(impostor: PhysicsImpostor): number;
  54293. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54294. getBodyRestitution(impostor: PhysicsImpostor): number;
  54295. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54296. sleepBody(impostor: PhysicsImpostor): void;
  54297. wakeUpBody(impostor: PhysicsImpostor): void;
  54298. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54299. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54300. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54301. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54302. getRadius(impostor: PhysicsImpostor): number;
  54303. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54304. dispose(): void;
  54305. /**
  54306. * Does a raycast in the physics world
  54307. * @param from when should the ray start?
  54308. * @param to when should the ray end?
  54309. * @returns PhysicsRaycastResult
  54310. */
  54311. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54312. }
  54313. }
  54314. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54315. import { Nullable } from "babylonjs/types";
  54316. import { Scene } from "babylonjs/scene";
  54317. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54318. import { Color4 } from "babylonjs/Maths/math.color";
  54319. import { Mesh } from "babylonjs/Meshes/mesh";
  54320. /**
  54321. * Class containing static functions to help procedurally build meshes
  54322. */
  54323. export class RibbonBuilder {
  54324. /**
  54325. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54326. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54327. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54328. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54329. * * 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
  54330. * * 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
  54331. * * 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
  54332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54335. * * 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
  54336. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54337. * * 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
  54338. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54340. * @param name defines the name of the mesh
  54341. * @param options defines the options used to create the mesh
  54342. * @param scene defines the hosting scene
  54343. * @returns the ribbon mesh
  54344. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54346. */
  54347. static CreateRibbon(name: string, options: {
  54348. pathArray: Vector3[][];
  54349. closeArray?: boolean;
  54350. closePath?: boolean;
  54351. offset?: number;
  54352. updatable?: boolean;
  54353. sideOrientation?: number;
  54354. frontUVs?: Vector4;
  54355. backUVs?: Vector4;
  54356. instance?: Mesh;
  54357. invertUV?: boolean;
  54358. uvs?: Vector2[];
  54359. colors?: Color4[];
  54360. }, scene?: Nullable<Scene>): Mesh;
  54361. }
  54362. }
  54363. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54364. import { Nullable } from "babylonjs/types";
  54365. import { Scene } from "babylonjs/scene";
  54366. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54367. import { Mesh } from "babylonjs/Meshes/mesh";
  54368. /**
  54369. * Class containing static functions to help procedurally build meshes
  54370. */
  54371. export class ShapeBuilder {
  54372. /**
  54373. * 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.
  54374. * * 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.
  54375. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54376. * * 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.
  54377. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54378. * * 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
  54379. * * 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
  54380. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54383. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54385. * @param name defines the name of the mesh
  54386. * @param options defines the options used to create the mesh
  54387. * @param scene defines the hosting scene
  54388. * @returns the extruded shape mesh
  54389. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54391. */
  54392. static ExtrudeShape(name: string, options: {
  54393. shape: Vector3[];
  54394. path: Vector3[];
  54395. scale?: number;
  54396. rotation?: number;
  54397. cap?: number;
  54398. updatable?: boolean;
  54399. sideOrientation?: number;
  54400. frontUVs?: Vector4;
  54401. backUVs?: Vector4;
  54402. instance?: Mesh;
  54403. invertUV?: boolean;
  54404. }, scene?: Nullable<Scene>): Mesh;
  54405. /**
  54406. * Creates an custom extruded shape mesh.
  54407. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54408. * * 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.
  54409. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54410. * * 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
  54411. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54412. * * 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
  54413. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54414. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54415. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54416. * * 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
  54417. * * 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
  54418. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54423. * @param name defines the name of the mesh
  54424. * @param options defines the options used to create the mesh
  54425. * @param scene defines the hosting scene
  54426. * @returns the custom extruded shape mesh
  54427. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54428. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54430. */
  54431. static ExtrudeShapeCustom(name: string, options: {
  54432. shape: Vector3[];
  54433. path: Vector3[];
  54434. scaleFunction?: any;
  54435. rotationFunction?: any;
  54436. ribbonCloseArray?: boolean;
  54437. ribbonClosePath?: boolean;
  54438. cap?: number;
  54439. updatable?: boolean;
  54440. sideOrientation?: number;
  54441. frontUVs?: Vector4;
  54442. backUVs?: Vector4;
  54443. instance?: Mesh;
  54444. invertUV?: boolean;
  54445. }, scene?: Nullable<Scene>): Mesh;
  54446. private static _ExtrudeShapeGeneric;
  54447. }
  54448. }
  54449. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54450. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54451. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54452. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54453. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54454. import { Nullable } from "babylonjs/types";
  54455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54456. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54457. /**
  54458. * AmmoJS Physics plugin
  54459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54460. * @see https://github.com/kripken/ammo.js/
  54461. */
  54462. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54463. private _useDeltaForWorldStep;
  54464. /**
  54465. * Reference to the Ammo library
  54466. */
  54467. bjsAMMO: any;
  54468. /**
  54469. * Created ammoJS world which physics bodies are added to
  54470. */
  54471. world: any;
  54472. /**
  54473. * Name of the plugin
  54474. */
  54475. name: string;
  54476. private _timeStep;
  54477. private _fixedTimeStep;
  54478. private _maxSteps;
  54479. private _tmpQuaternion;
  54480. private _tmpAmmoTransform;
  54481. private _tmpAmmoQuaternion;
  54482. private _tmpAmmoConcreteContactResultCallback;
  54483. private _collisionConfiguration;
  54484. private _dispatcher;
  54485. private _overlappingPairCache;
  54486. private _solver;
  54487. private _softBodySolver;
  54488. private _tmpAmmoVectorA;
  54489. private _tmpAmmoVectorB;
  54490. private _tmpAmmoVectorC;
  54491. private _tmpAmmoVectorD;
  54492. private _tmpContactCallbackResult;
  54493. private _tmpAmmoVectorRCA;
  54494. private _tmpAmmoVectorRCB;
  54495. private _raycastResult;
  54496. private static readonly DISABLE_COLLISION_FLAG;
  54497. private static readonly KINEMATIC_FLAG;
  54498. private static readonly DISABLE_DEACTIVATION_FLAG;
  54499. /**
  54500. * Initializes the ammoJS plugin
  54501. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54502. * @param ammoInjection can be used to inject your own ammo reference
  54503. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54504. */
  54505. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54506. /**
  54507. * Sets the gravity of the physics world (m/(s^2))
  54508. * @param gravity Gravity to set
  54509. */
  54510. setGravity(gravity: Vector3): void;
  54511. /**
  54512. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54513. * @param timeStep timestep to use in seconds
  54514. */
  54515. setTimeStep(timeStep: number): void;
  54516. /**
  54517. * 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)
  54518. * @param fixedTimeStep fixedTimeStep to use in seconds
  54519. */
  54520. setFixedTimeStep(fixedTimeStep: number): void;
  54521. /**
  54522. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54523. * @param maxSteps the maximum number of steps by the physics engine per frame
  54524. */
  54525. setMaxSteps(maxSteps: number): void;
  54526. /**
  54527. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54528. * @returns the current timestep in seconds
  54529. */
  54530. getTimeStep(): number;
  54531. private _isImpostorInContact;
  54532. private _isImpostorPairInContact;
  54533. private _stepSimulation;
  54534. /**
  54535. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54536. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54537. * After the step the babylon meshes are set to the position of the physics imposters
  54538. * @param delta amount of time to step forward
  54539. * @param impostors array of imposters to update before/after the step
  54540. */
  54541. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54542. /**
  54543. * Update babylon mesh to match physics world object
  54544. * @param impostor imposter to match
  54545. */
  54546. private _afterSoftStep;
  54547. /**
  54548. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54549. * @param impostor imposter to match
  54550. */
  54551. private _ropeStep;
  54552. /**
  54553. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54554. * @param impostor imposter to match
  54555. */
  54556. private _softbodyOrClothStep;
  54557. private _tmpVector;
  54558. private _tmpMatrix;
  54559. /**
  54560. * Applies an impulse on the imposter
  54561. * @param impostor imposter to apply impulse to
  54562. * @param force amount of force to be applied to the imposter
  54563. * @param contactPoint the location to apply the impulse on the imposter
  54564. */
  54565. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54566. /**
  54567. * Applies a force on the imposter
  54568. * @param impostor imposter to apply force
  54569. * @param force amount of force to be applied to the imposter
  54570. * @param contactPoint the location to apply the force on the imposter
  54571. */
  54572. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54573. /**
  54574. * Creates a physics body using the plugin
  54575. * @param impostor the imposter to create the physics body on
  54576. */
  54577. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54578. /**
  54579. * Removes the physics body from the imposter and disposes of the body's memory
  54580. * @param impostor imposter to remove the physics body from
  54581. */
  54582. removePhysicsBody(impostor: PhysicsImpostor): void;
  54583. /**
  54584. * Generates a joint
  54585. * @param impostorJoint the imposter joint to create the joint with
  54586. */
  54587. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54588. /**
  54589. * Removes a joint
  54590. * @param impostorJoint the imposter joint to remove the joint from
  54591. */
  54592. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54593. private _addMeshVerts;
  54594. /**
  54595. * Initialise the soft body vertices to match its object's (mesh) vertices
  54596. * Softbody vertices (nodes) are in world space and to match this
  54597. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54598. * @param impostor to create the softbody for
  54599. */
  54600. private _softVertexData;
  54601. /**
  54602. * Create an impostor's soft body
  54603. * @param impostor to create the softbody for
  54604. */
  54605. private _createSoftbody;
  54606. /**
  54607. * Create cloth for an impostor
  54608. * @param impostor to create the softbody for
  54609. */
  54610. private _createCloth;
  54611. /**
  54612. * Create rope for an impostor
  54613. * @param impostor to create the softbody for
  54614. */
  54615. private _createRope;
  54616. private _addHullVerts;
  54617. private _createShape;
  54618. /**
  54619. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54620. * @param impostor imposter containing the physics body and babylon object
  54621. */
  54622. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54623. /**
  54624. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54625. * @param impostor imposter containing the physics body and babylon object
  54626. * @param newPosition new position
  54627. * @param newRotation new rotation
  54628. */
  54629. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54630. /**
  54631. * If this plugin is supported
  54632. * @returns true if its supported
  54633. */
  54634. isSupported(): boolean;
  54635. /**
  54636. * Sets the linear velocity of the physics body
  54637. * @param impostor imposter to set the velocity on
  54638. * @param velocity velocity to set
  54639. */
  54640. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54641. /**
  54642. * Sets the angular velocity of the physics body
  54643. * @param impostor imposter to set the velocity on
  54644. * @param velocity velocity to set
  54645. */
  54646. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54647. /**
  54648. * gets the linear velocity
  54649. * @param impostor imposter to get linear velocity from
  54650. * @returns linear velocity
  54651. */
  54652. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54653. /**
  54654. * gets the angular velocity
  54655. * @param impostor imposter to get angular velocity from
  54656. * @returns angular velocity
  54657. */
  54658. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54659. /**
  54660. * Sets the mass of physics body
  54661. * @param impostor imposter to set the mass on
  54662. * @param mass mass to set
  54663. */
  54664. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54665. /**
  54666. * Gets the mass of the physics body
  54667. * @param impostor imposter to get the mass from
  54668. * @returns mass
  54669. */
  54670. getBodyMass(impostor: PhysicsImpostor): number;
  54671. /**
  54672. * Gets friction of the impostor
  54673. * @param impostor impostor to get friction from
  54674. * @returns friction value
  54675. */
  54676. getBodyFriction(impostor: PhysicsImpostor): number;
  54677. /**
  54678. * Sets friction of the impostor
  54679. * @param impostor impostor to set friction on
  54680. * @param friction friction value
  54681. */
  54682. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54683. /**
  54684. * Gets restitution of the impostor
  54685. * @param impostor impostor to get restitution from
  54686. * @returns restitution value
  54687. */
  54688. getBodyRestitution(impostor: PhysicsImpostor): number;
  54689. /**
  54690. * Sets resitution of the impostor
  54691. * @param impostor impostor to set resitution on
  54692. * @param restitution resitution value
  54693. */
  54694. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54695. /**
  54696. * Gets pressure inside the impostor
  54697. * @param impostor impostor to get pressure from
  54698. * @returns pressure value
  54699. */
  54700. getBodyPressure(impostor: PhysicsImpostor): number;
  54701. /**
  54702. * Sets pressure inside a soft body impostor
  54703. * Cloth and rope must remain 0 pressure
  54704. * @param impostor impostor to set pressure on
  54705. * @param pressure pressure value
  54706. */
  54707. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54708. /**
  54709. * Gets stiffness of the impostor
  54710. * @param impostor impostor to get stiffness from
  54711. * @returns pressure value
  54712. */
  54713. getBodyStiffness(impostor: PhysicsImpostor): number;
  54714. /**
  54715. * Sets stiffness of the impostor
  54716. * @param impostor impostor to set stiffness on
  54717. * @param stiffness stiffness value from 0 to 1
  54718. */
  54719. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54720. /**
  54721. * Gets velocityIterations of the impostor
  54722. * @param impostor impostor to get velocity iterations from
  54723. * @returns velocityIterations value
  54724. */
  54725. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54726. /**
  54727. * Sets velocityIterations of the impostor
  54728. * @param impostor impostor to set velocity iterations on
  54729. * @param velocityIterations velocityIterations value
  54730. */
  54731. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54732. /**
  54733. * Gets positionIterations of the impostor
  54734. * @param impostor impostor to get position iterations from
  54735. * @returns positionIterations value
  54736. */
  54737. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54738. /**
  54739. * Sets positionIterations of the impostor
  54740. * @param impostor impostor to set position on
  54741. * @param positionIterations positionIterations value
  54742. */
  54743. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54744. /**
  54745. * Append an anchor to a cloth object
  54746. * @param impostor is the cloth impostor to add anchor to
  54747. * @param otherImpostor is the rigid impostor to anchor to
  54748. * @param width ratio across width from 0 to 1
  54749. * @param height ratio up height from 0 to 1
  54750. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54751. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54752. */
  54753. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54754. /**
  54755. * Append an hook to a rope object
  54756. * @param impostor is the rope impostor to add hook to
  54757. * @param otherImpostor is the rigid impostor to hook to
  54758. * @param length ratio along the rope from 0 to 1
  54759. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54760. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54761. */
  54762. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54763. /**
  54764. * Sleeps the physics body and stops it from being active
  54765. * @param impostor impostor to sleep
  54766. */
  54767. sleepBody(impostor: PhysicsImpostor): void;
  54768. /**
  54769. * Activates the physics body
  54770. * @param impostor impostor to activate
  54771. */
  54772. wakeUpBody(impostor: PhysicsImpostor): void;
  54773. /**
  54774. * Updates the distance parameters of the joint
  54775. * @param joint joint to update
  54776. * @param maxDistance maximum distance of the joint
  54777. * @param minDistance minimum distance of the joint
  54778. */
  54779. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54780. /**
  54781. * Sets a motor on the joint
  54782. * @param joint joint to set motor on
  54783. * @param speed speed of the motor
  54784. * @param maxForce maximum force of the motor
  54785. * @param motorIndex index of the motor
  54786. */
  54787. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54788. /**
  54789. * Sets the motors limit
  54790. * @param joint joint to set limit on
  54791. * @param upperLimit upper limit
  54792. * @param lowerLimit lower limit
  54793. */
  54794. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54795. /**
  54796. * Syncs the position and rotation of a mesh with the impostor
  54797. * @param mesh mesh to sync
  54798. * @param impostor impostor to update the mesh with
  54799. */
  54800. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54801. /**
  54802. * Gets the radius of the impostor
  54803. * @param impostor impostor to get radius from
  54804. * @returns the radius
  54805. */
  54806. getRadius(impostor: PhysicsImpostor): number;
  54807. /**
  54808. * Gets the box size of the impostor
  54809. * @param impostor impostor to get box size from
  54810. * @param result the resulting box size
  54811. */
  54812. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54813. /**
  54814. * Disposes of the impostor
  54815. */
  54816. dispose(): void;
  54817. /**
  54818. * Does a raycast in the physics world
  54819. * @param from when should the ray start?
  54820. * @param to when should the ray end?
  54821. * @returns PhysicsRaycastResult
  54822. */
  54823. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54824. }
  54825. }
  54826. declare module "babylonjs/Probes/reflectionProbe" {
  54827. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54828. import { Vector3 } from "babylonjs/Maths/math.vector";
  54829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54830. import { Nullable } from "babylonjs/types";
  54831. import { Scene } from "babylonjs/scene";
  54832. module "babylonjs/abstractScene" {
  54833. interface AbstractScene {
  54834. /**
  54835. * The list of reflection probes added to the scene
  54836. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54837. */
  54838. reflectionProbes: Array<ReflectionProbe>;
  54839. /**
  54840. * Removes the given reflection probe from this scene.
  54841. * @param toRemove The reflection probe to remove
  54842. * @returns The index of the removed reflection probe
  54843. */
  54844. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54845. /**
  54846. * Adds the given reflection probe to this scene.
  54847. * @param newReflectionProbe The reflection probe to add
  54848. */
  54849. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54850. }
  54851. }
  54852. /**
  54853. * Class used to generate realtime reflection / refraction cube textures
  54854. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54855. */
  54856. export class ReflectionProbe {
  54857. /** defines the name of the probe */
  54858. name: string;
  54859. private _scene;
  54860. private _renderTargetTexture;
  54861. private _projectionMatrix;
  54862. private _viewMatrix;
  54863. private _target;
  54864. private _add;
  54865. private _attachedMesh;
  54866. private _invertYAxis;
  54867. /** Gets or sets probe position (center of the cube map) */
  54868. position: Vector3;
  54869. /**
  54870. * Creates a new reflection probe
  54871. * @param name defines the name of the probe
  54872. * @param size defines the texture resolution (for each face)
  54873. * @param scene defines the hosting scene
  54874. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54875. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54876. */
  54877. constructor(
  54878. /** defines the name of the probe */
  54879. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54880. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54881. samples: number;
  54882. /** Gets or sets the refresh rate to use (on every frame by default) */
  54883. refreshRate: number;
  54884. /**
  54885. * Gets the hosting scene
  54886. * @returns a Scene
  54887. */
  54888. getScene(): Scene;
  54889. /** Gets the internal CubeTexture used to render to */
  54890. readonly cubeTexture: RenderTargetTexture;
  54891. /** Gets the list of meshes to render */
  54892. readonly renderList: Nullable<AbstractMesh[]>;
  54893. /**
  54894. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54895. * @param mesh defines the mesh to attach to
  54896. */
  54897. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54898. /**
  54899. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54900. * @param renderingGroupId The rendering group id corresponding to its index
  54901. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54902. */
  54903. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54904. /**
  54905. * Clean all associated resources
  54906. */
  54907. dispose(): void;
  54908. /**
  54909. * Converts the reflection probe information to a readable string for debug purpose.
  54910. * @param fullDetails Supports for multiple levels of logging within scene loading
  54911. * @returns the human readable reflection probe info
  54912. */
  54913. toString(fullDetails?: boolean): string;
  54914. /**
  54915. * Get the class name of the relfection probe.
  54916. * @returns "ReflectionProbe"
  54917. */
  54918. getClassName(): string;
  54919. /**
  54920. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54921. * @returns The JSON representation of the texture
  54922. */
  54923. serialize(): any;
  54924. /**
  54925. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54926. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54927. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54928. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54929. * @returns The parsed reflection probe if successful
  54930. */
  54931. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54932. }
  54933. }
  54934. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54935. /** @hidden */
  54936. export var _BabylonLoaderRegistered: boolean;
  54937. /**
  54938. * Helps setting up some configuration for the babylon file loader.
  54939. */
  54940. export class BabylonFileLoaderConfiguration {
  54941. /**
  54942. * The loader does not allow injecting custom physix engine into the plugins.
  54943. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54944. * So you could set this variable to your engine import to make it work.
  54945. */
  54946. static LoaderInjectedPhysicsEngine: any;
  54947. }
  54948. }
  54949. declare module "babylonjs/Loading/Plugins/index" {
  54950. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54951. }
  54952. declare module "babylonjs/Loading/index" {
  54953. export * from "babylonjs/Loading/loadingScreen";
  54954. export * from "babylonjs/Loading/Plugins/index";
  54955. export * from "babylonjs/Loading/sceneLoader";
  54956. export * from "babylonjs/Loading/sceneLoaderFlags";
  54957. }
  54958. declare module "babylonjs/Materials/Background/index" {
  54959. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54960. }
  54961. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54962. import { Scene } from "babylonjs/scene";
  54963. import { Color3 } from "babylonjs/Maths/math.color";
  54964. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54966. /**
  54967. * The Physically based simple base material of BJS.
  54968. *
  54969. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54970. * It is used as the base class for both the specGloss and metalRough conventions.
  54971. */
  54972. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54973. /**
  54974. * Number of Simultaneous lights allowed on the material.
  54975. */
  54976. maxSimultaneousLights: number;
  54977. /**
  54978. * If sets to true, disables all the lights affecting the material.
  54979. */
  54980. disableLighting: boolean;
  54981. /**
  54982. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54983. */
  54984. environmentTexture: BaseTexture;
  54985. /**
  54986. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54987. */
  54988. invertNormalMapX: boolean;
  54989. /**
  54990. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54991. */
  54992. invertNormalMapY: boolean;
  54993. /**
  54994. * Normal map used in the model.
  54995. */
  54996. normalTexture: BaseTexture;
  54997. /**
  54998. * Emissivie color used to self-illuminate the model.
  54999. */
  55000. emissiveColor: Color3;
  55001. /**
  55002. * Emissivie texture used to self-illuminate the model.
  55003. */
  55004. emissiveTexture: BaseTexture;
  55005. /**
  55006. * Occlusion Channel Strenght.
  55007. */
  55008. occlusionStrength: number;
  55009. /**
  55010. * Occlusion Texture of the material (adding extra occlusion effects).
  55011. */
  55012. occlusionTexture: BaseTexture;
  55013. /**
  55014. * Defines the alpha limits in alpha test mode.
  55015. */
  55016. alphaCutOff: number;
  55017. /**
  55018. * Gets the current double sided mode.
  55019. */
  55020. /**
  55021. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55022. */
  55023. doubleSided: boolean;
  55024. /**
  55025. * Stores the pre-calculated light information of a mesh in a texture.
  55026. */
  55027. lightmapTexture: BaseTexture;
  55028. /**
  55029. * If true, the light map contains occlusion information instead of lighting info.
  55030. */
  55031. useLightmapAsShadowmap: boolean;
  55032. /**
  55033. * Instantiates a new PBRMaterial instance.
  55034. *
  55035. * @param name The material name
  55036. * @param scene The scene the material will be use in.
  55037. */
  55038. constructor(name: string, scene: Scene);
  55039. getClassName(): string;
  55040. }
  55041. }
  55042. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  55043. import { Scene } from "babylonjs/scene";
  55044. import { Color3 } from "babylonjs/Maths/math.color";
  55045. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55046. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55047. /**
  55048. * The PBR material of BJS following the metal roughness convention.
  55049. *
  55050. * This fits to the PBR convention in the GLTF definition:
  55051. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55052. */
  55053. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55054. /**
  55055. * The base color has two different interpretations depending on the value of metalness.
  55056. * When the material is a metal, the base color is the specific measured reflectance value
  55057. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55058. * of the material.
  55059. */
  55060. baseColor: Color3;
  55061. /**
  55062. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55063. * well as opacity information in the alpha channel.
  55064. */
  55065. baseTexture: BaseTexture;
  55066. /**
  55067. * Specifies the metallic scalar value of the material.
  55068. * Can also be used to scale the metalness values of the metallic texture.
  55069. */
  55070. metallic: number;
  55071. /**
  55072. * Specifies the roughness scalar value of the material.
  55073. * Can also be used to scale the roughness values of the metallic texture.
  55074. */
  55075. roughness: number;
  55076. /**
  55077. * Texture containing both the metallic value in the B channel and the
  55078. * roughness value in the G channel to keep better precision.
  55079. */
  55080. metallicRoughnessTexture: BaseTexture;
  55081. /**
  55082. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55083. *
  55084. * @param name The material name
  55085. * @param scene The scene the material will be use in.
  55086. */
  55087. constructor(name: string, scene: Scene);
  55088. /**
  55089. * Return the currrent class name of the material.
  55090. */
  55091. getClassName(): string;
  55092. /**
  55093. * Makes a duplicate of the current material.
  55094. * @param name - name to use for the new material.
  55095. */
  55096. clone(name: string): PBRMetallicRoughnessMaterial;
  55097. /**
  55098. * Serialize the material to a parsable JSON object.
  55099. */
  55100. serialize(): any;
  55101. /**
  55102. * Parses a JSON object correponding to the serialize function.
  55103. */
  55104. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55105. }
  55106. }
  55107. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  55108. import { Scene } from "babylonjs/scene";
  55109. import { Color3 } from "babylonjs/Maths/math.color";
  55110. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55111. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55112. /**
  55113. * The PBR material of BJS following the specular glossiness convention.
  55114. *
  55115. * This fits to the PBR convention in the GLTF definition:
  55116. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55117. */
  55118. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55119. /**
  55120. * Specifies the diffuse color of the material.
  55121. */
  55122. diffuseColor: Color3;
  55123. /**
  55124. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55125. * channel.
  55126. */
  55127. diffuseTexture: BaseTexture;
  55128. /**
  55129. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55130. */
  55131. specularColor: Color3;
  55132. /**
  55133. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55134. */
  55135. glossiness: number;
  55136. /**
  55137. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55138. */
  55139. specularGlossinessTexture: BaseTexture;
  55140. /**
  55141. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55142. *
  55143. * @param name The material name
  55144. * @param scene The scene the material will be use in.
  55145. */
  55146. constructor(name: string, scene: Scene);
  55147. /**
  55148. * Return the currrent class name of the material.
  55149. */
  55150. getClassName(): string;
  55151. /**
  55152. * Makes a duplicate of the current material.
  55153. * @param name - name to use for the new material.
  55154. */
  55155. clone(name: string): PBRSpecularGlossinessMaterial;
  55156. /**
  55157. * Serialize the material to a parsable JSON object.
  55158. */
  55159. serialize(): any;
  55160. /**
  55161. * Parses a JSON object correponding to the serialize function.
  55162. */
  55163. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55164. }
  55165. }
  55166. declare module "babylonjs/Materials/PBR/index" {
  55167. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55168. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55169. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55170. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55171. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55172. }
  55173. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55174. import { Nullable } from "babylonjs/types";
  55175. import { Scene } from "babylonjs/scene";
  55176. import { Matrix } from "babylonjs/Maths/math.vector";
  55177. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55178. /**
  55179. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55180. * It can help converting any input color in a desired output one. This can then be used to create effects
  55181. * from sepia, black and white to sixties or futuristic rendering...
  55182. *
  55183. * The only supported format is currently 3dl.
  55184. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55185. */
  55186. export class ColorGradingTexture extends BaseTexture {
  55187. /**
  55188. * The current texture matrix. (will always be identity in color grading texture)
  55189. */
  55190. private _textureMatrix;
  55191. /**
  55192. * The texture URL.
  55193. */
  55194. url: string;
  55195. /**
  55196. * Empty line regex stored for GC.
  55197. */
  55198. private static _noneEmptyLineRegex;
  55199. private _engine;
  55200. /**
  55201. * Instantiates a ColorGradingTexture from the following parameters.
  55202. *
  55203. * @param url The location of the color gradind data (currently only supporting 3dl)
  55204. * @param scene The scene the texture will be used in
  55205. */
  55206. constructor(url: string, scene: Scene);
  55207. /**
  55208. * Returns the texture matrix used in most of the material.
  55209. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55210. */
  55211. getTextureMatrix(): Matrix;
  55212. /**
  55213. * Occurs when the file being loaded is a .3dl LUT file.
  55214. */
  55215. private load3dlTexture;
  55216. /**
  55217. * Starts the loading process of the texture.
  55218. */
  55219. private loadTexture;
  55220. /**
  55221. * Clones the color gradind texture.
  55222. */
  55223. clone(): ColorGradingTexture;
  55224. /**
  55225. * Called during delayed load for textures.
  55226. */
  55227. delayLoad(): void;
  55228. /**
  55229. * Parses a color grading texture serialized by Babylon.
  55230. * @param parsedTexture The texture information being parsedTexture
  55231. * @param scene The scene to load the texture in
  55232. * @param rootUrl The root url of the data assets to load
  55233. * @return A color gradind texture
  55234. */
  55235. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55236. /**
  55237. * Serializes the LUT texture to json format.
  55238. */
  55239. serialize(): any;
  55240. }
  55241. }
  55242. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55244. import { Scene } from "babylonjs/scene";
  55245. import { Nullable } from "babylonjs/types";
  55246. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55247. /**
  55248. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55249. */
  55250. export class EquiRectangularCubeTexture extends BaseTexture {
  55251. /** The six faces of the cube. */
  55252. private static _FacesMapping;
  55253. private _noMipmap;
  55254. private _onLoad;
  55255. private _onError;
  55256. /** The size of the cubemap. */
  55257. private _size;
  55258. /** The buffer of the image. */
  55259. private _buffer;
  55260. /** The width of the input image. */
  55261. private _width;
  55262. /** The height of the input image. */
  55263. private _height;
  55264. /** The URL to the image. */
  55265. url: string;
  55266. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55267. coordinatesMode: number;
  55268. /**
  55269. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55270. * @param url The location of the image
  55271. * @param scene The scene the texture will be used in
  55272. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55273. * @param noMipmap Forces to not generate the mipmap if true
  55274. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55275. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55276. * @param onLoad — defines a callback called when texture is loaded
  55277. * @param onError — defines a callback called if there is an error
  55278. */
  55279. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55280. /**
  55281. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55282. */
  55283. private loadImage;
  55284. /**
  55285. * Convert the image buffer into a cubemap and create a CubeTexture.
  55286. */
  55287. private loadTexture;
  55288. /**
  55289. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55290. * @param buffer The ArrayBuffer that should be converted.
  55291. * @returns The buffer as Float32Array.
  55292. */
  55293. private getFloat32ArrayFromArrayBuffer;
  55294. /**
  55295. * Get the current class name of the texture useful for serialization or dynamic coding.
  55296. * @returns "EquiRectangularCubeTexture"
  55297. */
  55298. getClassName(): string;
  55299. /**
  55300. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55301. * @returns A clone of the current EquiRectangularCubeTexture.
  55302. */
  55303. clone(): EquiRectangularCubeTexture;
  55304. }
  55305. }
  55306. declare module "babylonjs/Misc/tga" {
  55307. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55308. /**
  55309. * Based on jsTGALoader - Javascript loader for TGA file
  55310. * By Vincent Thibault
  55311. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55312. */
  55313. export class TGATools {
  55314. private static _TYPE_INDEXED;
  55315. private static _TYPE_RGB;
  55316. private static _TYPE_GREY;
  55317. private static _TYPE_RLE_INDEXED;
  55318. private static _TYPE_RLE_RGB;
  55319. private static _TYPE_RLE_GREY;
  55320. private static _ORIGIN_MASK;
  55321. private static _ORIGIN_SHIFT;
  55322. private static _ORIGIN_BL;
  55323. private static _ORIGIN_BR;
  55324. private static _ORIGIN_UL;
  55325. private static _ORIGIN_UR;
  55326. /**
  55327. * Gets the header of a TGA file
  55328. * @param data defines the TGA data
  55329. * @returns the header
  55330. */
  55331. static GetTGAHeader(data: Uint8Array): any;
  55332. /**
  55333. * Uploads TGA content to a Babylon Texture
  55334. * @hidden
  55335. */
  55336. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55337. /** @hidden */
  55338. 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;
  55339. /** @hidden */
  55340. 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;
  55341. /** @hidden */
  55342. 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;
  55343. /** @hidden */
  55344. 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;
  55345. /** @hidden */
  55346. 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;
  55347. /** @hidden */
  55348. 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;
  55349. }
  55350. }
  55351. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55352. import { Nullable } from "babylonjs/types";
  55353. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55354. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55355. /**
  55356. * Implementation of the TGA Texture Loader.
  55357. * @hidden
  55358. */
  55359. export class _TGATextureLoader implements IInternalTextureLoader {
  55360. /**
  55361. * Defines wether the loader supports cascade loading the different faces.
  55362. */
  55363. readonly supportCascades: boolean;
  55364. /**
  55365. * This returns if the loader support the current file information.
  55366. * @param extension defines the file extension of the file being loaded
  55367. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55368. * @param fallback defines the fallback internal texture if any
  55369. * @param isBase64 defines whether the texture is encoded as a base64
  55370. * @param isBuffer defines whether the texture data are stored as a buffer
  55371. * @returns true if the loader can load the specified file
  55372. */
  55373. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55374. /**
  55375. * Transform the url before loading if required.
  55376. * @param rootUrl the url of the texture
  55377. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55378. * @returns the transformed texture
  55379. */
  55380. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55381. /**
  55382. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55383. * @param rootUrl the url of the texture
  55384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55385. * @returns the fallback texture
  55386. */
  55387. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55388. /**
  55389. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55390. * @param data contains the texture data
  55391. * @param texture defines the BabylonJS internal texture
  55392. * @param createPolynomials will be true if polynomials have been requested
  55393. * @param onLoad defines the callback to trigger once the texture is ready
  55394. * @param onError defines the callback to trigger in case of error
  55395. */
  55396. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55397. /**
  55398. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55399. * @param data contains the texture data
  55400. * @param texture defines the BabylonJS internal texture
  55401. * @param callback defines the method to call once ready to upload
  55402. */
  55403. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55404. }
  55405. }
  55406. declare module "babylonjs/Misc/basis" {
  55407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55408. /**
  55409. * Info about the .basis files
  55410. */
  55411. class BasisFileInfo {
  55412. /**
  55413. * If the file has alpha
  55414. */
  55415. hasAlpha: boolean;
  55416. /**
  55417. * Info about each image of the basis file
  55418. */
  55419. images: Array<{
  55420. levels: Array<{
  55421. width: number;
  55422. height: number;
  55423. transcodedPixels: ArrayBufferView;
  55424. }>;
  55425. }>;
  55426. }
  55427. /**
  55428. * Result of transcoding a basis file
  55429. */
  55430. class TranscodeResult {
  55431. /**
  55432. * Info about the .basis file
  55433. */
  55434. fileInfo: BasisFileInfo;
  55435. /**
  55436. * Format to use when loading the file
  55437. */
  55438. format: number;
  55439. }
  55440. /**
  55441. * Configuration options for the Basis transcoder
  55442. */
  55443. export class BasisTranscodeConfiguration {
  55444. /**
  55445. * Supported compression formats used to determine the supported output format of the transcoder
  55446. */
  55447. supportedCompressionFormats?: {
  55448. /**
  55449. * etc1 compression format
  55450. */
  55451. etc1?: boolean;
  55452. /**
  55453. * s3tc compression format
  55454. */
  55455. s3tc?: boolean;
  55456. /**
  55457. * pvrtc compression format
  55458. */
  55459. pvrtc?: boolean;
  55460. /**
  55461. * etc2 compression format
  55462. */
  55463. etc2?: boolean;
  55464. };
  55465. /**
  55466. * If mipmap levels should be loaded for transcoded images (Default: true)
  55467. */
  55468. loadMipmapLevels?: boolean;
  55469. /**
  55470. * Index of a single image to load (Default: all images)
  55471. */
  55472. loadSingleImage?: number;
  55473. }
  55474. /**
  55475. * Used to load .Basis files
  55476. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55477. */
  55478. export class BasisTools {
  55479. private static _IgnoreSupportedFormats;
  55480. /**
  55481. * URL to use when loading the basis transcoder
  55482. */
  55483. static JSModuleURL: string;
  55484. /**
  55485. * URL to use when loading the wasm module for the transcoder
  55486. */
  55487. static WasmModuleURL: string;
  55488. /**
  55489. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55490. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55491. * @returns internal format corresponding to the Basis format
  55492. */
  55493. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55494. private static _WorkerPromise;
  55495. private static _Worker;
  55496. private static _actionId;
  55497. private static _CreateWorkerAsync;
  55498. /**
  55499. * Transcodes a loaded image file to compressed pixel data
  55500. * @param imageData image data to transcode
  55501. * @param config configuration options for the transcoding
  55502. * @returns a promise resulting in the transcoded image
  55503. */
  55504. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55505. /**
  55506. * Loads a texture from the transcode result
  55507. * @param texture texture load to
  55508. * @param transcodeResult the result of transcoding the basis file to load from
  55509. */
  55510. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55511. }
  55512. }
  55513. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55514. import { Nullable } from "babylonjs/types";
  55515. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55516. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55517. /**
  55518. * Loader for .basis file format
  55519. */
  55520. export class _BasisTextureLoader implements IInternalTextureLoader {
  55521. /**
  55522. * Defines whether the loader supports cascade loading the different faces.
  55523. */
  55524. readonly supportCascades: boolean;
  55525. /**
  55526. * This returns if the loader support the current file information.
  55527. * @param extension defines the file extension of the file being loaded
  55528. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55529. * @param fallback defines the fallback internal texture if any
  55530. * @param isBase64 defines whether the texture is encoded as a base64
  55531. * @param isBuffer defines whether the texture data are stored as a buffer
  55532. * @returns true if the loader can load the specified file
  55533. */
  55534. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55535. /**
  55536. * Transform the url before loading if required.
  55537. * @param rootUrl the url of the texture
  55538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55539. * @returns the transformed texture
  55540. */
  55541. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55542. /**
  55543. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55544. * @param rootUrl the url of the texture
  55545. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55546. * @returns the fallback texture
  55547. */
  55548. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55549. /**
  55550. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55551. * @param data contains the texture data
  55552. * @param texture defines the BabylonJS internal texture
  55553. * @param createPolynomials will be true if polynomials have been requested
  55554. * @param onLoad defines the callback to trigger once the texture is ready
  55555. * @param onError defines the callback to trigger in case of error
  55556. */
  55557. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55558. /**
  55559. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55560. * @param data contains the texture data
  55561. * @param texture defines the BabylonJS internal texture
  55562. * @param callback defines the method to call once ready to upload
  55563. */
  55564. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55565. }
  55566. }
  55567. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55568. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55569. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55570. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55571. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55572. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55573. }
  55574. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55575. import { Scene } from "babylonjs/scene";
  55576. import { Texture } from "babylonjs/Materials/Textures/texture";
  55577. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55578. /**
  55579. * 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.
  55580. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55581. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55582. */
  55583. export class CustomProceduralTexture extends ProceduralTexture {
  55584. private _animate;
  55585. private _time;
  55586. private _config;
  55587. private _texturePath;
  55588. /**
  55589. * Instantiates a new Custom Procedural Texture.
  55590. * 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.
  55591. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55592. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55593. * @param name Define the name of the texture
  55594. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55595. * @param size Define the size of the texture to create
  55596. * @param scene Define the scene the texture belongs to
  55597. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55598. * @param generateMipMaps Define if the texture should creates mip maps or not
  55599. */
  55600. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55601. private _loadJson;
  55602. /**
  55603. * Is the texture ready to be used ? (rendered at least once)
  55604. * @returns true if ready, otherwise, false.
  55605. */
  55606. isReady(): boolean;
  55607. /**
  55608. * Render the texture to its associated render target.
  55609. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55610. */
  55611. render(useCameraPostProcess?: boolean): void;
  55612. /**
  55613. * Update the list of dependant textures samplers in the shader.
  55614. */
  55615. updateTextures(): void;
  55616. /**
  55617. * Update the uniform values of the procedural texture in the shader.
  55618. */
  55619. updateShaderUniforms(): void;
  55620. /**
  55621. * Define if the texture animates or not.
  55622. */
  55623. animate: boolean;
  55624. }
  55625. }
  55626. declare module "babylonjs/Shaders/noise.fragment" {
  55627. /** @hidden */
  55628. export var noisePixelShader: {
  55629. name: string;
  55630. shader: string;
  55631. };
  55632. }
  55633. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55634. import { Nullable } from "babylonjs/types";
  55635. import { Scene } from "babylonjs/scene";
  55636. import { Texture } from "babylonjs/Materials/Textures/texture";
  55637. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55638. import "babylonjs/Shaders/noise.fragment";
  55639. /**
  55640. * Class used to generate noise procedural textures
  55641. */
  55642. export class NoiseProceduralTexture extends ProceduralTexture {
  55643. private _time;
  55644. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55645. brightness: number;
  55646. /** Defines the number of octaves to process */
  55647. octaves: number;
  55648. /** Defines the level of persistence (0.8 by default) */
  55649. persistence: number;
  55650. /** Gets or sets animation speed factor (default is 1) */
  55651. animationSpeedFactor: number;
  55652. /**
  55653. * Creates a new NoiseProceduralTexture
  55654. * @param name defines the name fo the texture
  55655. * @param size defines the size of the texture (default is 256)
  55656. * @param scene defines the hosting scene
  55657. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55658. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55659. */
  55660. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55661. private _updateShaderUniforms;
  55662. protected _getDefines(): string;
  55663. /** Generate the current state of the procedural texture */
  55664. render(useCameraPostProcess?: boolean): void;
  55665. /**
  55666. * Serializes this noise procedural texture
  55667. * @returns a serialized noise procedural texture object
  55668. */
  55669. serialize(): any;
  55670. /**
  55671. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55672. * @param parsedTexture defines parsed texture data
  55673. * @param scene defines the current scene
  55674. * @param rootUrl defines the root URL containing noise procedural texture information
  55675. * @returns a parsed NoiseProceduralTexture
  55676. */
  55677. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55678. }
  55679. }
  55680. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55681. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55682. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55683. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55684. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55685. }
  55686. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55687. import { Nullable } from "babylonjs/types";
  55688. import { Scene } from "babylonjs/scene";
  55689. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55690. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55691. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55692. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55693. /**
  55694. * Raw cube texture where the raw buffers are passed in
  55695. */
  55696. export class RawCubeTexture extends CubeTexture {
  55697. /**
  55698. * Creates a cube texture where the raw buffers are passed in.
  55699. * @param scene defines the scene the texture is attached to
  55700. * @param data defines the array of data to use to create each face
  55701. * @param size defines the size of the textures
  55702. * @param format defines the format of the data
  55703. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55704. * @param generateMipMaps defines if the engine should generate the mip levels
  55705. * @param invertY defines if data must be stored with Y axis inverted
  55706. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55707. * @param compression defines the compression used (null by default)
  55708. */
  55709. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55710. /**
  55711. * Updates the raw cube texture.
  55712. * @param data defines the data to store
  55713. * @param format defines the data format
  55714. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55715. * @param invertY defines if data must be stored with Y axis inverted
  55716. * @param compression defines the compression used (null by default)
  55717. * @param level defines which level of the texture to update
  55718. */
  55719. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55720. /**
  55721. * Updates a raw cube texture with RGBD encoded data.
  55722. * @param data defines the array of data [mipmap][face] to use to create each face
  55723. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55724. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55725. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55726. * @returns a promsie that resolves when the operation is complete
  55727. */
  55728. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55729. /**
  55730. * Clones the raw cube texture.
  55731. * @return a new cube texture
  55732. */
  55733. clone(): CubeTexture;
  55734. /** @hidden */
  55735. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55736. }
  55737. }
  55738. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55739. import { Scene } from "babylonjs/scene";
  55740. import { Texture } from "babylonjs/Materials/Textures/texture";
  55741. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55742. /**
  55743. * Class used to store 3D textures containing user data
  55744. */
  55745. export class RawTexture3D extends Texture {
  55746. /** Gets or sets the texture format to use */
  55747. format: number;
  55748. private _engine;
  55749. /**
  55750. * Create a new RawTexture3D
  55751. * @param data defines the data of the texture
  55752. * @param width defines the width of the texture
  55753. * @param height defines the height of the texture
  55754. * @param depth defines the depth of the texture
  55755. * @param format defines the texture format to use
  55756. * @param scene defines the hosting scene
  55757. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55758. * @param invertY defines if texture must be stored with Y axis inverted
  55759. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55760. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55761. */
  55762. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55763. /** Gets or sets the texture format to use */
  55764. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55765. /**
  55766. * Update the texture with new data
  55767. * @param data defines the data to store in the texture
  55768. */
  55769. update(data: ArrayBufferView): void;
  55770. }
  55771. }
  55772. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55773. import { Scene } from "babylonjs/scene";
  55774. import { Texture } from "babylonjs/Materials/Textures/texture";
  55775. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55776. /**
  55777. * Class used to store 2D array textures containing user data
  55778. */
  55779. export class RawTexture2DArray extends Texture {
  55780. /** Gets or sets the texture format to use */
  55781. format: number;
  55782. private _engine;
  55783. /**
  55784. * Create a new RawTexture2DArray
  55785. * @param data defines the data of the texture
  55786. * @param width defines the width of the texture
  55787. * @param height defines the height of the texture
  55788. * @param depth defines the number of layers of the texture
  55789. * @param format defines the texture format to use
  55790. * @param scene defines the hosting scene
  55791. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55792. * @param invertY defines if texture must be stored with Y axis inverted
  55793. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55794. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55795. */
  55796. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55797. /** Gets or sets the texture format to use */
  55798. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55799. /**
  55800. * Update the texture with new data
  55801. * @param data defines the data to store in the texture
  55802. */
  55803. update(data: ArrayBufferView): void;
  55804. }
  55805. }
  55806. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55807. import { Scene } from "babylonjs/scene";
  55808. import { Plane } from "babylonjs/Maths/math.plane";
  55809. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55810. /**
  55811. * Creates a refraction texture used by refraction channel of the standard material.
  55812. * It is like a mirror but to see through a material.
  55813. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55814. */
  55815. export class RefractionTexture extends RenderTargetTexture {
  55816. /**
  55817. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55818. * 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.
  55819. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55820. */
  55821. refractionPlane: Plane;
  55822. /**
  55823. * Define how deep under the surface we should see.
  55824. */
  55825. depth: number;
  55826. /**
  55827. * Creates a refraction texture used by refraction channel of the standard material.
  55828. * It is like a mirror but to see through a material.
  55829. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55830. * @param name Define the texture name
  55831. * @param size Define the size of the underlying texture
  55832. * @param scene Define the scene the refraction belongs to
  55833. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55834. */
  55835. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55836. /**
  55837. * Clone the refraction texture.
  55838. * @returns the cloned texture
  55839. */
  55840. clone(): RefractionTexture;
  55841. /**
  55842. * Serialize the texture to a JSON representation you could use in Parse later on
  55843. * @returns the serialized JSON representation
  55844. */
  55845. serialize(): any;
  55846. }
  55847. }
  55848. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55849. import { Nullable } from "babylonjs/types";
  55850. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55851. import { Matrix } from "babylonjs/Maths/math.vector";
  55852. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55853. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55854. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55855. import { Scene } from "babylonjs/scene";
  55856. /**
  55857. * Defines the options related to the creation of an HtmlElementTexture
  55858. */
  55859. export interface IHtmlElementTextureOptions {
  55860. /**
  55861. * Defines wether mip maps should be created or not.
  55862. */
  55863. generateMipMaps?: boolean;
  55864. /**
  55865. * Defines the sampling mode of the texture.
  55866. */
  55867. samplingMode?: number;
  55868. /**
  55869. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55870. */
  55871. engine: Nullable<ThinEngine>;
  55872. /**
  55873. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55874. */
  55875. scene: Nullable<Scene>;
  55876. }
  55877. /**
  55878. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55879. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55880. * is automatically managed.
  55881. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55882. * in your application.
  55883. *
  55884. * As the update is not automatic, you need to call them manually.
  55885. */
  55886. export class HtmlElementTexture extends BaseTexture {
  55887. /**
  55888. * The texture URL.
  55889. */
  55890. element: HTMLVideoElement | HTMLCanvasElement;
  55891. private static readonly DefaultOptions;
  55892. private _textureMatrix;
  55893. private _engine;
  55894. private _isVideo;
  55895. private _generateMipMaps;
  55896. private _samplingMode;
  55897. /**
  55898. * Instantiates a HtmlElementTexture from the following parameters.
  55899. *
  55900. * @param name Defines the name of the texture
  55901. * @param element Defines the video or canvas the texture is filled with
  55902. * @param options Defines the other none mandatory texture creation options
  55903. */
  55904. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55905. private _createInternalTexture;
  55906. /**
  55907. * Returns the texture matrix used in most of the material.
  55908. */
  55909. getTextureMatrix(): Matrix;
  55910. /**
  55911. * Updates the content of the texture.
  55912. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55913. */
  55914. update(invertY?: Nullable<boolean>): void;
  55915. }
  55916. }
  55917. declare module "babylonjs/Materials/Textures/index" {
  55918. export * from "babylonjs/Materials/Textures/baseTexture";
  55919. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55920. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55921. export * from "babylonjs/Materials/Textures/cubeTexture";
  55922. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55923. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55924. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55925. export * from "babylonjs/Materials/Textures/internalTexture";
  55926. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55927. export * from "babylonjs/Materials/Textures/Loaders/index";
  55928. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55929. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55930. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55931. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55932. export * from "babylonjs/Materials/Textures/rawTexture";
  55933. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55934. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55935. export * from "babylonjs/Materials/Textures/refractionTexture";
  55936. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55937. export * from "babylonjs/Materials/Textures/texture";
  55938. export * from "babylonjs/Materials/Textures/videoTexture";
  55939. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55940. }
  55941. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55942. /**
  55943. * Enum used to define the target of a block
  55944. */
  55945. export enum NodeMaterialBlockTargets {
  55946. /** Vertex shader */
  55947. Vertex = 1,
  55948. /** Fragment shader */
  55949. Fragment = 2,
  55950. /** Neutral */
  55951. Neutral = 4,
  55952. /** Vertex and Fragment */
  55953. VertexAndFragment = 3
  55954. }
  55955. }
  55956. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55957. /**
  55958. * Defines the kind of connection point for node based material
  55959. */
  55960. export enum NodeMaterialBlockConnectionPointTypes {
  55961. /** Float */
  55962. Float = 1,
  55963. /** Int */
  55964. Int = 2,
  55965. /** Vector2 */
  55966. Vector2 = 4,
  55967. /** Vector3 */
  55968. Vector3 = 8,
  55969. /** Vector4 */
  55970. Vector4 = 16,
  55971. /** Color3 */
  55972. Color3 = 32,
  55973. /** Color4 */
  55974. Color4 = 64,
  55975. /** Matrix */
  55976. Matrix = 128,
  55977. /** Detect type based on connection */
  55978. AutoDetect = 1024,
  55979. /** Output type that will be defined by input type */
  55980. BasedOnInput = 2048
  55981. }
  55982. }
  55983. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55984. /**
  55985. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55986. */
  55987. export enum NodeMaterialBlockConnectionPointMode {
  55988. /** Value is an uniform */
  55989. Uniform = 0,
  55990. /** Value is a mesh attribute */
  55991. Attribute = 1,
  55992. /** Value is a varying between vertex and fragment shaders */
  55993. Varying = 2,
  55994. /** Mode is undefined */
  55995. Undefined = 3
  55996. }
  55997. }
  55998. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55999. /**
  56000. * Enum used to define system values e.g. values automatically provided by the system
  56001. */
  56002. export enum NodeMaterialSystemValues {
  56003. /** World */
  56004. World = 1,
  56005. /** View */
  56006. View = 2,
  56007. /** Projection */
  56008. Projection = 3,
  56009. /** ViewProjection */
  56010. ViewProjection = 4,
  56011. /** WorldView */
  56012. WorldView = 5,
  56013. /** WorldViewProjection */
  56014. WorldViewProjection = 6,
  56015. /** CameraPosition */
  56016. CameraPosition = 7,
  56017. /** Fog Color */
  56018. FogColor = 8,
  56019. /** Delta time */
  56020. DeltaTime = 9
  56021. }
  56022. }
  56023. declare module "babylonjs/Materials/Node/Enums/index" {
  56024. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56025. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56026. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  56027. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56028. }
  56029. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  56030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56031. /**
  56032. * Root class for all node material optimizers
  56033. */
  56034. export class NodeMaterialOptimizer {
  56035. /**
  56036. * Function used to optimize a NodeMaterial graph
  56037. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56038. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56039. */
  56040. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56041. }
  56042. }
  56043. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  56044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56047. import { Scene } from "babylonjs/scene";
  56048. /**
  56049. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56050. */
  56051. export class TransformBlock extends NodeMaterialBlock {
  56052. /**
  56053. * Defines the value to use to complement W value to transform it to a Vector4
  56054. */
  56055. complementW: number;
  56056. /**
  56057. * Defines the value to use to complement z value to transform it to a Vector4
  56058. */
  56059. complementZ: number;
  56060. /**
  56061. * Creates a new TransformBlock
  56062. * @param name defines the block name
  56063. */
  56064. constructor(name: string);
  56065. /**
  56066. * Gets the current class name
  56067. * @returns the class name
  56068. */
  56069. getClassName(): string;
  56070. /**
  56071. * Gets the vector input
  56072. */
  56073. readonly vector: NodeMaterialConnectionPoint;
  56074. /**
  56075. * Gets the output component
  56076. */
  56077. readonly output: NodeMaterialConnectionPoint;
  56078. /**
  56079. * Gets the matrix transform input
  56080. */
  56081. readonly transform: NodeMaterialConnectionPoint;
  56082. protected _buildBlock(state: NodeMaterialBuildState): this;
  56083. serialize(): any;
  56084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56085. protected _dumpPropertiesCode(): string;
  56086. }
  56087. }
  56088. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  56089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56090. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56092. /**
  56093. * Block used to output the vertex position
  56094. */
  56095. export class VertexOutputBlock extends NodeMaterialBlock {
  56096. /**
  56097. * Creates a new VertexOutputBlock
  56098. * @param name defines the block name
  56099. */
  56100. constructor(name: string);
  56101. /**
  56102. * Gets the current class name
  56103. * @returns the class name
  56104. */
  56105. getClassName(): string;
  56106. /**
  56107. * Gets the vector input component
  56108. */
  56109. readonly vector: NodeMaterialConnectionPoint;
  56110. protected _buildBlock(state: NodeMaterialBuildState): this;
  56111. }
  56112. }
  56113. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  56114. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56115. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56116. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56117. /**
  56118. * Block used to output the final color
  56119. */
  56120. export class FragmentOutputBlock extends NodeMaterialBlock {
  56121. /**
  56122. * Create a new FragmentOutputBlock
  56123. * @param name defines the block name
  56124. */
  56125. constructor(name: string);
  56126. /**
  56127. * Gets the current class name
  56128. * @returns the class name
  56129. */
  56130. getClassName(): string;
  56131. /**
  56132. * Gets the rgba input component
  56133. */
  56134. readonly rgba: NodeMaterialConnectionPoint;
  56135. /**
  56136. * Gets the rgb input component
  56137. */
  56138. readonly rgb: NodeMaterialConnectionPoint;
  56139. /**
  56140. * Gets the a input component
  56141. */
  56142. readonly a: NodeMaterialConnectionPoint;
  56143. protected _buildBlock(state: NodeMaterialBuildState): this;
  56144. }
  56145. }
  56146. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56147. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56148. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56149. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56150. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56152. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56153. import { Effect } from "babylonjs/Materials/effect";
  56154. import { Mesh } from "babylonjs/Meshes/mesh";
  56155. import { Nullable } from "babylonjs/types";
  56156. import { Scene } from "babylonjs/scene";
  56157. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56158. /**
  56159. * Block used to read a reflection texture from a sampler
  56160. */
  56161. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56162. private _define3DName;
  56163. private _defineCubicName;
  56164. private _defineExplicitName;
  56165. private _defineProjectionName;
  56166. private _defineLocalCubicName;
  56167. private _defineSphericalName;
  56168. private _definePlanarName;
  56169. private _defineEquirectangularName;
  56170. private _defineMirroredEquirectangularFixedName;
  56171. private _defineEquirectangularFixedName;
  56172. private _defineSkyboxName;
  56173. private _cubeSamplerName;
  56174. private _2DSamplerName;
  56175. private _positionUVWName;
  56176. private _directionWName;
  56177. private _reflectionCoordsName;
  56178. private _reflection2DCoordsName;
  56179. private _reflectionColorName;
  56180. private _reflectionMatrixName;
  56181. /**
  56182. * Gets or sets the texture associated with the node
  56183. */
  56184. texture: Nullable<BaseTexture>;
  56185. /**
  56186. * Create a new TextureBlock
  56187. * @param name defines the block name
  56188. */
  56189. constructor(name: string);
  56190. /**
  56191. * Gets the current class name
  56192. * @returns the class name
  56193. */
  56194. getClassName(): string;
  56195. /**
  56196. * Gets the world position input component
  56197. */
  56198. readonly position: NodeMaterialConnectionPoint;
  56199. /**
  56200. * Gets the world position input component
  56201. */
  56202. readonly worldPosition: NodeMaterialConnectionPoint;
  56203. /**
  56204. * Gets the world normal input component
  56205. */
  56206. readonly worldNormal: NodeMaterialConnectionPoint;
  56207. /**
  56208. * Gets the world input component
  56209. */
  56210. readonly world: NodeMaterialConnectionPoint;
  56211. /**
  56212. * Gets the camera (or eye) position component
  56213. */
  56214. readonly cameraPosition: NodeMaterialConnectionPoint;
  56215. /**
  56216. * Gets the view input component
  56217. */
  56218. readonly view: NodeMaterialConnectionPoint;
  56219. /**
  56220. * Gets the rgb output component
  56221. */
  56222. readonly rgb: NodeMaterialConnectionPoint;
  56223. /**
  56224. * Gets the r output component
  56225. */
  56226. readonly r: NodeMaterialConnectionPoint;
  56227. /**
  56228. * Gets the g output component
  56229. */
  56230. readonly g: NodeMaterialConnectionPoint;
  56231. /**
  56232. * Gets the b output component
  56233. */
  56234. readonly b: NodeMaterialConnectionPoint;
  56235. autoConfigure(material: NodeMaterial): void;
  56236. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56237. isReady(): boolean;
  56238. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56239. private _injectVertexCode;
  56240. private _writeOutput;
  56241. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56242. protected _dumpPropertiesCode(): string;
  56243. serialize(): any;
  56244. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56245. }
  56246. }
  56247. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56248. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56249. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56250. import { Scene } from "babylonjs/scene";
  56251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56252. import { Matrix } from "babylonjs/Maths/math.vector";
  56253. import { Mesh } from "babylonjs/Meshes/mesh";
  56254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56255. import { Observable } from "babylonjs/Misc/observable";
  56256. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56257. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56258. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56259. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56260. import { Nullable } from "babylonjs/types";
  56261. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56262. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56263. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56264. /**
  56265. * Interface used to configure the node material editor
  56266. */
  56267. export interface INodeMaterialEditorOptions {
  56268. /** Define the URl to load node editor script */
  56269. editorURL?: string;
  56270. }
  56271. /** @hidden */
  56272. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56273. /** BONES */
  56274. NUM_BONE_INFLUENCERS: number;
  56275. BonesPerMesh: number;
  56276. BONETEXTURE: boolean;
  56277. /** MORPH TARGETS */
  56278. MORPHTARGETS: boolean;
  56279. MORPHTARGETS_NORMAL: boolean;
  56280. MORPHTARGETS_TANGENT: boolean;
  56281. MORPHTARGETS_UV: boolean;
  56282. NUM_MORPH_INFLUENCERS: number;
  56283. /** IMAGE PROCESSING */
  56284. IMAGEPROCESSING: boolean;
  56285. VIGNETTE: boolean;
  56286. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56287. VIGNETTEBLENDMODEOPAQUE: boolean;
  56288. TONEMAPPING: boolean;
  56289. TONEMAPPING_ACES: boolean;
  56290. CONTRAST: boolean;
  56291. EXPOSURE: boolean;
  56292. COLORCURVES: boolean;
  56293. COLORGRADING: boolean;
  56294. COLORGRADING3D: boolean;
  56295. SAMPLER3DGREENDEPTH: boolean;
  56296. SAMPLER3DBGRMAP: boolean;
  56297. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56298. /** MISC. */
  56299. BUMPDIRECTUV: number;
  56300. constructor();
  56301. setValue(name: string, value: boolean): void;
  56302. }
  56303. /**
  56304. * Class used to configure NodeMaterial
  56305. */
  56306. export interface INodeMaterialOptions {
  56307. /**
  56308. * Defines if blocks should emit comments
  56309. */
  56310. emitComments: boolean;
  56311. }
  56312. /**
  56313. * Class used to create a node based material built by assembling shader blocks
  56314. */
  56315. export class NodeMaterial extends PushMaterial {
  56316. private static _BuildIdGenerator;
  56317. private _options;
  56318. private _vertexCompilationState;
  56319. private _fragmentCompilationState;
  56320. private _sharedData;
  56321. private _buildId;
  56322. private _buildWasSuccessful;
  56323. private _cachedWorldViewMatrix;
  56324. private _cachedWorldViewProjectionMatrix;
  56325. private _optimizers;
  56326. private _animationFrame;
  56327. /** Define the URl to load node editor script */
  56328. static EditorURL: string;
  56329. private BJSNODEMATERIALEDITOR;
  56330. /** Get the inspector from bundle or global */
  56331. private _getGlobalNodeMaterialEditor;
  56332. /**
  56333. * Gets or sets data used by visual editor
  56334. * @see https://nme.babylonjs.com
  56335. */
  56336. editorData: any;
  56337. /**
  56338. * 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)
  56339. */
  56340. ignoreAlpha: boolean;
  56341. /**
  56342. * Defines the maximum number of lights that can be used in the material
  56343. */
  56344. maxSimultaneousLights: number;
  56345. /**
  56346. * Observable raised when the material is built
  56347. */
  56348. onBuildObservable: Observable<NodeMaterial>;
  56349. /**
  56350. * Gets or sets the root nodes of the material vertex shader
  56351. */
  56352. _vertexOutputNodes: NodeMaterialBlock[];
  56353. /**
  56354. * Gets or sets the root nodes of the material fragment (pixel) shader
  56355. */
  56356. _fragmentOutputNodes: NodeMaterialBlock[];
  56357. /** Gets or sets options to control the node material overall behavior */
  56358. options: INodeMaterialOptions;
  56359. /**
  56360. * Default configuration related to image processing available in the standard Material.
  56361. */
  56362. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56363. /**
  56364. * Gets the image processing configuration used either in this material.
  56365. */
  56366. /**
  56367. * Sets the Default image processing configuration used either in the this material.
  56368. *
  56369. * If sets to null, the scene one is in use.
  56370. */
  56371. imageProcessingConfiguration: ImageProcessingConfiguration;
  56372. /**
  56373. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56374. */
  56375. attachedBlocks: NodeMaterialBlock[];
  56376. /**
  56377. * Create a new node based material
  56378. * @param name defines the material name
  56379. * @param scene defines the hosting scene
  56380. * @param options defines creation option
  56381. */
  56382. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56383. /**
  56384. * Gets the current class name of the material e.g. "NodeMaterial"
  56385. * @returns the class name
  56386. */
  56387. getClassName(): string;
  56388. /**
  56389. * Keep track of the image processing observer to allow dispose and replace.
  56390. */
  56391. private _imageProcessingObserver;
  56392. /**
  56393. * Attaches a new image processing configuration to the Standard Material.
  56394. * @param configuration
  56395. */
  56396. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56397. /**
  56398. * Get a block by its name
  56399. * @param name defines the name of the block to retrieve
  56400. * @returns the required block or null if not found
  56401. */
  56402. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56403. /**
  56404. * Get a block by its name
  56405. * @param predicate defines the predicate used to find the good candidate
  56406. * @returns the required block or null if not found
  56407. */
  56408. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56409. /**
  56410. * Get an input block by its name
  56411. * @param predicate defines the predicate used to find the good candidate
  56412. * @returns the required input block or null if not found
  56413. */
  56414. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56415. /**
  56416. * Gets the list of input blocks attached to this material
  56417. * @returns an array of InputBlocks
  56418. */
  56419. getInputBlocks(): InputBlock[];
  56420. /**
  56421. * Adds a new optimizer to the list of optimizers
  56422. * @param optimizer defines the optimizers to add
  56423. * @returns the current material
  56424. */
  56425. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56426. /**
  56427. * Remove an optimizer from the list of optimizers
  56428. * @param optimizer defines the optimizers to remove
  56429. * @returns the current material
  56430. */
  56431. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56432. /**
  56433. * Add a new block to the list of output nodes
  56434. * @param node defines the node to add
  56435. * @returns the current material
  56436. */
  56437. addOutputNode(node: NodeMaterialBlock): this;
  56438. /**
  56439. * Remove a block from the list of root nodes
  56440. * @param node defines the node to remove
  56441. * @returns the current material
  56442. */
  56443. removeOutputNode(node: NodeMaterialBlock): this;
  56444. private _addVertexOutputNode;
  56445. private _removeVertexOutputNode;
  56446. private _addFragmentOutputNode;
  56447. private _removeFragmentOutputNode;
  56448. /**
  56449. * Specifies if the material will require alpha blending
  56450. * @returns a boolean specifying if alpha blending is needed
  56451. */
  56452. needAlphaBlending(): boolean;
  56453. /**
  56454. * Specifies if this material should be rendered in alpha test mode
  56455. * @returns a boolean specifying if an alpha test is needed.
  56456. */
  56457. needAlphaTesting(): boolean;
  56458. private _initializeBlock;
  56459. private _resetDualBlocks;
  56460. /**
  56461. * Build the material and generates the inner effect
  56462. * @param verbose defines if the build should log activity
  56463. */
  56464. build(verbose?: boolean): void;
  56465. /**
  56466. * Runs an otpimization phase to try to improve the shader code
  56467. */
  56468. optimize(): void;
  56469. private _prepareDefinesForAttributes;
  56470. /**
  56471. * Get if the submesh is ready to be used and all its information available.
  56472. * Child classes can use it to update shaders
  56473. * @param mesh defines the mesh to check
  56474. * @param subMesh defines which submesh to check
  56475. * @param useInstances specifies that instances should be used
  56476. * @returns a boolean indicating that the submesh is ready or not
  56477. */
  56478. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56479. /**
  56480. * Get a string representing the shaders built by the current node graph
  56481. */
  56482. readonly compiledShaders: string;
  56483. /**
  56484. * Binds the world matrix to the material
  56485. * @param world defines the world transformation matrix
  56486. */
  56487. bindOnlyWorldMatrix(world: Matrix): void;
  56488. /**
  56489. * Binds the submesh to this material by preparing the effect and shader to draw
  56490. * @param world defines the world transformation matrix
  56491. * @param mesh defines the mesh containing the submesh
  56492. * @param subMesh defines the submesh to bind the material to
  56493. */
  56494. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56495. /**
  56496. * Gets the active textures from the material
  56497. * @returns an array of textures
  56498. */
  56499. getActiveTextures(): BaseTexture[];
  56500. /**
  56501. * Gets the list of texture blocks
  56502. * @returns an array of texture blocks
  56503. */
  56504. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56505. /**
  56506. * Specifies if the material uses a texture
  56507. * @param texture defines the texture to check against the material
  56508. * @returns a boolean specifying if the material uses the texture
  56509. */
  56510. hasTexture(texture: BaseTexture): boolean;
  56511. /**
  56512. * Disposes the material
  56513. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56514. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56515. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56516. */
  56517. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56518. /** Creates the node editor window. */
  56519. private _createNodeEditor;
  56520. /**
  56521. * Launch the node material editor
  56522. * @param config Define the configuration of the editor
  56523. * @return a promise fulfilled when the node editor is visible
  56524. */
  56525. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56526. /**
  56527. * Clear the current material
  56528. */
  56529. clear(): void;
  56530. /**
  56531. * Clear the current material and set it to a default state
  56532. */
  56533. setToDefault(): void;
  56534. /**
  56535. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56536. * @param url defines the url to load from
  56537. * @returns a promise that will fullfil when the material is fully loaded
  56538. */
  56539. loadAsync(url: string): Promise<void>;
  56540. private _gatherBlocks;
  56541. /**
  56542. * Generate a string containing the code declaration required to create an equivalent of this material
  56543. * @returns a string
  56544. */
  56545. generateCode(): string;
  56546. /**
  56547. * Serializes this material in a JSON representation
  56548. * @returns the serialized material object
  56549. */
  56550. serialize(): any;
  56551. private _restoreConnections;
  56552. /**
  56553. * Clear the current graph and load a new one from a serialization object
  56554. * @param source defines the JSON representation of the material
  56555. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56556. */
  56557. loadFromSerialization(source: any, rootUrl?: string): void;
  56558. /**
  56559. * Creates a node material from parsed material data
  56560. * @param source defines the JSON representation of the material
  56561. * @param scene defines the hosting scene
  56562. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56563. * @returns a new node material
  56564. */
  56565. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56566. /**
  56567. * Creates a new node material set to default basic configuration
  56568. * @param name defines the name of the material
  56569. * @param scene defines the hosting scene
  56570. * @returns a new NodeMaterial
  56571. */
  56572. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56573. }
  56574. }
  56575. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56576. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56577. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56578. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56581. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56582. import { Effect } from "babylonjs/Materials/effect";
  56583. import { Mesh } from "babylonjs/Meshes/mesh";
  56584. import { Nullable } from "babylonjs/types";
  56585. import { Texture } from "babylonjs/Materials/Textures/texture";
  56586. import { Scene } from "babylonjs/scene";
  56587. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56588. /**
  56589. * Block used to read a texture from a sampler
  56590. */
  56591. export class TextureBlock extends NodeMaterialBlock {
  56592. private _defineName;
  56593. private _linearDefineName;
  56594. private _tempTextureRead;
  56595. private _samplerName;
  56596. private _transformedUVName;
  56597. private _textureTransformName;
  56598. private _textureInfoName;
  56599. private _mainUVName;
  56600. private _mainUVDefineName;
  56601. /**
  56602. * Gets or sets the texture associated with the node
  56603. */
  56604. texture: Nullable<Texture>;
  56605. /**
  56606. * Create a new TextureBlock
  56607. * @param name defines the block name
  56608. */
  56609. constructor(name: string);
  56610. /**
  56611. * Gets the current class name
  56612. * @returns the class name
  56613. */
  56614. getClassName(): string;
  56615. /**
  56616. * Gets the uv input component
  56617. */
  56618. readonly uv: NodeMaterialConnectionPoint;
  56619. /**
  56620. * Gets the rgba output component
  56621. */
  56622. readonly rgba: NodeMaterialConnectionPoint;
  56623. /**
  56624. * Gets the rgb output component
  56625. */
  56626. readonly rgb: NodeMaterialConnectionPoint;
  56627. /**
  56628. * Gets the r output component
  56629. */
  56630. readonly r: NodeMaterialConnectionPoint;
  56631. /**
  56632. * Gets the g output component
  56633. */
  56634. readonly g: NodeMaterialConnectionPoint;
  56635. /**
  56636. * Gets the b output component
  56637. */
  56638. readonly b: NodeMaterialConnectionPoint;
  56639. /**
  56640. * Gets the a output component
  56641. */
  56642. readonly a: NodeMaterialConnectionPoint;
  56643. readonly target: NodeMaterialBlockTargets;
  56644. autoConfigure(material: NodeMaterial): void;
  56645. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56646. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56647. private _getTextureBase;
  56648. isReady(): boolean;
  56649. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56650. private readonly _isMixed;
  56651. private _injectVertexCode;
  56652. private _writeTextureRead;
  56653. private _writeOutput;
  56654. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56655. protected _dumpPropertiesCode(): string;
  56656. serialize(): any;
  56657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56658. }
  56659. }
  56660. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56663. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56664. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56665. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56666. import { Scene } from "babylonjs/scene";
  56667. /**
  56668. * Class used to store shared data between 2 NodeMaterialBuildState
  56669. */
  56670. export class NodeMaterialBuildStateSharedData {
  56671. /**
  56672. * Gets the list of emitted varyings
  56673. */
  56674. temps: string[];
  56675. /**
  56676. * Gets the list of emitted varyings
  56677. */
  56678. varyings: string[];
  56679. /**
  56680. * Gets the varying declaration string
  56681. */
  56682. varyingDeclaration: string;
  56683. /**
  56684. * Input blocks
  56685. */
  56686. inputBlocks: InputBlock[];
  56687. /**
  56688. * Input blocks
  56689. */
  56690. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56691. /**
  56692. * Bindable blocks (Blocks that need to set data to the effect)
  56693. */
  56694. bindableBlocks: NodeMaterialBlock[];
  56695. /**
  56696. * List of blocks that can provide a compilation fallback
  56697. */
  56698. blocksWithFallbacks: NodeMaterialBlock[];
  56699. /**
  56700. * List of blocks that can provide a define update
  56701. */
  56702. blocksWithDefines: NodeMaterialBlock[];
  56703. /**
  56704. * List of blocks that can provide a repeatable content
  56705. */
  56706. repeatableContentBlocks: NodeMaterialBlock[];
  56707. /**
  56708. * List of blocks that can provide a dynamic list of uniforms
  56709. */
  56710. dynamicUniformBlocks: NodeMaterialBlock[];
  56711. /**
  56712. * List of blocks that can block the isReady function for the material
  56713. */
  56714. blockingBlocks: NodeMaterialBlock[];
  56715. /**
  56716. * Gets the list of animated inputs
  56717. */
  56718. animatedInputs: InputBlock[];
  56719. /**
  56720. * Build Id used to avoid multiple recompilations
  56721. */
  56722. buildId: number;
  56723. /** List of emitted variables */
  56724. variableNames: {
  56725. [key: string]: number;
  56726. };
  56727. /** List of emitted defines */
  56728. defineNames: {
  56729. [key: string]: number;
  56730. };
  56731. /** Should emit comments? */
  56732. emitComments: boolean;
  56733. /** Emit build activity */
  56734. verbose: boolean;
  56735. /** Gets or sets the hosting scene */
  56736. scene: Scene;
  56737. /**
  56738. * Gets the compilation hints emitted at compilation time
  56739. */
  56740. hints: {
  56741. needWorldViewMatrix: boolean;
  56742. needWorldViewProjectionMatrix: boolean;
  56743. needAlphaBlending: boolean;
  56744. needAlphaTesting: boolean;
  56745. };
  56746. /**
  56747. * List of compilation checks
  56748. */
  56749. checks: {
  56750. emitVertex: boolean;
  56751. emitFragment: boolean;
  56752. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56753. };
  56754. /** Creates a new shared data */
  56755. constructor();
  56756. /**
  56757. * Emits console errors and exceptions if there is a failing check
  56758. */
  56759. emitErrors(): void;
  56760. }
  56761. }
  56762. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56763. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56764. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56765. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56766. /**
  56767. * Class used to store node based material build state
  56768. */
  56769. export class NodeMaterialBuildState {
  56770. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56771. supportUniformBuffers: boolean;
  56772. /**
  56773. * Gets the list of emitted attributes
  56774. */
  56775. attributes: string[];
  56776. /**
  56777. * Gets the list of emitted uniforms
  56778. */
  56779. uniforms: string[];
  56780. /**
  56781. * Gets the list of emitted constants
  56782. */
  56783. constants: string[];
  56784. /**
  56785. * Gets the list of emitted samplers
  56786. */
  56787. samplers: string[];
  56788. /**
  56789. * Gets the list of emitted functions
  56790. */
  56791. functions: {
  56792. [key: string]: string;
  56793. };
  56794. /**
  56795. * Gets the list of emitted extensions
  56796. */
  56797. extensions: {
  56798. [key: string]: string;
  56799. };
  56800. /**
  56801. * Gets the target of the compilation state
  56802. */
  56803. target: NodeMaterialBlockTargets;
  56804. /**
  56805. * Gets the list of emitted counters
  56806. */
  56807. counters: {
  56808. [key: string]: number;
  56809. };
  56810. /**
  56811. * Shared data between multiple NodeMaterialBuildState instances
  56812. */
  56813. sharedData: NodeMaterialBuildStateSharedData;
  56814. /** @hidden */
  56815. _vertexState: NodeMaterialBuildState;
  56816. /** @hidden */
  56817. _attributeDeclaration: string;
  56818. /** @hidden */
  56819. _uniformDeclaration: string;
  56820. /** @hidden */
  56821. _constantDeclaration: string;
  56822. /** @hidden */
  56823. _samplerDeclaration: string;
  56824. /** @hidden */
  56825. _varyingTransfer: string;
  56826. private _repeatableContentAnchorIndex;
  56827. /** @hidden */
  56828. _builtCompilationString: string;
  56829. /**
  56830. * Gets the emitted compilation strings
  56831. */
  56832. compilationString: string;
  56833. /**
  56834. * Finalize the compilation strings
  56835. * @param state defines the current compilation state
  56836. */
  56837. finalize(state: NodeMaterialBuildState): void;
  56838. /** @hidden */
  56839. readonly _repeatableContentAnchor: string;
  56840. /** @hidden */
  56841. _getFreeVariableName(prefix: string): string;
  56842. /** @hidden */
  56843. _getFreeDefineName(prefix: string): string;
  56844. /** @hidden */
  56845. _excludeVariableName(name: string): void;
  56846. /** @hidden */
  56847. _emit2DSampler(name: string): void;
  56848. /** @hidden */
  56849. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56850. /** @hidden */
  56851. _emitExtension(name: string, extension: string): void;
  56852. /** @hidden */
  56853. _emitFunction(name: string, code: string, comments: string): void;
  56854. /** @hidden */
  56855. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56856. replaceStrings?: {
  56857. search: RegExp;
  56858. replace: string;
  56859. }[];
  56860. repeatKey?: string;
  56861. }): string;
  56862. /** @hidden */
  56863. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56864. repeatKey?: string;
  56865. removeAttributes?: boolean;
  56866. removeUniforms?: boolean;
  56867. removeVaryings?: boolean;
  56868. removeIfDef?: boolean;
  56869. replaceStrings?: {
  56870. search: RegExp;
  56871. replace: string;
  56872. }[];
  56873. }, storeKey?: string): void;
  56874. /** @hidden */
  56875. _registerTempVariable(name: string): boolean;
  56876. /** @hidden */
  56877. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56878. /** @hidden */
  56879. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56880. /** @hidden */
  56881. _emitFloat(value: number): string;
  56882. }
  56883. }
  56884. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56885. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56887. import { Nullable } from "babylonjs/types";
  56888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56889. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56890. import { Effect } from "babylonjs/Materials/effect";
  56891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56892. import { Mesh } from "babylonjs/Meshes/mesh";
  56893. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56894. import { Scene } from "babylonjs/scene";
  56895. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56896. /**
  56897. * Defines a block that can be used inside a node based material
  56898. */
  56899. export class NodeMaterialBlock {
  56900. private _buildId;
  56901. private _buildTarget;
  56902. private _target;
  56903. private _isFinalMerger;
  56904. private _isInput;
  56905. protected _isUnique: boolean;
  56906. /** @hidden */
  56907. _codeVariableName: string;
  56908. /** @hidden */
  56909. _inputs: NodeMaterialConnectionPoint[];
  56910. /** @hidden */
  56911. _outputs: NodeMaterialConnectionPoint[];
  56912. /** @hidden */
  56913. _preparationId: number;
  56914. /**
  56915. * Gets or sets the name of the block
  56916. */
  56917. name: string;
  56918. /**
  56919. * Gets or sets the unique id of the node
  56920. */
  56921. uniqueId: number;
  56922. /**
  56923. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  56924. */
  56925. readonly isUnique: boolean;
  56926. /**
  56927. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56928. */
  56929. readonly isFinalMerger: boolean;
  56930. /**
  56931. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56932. */
  56933. readonly isInput: boolean;
  56934. /**
  56935. * Gets or sets the build Id
  56936. */
  56937. buildId: number;
  56938. /**
  56939. * Gets or sets the target of the block
  56940. */
  56941. target: NodeMaterialBlockTargets;
  56942. /**
  56943. * Gets the list of input points
  56944. */
  56945. readonly inputs: NodeMaterialConnectionPoint[];
  56946. /** Gets the list of output points */
  56947. readonly outputs: NodeMaterialConnectionPoint[];
  56948. /**
  56949. * Find an input by its name
  56950. * @param name defines the name of the input to look for
  56951. * @returns the input or null if not found
  56952. */
  56953. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56954. /**
  56955. * Find an output by its name
  56956. * @param name defines the name of the outputto look for
  56957. * @returns the output or null if not found
  56958. */
  56959. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56960. /**
  56961. * Creates a new NodeMaterialBlock
  56962. * @param name defines the block name
  56963. * @param target defines the target of that block (Vertex by default)
  56964. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56965. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56966. */
  56967. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56968. /**
  56969. * Initialize the block and prepare the context for build
  56970. * @param state defines the state that will be used for the build
  56971. */
  56972. initialize(state: NodeMaterialBuildState): void;
  56973. /**
  56974. * Bind data to effect. Will only be called for blocks with isBindable === true
  56975. * @param effect defines the effect to bind data to
  56976. * @param nodeMaterial defines the hosting NodeMaterial
  56977. * @param mesh defines the mesh that will be rendered
  56978. */
  56979. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56980. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56981. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56982. protected _writeFloat(value: number): string;
  56983. /**
  56984. * Gets the current class name e.g. "NodeMaterialBlock"
  56985. * @returns the class name
  56986. */
  56987. getClassName(): string;
  56988. /**
  56989. * Register a new input. Must be called inside a block constructor
  56990. * @param name defines the connection point name
  56991. * @param type defines the connection point type
  56992. * @param isOptional defines a boolean indicating that this input can be omitted
  56993. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56994. * @returns the current block
  56995. */
  56996. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56997. /**
  56998. * Register a new output. Must be called inside a block constructor
  56999. * @param name defines the connection point name
  57000. * @param type defines the connection point type
  57001. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57002. * @returns the current block
  57003. */
  57004. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57005. /**
  57006. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57007. * @param forOutput defines an optional connection point to check compatibility with
  57008. * @returns the first available input or null
  57009. */
  57010. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57011. /**
  57012. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57013. * @param forBlock defines an optional block to check compatibility with
  57014. * @returns the first available input or null
  57015. */
  57016. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57017. /**
  57018. * Gets the sibling of the given output
  57019. * @param current defines the current output
  57020. * @returns the next output in the list or null
  57021. */
  57022. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57023. /**
  57024. * Connect current block with another block
  57025. * @param other defines the block to connect with
  57026. * @param options define the various options to help pick the right connections
  57027. * @returns the current block
  57028. */
  57029. connectTo(other: NodeMaterialBlock, options?: {
  57030. input?: string;
  57031. output?: string;
  57032. outputSwizzle?: string;
  57033. }): this | undefined;
  57034. protected _buildBlock(state: NodeMaterialBuildState): void;
  57035. /**
  57036. * Add uniforms, samplers and uniform buffers at compilation time
  57037. * @param state defines the state to update
  57038. * @param nodeMaterial defines the node material requesting the update
  57039. * @param defines defines the material defines to update
  57040. * @param uniformBuffers defines the list of uniform buffer names
  57041. */
  57042. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57043. /**
  57044. * Add potential fallbacks if shader compilation fails
  57045. * @param mesh defines the mesh to be rendered
  57046. * @param fallbacks defines the current prioritized list of fallbacks
  57047. */
  57048. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57049. /**
  57050. * Initialize defines for shader compilation
  57051. * @param mesh defines the mesh to be rendered
  57052. * @param nodeMaterial defines the node material requesting the update
  57053. * @param defines defines the material defines to update
  57054. * @param useInstances specifies that instances should be used
  57055. */
  57056. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57057. /**
  57058. * Update defines for shader compilation
  57059. * @param mesh defines the mesh to be rendered
  57060. * @param nodeMaterial defines the node material requesting the update
  57061. * @param defines defines the material defines to update
  57062. * @param useInstances specifies that instances should be used
  57063. */
  57064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57065. /**
  57066. * Lets the block try to connect some inputs automatically
  57067. * @param material defines the hosting NodeMaterial
  57068. */
  57069. autoConfigure(material: NodeMaterial): void;
  57070. /**
  57071. * Function called when a block is declared as repeatable content generator
  57072. * @param vertexShaderState defines the current compilation state for the vertex shader
  57073. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57074. * @param mesh defines the mesh to be rendered
  57075. * @param defines defines the material defines to update
  57076. */
  57077. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57078. /**
  57079. * Checks if the block is ready
  57080. * @param mesh defines the mesh to be rendered
  57081. * @param nodeMaterial defines the node material requesting the update
  57082. * @param defines defines the material defines to update
  57083. * @param useInstances specifies that instances should be used
  57084. * @returns true if the block is ready
  57085. */
  57086. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57087. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57088. private _processBuild;
  57089. /**
  57090. * Compile the current node and generate the shader code
  57091. * @param state defines the current compilation state (uniforms, samplers, current string)
  57092. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57093. * @returns true if already built
  57094. */
  57095. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57096. protected _inputRename(name: string): string;
  57097. protected _outputRename(name: string): string;
  57098. protected _dumpPropertiesCode(): string;
  57099. /** @hidden */
  57100. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57101. /** @hidden */
  57102. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57103. /**
  57104. * Clone the current block to a new identical block
  57105. * @param scene defines the hosting scene
  57106. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57107. * @returns a copy of the current block
  57108. */
  57109. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57110. /**
  57111. * Serializes this block in a JSON representation
  57112. * @returns the serialized block object
  57113. */
  57114. serialize(): any;
  57115. /** @hidden */
  57116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57117. /**
  57118. * Release resources
  57119. */
  57120. dispose(): void;
  57121. }
  57122. }
  57123. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  57124. /**
  57125. * Enum defining the type of animations supported by InputBlock
  57126. */
  57127. export enum AnimatedInputBlockTypes {
  57128. /** No animation */
  57129. None = 0,
  57130. /** Time based animation. Will only work for floats */
  57131. Time = 1
  57132. }
  57133. }
  57134. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  57135. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57136. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57137. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57138. import { Nullable } from "babylonjs/types";
  57139. import { Effect } from "babylonjs/Materials/effect";
  57140. import { Matrix } from "babylonjs/Maths/math.vector";
  57141. import { Scene } from "babylonjs/scene";
  57142. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57143. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57144. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57145. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57146. /**
  57147. * Block used to expose an input value
  57148. */
  57149. export class InputBlock extends NodeMaterialBlock {
  57150. private _mode;
  57151. private _associatedVariableName;
  57152. private _storedValue;
  57153. private _valueCallback;
  57154. private _type;
  57155. private _animationType;
  57156. /** Gets or set a value used to limit the range of float values */
  57157. min: number;
  57158. /** Gets or set a value used to limit the range of float values */
  57159. max: number;
  57160. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57161. matrixMode: number;
  57162. /** @hidden */
  57163. _systemValue: Nullable<NodeMaterialSystemValues>;
  57164. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57165. visibleInInspector: boolean;
  57166. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57167. isConstant: boolean;
  57168. /**
  57169. * Gets or sets the connection point type (default is float)
  57170. */
  57171. readonly type: NodeMaterialBlockConnectionPointTypes;
  57172. /**
  57173. * Creates a new InputBlock
  57174. * @param name defines the block name
  57175. * @param target defines the target of that block (Vertex by default)
  57176. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57177. */
  57178. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57179. /**
  57180. * Gets the output component
  57181. */
  57182. readonly output: NodeMaterialConnectionPoint;
  57183. /**
  57184. * Set the source of this connection point to a vertex attribute
  57185. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57186. * @returns the current connection point
  57187. */
  57188. setAsAttribute(attributeName?: string): InputBlock;
  57189. /**
  57190. * Set the source of this connection point to a system value
  57191. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57192. * @returns the current connection point
  57193. */
  57194. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57195. /**
  57196. * Gets or sets the value of that point.
  57197. * Please note that this value will be ignored if valueCallback is defined
  57198. */
  57199. value: any;
  57200. /**
  57201. * Gets or sets a callback used to get the value of that point.
  57202. * Please note that setting this value will force the connection point to ignore the value property
  57203. */
  57204. valueCallback: () => any;
  57205. /**
  57206. * Gets or sets the associated variable name in the shader
  57207. */
  57208. associatedVariableName: string;
  57209. /** Gets or sets the type of animation applied to the input */
  57210. animationType: AnimatedInputBlockTypes;
  57211. /**
  57212. * Gets a boolean indicating that this connection point not defined yet
  57213. */
  57214. readonly isUndefined: boolean;
  57215. /**
  57216. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57217. * In this case the connection point name must be the name of the uniform to use.
  57218. * Can only be set on inputs
  57219. */
  57220. isUniform: boolean;
  57221. /**
  57222. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57223. * In this case the connection point name must be the name of the attribute to use
  57224. * Can only be set on inputs
  57225. */
  57226. isAttribute: boolean;
  57227. /**
  57228. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57229. * Can only be set on exit points
  57230. */
  57231. isVarying: boolean;
  57232. /**
  57233. * Gets a boolean indicating that the current connection point is a system value
  57234. */
  57235. readonly isSystemValue: boolean;
  57236. /**
  57237. * Gets or sets the current well known value or null if not defined as a system value
  57238. */
  57239. systemValue: Nullable<NodeMaterialSystemValues>;
  57240. /**
  57241. * Gets the current class name
  57242. * @returns the class name
  57243. */
  57244. getClassName(): string;
  57245. /**
  57246. * Animate the input if animationType !== None
  57247. * @param scene defines the rendering scene
  57248. */
  57249. animate(scene: Scene): void;
  57250. private _emitDefine;
  57251. initialize(state: NodeMaterialBuildState): void;
  57252. /**
  57253. * Set the input block to its default value (based on its type)
  57254. */
  57255. setDefaultValue(): void;
  57256. private _emitConstant;
  57257. private _emit;
  57258. /** @hidden */
  57259. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57260. /** @hidden */
  57261. _transmit(effect: Effect, scene: Scene): void;
  57262. protected _buildBlock(state: NodeMaterialBuildState): void;
  57263. protected _dumpPropertiesCode(): string;
  57264. serialize(): any;
  57265. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57266. }
  57267. }
  57268. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57269. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57270. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57271. import { Nullable } from "babylonjs/types";
  57272. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57273. import { Observable } from "babylonjs/Misc/observable";
  57274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57275. /**
  57276. * Enum used to define the compatibility state between two connection points
  57277. */
  57278. export enum NodeMaterialConnectionPointCompatibilityStates {
  57279. /** Points are compatibles */
  57280. Compatible = 0,
  57281. /** Points are incompatible because of their types */
  57282. TypeIncompatible = 1,
  57283. /** Points are incompatible because of their targets (vertex vs fragment) */
  57284. TargetIncompatible = 2
  57285. }
  57286. /**
  57287. * Defines a connection point for a block
  57288. */
  57289. export class NodeMaterialConnectionPoint {
  57290. /** @hidden */
  57291. _ownerBlock: NodeMaterialBlock;
  57292. /** @hidden */
  57293. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57294. private _endpoints;
  57295. private _associatedVariableName;
  57296. /** @hidden */
  57297. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57298. /** @hidden */
  57299. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57300. private _type;
  57301. /** @hidden */
  57302. _enforceAssociatedVariableName: boolean;
  57303. /**
  57304. * Gets or sets the additional types supported by this connection point
  57305. */
  57306. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57307. /**
  57308. * Gets or sets the additional types excluded by this connection point
  57309. */
  57310. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57311. /**
  57312. * Observable triggered when this point is connected
  57313. */
  57314. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57315. /**
  57316. * Gets or sets the associated variable name in the shader
  57317. */
  57318. associatedVariableName: string;
  57319. /**
  57320. * Gets or sets the connection point type (default is float)
  57321. */
  57322. type: NodeMaterialBlockConnectionPointTypes;
  57323. /**
  57324. * Gets or sets the connection point name
  57325. */
  57326. name: string;
  57327. /**
  57328. * Gets or sets a boolean indicating that this connection point can be omitted
  57329. */
  57330. isOptional: boolean;
  57331. /**
  57332. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57333. */
  57334. define: string;
  57335. /** @hidden */
  57336. _prioritizeVertex: boolean;
  57337. private _target;
  57338. /** Gets or sets the target of that connection point */
  57339. target: NodeMaterialBlockTargets;
  57340. /**
  57341. * Gets a boolean indicating that the current point is connected
  57342. */
  57343. readonly isConnected: boolean;
  57344. /**
  57345. * Gets a boolean indicating that the current point is connected to an input block
  57346. */
  57347. readonly isConnectedToInputBlock: boolean;
  57348. /**
  57349. * Gets a the connected input block (if any)
  57350. */
  57351. readonly connectInputBlock: Nullable<InputBlock>;
  57352. /** Get the other side of the connection (if any) */
  57353. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57354. /** Get the block that owns this connection point */
  57355. readonly ownerBlock: NodeMaterialBlock;
  57356. /** Get the block connected on the other side of this connection (if any) */
  57357. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57358. /** Get the block connected on the endpoints of this connection (if any) */
  57359. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57360. /** Gets the list of connected endpoints */
  57361. readonly endpoints: NodeMaterialConnectionPoint[];
  57362. /** Gets a boolean indicating if that output point is connected to at least one input */
  57363. readonly hasEndpoints: boolean;
  57364. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57365. readonly isConnectedInVertexShader: boolean;
  57366. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57367. readonly isConnectedInFragmentShader: boolean;
  57368. /**
  57369. * Creates a new connection point
  57370. * @param name defines the connection point name
  57371. * @param ownerBlock defines the block hosting this connection point
  57372. */
  57373. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57374. /**
  57375. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57376. * @returns the class name
  57377. */
  57378. getClassName(): string;
  57379. /**
  57380. * Gets a boolean indicating if the current point can be connected to another point
  57381. * @param connectionPoint defines the other connection point
  57382. * @returns a boolean
  57383. */
  57384. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57385. /**
  57386. * Gets a number indicating if the current point can be connected to another point
  57387. * @param connectionPoint defines the other connection point
  57388. * @returns a number defining the compatibility state
  57389. */
  57390. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57391. /**
  57392. * Connect this point to another connection point
  57393. * @param connectionPoint defines the other connection point
  57394. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57395. * @returns the current connection point
  57396. */
  57397. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57398. /**
  57399. * Disconnect this point from one of his endpoint
  57400. * @param endpoint defines the other connection point
  57401. * @returns the current connection point
  57402. */
  57403. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57404. /**
  57405. * Serializes this point in a JSON representation
  57406. * @returns the serialized point object
  57407. */
  57408. serialize(): any;
  57409. /**
  57410. * Release resources
  57411. */
  57412. dispose(): void;
  57413. }
  57414. }
  57415. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57416. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57417. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57419. import { Mesh } from "babylonjs/Meshes/mesh";
  57420. import { Effect } from "babylonjs/Materials/effect";
  57421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57422. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57423. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57424. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57425. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57426. /**
  57427. * Block used to add support for vertex skinning (bones)
  57428. */
  57429. export class BonesBlock extends NodeMaterialBlock {
  57430. /**
  57431. * Creates a new BonesBlock
  57432. * @param name defines the block name
  57433. */
  57434. constructor(name: string);
  57435. /**
  57436. * Initialize the block and prepare the context for build
  57437. * @param state defines the state that will be used for the build
  57438. */
  57439. initialize(state: NodeMaterialBuildState): void;
  57440. /**
  57441. * Gets the current class name
  57442. * @returns the class name
  57443. */
  57444. getClassName(): string;
  57445. /**
  57446. * Gets the matrix indices input component
  57447. */
  57448. readonly matricesIndices: NodeMaterialConnectionPoint;
  57449. /**
  57450. * Gets the matrix weights input component
  57451. */
  57452. readonly matricesWeights: NodeMaterialConnectionPoint;
  57453. /**
  57454. * Gets the extra matrix indices input component
  57455. */
  57456. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57457. /**
  57458. * Gets the extra matrix weights input component
  57459. */
  57460. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57461. /**
  57462. * Gets the world input component
  57463. */
  57464. readonly world: NodeMaterialConnectionPoint;
  57465. /**
  57466. * Gets the output component
  57467. */
  57468. readonly output: NodeMaterialConnectionPoint;
  57469. autoConfigure(material: NodeMaterial): void;
  57470. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57471. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57472. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57473. protected _buildBlock(state: NodeMaterialBuildState): this;
  57474. }
  57475. }
  57476. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57477. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57481. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57482. /**
  57483. * Block used to add support for instances
  57484. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57485. */
  57486. export class InstancesBlock extends NodeMaterialBlock {
  57487. /**
  57488. * Creates a new InstancesBlock
  57489. * @param name defines the block name
  57490. */
  57491. constructor(name: string);
  57492. /**
  57493. * Gets the current class name
  57494. * @returns the class name
  57495. */
  57496. getClassName(): string;
  57497. /**
  57498. * Gets the first world row input component
  57499. */
  57500. readonly world0: NodeMaterialConnectionPoint;
  57501. /**
  57502. * Gets the second world row input component
  57503. */
  57504. readonly world1: NodeMaterialConnectionPoint;
  57505. /**
  57506. * Gets the third world row input component
  57507. */
  57508. readonly world2: NodeMaterialConnectionPoint;
  57509. /**
  57510. * Gets the forth world row input component
  57511. */
  57512. readonly world3: NodeMaterialConnectionPoint;
  57513. /**
  57514. * Gets the world input component
  57515. */
  57516. readonly world: NodeMaterialConnectionPoint;
  57517. /**
  57518. * Gets the output component
  57519. */
  57520. readonly output: NodeMaterialConnectionPoint;
  57521. autoConfigure(material: NodeMaterial): void;
  57522. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57523. protected _buildBlock(state: NodeMaterialBuildState): this;
  57524. }
  57525. }
  57526. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57527. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57528. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57529. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57531. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57532. import { Effect } from "babylonjs/Materials/effect";
  57533. import { Mesh } from "babylonjs/Meshes/mesh";
  57534. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57535. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57536. /**
  57537. * Block used to add morph targets support to vertex shader
  57538. */
  57539. export class MorphTargetsBlock extends NodeMaterialBlock {
  57540. private _repeatableContentAnchor;
  57541. private _repeatebleContentGenerated;
  57542. /**
  57543. * Create a new MorphTargetsBlock
  57544. * @param name defines the block name
  57545. */
  57546. constructor(name: string);
  57547. /**
  57548. * Gets the current class name
  57549. * @returns the class name
  57550. */
  57551. getClassName(): string;
  57552. /**
  57553. * Gets the position input component
  57554. */
  57555. readonly position: NodeMaterialConnectionPoint;
  57556. /**
  57557. * Gets the normal input component
  57558. */
  57559. readonly normal: NodeMaterialConnectionPoint;
  57560. /**
  57561. * Gets the tangent input component
  57562. */
  57563. readonly tangent: NodeMaterialConnectionPoint;
  57564. /**
  57565. * Gets the tangent input component
  57566. */
  57567. readonly uv: NodeMaterialConnectionPoint;
  57568. /**
  57569. * Gets the position output component
  57570. */
  57571. readonly positionOutput: NodeMaterialConnectionPoint;
  57572. /**
  57573. * Gets the normal output component
  57574. */
  57575. readonly normalOutput: NodeMaterialConnectionPoint;
  57576. /**
  57577. * Gets the tangent output component
  57578. */
  57579. readonly tangentOutput: NodeMaterialConnectionPoint;
  57580. /**
  57581. * Gets the tangent output component
  57582. */
  57583. readonly uvOutput: NodeMaterialConnectionPoint;
  57584. initialize(state: NodeMaterialBuildState): void;
  57585. autoConfigure(material: NodeMaterial): void;
  57586. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57587. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57588. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57589. protected _buildBlock(state: NodeMaterialBuildState): this;
  57590. }
  57591. }
  57592. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57593. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57595. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57596. import { Nullable } from "babylonjs/types";
  57597. import { Scene } from "babylonjs/scene";
  57598. import { Effect } from "babylonjs/Materials/effect";
  57599. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57600. import { Mesh } from "babylonjs/Meshes/mesh";
  57601. import { Light } from "babylonjs/Lights/light";
  57602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57603. /**
  57604. * Block used to get data information from a light
  57605. */
  57606. export class LightInformationBlock extends NodeMaterialBlock {
  57607. private _lightDataUniformName;
  57608. private _lightColorUniformName;
  57609. private _lightTypeDefineName;
  57610. /**
  57611. * Gets or sets the light associated with this block
  57612. */
  57613. light: Nullable<Light>;
  57614. /**
  57615. * Creates a new LightInformationBlock
  57616. * @param name defines the block name
  57617. */
  57618. constructor(name: string);
  57619. /**
  57620. * Gets the current class name
  57621. * @returns the class name
  57622. */
  57623. getClassName(): string;
  57624. /**
  57625. * Gets the world position input component
  57626. */
  57627. readonly worldPosition: NodeMaterialConnectionPoint;
  57628. /**
  57629. * Gets the direction output component
  57630. */
  57631. readonly direction: NodeMaterialConnectionPoint;
  57632. /**
  57633. * Gets the direction output component
  57634. */
  57635. readonly color: NodeMaterialConnectionPoint;
  57636. /**
  57637. * Gets the direction output component
  57638. */
  57639. readonly intensity: NodeMaterialConnectionPoint;
  57640. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57641. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57642. protected _buildBlock(state: NodeMaterialBuildState): this;
  57643. serialize(): any;
  57644. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57645. }
  57646. }
  57647. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57648. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57649. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57650. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57651. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57652. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57653. }
  57654. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57655. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57656. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57659. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57660. import { Effect } from "babylonjs/Materials/effect";
  57661. import { Mesh } from "babylonjs/Meshes/mesh";
  57662. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57663. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57664. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57665. /**
  57666. * Block used to add image processing support to fragment shader
  57667. */
  57668. export class ImageProcessingBlock extends NodeMaterialBlock {
  57669. /**
  57670. * Create a new ImageProcessingBlock
  57671. * @param name defines the block name
  57672. */
  57673. constructor(name: string);
  57674. /**
  57675. * Gets the current class name
  57676. * @returns the class name
  57677. */
  57678. getClassName(): string;
  57679. /**
  57680. * Gets the color input component
  57681. */
  57682. readonly color: NodeMaterialConnectionPoint;
  57683. /**
  57684. * Gets the output component
  57685. */
  57686. readonly output: NodeMaterialConnectionPoint;
  57687. /**
  57688. * Initialize the block and prepare the context for build
  57689. * @param state defines the state that will be used for the build
  57690. */
  57691. initialize(state: NodeMaterialBuildState): void;
  57692. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57693. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57694. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57695. protected _buildBlock(state: NodeMaterialBuildState): this;
  57696. }
  57697. }
  57698. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57700. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57701. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57702. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57704. import { Effect } from "babylonjs/Materials/effect";
  57705. import { Mesh } from "babylonjs/Meshes/mesh";
  57706. import { Scene } from "babylonjs/scene";
  57707. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57708. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57709. /**
  57710. * Block used to pertub normals based on a normal map
  57711. */
  57712. export class PerturbNormalBlock extends NodeMaterialBlock {
  57713. private _tangentSpaceParameterName;
  57714. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57715. invertX: boolean;
  57716. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57717. invertY: boolean;
  57718. /**
  57719. * Create a new PerturbNormalBlock
  57720. * @param name defines the block name
  57721. */
  57722. constructor(name: string);
  57723. /**
  57724. * Gets the current class name
  57725. * @returns the class name
  57726. */
  57727. getClassName(): string;
  57728. /**
  57729. * Gets the world position input component
  57730. */
  57731. readonly worldPosition: NodeMaterialConnectionPoint;
  57732. /**
  57733. * Gets the world normal input component
  57734. */
  57735. readonly worldNormal: NodeMaterialConnectionPoint;
  57736. /**
  57737. * Gets the uv input component
  57738. */
  57739. readonly uv: NodeMaterialConnectionPoint;
  57740. /**
  57741. * Gets the normal map color input component
  57742. */
  57743. readonly normalMapColor: NodeMaterialConnectionPoint;
  57744. /**
  57745. * Gets the strength input component
  57746. */
  57747. readonly strength: NodeMaterialConnectionPoint;
  57748. /**
  57749. * Gets the output component
  57750. */
  57751. readonly output: NodeMaterialConnectionPoint;
  57752. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57753. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57754. autoConfigure(material: NodeMaterial): void;
  57755. protected _buildBlock(state: NodeMaterialBuildState): this;
  57756. protected _dumpPropertiesCode(): string;
  57757. serialize(): any;
  57758. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57759. }
  57760. }
  57761. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57765. /**
  57766. * Block used to discard a pixel if a value is smaller than a cutoff
  57767. */
  57768. export class DiscardBlock extends NodeMaterialBlock {
  57769. /**
  57770. * Create a new DiscardBlock
  57771. * @param name defines the block name
  57772. */
  57773. constructor(name: string);
  57774. /**
  57775. * Gets the current class name
  57776. * @returns the class name
  57777. */
  57778. getClassName(): string;
  57779. /**
  57780. * Gets the color input component
  57781. */
  57782. readonly value: NodeMaterialConnectionPoint;
  57783. /**
  57784. * Gets the cutoff input component
  57785. */
  57786. readonly cutoff: NodeMaterialConnectionPoint;
  57787. protected _buildBlock(state: NodeMaterialBuildState): this;
  57788. }
  57789. }
  57790. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  57791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57794. /**
  57795. * Block used to test if the fragment shader is front facing
  57796. */
  57797. export class FrontFacingBlock extends NodeMaterialBlock {
  57798. /**
  57799. * Creates a new FrontFacingBlock
  57800. * @param name defines the block name
  57801. */
  57802. constructor(name: string);
  57803. /**
  57804. * Gets the current class name
  57805. * @returns the class name
  57806. */
  57807. getClassName(): string;
  57808. /**
  57809. * Gets the output component
  57810. */
  57811. readonly output: NodeMaterialConnectionPoint;
  57812. protected _buildBlock(state: NodeMaterialBuildState): this;
  57813. }
  57814. }
  57815. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  57816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57819. /**
  57820. * Block used to get the derivative value on x and y of a given input
  57821. */
  57822. export class DerivativeBlock extends NodeMaterialBlock {
  57823. /**
  57824. * Create a new DerivativeBlock
  57825. * @param name defines the block name
  57826. */
  57827. constructor(name: string);
  57828. /**
  57829. * Gets the current class name
  57830. * @returns the class name
  57831. */
  57832. getClassName(): string;
  57833. /**
  57834. * Gets the input component
  57835. */
  57836. readonly input: NodeMaterialConnectionPoint;
  57837. /**
  57838. * Gets the derivative output on x
  57839. */
  57840. readonly dx: NodeMaterialConnectionPoint;
  57841. /**
  57842. * Gets the derivative output on y
  57843. */
  57844. readonly dy: NodeMaterialConnectionPoint;
  57845. protected _buildBlock(state: NodeMaterialBuildState): this;
  57846. }
  57847. }
  57848. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57849. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57850. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57851. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57852. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57853. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  57854. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  57855. }
  57856. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57857. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57858. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57859. import { Mesh } from "babylonjs/Meshes/mesh";
  57860. import { Effect } from "babylonjs/Materials/effect";
  57861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57863. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57864. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57865. /**
  57866. * Block used to add support for scene fog
  57867. */
  57868. export class FogBlock extends NodeMaterialBlock {
  57869. private _fogDistanceName;
  57870. private _fogParameters;
  57871. /**
  57872. * Create a new FogBlock
  57873. * @param name defines the block name
  57874. */
  57875. constructor(name: string);
  57876. /**
  57877. * Gets the current class name
  57878. * @returns the class name
  57879. */
  57880. getClassName(): string;
  57881. /**
  57882. * Gets the world position input component
  57883. */
  57884. readonly worldPosition: NodeMaterialConnectionPoint;
  57885. /**
  57886. * Gets the view input component
  57887. */
  57888. readonly view: NodeMaterialConnectionPoint;
  57889. /**
  57890. * Gets the color input component
  57891. */
  57892. readonly input: NodeMaterialConnectionPoint;
  57893. /**
  57894. * Gets the fog color input component
  57895. */
  57896. readonly fogColor: NodeMaterialConnectionPoint;
  57897. /**
  57898. * Gets the output component
  57899. */
  57900. readonly output: NodeMaterialConnectionPoint;
  57901. autoConfigure(material: NodeMaterial): void;
  57902. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57903. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57904. protected _buildBlock(state: NodeMaterialBuildState): this;
  57905. }
  57906. }
  57907. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57910. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57912. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57913. import { Effect } from "babylonjs/Materials/effect";
  57914. import { Mesh } from "babylonjs/Meshes/mesh";
  57915. import { Light } from "babylonjs/Lights/light";
  57916. import { Nullable } from "babylonjs/types";
  57917. import { Scene } from "babylonjs/scene";
  57918. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57919. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57920. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57921. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57922. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57923. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57924. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57925. /**
  57926. * Block used to add light in the fragment shader
  57927. */
  57928. export class LightBlock extends NodeMaterialBlock {
  57929. private _lightId;
  57930. /**
  57931. * Gets or sets the light associated with this block
  57932. */
  57933. light: Nullable<Light>;
  57934. /**
  57935. * Create a new LightBlock
  57936. * @param name defines the block name
  57937. */
  57938. constructor(name: string);
  57939. /**
  57940. * Gets the current class name
  57941. * @returns the class name
  57942. */
  57943. getClassName(): string;
  57944. /**
  57945. * Gets the world position input component
  57946. */
  57947. readonly worldPosition: NodeMaterialConnectionPoint;
  57948. /**
  57949. * Gets the world normal input component
  57950. */
  57951. readonly worldNormal: NodeMaterialConnectionPoint;
  57952. /**
  57953. * Gets the camera (or eye) position component
  57954. */
  57955. readonly cameraPosition: NodeMaterialConnectionPoint;
  57956. /**
  57957. * Gets the glossiness component
  57958. */
  57959. readonly glossiness: NodeMaterialConnectionPoint;
  57960. /**
  57961. * Gets the glossinness power component
  57962. */
  57963. readonly glossPower: NodeMaterialConnectionPoint;
  57964. /**
  57965. * Gets the diffuse color component
  57966. */
  57967. readonly diffuseColor: NodeMaterialConnectionPoint;
  57968. /**
  57969. * Gets the specular color component
  57970. */
  57971. readonly specularColor: NodeMaterialConnectionPoint;
  57972. /**
  57973. * Gets the diffuse output component
  57974. */
  57975. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57976. /**
  57977. * Gets the specular output component
  57978. */
  57979. readonly specularOutput: NodeMaterialConnectionPoint;
  57980. autoConfigure(material: NodeMaterial): void;
  57981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57982. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57983. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57984. private _injectVertexCode;
  57985. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57986. serialize(): any;
  57987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57988. }
  57989. }
  57990. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57991. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57992. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57993. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57994. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57995. }
  57996. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57997. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57998. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57999. }
  58000. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  58001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58004. /**
  58005. * Block used to multiply 2 values
  58006. */
  58007. export class MultiplyBlock extends NodeMaterialBlock {
  58008. /**
  58009. * Creates a new MultiplyBlock
  58010. * @param name defines the block name
  58011. */
  58012. constructor(name: string);
  58013. /**
  58014. * Gets the current class name
  58015. * @returns the class name
  58016. */
  58017. getClassName(): string;
  58018. /**
  58019. * Gets the left operand input component
  58020. */
  58021. readonly left: NodeMaterialConnectionPoint;
  58022. /**
  58023. * Gets the right operand input component
  58024. */
  58025. readonly right: NodeMaterialConnectionPoint;
  58026. /**
  58027. * Gets the output component
  58028. */
  58029. readonly output: NodeMaterialConnectionPoint;
  58030. protected _buildBlock(state: NodeMaterialBuildState): this;
  58031. }
  58032. }
  58033. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  58034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58037. /**
  58038. * Block used to add 2 vectors
  58039. */
  58040. export class AddBlock extends NodeMaterialBlock {
  58041. /**
  58042. * Creates a new AddBlock
  58043. * @param name defines the block name
  58044. */
  58045. constructor(name: string);
  58046. /**
  58047. * Gets the current class name
  58048. * @returns the class name
  58049. */
  58050. getClassName(): string;
  58051. /**
  58052. * Gets the left operand input component
  58053. */
  58054. readonly left: NodeMaterialConnectionPoint;
  58055. /**
  58056. * Gets the right operand input component
  58057. */
  58058. readonly right: NodeMaterialConnectionPoint;
  58059. /**
  58060. * Gets the output component
  58061. */
  58062. readonly output: NodeMaterialConnectionPoint;
  58063. protected _buildBlock(state: NodeMaterialBuildState): this;
  58064. }
  58065. }
  58066. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  58067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58070. /**
  58071. * Block used to scale a vector by a float
  58072. */
  58073. export class ScaleBlock extends NodeMaterialBlock {
  58074. /**
  58075. * Creates a new ScaleBlock
  58076. * @param name defines the block name
  58077. */
  58078. constructor(name: string);
  58079. /**
  58080. * Gets the current class name
  58081. * @returns the class name
  58082. */
  58083. getClassName(): string;
  58084. /**
  58085. * Gets the input component
  58086. */
  58087. readonly input: NodeMaterialConnectionPoint;
  58088. /**
  58089. * Gets the factor input component
  58090. */
  58091. readonly factor: NodeMaterialConnectionPoint;
  58092. /**
  58093. * Gets the output component
  58094. */
  58095. readonly output: NodeMaterialConnectionPoint;
  58096. protected _buildBlock(state: NodeMaterialBuildState): this;
  58097. }
  58098. }
  58099. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  58100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58101. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58102. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58103. import { Scene } from "babylonjs/scene";
  58104. /**
  58105. * Block used to clamp a float
  58106. */
  58107. export class ClampBlock extends NodeMaterialBlock {
  58108. /** Gets or sets the minimum range */
  58109. minimum: number;
  58110. /** Gets or sets the maximum range */
  58111. maximum: number;
  58112. /**
  58113. * Creates a new ClampBlock
  58114. * @param name defines the block name
  58115. */
  58116. constructor(name: string);
  58117. /**
  58118. * Gets the current class name
  58119. * @returns the class name
  58120. */
  58121. getClassName(): string;
  58122. /**
  58123. * Gets the value input component
  58124. */
  58125. readonly value: NodeMaterialConnectionPoint;
  58126. /**
  58127. * Gets the output component
  58128. */
  58129. readonly output: NodeMaterialConnectionPoint;
  58130. protected _buildBlock(state: NodeMaterialBuildState): this;
  58131. protected _dumpPropertiesCode(): string;
  58132. serialize(): any;
  58133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58134. }
  58135. }
  58136. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  58137. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58138. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58139. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58140. /**
  58141. * Block used to apply a cross product between 2 vectors
  58142. */
  58143. export class CrossBlock extends NodeMaterialBlock {
  58144. /**
  58145. * Creates a new CrossBlock
  58146. * @param name defines the block name
  58147. */
  58148. constructor(name: string);
  58149. /**
  58150. * Gets the current class name
  58151. * @returns the class name
  58152. */
  58153. getClassName(): string;
  58154. /**
  58155. * Gets the left operand input component
  58156. */
  58157. readonly left: NodeMaterialConnectionPoint;
  58158. /**
  58159. * Gets the right operand input component
  58160. */
  58161. readonly right: NodeMaterialConnectionPoint;
  58162. /**
  58163. * Gets the output component
  58164. */
  58165. readonly output: NodeMaterialConnectionPoint;
  58166. protected _buildBlock(state: NodeMaterialBuildState): this;
  58167. }
  58168. }
  58169. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  58170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58173. /**
  58174. * Block used to apply a dot product between 2 vectors
  58175. */
  58176. export class DotBlock extends NodeMaterialBlock {
  58177. /**
  58178. * Creates a new DotBlock
  58179. * @param name defines the block name
  58180. */
  58181. constructor(name: string);
  58182. /**
  58183. * Gets the current class name
  58184. * @returns the class name
  58185. */
  58186. getClassName(): string;
  58187. /**
  58188. * Gets the left operand input component
  58189. */
  58190. readonly left: NodeMaterialConnectionPoint;
  58191. /**
  58192. * Gets the right operand input component
  58193. */
  58194. readonly right: NodeMaterialConnectionPoint;
  58195. /**
  58196. * Gets the output component
  58197. */
  58198. readonly output: NodeMaterialConnectionPoint;
  58199. protected _buildBlock(state: NodeMaterialBuildState): this;
  58200. }
  58201. }
  58202. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58206. import { Vector2 } from "babylonjs/Maths/math.vector";
  58207. import { Scene } from "babylonjs/scene";
  58208. /**
  58209. * Block used to remap a float from a range to a new one
  58210. */
  58211. export class RemapBlock extends NodeMaterialBlock {
  58212. /**
  58213. * Gets or sets the source range
  58214. */
  58215. sourceRange: Vector2;
  58216. /**
  58217. * Gets or sets the target range
  58218. */
  58219. targetRange: Vector2;
  58220. /**
  58221. * Creates a new RemapBlock
  58222. * @param name defines the block name
  58223. */
  58224. constructor(name: string);
  58225. /**
  58226. * Gets the current class name
  58227. * @returns the class name
  58228. */
  58229. getClassName(): string;
  58230. /**
  58231. * Gets the input component
  58232. */
  58233. readonly input: NodeMaterialConnectionPoint;
  58234. /**
  58235. * Gets the source min input component
  58236. */
  58237. readonly sourceMin: NodeMaterialConnectionPoint;
  58238. /**
  58239. * Gets the source max input component
  58240. */
  58241. readonly sourceMax: NodeMaterialConnectionPoint;
  58242. /**
  58243. * Gets the target min input component
  58244. */
  58245. readonly targetMin: NodeMaterialConnectionPoint;
  58246. /**
  58247. * Gets the target max input component
  58248. */
  58249. readonly targetMax: NodeMaterialConnectionPoint;
  58250. /**
  58251. * Gets the output component
  58252. */
  58253. readonly output: NodeMaterialConnectionPoint;
  58254. protected _buildBlock(state: NodeMaterialBuildState): this;
  58255. protected _dumpPropertiesCode(): string;
  58256. serialize(): any;
  58257. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58258. }
  58259. }
  58260. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58264. /**
  58265. * Block used to normalize a vector
  58266. */
  58267. export class NormalizeBlock extends NodeMaterialBlock {
  58268. /**
  58269. * Creates a new NormalizeBlock
  58270. * @param name defines the block name
  58271. */
  58272. constructor(name: string);
  58273. /**
  58274. * Gets the current class name
  58275. * @returns the class name
  58276. */
  58277. getClassName(): string;
  58278. /**
  58279. * Gets the input component
  58280. */
  58281. readonly input: NodeMaterialConnectionPoint;
  58282. /**
  58283. * Gets the output component
  58284. */
  58285. readonly output: NodeMaterialConnectionPoint;
  58286. protected _buildBlock(state: NodeMaterialBuildState): this;
  58287. }
  58288. }
  58289. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58293. import { Scene } from "babylonjs/scene";
  58294. /**
  58295. * Operations supported by the Trigonometry block
  58296. */
  58297. export enum TrigonometryBlockOperations {
  58298. /** Cos */
  58299. Cos = 0,
  58300. /** Sin */
  58301. Sin = 1,
  58302. /** Abs */
  58303. Abs = 2,
  58304. /** Exp */
  58305. Exp = 3,
  58306. /** Exp2 */
  58307. Exp2 = 4,
  58308. /** Round */
  58309. Round = 5,
  58310. /** Floor */
  58311. Floor = 6,
  58312. /** Ceiling */
  58313. Ceiling = 7,
  58314. /** Square root */
  58315. Sqrt = 8,
  58316. /** Log */
  58317. Log = 9,
  58318. /** Tangent */
  58319. Tan = 10,
  58320. /** Arc tangent */
  58321. ArcTan = 11,
  58322. /** Arc cosinus */
  58323. ArcCos = 12,
  58324. /** Arc sinus */
  58325. ArcSin = 13,
  58326. /** Fraction */
  58327. Fract = 14,
  58328. /** Sign */
  58329. Sign = 15,
  58330. /** To radians (from degrees) */
  58331. Radians = 16,
  58332. /** To degrees (from radians) */
  58333. Degrees = 17
  58334. }
  58335. /**
  58336. * Block used to apply trigonometry operation to floats
  58337. */
  58338. export class TrigonometryBlock extends NodeMaterialBlock {
  58339. /**
  58340. * Gets or sets the operation applied by the block
  58341. */
  58342. operation: TrigonometryBlockOperations;
  58343. /**
  58344. * Creates a new TrigonometryBlock
  58345. * @param name defines the block name
  58346. */
  58347. constructor(name: string);
  58348. /**
  58349. * Gets the current class name
  58350. * @returns the class name
  58351. */
  58352. getClassName(): string;
  58353. /**
  58354. * Gets the input component
  58355. */
  58356. readonly input: NodeMaterialConnectionPoint;
  58357. /**
  58358. * Gets the output component
  58359. */
  58360. readonly output: NodeMaterialConnectionPoint;
  58361. protected _buildBlock(state: NodeMaterialBuildState): this;
  58362. serialize(): any;
  58363. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58364. protected _dumpPropertiesCode(): string;
  58365. }
  58366. }
  58367. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58370. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58371. /**
  58372. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58373. */
  58374. export class ColorMergerBlock extends NodeMaterialBlock {
  58375. /**
  58376. * Create a new ColorMergerBlock
  58377. * @param name defines the block name
  58378. */
  58379. constructor(name: string);
  58380. /**
  58381. * Gets the current class name
  58382. * @returns the class name
  58383. */
  58384. getClassName(): string;
  58385. /**
  58386. * Gets the rgb component (input)
  58387. */
  58388. readonly rgbIn: NodeMaterialConnectionPoint;
  58389. /**
  58390. * Gets the r component (input)
  58391. */
  58392. readonly r: NodeMaterialConnectionPoint;
  58393. /**
  58394. * Gets the g component (input)
  58395. */
  58396. readonly g: NodeMaterialConnectionPoint;
  58397. /**
  58398. * Gets the b component (input)
  58399. */
  58400. readonly b: NodeMaterialConnectionPoint;
  58401. /**
  58402. * Gets the a component (input)
  58403. */
  58404. readonly a: NodeMaterialConnectionPoint;
  58405. /**
  58406. * Gets the rgba component (output)
  58407. */
  58408. readonly rgba: NodeMaterialConnectionPoint;
  58409. /**
  58410. * Gets the rgb component (output)
  58411. */
  58412. readonly rgbOut: NodeMaterialConnectionPoint;
  58413. /**
  58414. * Gets the rgb component (output)
  58415. * @deprecated Please use rgbOut instead
  58416. */
  58417. readonly rgb: NodeMaterialConnectionPoint;
  58418. protected _buildBlock(state: NodeMaterialBuildState): this;
  58419. }
  58420. }
  58421. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58425. /**
  58426. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58427. */
  58428. export class VectorMergerBlock extends NodeMaterialBlock {
  58429. /**
  58430. * Create a new VectorMergerBlock
  58431. * @param name defines the block name
  58432. */
  58433. constructor(name: string);
  58434. /**
  58435. * Gets the current class name
  58436. * @returns the class name
  58437. */
  58438. getClassName(): string;
  58439. /**
  58440. * Gets the xyz component (input)
  58441. */
  58442. readonly xyzIn: NodeMaterialConnectionPoint;
  58443. /**
  58444. * Gets the xy component (input)
  58445. */
  58446. readonly xyIn: NodeMaterialConnectionPoint;
  58447. /**
  58448. * Gets the x component (input)
  58449. */
  58450. readonly x: NodeMaterialConnectionPoint;
  58451. /**
  58452. * Gets the y component (input)
  58453. */
  58454. readonly y: NodeMaterialConnectionPoint;
  58455. /**
  58456. * Gets the z component (input)
  58457. */
  58458. readonly z: NodeMaterialConnectionPoint;
  58459. /**
  58460. * Gets the w component (input)
  58461. */
  58462. readonly w: NodeMaterialConnectionPoint;
  58463. /**
  58464. * Gets the xyzw component (output)
  58465. */
  58466. readonly xyzw: NodeMaterialConnectionPoint;
  58467. /**
  58468. * Gets the xyz component (output)
  58469. */
  58470. readonly xyzOut: NodeMaterialConnectionPoint;
  58471. /**
  58472. * Gets the xy component (output)
  58473. */
  58474. readonly xyOut: NodeMaterialConnectionPoint;
  58475. /**
  58476. * Gets the xy component (output)
  58477. * @deprecated Please use xyOut instead
  58478. */
  58479. readonly xy: NodeMaterialConnectionPoint;
  58480. /**
  58481. * Gets the xyz component (output)
  58482. * @deprecated Please use xyzOut instead
  58483. */
  58484. readonly xyz: NodeMaterialConnectionPoint;
  58485. protected _buildBlock(state: NodeMaterialBuildState): this;
  58486. }
  58487. }
  58488. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58489. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58490. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58491. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58492. /**
  58493. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58494. */
  58495. export class ColorSplitterBlock extends NodeMaterialBlock {
  58496. /**
  58497. * Create a new ColorSplitterBlock
  58498. * @param name defines the block name
  58499. */
  58500. constructor(name: string);
  58501. /**
  58502. * Gets the current class name
  58503. * @returns the class name
  58504. */
  58505. getClassName(): string;
  58506. /**
  58507. * Gets the rgba component (input)
  58508. */
  58509. readonly rgba: NodeMaterialConnectionPoint;
  58510. /**
  58511. * Gets the rgb component (input)
  58512. */
  58513. readonly rgbIn: NodeMaterialConnectionPoint;
  58514. /**
  58515. * Gets the rgb component (output)
  58516. */
  58517. readonly rgbOut: NodeMaterialConnectionPoint;
  58518. /**
  58519. * Gets the r component (output)
  58520. */
  58521. readonly r: NodeMaterialConnectionPoint;
  58522. /**
  58523. * Gets the g component (output)
  58524. */
  58525. readonly g: NodeMaterialConnectionPoint;
  58526. /**
  58527. * Gets the b component (output)
  58528. */
  58529. readonly b: NodeMaterialConnectionPoint;
  58530. /**
  58531. * Gets the a component (output)
  58532. */
  58533. readonly a: NodeMaterialConnectionPoint;
  58534. protected _inputRename(name: string): string;
  58535. protected _outputRename(name: string): string;
  58536. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58537. }
  58538. }
  58539. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58543. /**
  58544. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58545. */
  58546. export class VectorSplitterBlock extends NodeMaterialBlock {
  58547. /**
  58548. * Create a new VectorSplitterBlock
  58549. * @param name defines the block name
  58550. */
  58551. constructor(name: string);
  58552. /**
  58553. * Gets the current class name
  58554. * @returns the class name
  58555. */
  58556. getClassName(): string;
  58557. /**
  58558. * Gets the xyzw component (input)
  58559. */
  58560. readonly xyzw: NodeMaterialConnectionPoint;
  58561. /**
  58562. * Gets the xyz component (input)
  58563. */
  58564. readonly xyzIn: NodeMaterialConnectionPoint;
  58565. /**
  58566. * Gets the xy component (input)
  58567. */
  58568. readonly xyIn: NodeMaterialConnectionPoint;
  58569. /**
  58570. * Gets the xyz component (output)
  58571. */
  58572. readonly xyzOut: NodeMaterialConnectionPoint;
  58573. /**
  58574. * Gets the xy component (output)
  58575. */
  58576. readonly xyOut: NodeMaterialConnectionPoint;
  58577. /**
  58578. * Gets the x component (output)
  58579. */
  58580. readonly x: NodeMaterialConnectionPoint;
  58581. /**
  58582. * Gets the y component (output)
  58583. */
  58584. readonly y: NodeMaterialConnectionPoint;
  58585. /**
  58586. * Gets the z component (output)
  58587. */
  58588. readonly z: NodeMaterialConnectionPoint;
  58589. /**
  58590. * Gets the w component (output)
  58591. */
  58592. readonly w: NodeMaterialConnectionPoint;
  58593. protected _inputRename(name: string): string;
  58594. protected _outputRename(name: string): string;
  58595. protected _buildBlock(state: NodeMaterialBuildState): this;
  58596. }
  58597. }
  58598. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58602. /**
  58603. * Block used to lerp between 2 values
  58604. */
  58605. export class LerpBlock extends NodeMaterialBlock {
  58606. /**
  58607. * Creates a new LerpBlock
  58608. * @param name defines the block name
  58609. */
  58610. constructor(name: string);
  58611. /**
  58612. * Gets the current class name
  58613. * @returns the class name
  58614. */
  58615. getClassName(): string;
  58616. /**
  58617. * Gets the left operand input component
  58618. */
  58619. readonly left: NodeMaterialConnectionPoint;
  58620. /**
  58621. * Gets the right operand input component
  58622. */
  58623. readonly right: NodeMaterialConnectionPoint;
  58624. /**
  58625. * Gets the gradient operand input component
  58626. */
  58627. readonly gradient: NodeMaterialConnectionPoint;
  58628. /**
  58629. * Gets the output component
  58630. */
  58631. readonly output: NodeMaterialConnectionPoint;
  58632. protected _buildBlock(state: NodeMaterialBuildState): this;
  58633. }
  58634. }
  58635. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58639. /**
  58640. * Block used to divide 2 vectors
  58641. */
  58642. export class DivideBlock extends NodeMaterialBlock {
  58643. /**
  58644. * Creates a new DivideBlock
  58645. * @param name defines the block name
  58646. */
  58647. constructor(name: string);
  58648. /**
  58649. * Gets the current class name
  58650. * @returns the class name
  58651. */
  58652. getClassName(): string;
  58653. /**
  58654. * Gets the left operand input component
  58655. */
  58656. readonly left: NodeMaterialConnectionPoint;
  58657. /**
  58658. * Gets the right operand input component
  58659. */
  58660. readonly right: NodeMaterialConnectionPoint;
  58661. /**
  58662. * Gets the output component
  58663. */
  58664. readonly output: NodeMaterialConnectionPoint;
  58665. protected _buildBlock(state: NodeMaterialBuildState): this;
  58666. }
  58667. }
  58668. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58672. /**
  58673. * Block used to subtract 2 vectors
  58674. */
  58675. export class SubtractBlock extends NodeMaterialBlock {
  58676. /**
  58677. * Creates a new SubtractBlock
  58678. * @param name defines the block name
  58679. */
  58680. constructor(name: string);
  58681. /**
  58682. * Gets the current class name
  58683. * @returns the class name
  58684. */
  58685. getClassName(): string;
  58686. /**
  58687. * Gets the left operand input component
  58688. */
  58689. readonly left: NodeMaterialConnectionPoint;
  58690. /**
  58691. * Gets the right operand input component
  58692. */
  58693. readonly right: NodeMaterialConnectionPoint;
  58694. /**
  58695. * Gets the output component
  58696. */
  58697. readonly output: NodeMaterialConnectionPoint;
  58698. protected _buildBlock(state: NodeMaterialBuildState): this;
  58699. }
  58700. }
  58701. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58702. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58705. /**
  58706. * Block used to step a value
  58707. */
  58708. export class StepBlock extends NodeMaterialBlock {
  58709. /**
  58710. * Creates a new StepBlock
  58711. * @param name defines the block name
  58712. */
  58713. constructor(name: string);
  58714. /**
  58715. * Gets the current class name
  58716. * @returns the class name
  58717. */
  58718. getClassName(): string;
  58719. /**
  58720. * Gets the value operand input component
  58721. */
  58722. readonly value: NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the edge operand input component
  58725. */
  58726. readonly edge: NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the output component
  58729. */
  58730. readonly output: NodeMaterialConnectionPoint;
  58731. protected _buildBlock(state: NodeMaterialBuildState): this;
  58732. }
  58733. }
  58734. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58737. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58738. /**
  58739. * Block used to get the opposite (1 - x) of a value
  58740. */
  58741. export class OneMinusBlock extends NodeMaterialBlock {
  58742. /**
  58743. * Creates a new OneMinusBlock
  58744. * @param name defines the block name
  58745. */
  58746. constructor(name: string);
  58747. /**
  58748. * Gets the current class name
  58749. * @returns the class name
  58750. */
  58751. getClassName(): string;
  58752. /**
  58753. * Gets the input component
  58754. */
  58755. readonly input: NodeMaterialConnectionPoint;
  58756. /**
  58757. * Gets the output component
  58758. */
  58759. readonly output: NodeMaterialConnectionPoint;
  58760. protected _buildBlock(state: NodeMaterialBuildState): this;
  58761. }
  58762. }
  58763. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58764. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58765. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58766. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58767. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58768. /**
  58769. * Block used to get the view direction
  58770. */
  58771. export class ViewDirectionBlock extends NodeMaterialBlock {
  58772. /**
  58773. * Creates a new ViewDirectionBlock
  58774. * @param name defines the block name
  58775. */
  58776. constructor(name: string);
  58777. /**
  58778. * Gets the current class name
  58779. * @returns the class name
  58780. */
  58781. getClassName(): string;
  58782. /**
  58783. * Gets the world position component
  58784. */
  58785. readonly worldPosition: NodeMaterialConnectionPoint;
  58786. /**
  58787. * Gets the camera position component
  58788. */
  58789. readonly cameraPosition: NodeMaterialConnectionPoint;
  58790. /**
  58791. * Gets the output component
  58792. */
  58793. readonly output: NodeMaterialConnectionPoint;
  58794. autoConfigure(material: NodeMaterial): void;
  58795. protected _buildBlock(state: NodeMaterialBuildState): this;
  58796. }
  58797. }
  58798. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58802. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58803. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58804. /**
  58805. * Block used to compute fresnel value
  58806. */
  58807. export class FresnelBlock extends NodeMaterialBlock {
  58808. /**
  58809. * Create a new FresnelBlock
  58810. * @param name defines the block name
  58811. */
  58812. constructor(name: string);
  58813. /**
  58814. * Gets the current class name
  58815. * @returns the class name
  58816. */
  58817. getClassName(): string;
  58818. /**
  58819. * Gets the world normal input component
  58820. */
  58821. readonly worldNormal: NodeMaterialConnectionPoint;
  58822. /**
  58823. * Gets the view direction input component
  58824. */
  58825. readonly viewDirection: NodeMaterialConnectionPoint;
  58826. /**
  58827. * Gets the bias input component
  58828. */
  58829. readonly bias: NodeMaterialConnectionPoint;
  58830. /**
  58831. * Gets the camera (or eye) position component
  58832. */
  58833. readonly power: NodeMaterialConnectionPoint;
  58834. /**
  58835. * Gets the fresnel output component
  58836. */
  58837. readonly fresnel: NodeMaterialConnectionPoint;
  58838. autoConfigure(material: NodeMaterial): void;
  58839. protected _buildBlock(state: NodeMaterialBuildState): this;
  58840. }
  58841. }
  58842. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58843. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58844. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58845. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58846. /**
  58847. * Block used to get the max of 2 values
  58848. */
  58849. export class MaxBlock extends NodeMaterialBlock {
  58850. /**
  58851. * Creates a new MaxBlock
  58852. * @param name defines the block name
  58853. */
  58854. constructor(name: string);
  58855. /**
  58856. * Gets the current class name
  58857. * @returns the class name
  58858. */
  58859. getClassName(): string;
  58860. /**
  58861. * Gets the left operand input component
  58862. */
  58863. readonly left: NodeMaterialConnectionPoint;
  58864. /**
  58865. * Gets the right operand input component
  58866. */
  58867. readonly right: NodeMaterialConnectionPoint;
  58868. /**
  58869. * Gets the output component
  58870. */
  58871. readonly output: NodeMaterialConnectionPoint;
  58872. protected _buildBlock(state: NodeMaterialBuildState): this;
  58873. }
  58874. }
  58875. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58879. /**
  58880. * Block used to get the min of 2 values
  58881. */
  58882. export class MinBlock extends NodeMaterialBlock {
  58883. /**
  58884. * Creates a new MinBlock
  58885. * @param name defines the block name
  58886. */
  58887. constructor(name: string);
  58888. /**
  58889. * Gets the current class name
  58890. * @returns the class name
  58891. */
  58892. getClassName(): string;
  58893. /**
  58894. * Gets the left operand input component
  58895. */
  58896. readonly left: NodeMaterialConnectionPoint;
  58897. /**
  58898. * Gets the right operand input component
  58899. */
  58900. readonly right: NodeMaterialConnectionPoint;
  58901. /**
  58902. * Gets the output component
  58903. */
  58904. readonly output: NodeMaterialConnectionPoint;
  58905. protected _buildBlock(state: NodeMaterialBuildState): this;
  58906. }
  58907. }
  58908. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58912. /**
  58913. * Block used to get the distance between 2 values
  58914. */
  58915. export class DistanceBlock extends NodeMaterialBlock {
  58916. /**
  58917. * Creates a new DistanceBlock
  58918. * @param name defines the block name
  58919. */
  58920. constructor(name: string);
  58921. /**
  58922. * Gets the current class name
  58923. * @returns the class name
  58924. */
  58925. getClassName(): string;
  58926. /**
  58927. * Gets the left operand input component
  58928. */
  58929. readonly left: NodeMaterialConnectionPoint;
  58930. /**
  58931. * Gets the right operand input component
  58932. */
  58933. readonly right: NodeMaterialConnectionPoint;
  58934. /**
  58935. * Gets the output component
  58936. */
  58937. readonly output: NodeMaterialConnectionPoint;
  58938. protected _buildBlock(state: NodeMaterialBuildState): this;
  58939. }
  58940. }
  58941. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58945. /**
  58946. * Block used to get the length of a vector
  58947. */
  58948. export class LengthBlock extends NodeMaterialBlock {
  58949. /**
  58950. * Creates a new LengthBlock
  58951. * @param name defines the block name
  58952. */
  58953. constructor(name: string);
  58954. /**
  58955. * Gets the current class name
  58956. * @returns the class name
  58957. */
  58958. getClassName(): string;
  58959. /**
  58960. * Gets the value input component
  58961. */
  58962. readonly value: NodeMaterialConnectionPoint;
  58963. /**
  58964. * Gets the output component
  58965. */
  58966. readonly output: NodeMaterialConnectionPoint;
  58967. protected _buildBlock(state: NodeMaterialBuildState): this;
  58968. }
  58969. }
  58970. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58974. /**
  58975. * Block used to get negative version of a value (i.e. x * -1)
  58976. */
  58977. export class NegateBlock extends NodeMaterialBlock {
  58978. /**
  58979. * Creates a new NegateBlock
  58980. * @param name defines the block name
  58981. */
  58982. constructor(name: string);
  58983. /**
  58984. * Gets the current class name
  58985. * @returns the class name
  58986. */
  58987. getClassName(): string;
  58988. /**
  58989. * Gets the value input component
  58990. */
  58991. readonly value: NodeMaterialConnectionPoint;
  58992. /**
  58993. * Gets the output component
  58994. */
  58995. readonly output: NodeMaterialConnectionPoint;
  58996. protected _buildBlock(state: NodeMaterialBuildState): this;
  58997. }
  58998. }
  58999. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  59000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59003. /**
  59004. * Block used to get the value of the first parameter raised to the power of the second
  59005. */
  59006. export class PowBlock extends NodeMaterialBlock {
  59007. /**
  59008. * Creates a new PowBlock
  59009. * @param name defines the block name
  59010. */
  59011. constructor(name: string);
  59012. /**
  59013. * Gets the current class name
  59014. * @returns the class name
  59015. */
  59016. getClassName(): string;
  59017. /**
  59018. * Gets the value operand input component
  59019. */
  59020. readonly value: NodeMaterialConnectionPoint;
  59021. /**
  59022. * Gets the power operand input component
  59023. */
  59024. readonly power: NodeMaterialConnectionPoint;
  59025. /**
  59026. * Gets the output component
  59027. */
  59028. readonly output: NodeMaterialConnectionPoint;
  59029. protected _buildBlock(state: NodeMaterialBuildState): this;
  59030. }
  59031. }
  59032. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  59033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59036. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59037. /**
  59038. * Block used to get a random number
  59039. */
  59040. export class RandomNumberBlock extends NodeMaterialBlock {
  59041. /**
  59042. * Creates a new RandomNumberBlock
  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 seed input component
  59053. */
  59054. readonly seed: NodeMaterialConnectionPoint;
  59055. /**
  59056. * Gets the output component
  59057. */
  59058. readonly output: NodeMaterialConnectionPoint;
  59059. protected _buildBlock(state: NodeMaterialBuildState): this;
  59060. }
  59061. }
  59062. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  59063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59066. /**
  59067. * Block used to compute arc tangent of 2 values
  59068. */
  59069. export class ArcTan2Block extends NodeMaterialBlock {
  59070. /**
  59071. * Creates a new ArcTan2Block
  59072. * @param name defines the block name
  59073. */
  59074. constructor(name: string);
  59075. /**
  59076. * Gets the current class name
  59077. * @returns the class name
  59078. */
  59079. getClassName(): string;
  59080. /**
  59081. * Gets the x operand input component
  59082. */
  59083. readonly x: NodeMaterialConnectionPoint;
  59084. /**
  59085. * Gets the y operand input component
  59086. */
  59087. readonly y: NodeMaterialConnectionPoint;
  59088. /**
  59089. * Gets the output component
  59090. */
  59091. readonly output: NodeMaterialConnectionPoint;
  59092. protected _buildBlock(state: NodeMaterialBuildState): this;
  59093. }
  59094. }
  59095. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  59096. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59099. /**
  59100. * Block used to smooth step a value
  59101. */
  59102. export class SmoothStepBlock extends NodeMaterialBlock {
  59103. /**
  59104. * Creates a new SmoothStepBlock
  59105. * @param name defines the block name
  59106. */
  59107. constructor(name: string);
  59108. /**
  59109. * Gets the current class name
  59110. * @returns the class name
  59111. */
  59112. getClassName(): string;
  59113. /**
  59114. * Gets the value operand input component
  59115. */
  59116. readonly value: NodeMaterialConnectionPoint;
  59117. /**
  59118. * Gets the first edge operand input component
  59119. */
  59120. readonly edge0: NodeMaterialConnectionPoint;
  59121. /**
  59122. * Gets the second edge operand input component
  59123. */
  59124. readonly edge1: NodeMaterialConnectionPoint;
  59125. /**
  59126. * Gets the output component
  59127. */
  59128. readonly output: NodeMaterialConnectionPoint;
  59129. protected _buildBlock(state: NodeMaterialBuildState): this;
  59130. }
  59131. }
  59132. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  59133. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59134. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59135. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59136. /**
  59137. * Block used to get the reciprocal (1 / x) of a value
  59138. */
  59139. export class ReciprocalBlock extends NodeMaterialBlock {
  59140. /**
  59141. * Creates a new ReciprocalBlock
  59142. * @param name defines the block name
  59143. */
  59144. constructor(name: string);
  59145. /**
  59146. * Gets the current class name
  59147. * @returns the class name
  59148. */
  59149. getClassName(): string;
  59150. /**
  59151. * Gets the input component
  59152. */
  59153. readonly input: NodeMaterialConnectionPoint;
  59154. /**
  59155. * Gets the output component
  59156. */
  59157. readonly output: NodeMaterialConnectionPoint;
  59158. protected _buildBlock(state: NodeMaterialBuildState): this;
  59159. }
  59160. }
  59161. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  59162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59165. /**
  59166. * Block used to replace a color by another one
  59167. */
  59168. export class ReplaceColorBlock extends NodeMaterialBlock {
  59169. /**
  59170. * Creates a new ReplaceColorBlock
  59171. * @param name defines the block name
  59172. */
  59173. constructor(name: string);
  59174. /**
  59175. * Gets the current class name
  59176. * @returns the class name
  59177. */
  59178. getClassName(): string;
  59179. /**
  59180. * Gets the value input component
  59181. */
  59182. readonly value: NodeMaterialConnectionPoint;
  59183. /**
  59184. * Gets the reference input component
  59185. */
  59186. readonly reference: NodeMaterialConnectionPoint;
  59187. /**
  59188. * Gets the distance input component
  59189. */
  59190. readonly distance: NodeMaterialConnectionPoint;
  59191. /**
  59192. * Gets the replacement input component
  59193. */
  59194. readonly replacement: NodeMaterialConnectionPoint;
  59195. /**
  59196. * Gets the output component
  59197. */
  59198. readonly output: NodeMaterialConnectionPoint;
  59199. protected _buildBlock(state: NodeMaterialBuildState): this;
  59200. }
  59201. }
  59202. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  59203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59206. /**
  59207. * Block used to posterize a value
  59208. * @see https://en.wikipedia.org/wiki/Posterization
  59209. */
  59210. export class PosterizeBlock extends NodeMaterialBlock {
  59211. /**
  59212. * Creates a new PosterizeBlock
  59213. * @param name defines the block name
  59214. */
  59215. constructor(name: string);
  59216. /**
  59217. * Gets the current class name
  59218. * @returns the class name
  59219. */
  59220. getClassName(): string;
  59221. /**
  59222. * Gets the value input component
  59223. */
  59224. readonly value: NodeMaterialConnectionPoint;
  59225. /**
  59226. * Gets the steps input component
  59227. */
  59228. readonly steps: NodeMaterialConnectionPoint;
  59229. /**
  59230. * Gets the output component
  59231. */
  59232. readonly output: NodeMaterialConnectionPoint;
  59233. protected _buildBlock(state: NodeMaterialBuildState): this;
  59234. }
  59235. }
  59236. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59237. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59238. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59240. import { Scene } from "babylonjs/scene";
  59241. /**
  59242. * Operations supported by the Wave block
  59243. */
  59244. export enum WaveBlockKind {
  59245. /** SawTooth */
  59246. SawTooth = 0,
  59247. /** Square */
  59248. Square = 1,
  59249. /** Triangle */
  59250. Triangle = 2
  59251. }
  59252. /**
  59253. * Block used to apply wave operation to floats
  59254. */
  59255. export class WaveBlock extends NodeMaterialBlock {
  59256. /**
  59257. * Gets or sets the kibnd of wave to be applied by the block
  59258. */
  59259. kind: WaveBlockKind;
  59260. /**
  59261. * Creates a new WaveBlock
  59262. * @param name defines the block name
  59263. */
  59264. constructor(name: string);
  59265. /**
  59266. * Gets the current class name
  59267. * @returns the class name
  59268. */
  59269. getClassName(): string;
  59270. /**
  59271. * Gets the input component
  59272. */
  59273. readonly input: NodeMaterialConnectionPoint;
  59274. /**
  59275. * Gets the output component
  59276. */
  59277. readonly output: NodeMaterialConnectionPoint;
  59278. protected _buildBlock(state: NodeMaterialBuildState): this;
  59279. serialize(): any;
  59280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59281. }
  59282. }
  59283. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59287. import { Color3 } from "babylonjs/Maths/math.color";
  59288. import { Scene } from "babylonjs/scene";
  59289. /**
  59290. * Class used to store a color step for the GradientBlock
  59291. */
  59292. export class GradientBlockColorStep {
  59293. /**
  59294. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59295. */
  59296. step: number;
  59297. /**
  59298. * Gets or sets the color associated with this step
  59299. */
  59300. color: Color3;
  59301. /**
  59302. * Creates a new GradientBlockColorStep
  59303. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59304. * @param color defines the color associated with this step
  59305. */
  59306. constructor(
  59307. /**
  59308. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59309. */
  59310. step: number,
  59311. /**
  59312. * Gets or sets the color associated with this step
  59313. */
  59314. color: Color3);
  59315. }
  59316. /**
  59317. * Block used to return a color from a gradient based on an input value between 0 and 1
  59318. */
  59319. export class GradientBlock extends NodeMaterialBlock {
  59320. /**
  59321. * Gets or sets the list of color steps
  59322. */
  59323. colorSteps: GradientBlockColorStep[];
  59324. /**
  59325. * Creates a new GradientBlock
  59326. * @param name defines the block name
  59327. */
  59328. constructor(name: string);
  59329. /**
  59330. * Gets the current class name
  59331. * @returns the class name
  59332. */
  59333. getClassName(): string;
  59334. /**
  59335. * Gets the gradient input component
  59336. */
  59337. readonly gradient: NodeMaterialConnectionPoint;
  59338. /**
  59339. * Gets the output component
  59340. */
  59341. readonly output: NodeMaterialConnectionPoint;
  59342. private _writeColorConstant;
  59343. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59344. serialize(): any;
  59345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59346. protected _dumpPropertiesCode(): string;
  59347. }
  59348. }
  59349. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59350. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59351. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59352. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59353. /**
  59354. * Block used to normalize lerp between 2 values
  59355. */
  59356. export class NLerpBlock extends NodeMaterialBlock {
  59357. /**
  59358. * Creates a new NLerpBlock
  59359. * @param name defines the block name
  59360. */
  59361. constructor(name: string);
  59362. /**
  59363. * Gets the current class name
  59364. * @returns the class name
  59365. */
  59366. getClassName(): string;
  59367. /**
  59368. * Gets the left operand input component
  59369. */
  59370. readonly left: NodeMaterialConnectionPoint;
  59371. /**
  59372. * Gets the right operand input component
  59373. */
  59374. readonly right: NodeMaterialConnectionPoint;
  59375. /**
  59376. * Gets the gradient operand input component
  59377. */
  59378. readonly gradient: NodeMaterialConnectionPoint;
  59379. /**
  59380. * Gets the output component
  59381. */
  59382. readonly output: NodeMaterialConnectionPoint;
  59383. protected _buildBlock(state: NodeMaterialBuildState): this;
  59384. }
  59385. }
  59386. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59390. import { Scene } from "babylonjs/scene";
  59391. /**
  59392. * block used to Generate a Worley Noise 3D Noise Pattern
  59393. */
  59394. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59395. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59396. manhattanDistance: boolean;
  59397. /**
  59398. * Creates a new WorleyNoise3DBlock
  59399. * @param name defines the block name
  59400. */
  59401. constructor(name: string);
  59402. /**
  59403. * Gets the current class name
  59404. * @returns the class name
  59405. */
  59406. getClassName(): string;
  59407. /**
  59408. * Gets the seed input component
  59409. */
  59410. readonly seed: NodeMaterialConnectionPoint;
  59411. /**
  59412. * Gets the jitter input component
  59413. */
  59414. readonly jitter: NodeMaterialConnectionPoint;
  59415. /**
  59416. * Gets the output component
  59417. */
  59418. readonly output: NodeMaterialConnectionPoint;
  59419. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59420. /**
  59421. * Exposes the properties to the UI?
  59422. */
  59423. protected _dumpPropertiesCode(): string;
  59424. /**
  59425. * Exposes the properties to the Seralize?
  59426. */
  59427. serialize(): any;
  59428. /**
  59429. * Exposes the properties to the deseralize?
  59430. */
  59431. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59432. }
  59433. }
  59434. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59436. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59437. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59438. /**
  59439. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59440. */
  59441. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59442. /**
  59443. * Creates a new SimplexPerlin3DBlock
  59444. * @param name defines the block name
  59445. */
  59446. constructor(name: string);
  59447. /**
  59448. * Gets the current class name
  59449. * @returns the class name
  59450. */
  59451. getClassName(): string;
  59452. /**
  59453. * Gets the seed operand input component
  59454. */
  59455. readonly seed: NodeMaterialConnectionPoint;
  59456. /**
  59457. * Gets the output component
  59458. */
  59459. readonly output: NodeMaterialConnectionPoint;
  59460. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59461. }
  59462. }
  59463. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59465. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59467. /**
  59468. * Block used to blend normals
  59469. */
  59470. export class NormalBlendBlock extends NodeMaterialBlock {
  59471. /**
  59472. * Creates a new NormalBlendBlock
  59473. * @param name defines the block name
  59474. */
  59475. constructor(name: string);
  59476. /**
  59477. * Gets the current class name
  59478. * @returns the class name
  59479. */
  59480. getClassName(): string;
  59481. /**
  59482. * Gets the first input component
  59483. */
  59484. readonly normalMap0: NodeMaterialConnectionPoint;
  59485. /**
  59486. * Gets the second input component
  59487. */
  59488. readonly normalMap1: NodeMaterialConnectionPoint;
  59489. /**
  59490. * Gets the output component
  59491. */
  59492. readonly output: NodeMaterialConnectionPoint;
  59493. protected _buildBlock(state: NodeMaterialBuildState): this;
  59494. }
  59495. }
  59496. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  59497. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59498. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59499. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59500. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59501. /**
  59502. * Block used to rotate a 2d vector by a given angle
  59503. */
  59504. export class Rotate2dBlock extends NodeMaterialBlock {
  59505. /**
  59506. * Creates a new Rotate2dBlock
  59507. * @param name defines the block name
  59508. */
  59509. constructor(name: string);
  59510. /**
  59511. * Gets the current class name
  59512. * @returns the class name
  59513. */
  59514. getClassName(): string;
  59515. /**
  59516. * Gets the input vector
  59517. */
  59518. readonly input: NodeMaterialConnectionPoint;
  59519. /**
  59520. * Gets the input angle
  59521. */
  59522. readonly angle: NodeMaterialConnectionPoint;
  59523. /**
  59524. * Gets the output component
  59525. */
  59526. readonly output: NodeMaterialConnectionPoint;
  59527. autoConfigure(material: NodeMaterial): void;
  59528. protected _buildBlock(state: NodeMaterialBuildState): this;
  59529. }
  59530. }
  59531. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  59532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59535. /**
  59536. * Block used to get the reflected vector from a direction and a normal
  59537. */
  59538. export class ReflectBlock extends NodeMaterialBlock {
  59539. /**
  59540. * Creates a new ReflectBlock
  59541. * @param name defines the block name
  59542. */
  59543. constructor(name: string);
  59544. /**
  59545. * Gets the current class name
  59546. * @returns the class name
  59547. */
  59548. getClassName(): string;
  59549. /**
  59550. * Gets the incident component
  59551. */
  59552. readonly incident: NodeMaterialConnectionPoint;
  59553. /**
  59554. * Gets the normal component
  59555. */
  59556. readonly normal: NodeMaterialConnectionPoint;
  59557. /**
  59558. * Gets the output component
  59559. */
  59560. readonly output: NodeMaterialConnectionPoint;
  59561. protected _buildBlock(state: NodeMaterialBuildState): this;
  59562. }
  59563. }
  59564. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  59565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59568. /**
  59569. * Block used to get the refracted vector from a direction and a normal
  59570. */
  59571. export class RefractBlock extends NodeMaterialBlock {
  59572. /**
  59573. * Creates a new RefractBlock
  59574. * @param name defines the block name
  59575. */
  59576. constructor(name: string);
  59577. /**
  59578. * Gets the current class name
  59579. * @returns the class name
  59580. */
  59581. getClassName(): string;
  59582. /**
  59583. * Gets the incident component
  59584. */
  59585. readonly incident: NodeMaterialConnectionPoint;
  59586. /**
  59587. * Gets the normal component
  59588. */
  59589. readonly normal: NodeMaterialConnectionPoint;
  59590. /**
  59591. * Gets the index of refraction component
  59592. */
  59593. readonly ior: NodeMaterialConnectionPoint;
  59594. /**
  59595. * Gets the output component
  59596. */
  59597. readonly output: NodeMaterialConnectionPoint;
  59598. protected _buildBlock(state: NodeMaterialBuildState): this;
  59599. }
  59600. }
  59601. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  59602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59604. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59605. /**
  59606. * Block used to desaturate a color
  59607. */
  59608. export class DesaturateBlock extends NodeMaterialBlock {
  59609. /**
  59610. * Creates a new DesaturateBlock
  59611. * @param name defines the block name
  59612. */
  59613. constructor(name: string);
  59614. /**
  59615. * Gets the current class name
  59616. * @returns the class name
  59617. */
  59618. getClassName(): string;
  59619. /**
  59620. * Gets the color operand input component
  59621. */
  59622. readonly color: NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the level operand input component
  59625. */
  59626. readonly level: NodeMaterialConnectionPoint;
  59627. /**
  59628. * Gets the output component
  59629. */
  59630. readonly output: NodeMaterialConnectionPoint;
  59631. protected _buildBlock(state: NodeMaterialBuildState): this;
  59632. }
  59633. }
  59634. declare module "babylonjs/Materials/Node/Blocks/index" {
  59635. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59636. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59637. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59638. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59639. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59640. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59641. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59642. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59643. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59644. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59645. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59646. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59647. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59648. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59649. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59650. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59651. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59652. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59653. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59654. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59655. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59656. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59657. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59658. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59659. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59660. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59661. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59662. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59663. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59664. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59665. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59666. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59667. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59668. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59669. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59670. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59671. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59672. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59673. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59674. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59675. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  59676. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  59677. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  59678. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  59679. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  59680. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  59681. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  59682. }
  59683. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59684. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59685. }
  59686. declare module "babylonjs/Materials/Node/index" {
  59687. export * from "babylonjs/Materials/Node/Enums/index";
  59688. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59689. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59690. export * from "babylonjs/Materials/Node/nodeMaterial";
  59691. export * from "babylonjs/Materials/Node/Blocks/index";
  59692. export * from "babylonjs/Materials/Node/Optimizers/index";
  59693. }
  59694. declare module "babylonjs/Materials/effectRenderer" {
  59695. import { Nullable } from "babylonjs/types";
  59696. import { Texture } from "babylonjs/Materials/Textures/texture";
  59697. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59698. import { Viewport } from "babylonjs/Maths/math.viewport";
  59699. import { Observable } from "babylonjs/Misc/observable";
  59700. import { Effect } from "babylonjs/Materials/effect";
  59701. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59702. import "babylonjs/Shaders/postprocess.vertex";
  59703. /**
  59704. * Effect Render Options
  59705. */
  59706. export interface IEffectRendererOptions {
  59707. /**
  59708. * Defines the vertices positions.
  59709. */
  59710. positions?: number[];
  59711. /**
  59712. * Defines the indices.
  59713. */
  59714. indices?: number[];
  59715. }
  59716. /**
  59717. * Helper class to render one or more effects
  59718. */
  59719. export class EffectRenderer {
  59720. private engine;
  59721. private static _DefaultOptions;
  59722. private _vertexBuffers;
  59723. private _indexBuffer;
  59724. private _ringBufferIndex;
  59725. private _ringScreenBuffer;
  59726. private _fullscreenViewport;
  59727. private _getNextFrameBuffer;
  59728. /**
  59729. * Creates an effect renderer
  59730. * @param engine the engine to use for rendering
  59731. * @param options defines the options of the effect renderer
  59732. */
  59733. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59734. /**
  59735. * Sets the current viewport in normalized coordinates 0-1
  59736. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59737. */
  59738. setViewport(viewport?: Viewport): void;
  59739. /**
  59740. * Binds the embedded attributes buffer to the effect.
  59741. * @param effect Defines the effect to bind the attributes for
  59742. */
  59743. bindBuffers(effect: Effect): void;
  59744. /**
  59745. * Sets the current effect wrapper to use during draw.
  59746. * The effect needs to be ready before calling this api.
  59747. * This also sets the default full screen position attribute.
  59748. * @param effectWrapper Defines the effect to draw with
  59749. */
  59750. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59751. /**
  59752. * Draws a full screen quad.
  59753. */
  59754. draw(): void;
  59755. /**
  59756. * renders one or more effects to a specified texture
  59757. * @param effectWrappers list of effects to renderer
  59758. * @param outputTexture texture to draw to, if null it will render to the screen
  59759. */
  59760. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59761. /**
  59762. * Disposes of the effect renderer
  59763. */
  59764. dispose(): void;
  59765. }
  59766. /**
  59767. * Options to create an EffectWrapper
  59768. */
  59769. interface EffectWrapperCreationOptions {
  59770. /**
  59771. * Engine to use to create the effect
  59772. */
  59773. engine: ThinEngine;
  59774. /**
  59775. * Fragment shader for the effect
  59776. */
  59777. fragmentShader: string;
  59778. /**
  59779. * Vertex shader for the effect
  59780. */
  59781. vertexShader?: string;
  59782. /**
  59783. * Attributes to use in the shader
  59784. */
  59785. attributeNames?: Array<string>;
  59786. /**
  59787. * Uniforms to use in the shader
  59788. */
  59789. uniformNames?: Array<string>;
  59790. /**
  59791. * Texture sampler names to use in the shader
  59792. */
  59793. samplerNames?: Array<string>;
  59794. /**
  59795. * The friendly name of the effect displayed in Spector.
  59796. */
  59797. name?: string;
  59798. }
  59799. /**
  59800. * Wraps an effect to be used for rendering
  59801. */
  59802. export class EffectWrapper {
  59803. /**
  59804. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59805. */
  59806. onApplyObservable: Observable<{}>;
  59807. /**
  59808. * The underlying effect
  59809. */
  59810. effect: Effect;
  59811. /**
  59812. * Creates an effect to be renderer
  59813. * @param creationOptions options to create the effect
  59814. */
  59815. constructor(creationOptions: EffectWrapperCreationOptions);
  59816. /**
  59817. * Disposes of the effect wrapper
  59818. */
  59819. dispose(): void;
  59820. }
  59821. }
  59822. declare module "babylonjs/Materials/index" {
  59823. export * from "babylonjs/Materials/Background/index";
  59824. export * from "babylonjs/Materials/colorCurves";
  59825. export * from "babylonjs/Materials/iEffectFallbacks";
  59826. export * from "babylonjs/Materials/effectFallbacks";
  59827. export * from "babylonjs/Materials/effect";
  59828. export * from "babylonjs/Materials/fresnelParameters";
  59829. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59830. export * from "babylonjs/Materials/material";
  59831. export * from "babylonjs/Materials/materialDefines";
  59832. export * from "babylonjs/Materials/materialHelper";
  59833. export * from "babylonjs/Materials/multiMaterial";
  59834. export * from "babylonjs/Materials/PBR/index";
  59835. export * from "babylonjs/Materials/pushMaterial";
  59836. export * from "babylonjs/Materials/shaderMaterial";
  59837. export * from "babylonjs/Materials/standardMaterial";
  59838. export * from "babylonjs/Materials/Textures/index";
  59839. export * from "babylonjs/Materials/uniformBuffer";
  59840. export * from "babylonjs/Materials/materialFlags";
  59841. export * from "babylonjs/Materials/Node/index";
  59842. export * from "babylonjs/Materials/effectRenderer";
  59843. }
  59844. declare module "babylonjs/Maths/index" {
  59845. export * from "babylonjs/Maths/math.scalar";
  59846. export * from "babylonjs/Maths/math";
  59847. export * from "babylonjs/Maths/sphericalPolynomial";
  59848. }
  59849. declare module "babylonjs/Misc/workerPool" {
  59850. import { IDisposable } from "babylonjs/scene";
  59851. /**
  59852. * Helper class to push actions to a pool of workers.
  59853. */
  59854. export class WorkerPool implements IDisposable {
  59855. private _workerInfos;
  59856. private _pendingActions;
  59857. /**
  59858. * Constructor
  59859. * @param workers Array of workers to use for actions
  59860. */
  59861. constructor(workers: Array<Worker>);
  59862. /**
  59863. * Terminates all workers and clears any pending actions.
  59864. */
  59865. dispose(): void;
  59866. /**
  59867. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59868. * pended until a worker has completed its action.
  59869. * @param action The action to perform. Call onComplete when the action is complete.
  59870. */
  59871. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59872. private _execute;
  59873. }
  59874. }
  59875. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59876. import { IDisposable } from "babylonjs/scene";
  59877. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59878. /**
  59879. * Configuration for Draco compression
  59880. */
  59881. export interface IDracoCompressionConfiguration {
  59882. /**
  59883. * Configuration for the decoder.
  59884. */
  59885. decoder: {
  59886. /**
  59887. * The url to the WebAssembly module.
  59888. */
  59889. wasmUrl?: string;
  59890. /**
  59891. * The url to the WebAssembly binary.
  59892. */
  59893. wasmBinaryUrl?: string;
  59894. /**
  59895. * The url to the fallback JavaScript module.
  59896. */
  59897. fallbackUrl?: string;
  59898. };
  59899. }
  59900. /**
  59901. * Draco compression (https://google.github.io/draco/)
  59902. *
  59903. * This class wraps the Draco module.
  59904. *
  59905. * **Encoder**
  59906. *
  59907. * The encoder is not currently implemented.
  59908. *
  59909. * **Decoder**
  59910. *
  59911. * 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.
  59912. *
  59913. * To update the configuration, use the following code:
  59914. * ```javascript
  59915. * DracoCompression.Configuration = {
  59916. * decoder: {
  59917. * wasmUrl: "<url to the WebAssembly library>",
  59918. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59919. * fallbackUrl: "<url to the fallback JavaScript library>",
  59920. * }
  59921. * };
  59922. * ```
  59923. *
  59924. * 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.
  59925. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59926. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59927. *
  59928. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59929. * ```javascript
  59930. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59931. * ```
  59932. *
  59933. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59934. */
  59935. export class DracoCompression implements IDisposable {
  59936. private _workerPoolPromise?;
  59937. private _decoderModulePromise?;
  59938. /**
  59939. * The configuration. Defaults to the following urls:
  59940. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59941. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59942. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59943. */
  59944. static Configuration: IDracoCompressionConfiguration;
  59945. /**
  59946. * Returns true if the decoder configuration is available.
  59947. */
  59948. static readonly DecoderAvailable: boolean;
  59949. /**
  59950. * Default number of workers to create when creating the draco compression object.
  59951. */
  59952. static DefaultNumWorkers: number;
  59953. private static GetDefaultNumWorkers;
  59954. private static _Default;
  59955. /**
  59956. * Default instance for the draco compression object.
  59957. */
  59958. static readonly Default: DracoCompression;
  59959. /**
  59960. * Constructor
  59961. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59962. */
  59963. constructor(numWorkers?: number);
  59964. /**
  59965. * Stop all async operations and release resources.
  59966. */
  59967. dispose(): void;
  59968. /**
  59969. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59970. * @returns a promise that resolves when ready
  59971. */
  59972. whenReadyAsync(): Promise<void>;
  59973. /**
  59974. * Decode Draco compressed mesh data to vertex data.
  59975. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59976. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59977. * @returns A promise that resolves with the decoded vertex data
  59978. */
  59979. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59980. [kind: string]: number;
  59981. }): Promise<VertexData>;
  59982. }
  59983. }
  59984. declare module "babylonjs/Meshes/Compression/index" {
  59985. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59986. }
  59987. declare module "babylonjs/Meshes/csg" {
  59988. import { Nullable } from "babylonjs/types";
  59989. import { Scene } from "babylonjs/scene";
  59990. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59991. import { Mesh } from "babylonjs/Meshes/mesh";
  59992. import { Material } from "babylonjs/Materials/material";
  59993. /**
  59994. * Class for building Constructive Solid Geometry
  59995. */
  59996. export class CSG {
  59997. private polygons;
  59998. /**
  59999. * The world matrix
  60000. */
  60001. matrix: Matrix;
  60002. /**
  60003. * Stores the position
  60004. */
  60005. position: Vector3;
  60006. /**
  60007. * Stores the rotation
  60008. */
  60009. rotation: Vector3;
  60010. /**
  60011. * Stores the rotation quaternion
  60012. */
  60013. rotationQuaternion: Nullable<Quaternion>;
  60014. /**
  60015. * Stores the scaling vector
  60016. */
  60017. scaling: Vector3;
  60018. /**
  60019. * Convert the Mesh to CSG
  60020. * @param mesh The Mesh to convert to CSG
  60021. * @returns A new CSG from the Mesh
  60022. */
  60023. static FromMesh(mesh: Mesh): CSG;
  60024. /**
  60025. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60026. * @param polygons Polygons used to construct a CSG solid
  60027. */
  60028. private static FromPolygons;
  60029. /**
  60030. * Clones, or makes a deep copy, of the CSG
  60031. * @returns A new CSG
  60032. */
  60033. clone(): CSG;
  60034. /**
  60035. * Unions this CSG with another CSG
  60036. * @param csg The CSG to union against this CSG
  60037. * @returns The unioned CSG
  60038. */
  60039. union(csg: CSG): CSG;
  60040. /**
  60041. * Unions this CSG with another CSG in place
  60042. * @param csg The CSG to union against this CSG
  60043. */
  60044. unionInPlace(csg: CSG): void;
  60045. /**
  60046. * Subtracts this CSG with another CSG
  60047. * @param csg The CSG to subtract against this CSG
  60048. * @returns A new CSG
  60049. */
  60050. subtract(csg: CSG): CSG;
  60051. /**
  60052. * Subtracts this CSG with another CSG in place
  60053. * @param csg The CSG to subtact against this CSG
  60054. */
  60055. subtractInPlace(csg: CSG): void;
  60056. /**
  60057. * Intersect this CSG with another CSG
  60058. * @param csg The CSG to intersect against this CSG
  60059. * @returns A new CSG
  60060. */
  60061. intersect(csg: CSG): CSG;
  60062. /**
  60063. * Intersects this CSG with another CSG in place
  60064. * @param csg The CSG to intersect against this CSG
  60065. */
  60066. intersectInPlace(csg: CSG): void;
  60067. /**
  60068. * Return a new CSG solid with solid and empty space switched. This solid is
  60069. * not modified.
  60070. * @returns A new CSG solid with solid and empty space switched
  60071. */
  60072. inverse(): CSG;
  60073. /**
  60074. * Inverses the CSG in place
  60075. */
  60076. inverseInPlace(): void;
  60077. /**
  60078. * This is used to keep meshes transformations so they can be restored
  60079. * when we build back a Babylon Mesh
  60080. * NB : All CSG operations are performed in world coordinates
  60081. * @param csg The CSG to copy the transform attributes from
  60082. * @returns This CSG
  60083. */
  60084. copyTransformAttributes(csg: CSG): CSG;
  60085. /**
  60086. * Build Raw mesh from CSG
  60087. * Coordinates here are in world space
  60088. * @param name The name of the mesh geometry
  60089. * @param scene The Scene
  60090. * @param keepSubMeshes Specifies if the submeshes should be kept
  60091. * @returns A new Mesh
  60092. */
  60093. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60094. /**
  60095. * Build Mesh from CSG taking material and transforms into account
  60096. * @param name The name of the Mesh
  60097. * @param material The material of the Mesh
  60098. * @param scene The Scene
  60099. * @param keepSubMeshes Specifies if submeshes should be kept
  60100. * @returns The new Mesh
  60101. */
  60102. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60103. }
  60104. }
  60105. declare module "babylonjs/Meshes/trailMesh" {
  60106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60107. import { Mesh } from "babylonjs/Meshes/mesh";
  60108. import { Scene } from "babylonjs/scene";
  60109. /**
  60110. * Class used to create a trail following a mesh
  60111. */
  60112. export class TrailMesh extends Mesh {
  60113. private _generator;
  60114. private _autoStart;
  60115. private _running;
  60116. private _diameter;
  60117. private _length;
  60118. private _sectionPolygonPointsCount;
  60119. private _sectionVectors;
  60120. private _sectionNormalVectors;
  60121. private _beforeRenderObserver;
  60122. /**
  60123. * @constructor
  60124. * @param name The value used by scene.getMeshByName() to do a lookup.
  60125. * @param generator The mesh to generate a trail.
  60126. * @param scene The scene to add this mesh to.
  60127. * @param diameter Diameter of trailing mesh. Default is 1.
  60128. * @param length Length of trailing mesh. Default is 60.
  60129. * @param autoStart Automatically start trailing mesh. Default true.
  60130. */
  60131. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60132. /**
  60133. * "TrailMesh"
  60134. * @returns "TrailMesh"
  60135. */
  60136. getClassName(): string;
  60137. private _createMesh;
  60138. /**
  60139. * Start trailing mesh.
  60140. */
  60141. start(): void;
  60142. /**
  60143. * Stop trailing mesh.
  60144. */
  60145. stop(): void;
  60146. /**
  60147. * Update trailing mesh geometry.
  60148. */
  60149. update(): void;
  60150. /**
  60151. * Returns a new TrailMesh object.
  60152. * @param name is a string, the name given to the new mesh
  60153. * @param newGenerator use new generator object for cloned trail mesh
  60154. * @returns a new mesh
  60155. */
  60156. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60157. /**
  60158. * Serializes this trail mesh
  60159. * @param serializationObject object to write serialization to
  60160. */
  60161. serialize(serializationObject: any): void;
  60162. /**
  60163. * Parses a serialized trail mesh
  60164. * @param parsedMesh the serialized mesh
  60165. * @param scene the scene to create the trail mesh in
  60166. * @returns the created trail mesh
  60167. */
  60168. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60169. }
  60170. }
  60171. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  60172. import { Nullable } from "babylonjs/types";
  60173. import { Scene } from "babylonjs/scene";
  60174. import { Vector4 } from "babylonjs/Maths/math.vector";
  60175. import { Color4 } from "babylonjs/Maths/math.color";
  60176. import { Mesh } from "babylonjs/Meshes/mesh";
  60177. /**
  60178. * Class containing static functions to help procedurally build meshes
  60179. */
  60180. export class TiledBoxBuilder {
  60181. /**
  60182. * Creates a box mesh
  60183. * 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)
  60184. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60188. * @param name defines the name of the mesh
  60189. * @param options defines the options used to create the mesh
  60190. * @param scene defines the hosting scene
  60191. * @returns the box mesh
  60192. */
  60193. static CreateTiledBox(name: string, options: {
  60194. pattern?: number;
  60195. width?: number;
  60196. height?: number;
  60197. depth?: number;
  60198. tileSize?: number;
  60199. tileWidth?: number;
  60200. tileHeight?: number;
  60201. alignHorizontal?: number;
  60202. alignVertical?: number;
  60203. faceUV?: Vector4[];
  60204. faceColors?: Color4[];
  60205. sideOrientation?: number;
  60206. updatable?: boolean;
  60207. }, scene?: Nullable<Scene>): Mesh;
  60208. }
  60209. }
  60210. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  60211. import { Vector4 } from "babylonjs/Maths/math.vector";
  60212. import { Mesh } from "babylonjs/Meshes/mesh";
  60213. /**
  60214. * Class containing static functions to help procedurally build meshes
  60215. */
  60216. export class TorusKnotBuilder {
  60217. /**
  60218. * Creates a torus knot mesh
  60219. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60220. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60221. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60222. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60226. * @param name defines the name of the mesh
  60227. * @param options defines the options used to create the mesh
  60228. * @param scene defines the hosting scene
  60229. * @returns the torus knot mesh
  60230. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60231. */
  60232. static CreateTorusKnot(name: string, options: {
  60233. radius?: number;
  60234. tube?: number;
  60235. radialSegments?: number;
  60236. tubularSegments?: number;
  60237. p?: number;
  60238. q?: number;
  60239. updatable?: boolean;
  60240. sideOrientation?: number;
  60241. frontUVs?: Vector4;
  60242. backUVs?: Vector4;
  60243. }, scene: any): Mesh;
  60244. }
  60245. }
  60246. declare module "babylonjs/Meshes/polygonMesh" {
  60247. import { Scene } from "babylonjs/scene";
  60248. import { Vector2 } from "babylonjs/Maths/math.vector";
  60249. import { Mesh } from "babylonjs/Meshes/mesh";
  60250. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60251. import { Path2 } from "babylonjs/Maths/math.path";
  60252. /**
  60253. * Polygon
  60254. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60255. */
  60256. export class Polygon {
  60257. /**
  60258. * Creates a rectangle
  60259. * @param xmin bottom X coord
  60260. * @param ymin bottom Y coord
  60261. * @param xmax top X coord
  60262. * @param ymax top Y coord
  60263. * @returns points that make the resulting rectation
  60264. */
  60265. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60266. /**
  60267. * Creates a circle
  60268. * @param radius radius of circle
  60269. * @param cx scale in x
  60270. * @param cy scale in y
  60271. * @param numberOfSides number of sides that make up the circle
  60272. * @returns points that make the resulting circle
  60273. */
  60274. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60275. /**
  60276. * Creates a polygon from input string
  60277. * @param input Input polygon data
  60278. * @returns the parsed points
  60279. */
  60280. static Parse(input: string): Vector2[];
  60281. /**
  60282. * Starts building a polygon from x and y coordinates
  60283. * @param x x coordinate
  60284. * @param y y coordinate
  60285. * @returns the started path2
  60286. */
  60287. static StartingAt(x: number, y: number): Path2;
  60288. }
  60289. /**
  60290. * Builds a polygon
  60291. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60292. */
  60293. export class PolygonMeshBuilder {
  60294. private _points;
  60295. private _outlinepoints;
  60296. private _holes;
  60297. private _name;
  60298. private _scene;
  60299. private _epoints;
  60300. private _eholes;
  60301. private _addToepoint;
  60302. /**
  60303. * Babylon reference to the earcut plugin.
  60304. */
  60305. bjsEarcut: any;
  60306. /**
  60307. * Creates a PolygonMeshBuilder
  60308. * @param name name of the builder
  60309. * @param contours Path of the polygon
  60310. * @param scene scene to add to when creating the mesh
  60311. * @param earcutInjection can be used to inject your own earcut reference
  60312. */
  60313. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60314. /**
  60315. * Adds a whole within the polygon
  60316. * @param hole Array of points defining the hole
  60317. * @returns this
  60318. */
  60319. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60320. /**
  60321. * Creates the polygon
  60322. * @param updatable If the mesh should be updatable
  60323. * @param depth The depth of the mesh created
  60324. * @returns the created mesh
  60325. */
  60326. build(updatable?: boolean, depth?: number): Mesh;
  60327. /**
  60328. * Creates the polygon
  60329. * @param depth The depth of the mesh created
  60330. * @returns the created VertexData
  60331. */
  60332. buildVertexData(depth?: number): VertexData;
  60333. /**
  60334. * Adds a side to the polygon
  60335. * @param positions points that make the polygon
  60336. * @param normals normals of the polygon
  60337. * @param uvs uvs of the polygon
  60338. * @param indices indices of the polygon
  60339. * @param bounds bounds of the polygon
  60340. * @param points points of the polygon
  60341. * @param depth depth of the polygon
  60342. * @param flip flip of the polygon
  60343. */
  60344. private addSide;
  60345. }
  60346. }
  60347. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  60348. import { Scene } from "babylonjs/scene";
  60349. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60350. import { Color4 } from "babylonjs/Maths/math.color";
  60351. import { Mesh } from "babylonjs/Meshes/mesh";
  60352. import { Nullable } from "babylonjs/types";
  60353. /**
  60354. * Class containing static functions to help procedurally build meshes
  60355. */
  60356. export class PolygonBuilder {
  60357. /**
  60358. * Creates a polygon mesh
  60359. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60360. * * 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
  60361. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60364. * * Remember you can only change the shape positions, not their number when updating a polygon
  60365. * @param name defines the name of the mesh
  60366. * @param options defines the options used to create the mesh
  60367. * @param scene defines the hosting scene
  60368. * @param earcutInjection can be used to inject your own earcut reference
  60369. * @returns the polygon mesh
  60370. */
  60371. static CreatePolygon(name: string, options: {
  60372. shape: Vector3[];
  60373. holes?: Vector3[][];
  60374. depth?: number;
  60375. faceUV?: Vector4[];
  60376. faceColors?: Color4[];
  60377. updatable?: boolean;
  60378. sideOrientation?: number;
  60379. frontUVs?: Vector4;
  60380. backUVs?: Vector4;
  60381. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60382. /**
  60383. * Creates an extruded polygon mesh, with depth in the Y direction.
  60384. * * 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)
  60385. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60386. * @param name defines the name of the mesh
  60387. * @param options defines the options used to create the mesh
  60388. * @param scene defines the hosting scene
  60389. * @param earcutInjection can be used to inject your own earcut reference
  60390. * @returns the polygon mesh
  60391. */
  60392. static ExtrudePolygon(name: string, options: {
  60393. shape: Vector3[];
  60394. holes?: Vector3[][];
  60395. depth?: number;
  60396. faceUV?: Vector4[];
  60397. faceColors?: Color4[];
  60398. updatable?: boolean;
  60399. sideOrientation?: number;
  60400. frontUVs?: Vector4;
  60401. backUVs?: Vector4;
  60402. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60403. }
  60404. }
  60405. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60406. import { Scene } from "babylonjs/scene";
  60407. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60408. import { Mesh } from "babylonjs/Meshes/mesh";
  60409. import { Nullable } from "babylonjs/types";
  60410. /**
  60411. * Class containing static functions to help procedurally build meshes
  60412. */
  60413. export class LatheBuilder {
  60414. /**
  60415. * Creates lathe mesh.
  60416. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60417. * * 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
  60418. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60419. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60420. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60421. * * 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
  60422. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60423. * * 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
  60424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60428. * @param name defines the name of the mesh
  60429. * @param options defines the options used to create the mesh
  60430. * @param scene defines the hosting scene
  60431. * @returns the lathe mesh
  60432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60433. */
  60434. static CreateLathe(name: string, options: {
  60435. shape: Vector3[];
  60436. radius?: number;
  60437. tessellation?: number;
  60438. clip?: number;
  60439. arc?: number;
  60440. closed?: boolean;
  60441. updatable?: boolean;
  60442. sideOrientation?: number;
  60443. frontUVs?: Vector4;
  60444. backUVs?: Vector4;
  60445. cap?: number;
  60446. invertUV?: boolean;
  60447. }, scene?: Nullable<Scene>): Mesh;
  60448. }
  60449. }
  60450. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60451. import { Nullable } from "babylonjs/types";
  60452. import { Scene } from "babylonjs/scene";
  60453. import { Vector4 } from "babylonjs/Maths/math.vector";
  60454. import { Mesh } from "babylonjs/Meshes/mesh";
  60455. /**
  60456. * Class containing static functions to help procedurally build meshes
  60457. */
  60458. export class TiledPlaneBuilder {
  60459. /**
  60460. * Creates a tiled plane mesh
  60461. * * The parameter `pattern` will, depending on value, do nothing or
  60462. * * * flip (reflect about central vertical) alternate tiles across and up
  60463. * * * flip every tile on alternate rows
  60464. * * * rotate (180 degs) alternate tiles across and up
  60465. * * * rotate every tile on alternate rows
  60466. * * * flip and rotate alternate tiles across and up
  60467. * * * flip and rotate every tile on alternate rows
  60468. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60469. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60472. * * 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)
  60473. * * 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)
  60474. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60475. * @param name defines the name of the mesh
  60476. * @param options defines the options used to create the mesh
  60477. * @param scene defines the hosting scene
  60478. * @returns the box mesh
  60479. */
  60480. static CreateTiledPlane(name: string, options: {
  60481. pattern?: number;
  60482. tileSize?: number;
  60483. tileWidth?: number;
  60484. tileHeight?: number;
  60485. size?: number;
  60486. width?: number;
  60487. height?: number;
  60488. alignHorizontal?: number;
  60489. alignVertical?: number;
  60490. sideOrientation?: number;
  60491. frontUVs?: Vector4;
  60492. backUVs?: Vector4;
  60493. updatable?: boolean;
  60494. }, scene?: Nullable<Scene>): Mesh;
  60495. }
  60496. }
  60497. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60498. import { Nullable } from "babylonjs/types";
  60499. import { Scene } from "babylonjs/scene";
  60500. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60501. import { Mesh } from "babylonjs/Meshes/mesh";
  60502. /**
  60503. * Class containing static functions to help procedurally build meshes
  60504. */
  60505. export class TubeBuilder {
  60506. /**
  60507. * Creates a tube mesh.
  60508. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60509. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60510. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60511. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60512. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60513. * * 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)
  60514. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60515. * * 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
  60516. * * 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
  60517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60519. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60521. * @param name defines the name of the mesh
  60522. * @param options defines the options used to create the mesh
  60523. * @param scene defines the hosting scene
  60524. * @returns the tube mesh
  60525. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60526. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60527. */
  60528. static CreateTube(name: string, options: {
  60529. path: Vector3[];
  60530. radius?: number;
  60531. tessellation?: number;
  60532. radiusFunction?: {
  60533. (i: number, distance: number): number;
  60534. };
  60535. cap?: number;
  60536. arc?: number;
  60537. updatable?: boolean;
  60538. sideOrientation?: number;
  60539. frontUVs?: Vector4;
  60540. backUVs?: Vector4;
  60541. instance?: Mesh;
  60542. invertUV?: boolean;
  60543. }, scene?: Nullable<Scene>): Mesh;
  60544. }
  60545. }
  60546. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60547. import { Scene } from "babylonjs/scene";
  60548. import { Vector4 } from "babylonjs/Maths/math.vector";
  60549. import { Mesh } from "babylonjs/Meshes/mesh";
  60550. import { Nullable } from "babylonjs/types";
  60551. /**
  60552. * Class containing static functions to help procedurally build meshes
  60553. */
  60554. export class IcoSphereBuilder {
  60555. /**
  60556. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60557. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60558. * * 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`)
  60559. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60560. * * 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
  60561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60564. * @param name defines the name of the mesh
  60565. * @param options defines the options used to create the mesh
  60566. * @param scene defines the hosting scene
  60567. * @returns the icosahedron mesh
  60568. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60569. */
  60570. static CreateIcoSphere(name: string, options: {
  60571. radius?: number;
  60572. radiusX?: number;
  60573. radiusY?: number;
  60574. radiusZ?: number;
  60575. flat?: boolean;
  60576. subdivisions?: number;
  60577. sideOrientation?: number;
  60578. frontUVs?: Vector4;
  60579. backUVs?: Vector4;
  60580. updatable?: boolean;
  60581. }, scene?: Nullable<Scene>): Mesh;
  60582. }
  60583. }
  60584. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60585. import { Vector3 } from "babylonjs/Maths/math.vector";
  60586. import { Mesh } from "babylonjs/Meshes/mesh";
  60587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60588. /**
  60589. * Class containing static functions to help procedurally build meshes
  60590. */
  60591. export class DecalBuilder {
  60592. /**
  60593. * Creates a decal mesh.
  60594. * 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
  60595. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60596. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60597. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60598. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60599. * @param name defines the name of the mesh
  60600. * @param sourceMesh defines the mesh where the decal must be applied
  60601. * @param options defines the options used to create the mesh
  60602. * @param scene defines the hosting scene
  60603. * @returns the decal mesh
  60604. * @see https://doc.babylonjs.com/how_to/decals
  60605. */
  60606. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60607. position?: Vector3;
  60608. normal?: Vector3;
  60609. size?: Vector3;
  60610. angle?: number;
  60611. }): Mesh;
  60612. }
  60613. }
  60614. declare module "babylonjs/Meshes/meshBuilder" {
  60615. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60616. import { Nullable } from "babylonjs/types";
  60617. import { Scene } from "babylonjs/scene";
  60618. import { Mesh } from "babylonjs/Meshes/mesh";
  60619. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60620. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60622. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60623. import { Plane } from "babylonjs/Maths/math.plane";
  60624. /**
  60625. * Class containing static functions to help procedurally build meshes
  60626. */
  60627. export class MeshBuilder {
  60628. /**
  60629. * Creates a box mesh
  60630. * * The parameter `size` sets the size (float) of each box side (default 1)
  60631. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60632. * * 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)
  60633. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60635. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60637. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60638. * @param name defines the name of the mesh
  60639. * @param options defines the options used to create the mesh
  60640. * @param scene defines the hosting scene
  60641. * @returns the box mesh
  60642. */
  60643. static CreateBox(name: string, options: {
  60644. size?: number;
  60645. width?: number;
  60646. height?: number;
  60647. depth?: number;
  60648. faceUV?: Vector4[];
  60649. faceColors?: Color4[];
  60650. sideOrientation?: number;
  60651. frontUVs?: Vector4;
  60652. backUVs?: Vector4;
  60653. updatable?: boolean;
  60654. }, scene?: Nullable<Scene>): Mesh;
  60655. /**
  60656. * Creates a tiled box mesh
  60657. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60659. * @param name defines the name of the mesh
  60660. * @param options defines the options used to create the mesh
  60661. * @param scene defines the hosting scene
  60662. * @returns the tiled box mesh
  60663. */
  60664. static CreateTiledBox(name: string, options: {
  60665. pattern?: number;
  60666. size?: number;
  60667. width?: number;
  60668. height?: number;
  60669. depth: number;
  60670. tileSize?: number;
  60671. tileWidth?: number;
  60672. tileHeight?: number;
  60673. faceUV?: Vector4[];
  60674. faceColors?: Color4[];
  60675. alignHorizontal?: number;
  60676. alignVertical?: number;
  60677. sideOrientation?: number;
  60678. updatable?: boolean;
  60679. }, scene?: Nullable<Scene>): Mesh;
  60680. /**
  60681. * Creates a sphere mesh
  60682. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60683. * * 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`)
  60684. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60685. * * 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
  60686. * * 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)
  60687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60690. * @param name defines the name of the mesh
  60691. * @param options defines the options used to create the mesh
  60692. * @param scene defines the hosting scene
  60693. * @returns the sphere mesh
  60694. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60695. */
  60696. static CreateSphere(name: string, options: {
  60697. segments?: number;
  60698. diameter?: number;
  60699. diameterX?: number;
  60700. diameterY?: number;
  60701. diameterZ?: number;
  60702. arc?: number;
  60703. slice?: number;
  60704. sideOrientation?: number;
  60705. frontUVs?: Vector4;
  60706. backUVs?: Vector4;
  60707. updatable?: boolean;
  60708. }, scene?: Nullable<Scene>): Mesh;
  60709. /**
  60710. * Creates a plane polygonal mesh. By default, this is a disc
  60711. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60712. * * 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
  60713. * * 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
  60714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60717. * @param name defines the name of the mesh
  60718. * @param options defines the options used to create the mesh
  60719. * @param scene defines the hosting scene
  60720. * @returns the plane polygonal mesh
  60721. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60722. */
  60723. static CreateDisc(name: string, options: {
  60724. radius?: number;
  60725. tessellation?: number;
  60726. arc?: number;
  60727. updatable?: boolean;
  60728. sideOrientation?: number;
  60729. frontUVs?: Vector4;
  60730. backUVs?: Vector4;
  60731. }, scene?: Nullable<Scene>): Mesh;
  60732. /**
  60733. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60734. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60735. * * 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`)
  60736. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60737. * * 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
  60738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60741. * @param name defines the name of the mesh
  60742. * @param options defines the options used to create the mesh
  60743. * @param scene defines the hosting scene
  60744. * @returns the icosahedron mesh
  60745. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60746. */
  60747. static CreateIcoSphere(name: string, options: {
  60748. radius?: number;
  60749. radiusX?: number;
  60750. radiusY?: number;
  60751. radiusZ?: number;
  60752. flat?: boolean;
  60753. subdivisions?: number;
  60754. sideOrientation?: number;
  60755. frontUVs?: Vector4;
  60756. backUVs?: Vector4;
  60757. updatable?: boolean;
  60758. }, scene?: Nullable<Scene>): Mesh;
  60759. /**
  60760. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60761. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60762. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60763. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60764. * * 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
  60765. * * 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
  60766. * * 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
  60767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60770. * * 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
  60771. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60772. * * 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
  60773. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60775. * @param name defines the name of the mesh
  60776. * @param options defines the options used to create the mesh
  60777. * @param scene defines the hosting scene
  60778. * @returns the ribbon mesh
  60779. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60780. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60781. */
  60782. static CreateRibbon(name: string, options: {
  60783. pathArray: Vector3[][];
  60784. closeArray?: boolean;
  60785. closePath?: boolean;
  60786. offset?: number;
  60787. updatable?: boolean;
  60788. sideOrientation?: number;
  60789. frontUVs?: Vector4;
  60790. backUVs?: Vector4;
  60791. instance?: Mesh;
  60792. invertUV?: boolean;
  60793. uvs?: Vector2[];
  60794. colors?: Color4[];
  60795. }, scene?: Nullable<Scene>): Mesh;
  60796. /**
  60797. * Creates a cylinder or a cone mesh
  60798. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60799. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60800. * * 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.
  60801. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60802. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60803. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60804. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60805. * * 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).
  60806. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60807. * * 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).
  60808. * * 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
  60809. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60810. * * 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
  60811. * * 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.
  60812. * * If `enclose` is false, a ring surface is one element.
  60813. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60814. * * 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
  60815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60818. * @param name defines the name of the mesh
  60819. * @param options defines the options used to create the mesh
  60820. * @param scene defines the hosting scene
  60821. * @returns the cylinder mesh
  60822. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60823. */
  60824. static CreateCylinder(name: string, options: {
  60825. height?: number;
  60826. diameterTop?: number;
  60827. diameterBottom?: number;
  60828. diameter?: number;
  60829. tessellation?: number;
  60830. subdivisions?: number;
  60831. arc?: number;
  60832. faceColors?: Color4[];
  60833. faceUV?: Vector4[];
  60834. updatable?: boolean;
  60835. hasRings?: boolean;
  60836. enclose?: boolean;
  60837. cap?: number;
  60838. sideOrientation?: number;
  60839. frontUVs?: Vector4;
  60840. backUVs?: Vector4;
  60841. }, scene?: Nullable<Scene>): Mesh;
  60842. /**
  60843. * Creates a torus mesh
  60844. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60845. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60846. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60850. * @param name defines the name of the mesh
  60851. * @param options defines the options used to create the mesh
  60852. * @param scene defines the hosting scene
  60853. * @returns the torus mesh
  60854. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60855. */
  60856. static CreateTorus(name: string, options: {
  60857. diameter?: number;
  60858. thickness?: number;
  60859. tessellation?: number;
  60860. updatable?: boolean;
  60861. sideOrientation?: number;
  60862. frontUVs?: Vector4;
  60863. backUVs?: Vector4;
  60864. }, scene?: Nullable<Scene>): Mesh;
  60865. /**
  60866. * Creates a torus knot mesh
  60867. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60868. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60869. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60870. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60874. * @param name defines the name of the mesh
  60875. * @param options defines the options used to create the mesh
  60876. * @param scene defines the hosting scene
  60877. * @returns the torus knot mesh
  60878. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60879. */
  60880. static CreateTorusKnot(name: string, options: {
  60881. radius?: number;
  60882. tube?: number;
  60883. radialSegments?: number;
  60884. tubularSegments?: number;
  60885. p?: number;
  60886. q?: number;
  60887. updatable?: boolean;
  60888. sideOrientation?: number;
  60889. frontUVs?: Vector4;
  60890. backUVs?: Vector4;
  60891. }, scene?: Nullable<Scene>): Mesh;
  60892. /**
  60893. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60894. * * 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
  60895. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60896. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60897. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60898. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60899. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60900. * * 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
  60901. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60904. * @param name defines the name of the new line system
  60905. * @param options defines the options used to create the line system
  60906. * @param scene defines the hosting scene
  60907. * @returns a new line system mesh
  60908. */
  60909. static CreateLineSystem(name: string, options: {
  60910. lines: Vector3[][];
  60911. updatable?: boolean;
  60912. instance?: Nullable<LinesMesh>;
  60913. colors?: Nullable<Color4[][]>;
  60914. useVertexAlpha?: boolean;
  60915. }, scene: Nullable<Scene>): LinesMesh;
  60916. /**
  60917. * Creates a line mesh
  60918. * 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
  60919. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60920. * * The parameter `points` is an array successive Vector3
  60921. * * 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
  60922. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60923. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60924. * * When updating an instance, remember that only point positions can change, not the number of points
  60925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60927. * @param name defines the name of the new line system
  60928. * @param options defines the options used to create the line system
  60929. * @param scene defines the hosting scene
  60930. * @returns a new line mesh
  60931. */
  60932. static CreateLines(name: string, options: {
  60933. points: Vector3[];
  60934. updatable?: boolean;
  60935. instance?: Nullable<LinesMesh>;
  60936. colors?: Color4[];
  60937. useVertexAlpha?: boolean;
  60938. }, scene?: Nullable<Scene>): LinesMesh;
  60939. /**
  60940. * Creates a dashed line mesh
  60941. * * 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
  60942. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60943. * * The parameter `points` is an array successive Vector3
  60944. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60945. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60946. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60947. * * 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
  60948. * * When updating an instance, remember that only point positions can change, not the number of points
  60949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60950. * @param name defines the name of the mesh
  60951. * @param options defines the options used to create the mesh
  60952. * @param scene defines the hosting scene
  60953. * @returns the dashed line mesh
  60954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60955. */
  60956. static CreateDashedLines(name: string, options: {
  60957. points: Vector3[];
  60958. dashSize?: number;
  60959. gapSize?: number;
  60960. dashNb?: number;
  60961. updatable?: boolean;
  60962. instance?: LinesMesh;
  60963. }, scene?: Nullable<Scene>): LinesMesh;
  60964. /**
  60965. * 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.
  60966. * * 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.
  60967. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60968. * * 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.
  60969. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60970. * * 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
  60971. * * 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
  60972. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60977. * @param name defines the name of the mesh
  60978. * @param options defines the options used to create the mesh
  60979. * @param scene defines the hosting scene
  60980. * @returns the extruded shape mesh
  60981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60983. */
  60984. static ExtrudeShape(name: string, options: {
  60985. shape: Vector3[];
  60986. path: Vector3[];
  60987. scale?: number;
  60988. rotation?: number;
  60989. cap?: number;
  60990. updatable?: boolean;
  60991. sideOrientation?: number;
  60992. frontUVs?: Vector4;
  60993. backUVs?: Vector4;
  60994. instance?: Mesh;
  60995. invertUV?: boolean;
  60996. }, scene?: Nullable<Scene>): Mesh;
  60997. /**
  60998. * Creates an custom extruded shape mesh.
  60999. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61000. * * 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.
  61001. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61002. * * 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
  61003. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61004. * * 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
  61005. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61006. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61007. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61008. * * 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
  61009. * * 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
  61010. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61013. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61015. * @param name defines the name of the mesh
  61016. * @param options defines the options used to create the mesh
  61017. * @param scene defines the hosting scene
  61018. * @returns the custom extruded shape mesh
  61019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61020. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61022. */
  61023. static ExtrudeShapeCustom(name: string, options: {
  61024. shape: Vector3[];
  61025. path: Vector3[];
  61026. scaleFunction?: any;
  61027. rotationFunction?: any;
  61028. ribbonCloseArray?: boolean;
  61029. ribbonClosePath?: boolean;
  61030. cap?: number;
  61031. updatable?: boolean;
  61032. sideOrientation?: number;
  61033. frontUVs?: Vector4;
  61034. backUVs?: Vector4;
  61035. instance?: Mesh;
  61036. invertUV?: boolean;
  61037. }, scene?: Nullable<Scene>): Mesh;
  61038. /**
  61039. * Creates lathe mesh.
  61040. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61041. * * 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
  61042. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61043. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61044. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61045. * * 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
  61046. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61047. * * 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
  61048. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61049. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61050. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61052. * @param name defines the name of the mesh
  61053. * @param options defines the options used to create the mesh
  61054. * @param scene defines the hosting scene
  61055. * @returns the lathe mesh
  61056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61057. */
  61058. static CreateLathe(name: string, options: {
  61059. shape: Vector3[];
  61060. radius?: number;
  61061. tessellation?: number;
  61062. clip?: number;
  61063. arc?: number;
  61064. closed?: boolean;
  61065. updatable?: boolean;
  61066. sideOrientation?: number;
  61067. frontUVs?: Vector4;
  61068. backUVs?: Vector4;
  61069. cap?: number;
  61070. invertUV?: boolean;
  61071. }, scene?: Nullable<Scene>): Mesh;
  61072. /**
  61073. * Creates a tiled plane mesh
  61074. * * You can set a limited pattern arrangement with the tiles
  61075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61078. * @param name defines the name of the mesh
  61079. * @param options defines the options used to create the mesh
  61080. * @param scene defines the hosting scene
  61081. * @returns the plane mesh
  61082. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61083. */
  61084. static CreateTiledPlane(name: string, options: {
  61085. pattern?: number;
  61086. tileSize?: number;
  61087. tileWidth?: number;
  61088. tileHeight?: number;
  61089. size?: number;
  61090. width?: number;
  61091. height?: number;
  61092. alignHorizontal?: number;
  61093. alignVertical?: number;
  61094. sideOrientation?: number;
  61095. frontUVs?: Vector4;
  61096. backUVs?: Vector4;
  61097. updatable?: boolean;
  61098. }, scene?: Nullable<Scene>): Mesh;
  61099. /**
  61100. * Creates a plane mesh
  61101. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61102. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61103. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61107. * @param name defines the name of the mesh
  61108. * @param options defines the options used to create the mesh
  61109. * @param scene defines the hosting scene
  61110. * @returns the plane mesh
  61111. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61112. */
  61113. static CreatePlane(name: string, options: {
  61114. size?: number;
  61115. width?: number;
  61116. height?: number;
  61117. sideOrientation?: number;
  61118. frontUVs?: Vector4;
  61119. backUVs?: Vector4;
  61120. updatable?: boolean;
  61121. sourcePlane?: Plane;
  61122. }, scene?: Nullable<Scene>): Mesh;
  61123. /**
  61124. * Creates a ground mesh
  61125. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61126. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61128. * @param name defines the name of the mesh
  61129. * @param options defines the options used to create the mesh
  61130. * @param scene defines the hosting scene
  61131. * @returns the ground mesh
  61132. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61133. */
  61134. static CreateGround(name: string, options: {
  61135. width?: number;
  61136. height?: number;
  61137. subdivisions?: number;
  61138. subdivisionsX?: number;
  61139. subdivisionsY?: number;
  61140. updatable?: boolean;
  61141. }, scene?: Nullable<Scene>): Mesh;
  61142. /**
  61143. * Creates a tiled ground mesh
  61144. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61145. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61146. * * 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
  61147. * * 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
  61148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61149. * @param name defines the name of the mesh
  61150. * @param options defines the options used to create the mesh
  61151. * @param scene defines the hosting scene
  61152. * @returns the tiled ground mesh
  61153. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61154. */
  61155. static CreateTiledGround(name: string, options: {
  61156. xmin: number;
  61157. zmin: number;
  61158. xmax: number;
  61159. zmax: number;
  61160. subdivisions?: {
  61161. w: number;
  61162. h: number;
  61163. };
  61164. precision?: {
  61165. w: number;
  61166. h: number;
  61167. };
  61168. updatable?: boolean;
  61169. }, scene?: Nullable<Scene>): Mesh;
  61170. /**
  61171. * Creates a ground mesh from a height map
  61172. * * The parameter `url` sets the URL of the height map image resource.
  61173. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61174. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61175. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61176. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61177. * * 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.
  61178. * * 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).
  61179. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61181. * @param name defines the name of the mesh
  61182. * @param url defines the url to the height map
  61183. * @param options defines the options used to create the mesh
  61184. * @param scene defines the hosting scene
  61185. * @returns the ground mesh
  61186. * @see https://doc.babylonjs.com/babylon101/height_map
  61187. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61188. */
  61189. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61190. width?: number;
  61191. height?: number;
  61192. subdivisions?: number;
  61193. minHeight?: number;
  61194. maxHeight?: number;
  61195. colorFilter?: Color3;
  61196. alphaFilter?: number;
  61197. updatable?: boolean;
  61198. onReady?: (mesh: GroundMesh) => void;
  61199. }, scene?: Nullable<Scene>): GroundMesh;
  61200. /**
  61201. * Creates a polygon mesh
  61202. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61203. * * 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
  61204. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61207. * * Remember you can only change the shape positions, not their number when updating a polygon
  61208. * @param name defines the name of the mesh
  61209. * @param options defines the options used to create the mesh
  61210. * @param scene defines the hosting scene
  61211. * @param earcutInjection can be used to inject your own earcut reference
  61212. * @returns the polygon mesh
  61213. */
  61214. static CreatePolygon(name: string, options: {
  61215. shape: Vector3[];
  61216. holes?: Vector3[][];
  61217. depth?: number;
  61218. faceUV?: Vector4[];
  61219. faceColors?: Color4[];
  61220. updatable?: boolean;
  61221. sideOrientation?: number;
  61222. frontUVs?: Vector4;
  61223. backUVs?: Vector4;
  61224. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61225. /**
  61226. * Creates an extruded polygon mesh, with depth in the Y direction.
  61227. * * 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)
  61228. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61229. * @param name defines the name of the mesh
  61230. * @param options defines the options used to create the mesh
  61231. * @param scene defines the hosting scene
  61232. * @param earcutInjection can be used to inject your own earcut reference
  61233. * @returns the polygon mesh
  61234. */
  61235. static ExtrudePolygon(name: string, options: {
  61236. shape: Vector3[];
  61237. holes?: Vector3[][];
  61238. depth?: number;
  61239. faceUV?: Vector4[];
  61240. faceColors?: Color4[];
  61241. updatable?: boolean;
  61242. sideOrientation?: number;
  61243. frontUVs?: Vector4;
  61244. backUVs?: Vector4;
  61245. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61246. /**
  61247. * Creates a tube mesh.
  61248. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61249. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61250. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61251. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61252. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61253. * * 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)
  61254. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61255. * * 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
  61256. * * 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
  61257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61261. * @param name defines the name of the mesh
  61262. * @param options defines the options used to create the mesh
  61263. * @param scene defines the hosting scene
  61264. * @returns the tube mesh
  61265. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61266. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61267. */
  61268. static CreateTube(name: string, options: {
  61269. path: Vector3[];
  61270. radius?: number;
  61271. tessellation?: number;
  61272. radiusFunction?: {
  61273. (i: number, distance: number): number;
  61274. };
  61275. cap?: number;
  61276. arc?: number;
  61277. updatable?: boolean;
  61278. sideOrientation?: number;
  61279. frontUVs?: Vector4;
  61280. backUVs?: Vector4;
  61281. instance?: Mesh;
  61282. invertUV?: boolean;
  61283. }, scene?: Nullable<Scene>): Mesh;
  61284. /**
  61285. * Creates a polyhedron mesh
  61286. * * 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
  61287. * * The parameter `size` (positive float, default 1) sets the polygon size
  61288. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61289. * * 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`
  61290. * * 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
  61291. * * 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)`)
  61292. * * 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
  61293. * * 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
  61294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61297. * @param name defines the name of the mesh
  61298. * @param options defines the options used to create the mesh
  61299. * @param scene defines the hosting scene
  61300. * @returns the polyhedron mesh
  61301. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61302. */
  61303. static CreatePolyhedron(name: string, options: {
  61304. type?: number;
  61305. size?: number;
  61306. sizeX?: number;
  61307. sizeY?: number;
  61308. sizeZ?: number;
  61309. custom?: any;
  61310. faceUV?: Vector4[];
  61311. faceColors?: Color4[];
  61312. flat?: boolean;
  61313. updatable?: boolean;
  61314. sideOrientation?: number;
  61315. frontUVs?: Vector4;
  61316. backUVs?: Vector4;
  61317. }, scene?: Nullable<Scene>): Mesh;
  61318. /**
  61319. * Creates a decal mesh.
  61320. * 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
  61321. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61322. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61323. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61324. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61325. * @param name defines the name of the mesh
  61326. * @param sourceMesh defines the mesh where the decal must be applied
  61327. * @param options defines the options used to create the mesh
  61328. * @param scene defines the hosting scene
  61329. * @returns the decal mesh
  61330. * @see https://doc.babylonjs.com/how_to/decals
  61331. */
  61332. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61333. position?: Vector3;
  61334. normal?: Vector3;
  61335. size?: Vector3;
  61336. angle?: number;
  61337. }): Mesh;
  61338. }
  61339. }
  61340. declare module "babylonjs/Meshes/meshSimplification" {
  61341. import { Mesh } from "babylonjs/Meshes/mesh";
  61342. /**
  61343. * A simplifier interface for future simplification implementations
  61344. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61345. */
  61346. export interface ISimplifier {
  61347. /**
  61348. * Simplification of a given mesh according to the given settings.
  61349. * Since this requires computation, it is assumed that the function runs async.
  61350. * @param settings The settings of the simplification, including quality and distance
  61351. * @param successCallback A callback that will be called after the mesh was simplified.
  61352. * @param errorCallback in case of an error, this callback will be called. optional.
  61353. */
  61354. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61355. }
  61356. /**
  61357. * Expected simplification settings.
  61358. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61359. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61360. */
  61361. export interface ISimplificationSettings {
  61362. /**
  61363. * Gets or sets the expected quality
  61364. */
  61365. quality: number;
  61366. /**
  61367. * Gets or sets the distance when this optimized version should be used
  61368. */
  61369. distance: number;
  61370. /**
  61371. * Gets an already optimized mesh
  61372. */
  61373. optimizeMesh?: boolean;
  61374. }
  61375. /**
  61376. * Class used to specify simplification options
  61377. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61378. */
  61379. export class SimplificationSettings implements ISimplificationSettings {
  61380. /** expected quality */
  61381. quality: number;
  61382. /** distance when this optimized version should be used */
  61383. distance: number;
  61384. /** already optimized mesh */
  61385. optimizeMesh?: boolean | undefined;
  61386. /**
  61387. * Creates a SimplificationSettings
  61388. * @param quality expected quality
  61389. * @param distance distance when this optimized version should be used
  61390. * @param optimizeMesh already optimized mesh
  61391. */
  61392. constructor(
  61393. /** expected quality */
  61394. quality: number,
  61395. /** distance when this optimized version should be used */
  61396. distance: number,
  61397. /** already optimized mesh */
  61398. optimizeMesh?: boolean | undefined);
  61399. }
  61400. /**
  61401. * Interface used to define a simplification task
  61402. */
  61403. export interface ISimplificationTask {
  61404. /**
  61405. * Array of settings
  61406. */
  61407. settings: Array<ISimplificationSettings>;
  61408. /**
  61409. * Simplification type
  61410. */
  61411. simplificationType: SimplificationType;
  61412. /**
  61413. * Mesh to simplify
  61414. */
  61415. mesh: Mesh;
  61416. /**
  61417. * Callback called on success
  61418. */
  61419. successCallback?: () => void;
  61420. /**
  61421. * Defines if parallel processing can be used
  61422. */
  61423. parallelProcessing: boolean;
  61424. }
  61425. /**
  61426. * Queue used to order the simplification tasks
  61427. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61428. */
  61429. export class SimplificationQueue {
  61430. private _simplificationArray;
  61431. /**
  61432. * Gets a boolean indicating that the process is still running
  61433. */
  61434. running: boolean;
  61435. /**
  61436. * Creates a new queue
  61437. */
  61438. constructor();
  61439. /**
  61440. * Adds a new simplification task
  61441. * @param task defines a task to add
  61442. */
  61443. addTask(task: ISimplificationTask): void;
  61444. /**
  61445. * Execute next task
  61446. */
  61447. executeNext(): void;
  61448. /**
  61449. * Execute a simplification task
  61450. * @param task defines the task to run
  61451. */
  61452. runSimplification(task: ISimplificationTask): void;
  61453. private getSimplifier;
  61454. }
  61455. /**
  61456. * The implemented types of simplification
  61457. * At the moment only Quadratic Error Decimation is implemented
  61458. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61459. */
  61460. export enum SimplificationType {
  61461. /** Quadratic error decimation */
  61462. QUADRATIC = 0
  61463. }
  61464. }
  61465. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61466. import { Scene } from "babylonjs/scene";
  61467. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61468. import { ISceneComponent } from "babylonjs/sceneComponent";
  61469. module "babylonjs/scene" {
  61470. interface Scene {
  61471. /** @hidden (Backing field) */
  61472. _simplificationQueue: SimplificationQueue;
  61473. /**
  61474. * Gets or sets the simplification queue attached to the scene
  61475. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61476. */
  61477. simplificationQueue: SimplificationQueue;
  61478. }
  61479. }
  61480. module "babylonjs/Meshes/mesh" {
  61481. interface Mesh {
  61482. /**
  61483. * Simplify the mesh according to the given array of settings.
  61484. * Function will return immediately and will simplify async
  61485. * @param settings a collection of simplification settings
  61486. * @param parallelProcessing should all levels calculate parallel or one after the other
  61487. * @param simplificationType the type of simplification to run
  61488. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61489. * @returns the current mesh
  61490. */
  61491. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61492. }
  61493. }
  61494. /**
  61495. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61496. * created in a scene
  61497. */
  61498. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61499. /**
  61500. * The component name helpfull to identify the component in the list of scene components.
  61501. */
  61502. readonly name: string;
  61503. /**
  61504. * The scene the component belongs to.
  61505. */
  61506. scene: Scene;
  61507. /**
  61508. * Creates a new instance of the component for the given scene
  61509. * @param scene Defines the scene to register the component in
  61510. */
  61511. constructor(scene: Scene);
  61512. /**
  61513. * Registers the component in a given scene
  61514. */
  61515. register(): void;
  61516. /**
  61517. * Rebuilds the elements related to this component in case of
  61518. * context lost for instance.
  61519. */
  61520. rebuild(): void;
  61521. /**
  61522. * Disposes the component and the associated ressources
  61523. */
  61524. dispose(): void;
  61525. private _beforeCameraUpdate;
  61526. }
  61527. }
  61528. declare module "babylonjs/Meshes/Builders/index" {
  61529. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61530. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61531. export * from "babylonjs/Meshes/Builders/discBuilder";
  61532. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61533. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61534. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61535. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61536. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61537. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61538. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61539. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61540. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61541. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61542. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61543. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61544. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61545. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61546. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61547. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61548. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61549. }
  61550. declare module "babylonjs/Meshes/index" {
  61551. export * from "babylonjs/Meshes/abstractMesh";
  61552. export * from "babylonjs/Meshes/buffer";
  61553. export * from "babylonjs/Meshes/Compression/index";
  61554. export * from "babylonjs/Meshes/csg";
  61555. export * from "babylonjs/Meshes/geometry";
  61556. export * from "babylonjs/Meshes/groundMesh";
  61557. export * from "babylonjs/Meshes/trailMesh";
  61558. export * from "babylonjs/Meshes/instancedMesh";
  61559. export * from "babylonjs/Meshes/linesMesh";
  61560. export * from "babylonjs/Meshes/mesh";
  61561. export * from "babylonjs/Meshes/mesh.vertexData";
  61562. export * from "babylonjs/Meshes/meshBuilder";
  61563. export * from "babylonjs/Meshes/meshSimplification";
  61564. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61565. export * from "babylonjs/Meshes/polygonMesh";
  61566. export * from "babylonjs/Meshes/subMesh";
  61567. export * from "babylonjs/Meshes/meshLODLevel";
  61568. export * from "babylonjs/Meshes/transformNode";
  61569. export * from "babylonjs/Meshes/Builders/index";
  61570. export * from "babylonjs/Meshes/dataBuffer";
  61571. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61572. }
  61573. declare module "babylonjs/Morph/index" {
  61574. export * from "babylonjs/Morph/morphTarget";
  61575. export * from "babylonjs/Morph/morphTargetManager";
  61576. }
  61577. declare module "babylonjs/Navigation/INavigationEngine" {
  61578. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61579. import { Vector3 } from "babylonjs/Maths/math";
  61580. import { Mesh } from "babylonjs/Meshes/mesh";
  61581. import { Scene } from "babylonjs/scene";
  61582. /**
  61583. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61584. */
  61585. export interface INavigationEnginePlugin {
  61586. /**
  61587. * plugin name
  61588. */
  61589. name: string;
  61590. /**
  61591. * Creates a navigation mesh
  61592. * @param meshes array of all the geometry used to compute the navigatio mesh
  61593. * @param parameters bunch of parameters used to filter geometry
  61594. */
  61595. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61596. /**
  61597. * Create a navigation mesh debug mesh
  61598. * @param scene is where the mesh will be added
  61599. * @returns debug display mesh
  61600. */
  61601. createDebugNavMesh(scene: Scene): Mesh;
  61602. /**
  61603. * Get a navigation mesh constrained position, closest to the parameter position
  61604. * @param position world position
  61605. * @returns the closest point to position constrained by the navigation mesh
  61606. */
  61607. getClosestPoint(position: Vector3): Vector3;
  61608. /**
  61609. * Get a navigation mesh constrained position, within a particular radius
  61610. * @param position world position
  61611. * @param maxRadius the maximum distance to the constrained world position
  61612. * @returns the closest point to position constrained by the navigation mesh
  61613. */
  61614. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61615. /**
  61616. * Compute the final position from a segment made of destination-position
  61617. * @param position world position
  61618. * @param destination world position
  61619. * @returns the resulting point along the navmesh
  61620. */
  61621. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61622. /**
  61623. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61624. * @param start world position
  61625. * @param end world position
  61626. * @returns array containing world position composing the path
  61627. */
  61628. computePath(start: Vector3, end: Vector3): Vector3[];
  61629. /**
  61630. * If this plugin is supported
  61631. * @returns true if plugin is supported
  61632. */
  61633. isSupported(): boolean;
  61634. /**
  61635. * Create a new Crowd so you can add agents
  61636. * @param maxAgents the maximum agent count in the crowd
  61637. * @param maxAgentRadius the maximum radius an agent can have
  61638. * @param scene to attach the crowd to
  61639. * @returns the crowd you can add agents to
  61640. */
  61641. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61642. /**
  61643. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61644. * The queries will try to find a solution within those bounds
  61645. * default is (1,1,1)
  61646. * @param extent x,y,z value that define the extent around the queries point of reference
  61647. */
  61648. setDefaultQueryExtent(extent: Vector3): void;
  61649. /**
  61650. * Get the Bounding box extent specified by setDefaultQueryExtent
  61651. * @returns the box extent values
  61652. */
  61653. getDefaultQueryExtent(): Vector3;
  61654. /**
  61655. * Release all resources
  61656. */
  61657. dispose(): void;
  61658. }
  61659. /**
  61660. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61661. */
  61662. export interface ICrowd {
  61663. /**
  61664. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61665. * You can attach anything to that node. The node position is updated in the scene update tick.
  61666. * @param pos world position that will be constrained by the navigation mesh
  61667. * @param parameters agent parameters
  61668. * @param transform hooked to the agent that will be update by the scene
  61669. * @returns agent index
  61670. */
  61671. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61672. /**
  61673. * Returns the agent position in world space
  61674. * @param index agent index returned by addAgent
  61675. * @returns world space position
  61676. */
  61677. getAgentPosition(index: number): Vector3;
  61678. /**
  61679. * Gets the agent velocity in world space
  61680. * @param index agent index returned by addAgent
  61681. * @returns world space velocity
  61682. */
  61683. getAgentVelocity(index: number): Vector3;
  61684. /**
  61685. * remove a particular agent previously created
  61686. * @param index agent index returned by addAgent
  61687. */
  61688. removeAgent(index: number): void;
  61689. /**
  61690. * get the list of all agents attached to this crowd
  61691. * @returns list of agent indices
  61692. */
  61693. getAgents(): number[];
  61694. /**
  61695. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61696. * @param deltaTime in seconds
  61697. */
  61698. update(deltaTime: number): void;
  61699. /**
  61700. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61701. * @param index agent index returned by addAgent
  61702. * @param destination targeted world position
  61703. */
  61704. agentGoto(index: number, destination: Vector3): void;
  61705. /**
  61706. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61707. * The queries will try to find a solution within those bounds
  61708. * default is (1,1,1)
  61709. * @param extent x,y,z value that define the extent around the queries point of reference
  61710. */
  61711. setDefaultQueryExtent(extent: Vector3): void;
  61712. /**
  61713. * Get the Bounding box extent specified by setDefaultQueryExtent
  61714. * @returns the box extent values
  61715. */
  61716. getDefaultQueryExtent(): Vector3;
  61717. /**
  61718. * Release all resources
  61719. */
  61720. dispose(): void;
  61721. }
  61722. /**
  61723. * Configures an agent
  61724. */
  61725. export interface IAgentParameters {
  61726. /**
  61727. * Agent radius. [Limit: >= 0]
  61728. */
  61729. radius: number;
  61730. /**
  61731. * Agent height. [Limit: > 0]
  61732. */
  61733. height: number;
  61734. /**
  61735. * Maximum allowed acceleration. [Limit: >= 0]
  61736. */
  61737. maxAcceleration: number;
  61738. /**
  61739. * Maximum allowed speed. [Limit: >= 0]
  61740. */
  61741. maxSpeed: number;
  61742. /**
  61743. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61744. */
  61745. collisionQueryRange: number;
  61746. /**
  61747. * The path visibility optimization range. [Limit: > 0]
  61748. */
  61749. pathOptimizationRange: number;
  61750. /**
  61751. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61752. */
  61753. separationWeight: number;
  61754. }
  61755. /**
  61756. * Configures the navigation mesh creation
  61757. */
  61758. export interface INavMeshParameters {
  61759. /**
  61760. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61761. */
  61762. cs: number;
  61763. /**
  61764. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61765. */
  61766. ch: number;
  61767. /**
  61768. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61769. */
  61770. walkableSlopeAngle: number;
  61771. /**
  61772. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61773. * be considered walkable. [Limit: >= 3] [Units: vx]
  61774. */
  61775. walkableHeight: number;
  61776. /**
  61777. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61778. */
  61779. walkableClimb: number;
  61780. /**
  61781. * The distance to erode/shrink the walkable area of the heightfield away from
  61782. * obstructions. [Limit: >=0] [Units: vx]
  61783. */
  61784. walkableRadius: number;
  61785. /**
  61786. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61787. */
  61788. maxEdgeLen: number;
  61789. /**
  61790. * The maximum distance a simplfied contour's border edges should deviate
  61791. * the original raw contour. [Limit: >=0] [Units: vx]
  61792. */
  61793. maxSimplificationError: number;
  61794. /**
  61795. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61796. */
  61797. minRegionArea: number;
  61798. /**
  61799. * Any regions with a span count smaller than this value will, if possible,
  61800. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61801. */
  61802. mergeRegionArea: number;
  61803. /**
  61804. * The maximum number of vertices allowed for polygons generated during the
  61805. * contour to polygon conversion process. [Limit: >= 3]
  61806. */
  61807. maxVertsPerPoly: number;
  61808. /**
  61809. * Sets the sampling distance to use when generating the detail mesh.
  61810. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61811. */
  61812. detailSampleDist: number;
  61813. /**
  61814. * The maximum distance the detail mesh surface should deviate from heightfield
  61815. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61816. */
  61817. detailSampleMaxError: number;
  61818. }
  61819. }
  61820. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61821. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61822. import { Mesh } from "babylonjs/Meshes/mesh";
  61823. import { Scene } from "babylonjs/scene";
  61824. import { Vector3 } from "babylonjs/Maths/math";
  61825. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61826. /**
  61827. * RecastJS navigation plugin
  61828. */
  61829. export class RecastJSPlugin implements INavigationEnginePlugin {
  61830. /**
  61831. * Reference to the Recast library
  61832. */
  61833. bjsRECAST: any;
  61834. /**
  61835. * plugin name
  61836. */
  61837. name: string;
  61838. /**
  61839. * the first navmesh created. We might extend this to support multiple navmeshes
  61840. */
  61841. navMesh: any;
  61842. /**
  61843. * Initializes the recastJS plugin
  61844. * @param recastInjection can be used to inject your own recast reference
  61845. */
  61846. constructor(recastInjection?: any);
  61847. /**
  61848. * Creates a navigation mesh
  61849. * @param meshes array of all the geometry used to compute the navigatio mesh
  61850. * @param parameters bunch of parameters used to filter geometry
  61851. */
  61852. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61853. /**
  61854. * Create a navigation mesh debug mesh
  61855. * @param scene is where the mesh will be added
  61856. * @returns debug display mesh
  61857. */
  61858. createDebugNavMesh(scene: Scene): Mesh;
  61859. /**
  61860. * Get a navigation mesh constrained position, closest to the parameter position
  61861. * @param position world position
  61862. * @returns the closest point to position constrained by the navigation mesh
  61863. */
  61864. getClosestPoint(position: Vector3): Vector3;
  61865. /**
  61866. * Get a navigation mesh constrained position, within a particular radius
  61867. * @param position world position
  61868. * @param maxRadius the maximum distance to the constrained world position
  61869. * @returns the closest point to position constrained by the navigation mesh
  61870. */
  61871. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61872. /**
  61873. * Compute the final position from a segment made of destination-position
  61874. * @param position world position
  61875. * @param destination world position
  61876. * @returns the resulting point along the navmesh
  61877. */
  61878. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61879. /**
  61880. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61881. * @param start world position
  61882. * @param end world position
  61883. * @returns array containing world position composing the path
  61884. */
  61885. computePath(start: Vector3, end: Vector3): Vector3[];
  61886. /**
  61887. * Create a new Crowd so you can add agents
  61888. * @param maxAgents the maximum agent count in the crowd
  61889. * @param maxAgentRadius the maximum radius an agent can have
  61890. * @param scene to attach the crowd to
  61891. * @returns the crowd you can add agents to
  61892. */
  61893. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61894. /**
  61895. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61896. * The queries will try to find a solution within those bounds
  61897. * default is (1,1,1)
  61898. * @param extent x,y,z value that define the extent around the queries point of reference
  61899. */
  61900. setDefaultQueryExtent(extent: Vector3): void;
  61901. /**
  61902. * Get the Bounding box extent specified by setDefaultQueryExtent
  61903. * @returns the box extent values
  61904. */
  61905. getDefaultQueryExtent(): Vector3;
  61906. /**
  61907. * Disposes
  61908. */
  61909. dispose(): void;
  61910. /**
  61911. * If this plugin is supported
  61912. * @returns true if plugin is supported
  61913. */
  61914. isSupported(): boolean;
  61915. }
  61916. /**
  61917. * Recast detour crowd implementation
  61918. */
  61919. export class RecastJSCrowd implements ICrowd {
  61920. /**
  61921. * Recast/detour plugin
  61922. */
  61923. bjsRECASTPlugin: RecastJSPlugin;
  61924. /**
  61925. * Link to the detour crowd
  61926. */
  61927. recastCrowd: any;
  61928. /**
  61929. * One transform per agent
  61930. */
  61931. transforms: TransformNode[];
  61932. /**
  61933. * All agents created
  61934. */
  61935. agents: number[];
  61936. /**
  61937. * Link to the scene is kept to unregister the crowd from the scene
  61938. */
  61939. private _scene;
  61940. /**
  61941. * Observer for crowd updates
  61942. */
  61943. private _onBeforeAnimationsObserver;
  61944. /**
  61945. * Constructor
  61946. * @param plugin recastJS plugin
  61947. * @param maxAgents the maximum agent count in the crowd
  61948. * @param maxAgentRadius the maximum radius an agent can have
  61949. * @param scene to attach the crowd to
  61950. * @returns the crowd you can add agents to
  61951. */
  61952. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61953. /**
  61954. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61955. * You can attach anything to that node. The node position is updated in the scene update tick.
  61956. * @param pos world position that will be constrained by the navigation mesh
  61957. * @param parameters agent parameters
  61958. * @param transform hooked to the agent that will be update by the scene
  61959. * @returns agent index
  61960. */
  61961. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61962. /**
  61963. * Returns the agent position in world space
  61964. * @param index agent index returned by addAgent
  61965. * @returns world space position
  61966. */
  61967. getAgentPosition(index: number): Vector3;
  61968. /**
  61969. * Returns the agent velocity in world space
  61970. * @param index agent index returned by addAgent
  61971. * @returns world space velocity
  61972. */
  61973. getAgentVelocity(index: number): Vector3;
  61974. /**
  61975. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61976. * @param index agent index returned by addAgent
  61977. * @param destination targeted world position
  61978. */
  61979. agentGoto(index: number, destination: Vector3): void;
  61980. /**
  61981. * remove a particular agent previously created
  61982. * @param index agent index returned by addAgent
  61983. */
  61984. removeAgent(index: number): void;
  61985. /**
  61986. * get the list of all agents attached to this crowd
  61987. * @returns list of agent indices
  61988. */
  61989. getAgents(): number[];
  61990. /**
  61991. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61992. * @param deltaTime in seconds
  61993. */
  61994. update(deltaTime: number): void;
  61995. /**
  61996. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61997. * The queries will try to find a solution within those bounds
  61998. * default is (1,1,1)
  61999. * @param extent x,y,z value that define the extent around the queries point of reference
  62000. */
  62001. setDefaultQueryExtent(extent: Vector3): void;
  62002. /**
  62003. * Get the Bounding box extent specified by setDefaultQueryExtent
  62004. * @returns the box extent values
  62005. */
  62006. getDefaultQueryExtent(): Vector3;
  62007. /**
  62008. * Release all resources
  62009. */
  62010. dispose(): void;
  62011. }
  62012. }
  62013. declare module "babylonjs/Navigation/Plugins/index" {
  62014. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  62015. }
  62016. declare module "babylonjs/Navigation/index" {
  62017. export * from "babylonjs/Navigation/INavigationEngine";
  62018. export * from "babylonjs/Navigation/Plugins/index";
  62019. }
  62020. declare module "babylonjs/Offline/database" {
  62021. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  62022. /**
  62023. * Class used to enable access to IndexedDB
  62024. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62025. */
  62026. export class Database implements IOfflineProvider {
  62027. private _callbackManifestChecked;
  62028. private _currentSceneUrl;
  62029. private _db;
  62030. private _enableSceneOffline;
  62031. private _enableTexturesOffline;
  62032. private _manifestVersionFound;
  62033. private _mustUpdateRessources;
  62034. private _hasReachedQuota;
  62035. private _isSupported;
  62036. private _idbFactory;
  62037. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62038. private static IsUASupportingBlobStorage;
  62039. /**
  62040. * Gets a boolean indicating if Database storate is enabled (off by default)
  62041. */
  62042. static IDBStorageEnabled: boolean;
  62043. /**
  62044. * Gets a boolean indicating if scene must be saved in the database
  62045. */
  62046. readonly enableSceneOffline: boolean;
  62047. /**
  62048. * Gets a boolean indicating if textures must be saved in the database
  62049. */
  62050. readonly enableTexturesOffline: boolean;
  62051. /**
  62052. * Creates a new Database
  62053. * @param urlToScene defines the url to load the scene
  62054. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62055. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62056. */
  62057. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62058. private static _ParseURL;
  62059. private static _ReturnFullUrlLocation;
  62060. private _checkManifestFile;
  62061. /**
  62062. * Open the database and make it available
  62063. * @param successCallback defines the callback to call on success
  62064. * @param errorCallback defines the callback to call on error
  62065. */
  62066. open(successCallback: () => void, errorCallback: () => void): void;
  62067. /**
  62068. * Loads an image from the database
  62069. * @param url defines the url to load from
  62070. * @param image defines the target DOM image
  62071. */
  62072. loadImage(url: string, image: HTMLImageElement): void;
  62073. private _loadImageFromDBAsync;
  62074. private _saveImageIntoDBAsync;
  62075. private _checkVersionFromDB;
  62076. private _loadVersionFromDBAsync;
  62077. private _saveVersionIntoDBAsync;
  62078. /**
  62079. * Loads a file from database
  62080. * @param url defines the URL to load from
  62081. * @param sceneLoaded defines a callback to call on success
  62082. * @param progressCallBack defines a callback to call when progress changed
  62083. * @param errorCallback defines a callback to call on error
  62084. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62085. */
  62086. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62087. private _loadFileAsync;
  62088. private _saveFileAsync;
  62089. /**
  62090. * Validates if xhr data is correct
  62091. * @param xhr defines the request to validate
  62092. * @param dataType defines the expected data type
  62093. * @returns true if data is correct
  62094. */
  62095. private static _ValidateXHRData;
  62096. }
  62097. }
  62098. declare module "babylonjs/Offline/index" {
  62099. export * from "babylonjs/Offline/database";
  62100. export * from "babylonjs/Offline/IOfflineProvider";
  62101. }
  62102. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  62103. /** @hidden */
  62104. export var gpuUpdateParticlesPixelShader: {
  62105. name: string;
  62106. shader: string;
  62107. };
  62108. }
  62109. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  62110. /** @hidden */
  62111. export var gpuUpdateParticlesVertexShader: {
  62112. name: string;
  62113. shader: string;
  62114. };
  62115. }
  62116. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  62117. /** @hidden */
  62118. export var clipPlaneFragmentDeclaration2: {
  62119. name: string;
  62120. shader: string;
  62121. };
  62122. }
  62123. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  62124. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  62125. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62126. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62127. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62128. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  62129. /** @hidden */
  62130. export var gpuRenderParticlesPixelShader: {
  62131. name: string;
  62132. shader: string;
  62133. };
  62134. }
  62135. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  62136. /** @hidden */
  62137. export var clipPlaneVertexDeclaration2: {
  62138. name: string;
  62139. shader: string;
  62140. };
  62141. }
  62142. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  62143. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  62144. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  62145. /** @hidden */
  62146. export var gpuRenderParticlesVertexShader: {
  62147. name: string;
  62148. shader: string;
  62149. };
  62150. }
  62151. declare module "babylonjs/Particles/gpuParticleSystem" {
  62152. import { Nullable } from "babylonjs/types";
  62153. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  62154. import { Observable } from "babylonjs/Misc/observable";
  62155. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62156. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62157. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  62158. import { Scene, IDisposable } from "babylonjs/scene";
  62159. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  62160. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62161. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  62162. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  62163. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  62164. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  62165. /**
  62166. * This represents a GPU particle system in Babylon
  62167. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62168. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62169. */
  62170. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62171. /**
  62172. * The layer mask we are rendering the particles through.
  62173. */
  62174. layerMask: number;
  62175. private _capacity;
  62176. private _activeCount;
  62177. private _currentActiveCount;
  62178. private _accumulatedCount;
  62179. private _renderEffect;
  62180. private _updateEffect;
  62181. private _buffer0;
  62182. private _buffer1;
  62183. private _spriteBuffer;
  62184. private _updateVAO;
  62185. private _renderVAO;
  62186. private _targetIndex;
  62187. private _sourceBuffer;
  62188. private _targetBuffer;
  62189. private _engine;
  62190. private _currentRenderId;
  62191. private _started;
  62192. private _stopped;
  62193. private _timeDelta;
  62194. private _randomTexture;
  62195. private _randomTexture2;
  62196. private _attributesStrideSize;
  62197. private _updateEffectOptions;
  62198. private _randomTextureSize;
  62199. private _actualFrame;
  62200. private readonly _rawTextureWidth;
  62201. /**
  62202. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62203. */
  62204. static readonly IsSupported: boolean;
  62205. /**
  62206. * An event triggered when the system is disposed.
  62207. */
  62208. onDisposeObservable: Observable<GPUParticleSystem>;
  62209. /**
  62210. * Gets the maximum number of particles active at the same time.
  62211. * @returns The max number of active particles.
  62212. */
  62213. getCapacity(): number;
  62214. /**
  62215. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62216. * to override the particles.
  62217. */
  62218. forceDepthWrite: boolean;
  62219. /**
  62220. * Gets or set the number of active particles
  62221. */
  62222. activeParticleCount: number;
  62223. private _preWarmDone;
  62224. /**
  62225. * Is this system ready to be used/rendered
  62226. * @return true if the system is ready
  62227. */
  62228. isReady(): boolean;
  62229. /**
  62230. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62231. * @returns True if it has been started, otherwise false.
  62232. */
  62233. isStarted(): boolean;
  62234. /**
  62235. * Starts the particle system and begins to emit
  62236. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62237. */
  62238. start(delay?: number): void;
  62239. /**
  62240. * Stops the particle system.
  62241. */
  62242. stop(): void;
  62243. /**
  62244. * Remove all active particles
  62245. */
  62246. reset(): void;
  62247. /**
  62248. * Returns the string "GPUParticleSystem"
  62249. * @returns a string containing the class name
  62250. */
  62251. getClassName(): string;
  62252. private _colorGradientsTexture;
  62253. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62254. /**
  62255. * Adds a new color gradient
  62256. * @param gradient defines the gradient to use (between 0 and 1)
  62257. * @param color1 defines the color to affect to the specified gradient
  62258. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62259. * @returns the current particle system
  62260. */
  62261. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62262. /**
  62263. * Remove a specific color gradient
  62264. * @param gradient defines the gradient to remove
  62265. * @returns the current particle system
  62266. */
  62267. removeColorGradient(gradient: number): GPUParticleSystem;
  62268. private _angularSpeedGradientsTexture;
  62269. private _sizeGradientsTexture;
  62270. private _velocityGradientsTexture;
  62271. private _limitVelocityGradientsTexture;
  62272. private _dragGradientsTexture;
  62273. private _addFactorGradient;
  62274. /**
  62275. * Adds a new size gradient
  62276. * @param gradient defines the gradient to use (between 0 and 1)
  62277. * @param factor defines the size factor to affect to the specified gradient
  62278. * @returns the current particle system
  62279. */
  62280. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62281. /**
  62282. * Remove a specific size gradient
  62283. * @param gradient defines the gradient to remove
  62284. * @returns the current particle system
  62285. */
  62286. removeSizeGradient(gradient: number): GPUParticleSystem;
  62287. /**
  62288. * Adds a new angular speed gradient
  62289. * @param gradient defines the gradient to use (between 0 and 1)
  62290. * @param factor defines the angular speed to affect to the specified gradient
  62291. * @returns the current particle system
  62292. */
  62293. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62294. /**
  62295. * Remove a specific angular speed gradient
  62296. * @param gradient defines the gradient to remove
  62297. * @returns the current particle system
  62298. */
  62299. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62300. /**
  62301. * Adds a new velocity gradient
  62302. * @param gradient defines the gradient to use (between 0 and 1)
  62303. * @param factor defines the velocity to affect to the specified gradient
  62304. * @returns the current particle system
  62305. */
  62306. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62307. /**
  62308. * Remove a specific velocity gradient
  62309. * @param gradient defines the gradient to remove
  62310. * @returns the current particle system
  62311. */
  62312. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62313. /**
  62314. * Adds a new limit velocity gradient
  62315. * @param gradient defines the gradient to use (between 0 and 1)
  62316. * @param factor defines the limit velocity value to affect to the specified gradient
  62317. * @returns the current particle system
  62318. */
  62319. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62320. /**
  62321. * Remove a specific limit velocity gradient
  62322. * @param gradient defines the gradient to remove
  62323. * @returns the current particle system
  62324. */
  62325. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62326. /**
  62327. * Adds a new drag gradient
  62328. * @param gradient defines the gradient to use (between 0 and 1)
  62329. * @param factor defines the drag value to affect to the specified gradient
  62330. * @returns the current particle system
  62331. */
  62332. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62333. /**
  62334. * Remove a specific drag gradient
  62335. * @param gradient defines the gradient to remove
  62336. * @returns the current particle system
  62337. */
  62338. removeDragGradient(gradient: number): GPUParticleSystem;
  62339. /**
  62340. * Not supported by GPUParticleSystem
  62341. * @param gradient defines the gradient to use (between 0 and 1)
  62342. * @param factor defines the emit rate value to affect to the specified gradient
  62343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62344. * @returns the current particle system
  62345. */
  62346. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62347. /**
  62348. * Not supported by GPUParticleSystem
  62349. * @param gradient defines the gradient to remove
  62350. * @returns the current particle system
  62351. */
  62352. removeEmitRateGradient(gradient: number): IParticleSystem;
  62353. /**
  62354. * Not supported by GPUParticleSystem
  62355. * @param gradient defines the gradient to use (between 0 and 1)
  62356. * @param factor defines the start size value to affect to the specified gradient
  62357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62358. * @returns the current particle system
  62359. */
  62360. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62361. /**
  62362. * Not supported by GPUParticleSystem
  62363. * @param gradient defines the gradient to remove
  62364. * @returns the current particle system
  62365. */
  62366. removeStartSizeGradient(gradient: number): IParticleSystem;
  62367. /**
  62368. * Not supported by GPUParticleSystem
  62369. * @param gradient defines the gradient to use (between 0 and 1)
  62370. * @param min defines the color remap minimal range
  62371. * @param max defines the color remap maximal range
  62372. * @returns the current particle system
  62373. */
  62374. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62375. /**
  62376. * Not supported by GPUParticleSystem
  62377. * @param gradient defines the gradient to remove
  62378. * @returns the current particle system
  62379. */
  62380. removeColorRemapGradient(): IParticleSystem;
  62381. /**
  62382. * Not supported by GPUParticleSystem
  62383. * @param gradient defines the gradient to use (between 0 and 1)
  62384. * @param min defines the alpha remap minimal range
  62385. * @param max defines the alpha remap maximal range
  62386. * @returns the current particle system
  62387. */
  62388. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62389. /**
  62390. * Not supported by GPUParticleSystem
  62391. * @param gradient defines the gradient to remove
  62392. * @returns the current particle system
  62393. */
  62394. removeAlphaRemapGradient(): IParticleSystem;
  62395. /**
  62396. * Not supported by GPUParticleSystem
  62397. * @param gradient defines the gradient to use (between 0 and 1)
  62398. * @param color defines the color to affect to the specified gradient
  62399. * @returns the current particle system
  62400. */
  62401. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62402. /**
  62403. * Not supported by GPUParticleSystem
  62404. * @param gradient defines the gradient to remove
  62405. * @returns the current particle system
  62406. */
  62407. removeRampGradient(): IParticleSystem;
  62408. /**
  62409. * Not supported by GPUParticleSystem
  62410. * @returns the list of ramp gradients
  62411. */
  62412. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62413. /**
  62414. * Not supported by GPUParticleSystem
  62415. * Gets or sets a boolean indicating that ramp gradients must be used
  62416. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62417. */
  62418. useRampGradients: boolean;
  62419. /**
  62420. * Not supported by GPUParticleSystem
  62421. * @param gradient defines the gradient to use (between 0 and 1)
  62422. * @param factor defines the life time factor to affect to the specified gradient
  62423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62424. * @returns the current particle system
  62425. */
  62426. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62427. /**
  62428. * Not supported by GPUParticleSystem
  62429. * @param gradient defines the gradient to remove
  62430. * @returns the current particle system
  62431. */
  62432. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62433. /**
  62434. * Instantiates a GPU particle system.
  62435. * 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.
  62436. * @param name The name of the particle system
  62437. * @param options The options used to create the system
  62438. * @param scene The scene the particle system belongs to
  62439. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62440. */
  62441. constructor(name: string, options: Partial<{
  62442. capacity: number;
  62443. randomTextureSize: number;
  62444. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62445. protected _reset(): void;
  62446. private _createUpdateVAO;
  62447. private _createRenderVAO;
  62448. private _initialize;
  62449. /** @hidden */
  62450. _recreateUpdateEffect(): void;
  62451. /** @hidden */
  62452. _recreateRenderEffect(): void;
  62453. /**
  62454. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62455. * @param preWarm defines if we are in the pre-warmimg phase
  62456. */
  62457. animate(preWarm?: boolean): void;
  62458. private _createFactorGradientTexture;
  62459. private _createSizeGradientTexture;
  62460. private _createAngularSpeedGradientTexture;
  62461. private _createVelocityGradientTexture;
  62462. private _createLimitVelocityGradientTexture;
  62463. private _createDragGradientTexture;
  62464. private _createColorGradientTexture;
  62465. /**
  62466. * Renders the particle system in its current state
  62467. * @param preWarm defines if the system should only update the particles but not render them
  62468. * @returns the current number of particles
  62469. */
  62470. render(preWarm?: boolean): number;
  62471. /**
  62472. * Rebuilds the particle system
  62473. */
  62474. rebuild(): void;
  62475. private _releaseBuffers;
  62476. private _releaseVAOs;
  62477. /**
  62478. * Disposes the particle system and free the associated resources
  62479. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62480. */
  62481. dispose(disposeTexture?: boolean): void;
  62482. /**
  62483. * Clones the particle system.
  62484. * @param name The name of the cloned object
  62485. * @param newEmitter The new emitter to use
  62486. * @returns the cloned particle system
  62487. */
  62488. clone(name: string, newEmitter: any): GPUParticleSystem;
  62489. /**
  62490. * Serializes the particle system to a JSON object.
  62491. * @returns the JSON object
  62492. */
  62493. serialize(): any;
  62494. /**
  62495. * Parses a JSON object to create a GPU particle system.
  62496. * @param parsedParticleSystem The JSON object to parse
  62497. * @param scene The scene to create the particle system in
  62498. * @param rootUrl The root url to use to load external dependencies like texture
  62499. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62500. * @returns the parsed GPU particle system
  62501. */
  62502. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62503. }
  62504. }
  62505. declare module "babylonjs/Particles/particleSystemSet" {
  62506. import { Nullable } from "babylonjs/types";
  62507. import { Color3 } from "babylonjs/Maths/math.color";
  62508. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62510. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62511. import { Scene, IDisposable } from "babylonjs/scene";
  62512. /**
  62513. * Represents a set of particle systems working together to create a specific effect
  62514. */
  62515. export class ParticleSystemSet implements IDisposable {
  62516. /**
  62517. * Gets or sets base Assets URL
  62518. */
  62519. static BaseAssetsUrl: string;
  62520. private _emitterCreationOptions;
  62521. private _emitterNode;
  62522. /**
  62523. * Gets the particle system list
  62524. */
  62525. systems: IParticleSystem[];
  62526. /**
  62527. * Gets the emitter node used with this set
  62528. */
  62529. readonly emitterNode: Nullable<TransformNode>;
  62530. /**
  62531. * Creates a new emitter mesh as a sphere
  62532. * @param options defines the options used to create the sphere
  62533. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62534. * @param scene defines the hosting scene
  62535. */
  62536. setEmitterAsSphere(options: {
  62537. diameter: number;
  62538. segments: number;
  62539. color: Color3;
  62540. }, renderingGroupId: number, scene: Scene): void;
  62541. /**
  62542. * Starts all particle systems of the set
  62543. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62544. */
  62545. start(emitter?: AbstractMesh): void;
  62546. /**
  62547. * Release all associated resources
  62548. */
  62549. dispose(): void;
  62550. /**
  62551. * Serialize the set into a JSON compatible object
  62552. * @returns a JSON compatible representation of the set
  62553. */
  62554. serialize(): any;
  62555. /**
  62556. * Parse a new ParticleSystemSet from a serialized source
  62557. * @param data defines a JSON compatible representation of the set
  62558. * @param scene defines the hosting scene
  62559. * @param gpu defines if we want GPU particles or CPU particles
  62560. * @returns a new ParticleSystemSet
  62561. */
  62562. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62563. }
  62564. }
  62565. declare module "babylonjs/Particles/particleHelper" {
  62566. import { Nullable } from "babylonjs/types";
  62567. import { Scene } from "babylonjs/scene";
  62568. import { Vector3 } from "babylonjs/Maths/math.vector";
  62569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62570. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62571. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62572. /**
  62573. * This class is made for on one-liner static method to help creating particle system set.
  62574. */
  62575. export class ParticleHelper {
  62576. /**
  62577. * Gets or sets base Assets URL
  62578. */
  62579. static BaseAssetsUrl: string;
  62580. /**
  62581. * Create a default particle system that you can tweak
  62582. * @param emitter defines the emitter to use
  62583. * @param capacity defines the system capacity (default is 500 particles)
  62584. * @param scene defines the hosting scene
  62585. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62586. * @returns the new Particle system
  62587. */
  62588. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62589. /**
  62590. * This is the main static method (one-liner) of this helper to create different particle systems
  62591. * @param type This string represents the type to the particle system to create
  62592. * @param scene The scene where the particle system should live
  62593. * @param gpu If the system will use gpu
  62594. * @returns the ParticleSystemSet created
  62595. */
  62596. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62597. /**
  62598. * Static function used to export a particle system to a ParticleSystemSet variable.
  62599. * Please note that the emitter shape is not exported
  62600. * @param systems defines the particle systems to export
  62601. * @returns the created particle system set
  62602. */
  62603. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62604. }
  62605. }
  62606. declare module "babylonjs/Particles/particleSystemComponent" {
  62607. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62608. import { Effect } from "babylonjs/Materials/effect";
  62609. import "babylonjs/Shaders/particles.vertex";
  62610. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62611. module "babylonjs/Engines/engine" {
  62612. interface Engine {
  62613. /**
  62614. * Create an effect to use with particle systems.
  62615. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62616. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62617. * @param uniformsNames defines a list of attribute names
  62618. * @param samplers defines an array of string used to represent textures
  62619. * @param defines defines the string containing the defines to use to compile the shaders
  62620. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62621. * @param onCompiled defines a function to call when the effect creation is successful
  62622. * @param onError defines a function to call when the effect creation has failed
  62623. * @returns the new Effect
  62624. */
  62625. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62626. }
  62627. }
  62628. module "babylonjs/Meshes/mesh" {
  62629. interface Mesh {
  62630. /**
  62631. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62632. * @returns an array of IParticleSystem
  62633. */
  62634. getEmittedParticleSystems(): IParticleSystem[];
  62635. /**
  62636. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62637. * @returns an array of IParticleSystem
  62638. */
  62639. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62640. }
  62641. }
  62642. /**
  62643. * @hidden
  62644. */
  62645. export var _IDoNeedToBeInTheBuild: number;
  62646. }
  62647. declare module "babylonjs/Particles/pointsCloudSystem" {
  62648. import { Color4 } from "babylonjs/Maths/math";
  62649. import { Mesh } from "babylonjs/Meshes/mesh";
  62650. import { Scene, IDisposable } from "babylonjs/scene";
  62651. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62652. /** Defines the 4 color options */
  62653. export enum PointColor {
  62654. /** color value */
  62655. Color = 2,
  62656. /** uv value */
  62657. UV = 1,
  62658. /** random value */
  62659. Random = 0,
  62660. /** stated value */
  62661. Stated = 3
  62662. }
  62663. /**
  62664. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62665. * 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.
  62666. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62667. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62668. *
  62669. * Full documentation here : TO BE ENTERED
  62670. */
  62671. export class PointsCloudSystem implements IDisposable {
  62672. /**
  62673. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62674. * Example : var p = SPS.particles[i];
  62675. */
  62676. particles: CloudPoint[];
  62677. /**
  62678. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62679. */
  62680. nbParticles: number;
  62681. /**
  62682. * This a counter for your own usage. It's not set by any SPS functions.
  62683. */
  62684. counter: number;
  62685. /**
  62686. * The PCS name. This name is also given to the underlying mesh.
  62687. */
  62688. name: string;
  62689. /**
  62690. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62691. */
  62692. mesh: Mesh;
  62693. /**
  62694. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62695. * Please read :
  62696. */
  62697. vars: any;
  62698. /**
  62699. * @hidden
  62700. */
  62701. _size: number;
  62702. private _scene;
  62703. private _promises;
  62704. private _positions;
  62705. private _indices;
  62706. private _normals;
  62707. private _colors;
  62708. private _uvs;
  62709. private _indices32;
  62710. private _positions32;
  62711. private _colors32;
  62712. private _uvs32;
  62713. private _updatable;
  62714. private _isVisibilityBoxLocked;
  62715. private _alwaysVisible;
  62716. private _groups;
  62717. private _groupCounter;
  62718. private _computeParticleColor;
  62719. private _computeParticleTexture;
  62720. private _computeParticleRotation;
  62721. private _computeBoundingBox;
  62722. private _isReady;
  62723. /**
  62724. * Creates a PCS (Points Cloud System) object
  62725. * @param name (String) is the PCS name, this will be the underlying mesh name
  62726. * @param pointSize (number) is the size for each point
  62727. * @param scene (Scene) is the scene in which the PCS is added
  62728. * @param options defines the options of the PCS e.g.
  62729. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62730. */
  62731. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62732. updatable?: boolean;
  62733. });
  62734. /**
  62735. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62736. * If no points were added to the PCS, the returned mesh is just a single point.
  62737. * @returns a promise for the created mesh
  62738. */
  62739. buildMeshAsync(): Promise<Mesh>;
  62740. /**
  62741. * @hidden
  62742. */
  62743. private _buildMesh;
  62744. private _addParticle;
  62745. private _randomUnitVector;
  62746. private _getColorIndicesForCoord;
  62747. private _setPointsColorOrUV;
  62748. private _colorFromTexture;
  62749. private _calculateDensity;
  62750. /**
  62751. * Adds points to the PCS in random positions within a unit sphere
  62752. * @param nb (positive integer) the number of particles to be created from this model
  62753. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62754. * @returns the number of groups in the system
  62755. */
  62756. addPoints(nb: number, pointFunction?: any): number;
  62757. /**
  62758. * Adds points to the PCS from the surface of the model shape
  62759. * @param mesh is any Mesh object that will be used as a surface model for the points
  62760. * @param nb (positive integer) the number of particles to be created from this model
  62761. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62762. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62763. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62764. * @returns the number of groups in the system
  62765. */
  62766. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62767. /**
  62768. * Adds points to the PCS inside the model shape
  62769. * @param mesh is any Mesh object that will be used as a surface model for the points
  62770. * @param nb (positive integer) the number of particles to be created from this model
  62771. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62772. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62773. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62774. * @returns the number of groups in the system
  62775. */
  62776. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62777. /**
  62778. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62779. * This method calls `updateParticle()` for each particle of the SPS.
  62780. * For an animated SPS, it is usually called within the render loop.
  62781. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62782. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62783. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62784. * @returns the PCS.
  62785. */
  62786. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62787. /**
  62788. * Disposes the PCS.
  62789. */
  62790. dispose(): void;
  62791. /**
  62792. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62793. * doc :
  62794. * @returns the PCS.
  62795. */
  62796. refreshVisibleSize(): PointsCloudSystem;
  62797. /**
  62798. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62799. * @param size the size (float) of the visibility box
  62800. * note : this doesn't lock the PCS mesh bounding box.
  62801. * doc :
  62802. */
  62803. setVisibilityBox(size: number): void;
  62804. /**
  62805. * Gets whether the PCS is always visible or not
  62806. * doc :
  62807. */
  62808. /**
  62809. * Sets the PCS as always visible or not
  62810. * doc :
  62811. */
  62812. isAlwaysVisible: boolean;
  62813. /**
  62814. * Tells to `setParticles()` to compute the particle rotations or not
  62815. * Default value : false. The PCS is faster when it's set to false
  62816. * Note : particle rotations are only applied to parent particles
  62817. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62818. */
  62819. computeParticleRotation: boolean;
  62820. /**
  62821. * Tells to `setParticles()` to compute the particle colors or not.
  62822. * Default value : true. The PCS is faster when it's set to false.
  62823. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62824. */
  62825. /**
  62826. * Gets if `setParticles()` computes the particle colors or not.
  62827. * Default value : false. The PCS is faster when it's set to false.
  62828. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62829. */
  62830. computeParticleColor: boolean;
  62831. /**
  62832. * Gets if `setParticles()` computes the particle textures or not.
  62833. * Default value : false. The PCS is faster when it's set to false.
  62834. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62835. */
  62836. computeParticleTexture: boolean;
  62837. /**
  62838. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62839. */
  62840. /**
  62841. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62842. */
  62843. computeBoundingBox: boolean;
  62844. /**
  62845. * This function does nothing. It may be overwritten to set all the particle first values.
  62846. * The PCS doesn't call this function, you may have to call it by your own.
  62847. * doc :
  62848. */
  62849. initParticles(): void;
  62850. /**
  62851. * This function does nothing. It may be overwritten to recycle a particle
  62852. * The PCS doesn't call this function, you can to call it
  62853. * doc :
  62854. * @param particle The particle to recycle
  62855. * @returns the recycled particle
  62856. */
  62857. recycleParticle(particle: CloudPoint): CloudPoint;
  62858. /**
  62859. * Updates a particle : this function should be overwritten by the user.
  62860. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62861. * doc :
  62862. * @example : just set a particle position or velocity and recycle conditions
  62863. * @param particle The particle to update
  62864. * @returns the updated particle
  62865. */
  62866. updateParticle(particle: CloudPoint): CloudPoint;
  62867. /**
  62868. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62869. * This does nothing and may be overwritten by the user.
  62870. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62871. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62872. * @param update the boolean update value actually passed to setParticles()
  62873. */
  62874. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62875. /**
  62876. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62877. * This will be passed three parameters.
  62878. * This does nothing and may be overwritten by the user.
  62879. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62880. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62881. * @param update the boolean update value actually passed to setParticles()
  62882. */
  62883. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62884. }
  62885. }
  62886. declare module "babylonjs/Particles/cloudPoint" {
  62887. import { Nullable } from "babylonjs/types";
  62888. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62889. import { Mesh } from "babylonjs/Meshes/mesh";
  62890. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62891. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62892. /**
  62893. * Represents one particle of a points cloud system.
  62894. */
  62895. export class CloudPoint {
  62896. /**
  62897. * particle global index
  62898. */
  62899. idx: number;
  62900. /**
  62901. * The color of the particle
  62902. */
  62903. color: Nullable<Color4>;
  62904. /**
  62905. * The world space position of the particle.
  62906. */
  62907. position: Vector3;
  62908. /**
  62909. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62910. */
  62911. rotation: Vector3;
  62912. /**
  62913. * The world space rotation quaternion of the particle.
  62914. */
  62915. rotationQuaternion: Nullable<Quaternion>;
  62916. /**
  62917. * The uv of the particle.
  62918. */
  62919. uv: Nullable<Vector2>;
  62920. /**
  62921. * The current speed of the particle.
  62922. */
  62923. velocity: Vector3;
  62924. /**
  62925. * The pivot point in the particle local space.
  62926. */
  62927. pivot: Vector3;
  62928. /**
  62929. * Must the particle be translated from its pivot point in its local space ?
  62930. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62931. * Default : false
  62932. */
  62933. translateFromPivot: boolean;
  62934. /**
  62935. * Index of this particle in the global "positions" array (Internal use)
  62936. * @hidden
  62937. */
  62938. _pos: number;
  62939. /**
  62940. * @hidden Index of this particle in the global "indices" array (Internal use)
  62941. */
  62942. _ind: number;
  62943. /**
  62944. * Group this particle belongs to
  62945. */
  62946. _group: PointsGroup;
  62947. /**
  62948. * Group id of this particle
  62949. */
  62950. groupId: number;
  62951. /**
  62952. * Index of the particle in its group id (Internal use)
  62953. */
  62954. idxInGroup: number;
  62955. /**
  62956. * @hidden Particle BoundingInfo object (Internal use)
  62957. */
  62958. _boundingInfo: BoundingInfo;
  62959. /**
  62960. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62961. */
  62962. _pcs: PointsCloudSystem;
  62963. /**
  62964. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62965. */
  62966. _stillInvisible: boolean;
  62967. /**
  62968. * @hidden Last computed particle rotation matrix
  62969. */
  62970. _rotationMatrix: number[];
  62971. /**
  62972. * Parent particle Id, if any.
  62973. * Default null.
  62974. */
  62975. parentId: Nullable<number>;
  62976. /**
  62977. * @hidden Internal global position in the PCS.
  62978. */
  62979. _globalPosition: Vector3;
  62980. /**
  62981. * Creates a Point Cloud object.
  62982. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62983. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62984. * @param group (PointsGroup) is the group the particle belongs to
  62985. * @param groupId (integer) is the group identifier in the PCS.
  62986. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62987. * @param pcs defines the PCS it is associated to
  62988. */
  62989. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62990. /**
  62991. * get point size
  62992. */
  62993. /**
  62994. * Set point size
  62995. */
  62996. size: Vector3;
  62997. /**
  62998. * Legacy support, changed quaternion to rotationQuaternion
  62999. */
  63000. /**
  63001. * Legacy support, changed quaternion to rotationQuaternion
  63002. */
  63003. quaternion: Nullable<Quaternion>;
  63004. /**
  63005. * Returns a boolean. True if the particle intersects a mesh, else false
  63006. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63007. * @param target is the object (point or mesh) what the intersection is computed against
  63008. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63009. * @returns true if it intersects
  63010. */
  63011. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63012. /**
  63013. * get the rotation matrix of the particle
  63014. * @hidden
  63015. */
  63016. getRotationMatrix(m: Matrix): void;
  63017. }
  63018. /**
  63019. * Represents a group of points in a points cloud system
  63020. * * PCS internal tool, don't use it manually.
  63021. */
  63022. export class PointsGroup {
  63023. /**
  63024. * The group id
  63025. * @hidden
  63026. */
  63027. groupID: number;
  63028. /**
  63029. * image data for group (internal use)
  63030. * @hidden
  63031. */
  63032. _groupImageData: Nullable<ArrayBufferView>;
  63033. /**
  63034. * Image Width (internal use)
  63035. * @hidden
  63036. */
  63037. _groupImgWidth: number;
  63038. /**
  63039. * Image Height (internal use)
  63040. * @hidden
  63041. */
  63042. _groupImgHeight: number;
  63043. /**
  63044. * Custom position function (internal use)
  63045. * @hidden
  63046. */
  63047. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63048. /**
  63049. * density per facet for surface points
  63050. * @hidden
  63051. */
  63052. _groupDensity: number[];
  63053. /**
  63054. * Only when points are colored by texture carries pointer to texture list array
  63055. * @hidden
  63056. */
  63057. _textureNb: number;
  63058. /**
  63059. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63060. * PCS internal tool, don't use it manually.
  63061. * @hidden
  63062. */
  63063. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63064. }
  63065. }
  63066. declare module "babylonjs/Particles/index" {
  63067. export * from "babylonjs/Particles/baseParticleSystem";
  63068. export * from "babylonjs/Particles/EmitterTypes/index";
  63069. export * from "babylonjs/Particles/gpuParticleSystem";
  63070. export * from "babylonjs/Particles/IParticleSystem";
  63071. export * from "babylonjs/Particles/particle";
  63072. export * from "babylonjs/Particles/particleHelper";
  63073. export * from "babylonjs/Particles/particleSystem";
  63074. export * from "babylonjs/Particles/particleSystemComponent";
  63075. export * from "babylonjs/Particles/particleSystemSet";
  63076. export * from "babylonjs/Particles/solidParticle";
  63077. export * from "babylonjs/Particles/solidParticleSystem";
  63078. export * from "babylonjs/Particles/cloudPoint";
  63079. export * from "babylonjs/Particles/pointsCloudSystem";
  63080. export * from "babylonjs/Particles/subEmitter";
  63081. }
  63082. declare module "babylonjs/Physics/physicsEngineComponent" {
  63083. import { Nullable } from "babylonjs/types";
  63084. import { Observable, Observer } from "babylonjs/Misc/observable";
  63085. import { Vector3 } from "babylonjs/Maths/math.vector";
  63086. import { Mesh } from "babylonjs/Meshes/mesh";
  63087. import { ISceneComponent } from "babylonjs/sceneComponent";
  63088. import { Scene } from "babylonjs/scene";
  63089. import { Node } from "babylonjs/node";
  63090. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63091. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63092. module "babylonjs/scene" {
  63093. interface Scene {
  63094. /** @hidden (Backing field) */
  63095. _physicsEngine: Nullable<IPhysicsEngine>;
  63096. /**
  63097. * Gets the current physics engine
  63098. * @returns a IPhysicsEngine or null if none attached
  63099. */
  63100. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63101. /**
  63102. * Enables physics to the current scene
  63103. * @param gravity defines the scene's gravity for the physics engine
  63104. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63105. * @return a boolean indicating if the physics engine was initialized
  63106. */
  63107. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63108. /**
  63109. * Disables and disposes the physics engine associated with the scene
  63110. */
  63111. disablePhysicsEngine(): void;
  63112. /**
  63113. * Gets a boolean indicating if there is an active physics engine
  63114. * @returns a boolean indicating if there is an active physics engine
  63115. */
  63116. isPhysicsEnabled(): boolean;
  63117. /**
  63118. * Deletes a physics compound impostor
  63119. * @param compound defines the compound to delete
  63120. */
  63121. deleteCompoundImpostor(compound: any): void;
  63122. /**
  63123. * An event triggered when physic simulation is about to be run
  63124. */
  63125. onBeforePhysicsObservable: Observable<Scene>;
  63126. /**
  63127. * An event triggered when physic simulation has been done
  63128. */
  63129. onAfterPhysicsObservable: Observable<Scene>;
  63130. }
  63131. }
  63132. module "babylonjs/Meshes/abstractMesh" {
  63133. interface AbstractMesh {
  63134. /** @hidden */
  63135. _physicsImpostor: Nullable<PhysicsImpostor>;
  63136. /**
  63137. * Gets or sets impostor used for physic simulation
  63138. * @see http://doc.babylonjs.com/features/physics_engine
  63139. */
  63140. physicsImpostor: Nullable<PhysicsImpostor>;
  63141. /**
  63142. * Gets the current physics impostor
  63143. * @see http://doc.babylonjs.com/features/physics_engine
  63144. * @returns a physics impostor or null
  63145. */
  63146. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63147. /** Apply a physic impulse to the mesh
  63148. * @param force defines the force to apply
  63149. * @param contactPoint defines where to apply the force
  63150. * @returns the current mesh
  63151. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63152. */
  63153. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63154. /**
  63155. * Creates a physic joint between two meshes
  63156. * @param otherMesh defines the other mesh to use
  63157. * @param pivot1 defines the pivot to use on this mesh
  63158. * @param pivot2 defines the pivot to use on the other mesh
  63159. * @param options defines additional options (can be plugin dependent)
  63160. * @returns the current mesh
  63161. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63162. */
  63163. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63164. /** @hidden */
  63165. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63166. }
  63167. }
  63168. /**
  63169. * Defines the physics engine scene component responsible to manage a physics engine
  63170. */
  63171. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63172. /**
  63173. * The component name helpful to identify the component in the list of scene components.
  63174. */
  63175. readonly name: string;
  63176. /**
  63177. * The scene the component belongs to.
  63178. */
  63179. scene: Scene;
  63180. /**
  63181. * Creates a new instance of the component for the given scene
  63182. * @param scene Defines the scene to register the component in
  63183. */
  63184. constructor(scene: Scene);
  63185. /**
  63186. * Registers the component in a given scene
  63187. */
  63188. register(): void;
  63189. /**
  63190. * Rebuilds the elements related to this component in case of
  63191. * context lost for instance.
  63192. */
  63193. rebuild(): void;
  63194. /**
  63195. * Disposes the component and the associated ressources
  63196. */
  63197. dispose(): void;
  63198. }
  63199. }
  63200. declare module "babylonjs/Physics/physicsHelper" {
  63201. import { Nullable } from "babylonjs/types";
  63202. import { Vector3 } from "babylonjs/Maths/math.vector";
  63203. import { Mesh } from "babylonjs/Meshes/mesh";
  63204. import { Scene } from "babylonjs/scene";
  63205. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63206. /**
  63207. * A helper for physics simulations
  63208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63209. */
  63210. export class PhysicsHelper {
  63211. private _scene;
  63212. private _physicsEngine;
  63213. /**
  63214. * Initializes the Physics helper
  63215. * @param scene Babylon.js scene
  63216. */
  63217. constructor(scene: Scene);
  63218. /**
  63219. * Applies a radial explosion impulse
  63220. * @param origin the origin of the explosion
  63221. * @param radiusOrEventOptions the radius or the options of radial explosion
  63222. * @param strength the explosion strength
  63223. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63224. * @returns A physics radial explosion event, or null
  63225. */
  63226. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63227. /**
  63228. * Applies a radial explosion force
  63229. * @param origin the origin of the explosion
  63230. * @param radiusOrEventOptions the radius or the options of radial explosion
  63231. * @param strength the explosion strength
  63232. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63233. * @returns A physics radial explosion event, or null
  63234. */
  63235. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63236. /**
  63237. * Creates a gravitational field
  63238. * @param origin the origin of the explosion
  63239. * @param radiusOrEventOptions the radius or the options of radial explosion
  63240. * @param strength the explosion strength
  63241. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63242. * @returns A physics gravitational field event, or null
  63243. */
  63244. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63245. /**
  63246. * Creates a physics updraft event
  63247. * @param origin the origin of the updraft
  63248. * @param radiusOrEventOptions the radius or the options of the updraft
  63249. * @param strength the strength of the updraft
  63250. * @param height the height of the updraft
  63251. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63252. * @returns A physics updraft event, or null
  63253. */
  63254. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63255. /**
  63256. * Creates a physics vortex event
  63257. * @param origin the of the vortex
  63258. * @param radiusOrEventOptions the radius or the options of the vortex
  63259. * @param strength the strength of the vortex
  63260. * @param height the height of the vortex
  63261. * @returns a Physics vortex event, or null
  63262. * A physics vortex event or null
  63263. */
  63264. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63265. }
  63266. /**
  63267. * Represents a physics radial explosion event
  63268. */
  63269. class PhysicsRadialExplosionEvent {
  63270. private _scene;
  63271. private _options;
  63272. private _sphere;
  63273. private _dataFetched;
  63274. /**
  63275. * Initializes a radial explosioin event
  63276. * @param _scene BabylonJS scene
  63277. * @param _options The options for the vortex event
  63278. */
  63279. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63280. /**
  63281. * Returns the data related to the radial explosion event (sphere).
  63282. * @returns The radial explosion event data
  63283. */
  63284. getData(): PhysicsRadialExplosionEventData;
  63285. /**
  63286. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63287. * @param impostor A physics imposter
  63288. * @param origin the origin of the explosion
  63289. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63290. */
  63291. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63292. /**
  63293. * Triggers affecterd impostors callbacks
  63294. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63295. */
  63296. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63297. /**
  63298. * Disposes the sphere.
  63299. * @param force Specifies if the sphere should be disposed by force
  63300. */
  63301. dispose(force?: boolean): void;
  63302. /*** Helpers ***/
  63303. private _prepareSphere;
  63304. private _intersectsWithSphere;
  63305. }
  63306. /**
  63307. * Represents a gravitational field event
  63308. */
  63309. class PhysicsGravitationalFieldEvent {
  63310. private _physicsHelper;
  63311. private _scene;
  63312. private _origin;
  63313. private _options;
  63314. private _tickCallback;
  63315. private _sphere;
  63316. private _dataFetched;
  63317. /**
  63318. * Initializes the physics gravitational field event
  63319. * @param _physicsHelper A physics helper
  63320. * @param _scene BabylonJS scene
  63321. * @param _origin The origin position of the gravitational field event
  63322. * @param _options The options for the vortex event
  63323. */
  63324. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63325. /**
  63326. * Returns the data related to the gravitational field event (sphere).
  63327. * @returns A gravitational field event
  63328. */
  63329. getData(): PhysicsGravitationalFieldEventData;
  63330. /**
  63331. * Enables the gravitational field.
  63332. */
  63333. enable(): void;
  63334. /**
  63335. * Disables the gravitational field.
  63336. */
  63337. disable(): void;
  63338. /**
  63339. * Disposes the sphere.
  63340. * @param force The force to dispose from the gravitational field event
  63341. */
  63342. dispose(force?: boolean): void;
  63343. private _tick;
  63344. }
  63345. /**
  63346. * Represents a physics updraft event
  63347. */
  63348. class PhysicsUpdraftEvent {
  63349. private _scene;
  63350. private _origin;
  63351. private _options;
  63352. private _physicsEngine;
  63353. private _originTop;
  63354. private _originDirection;
  63355. private _tickCallback;
  63356. private _cylinder;
  63357. private _cylinderPosition;
  63358. private _dataFetched;
  63359. /**
  63360. * Initializes the physics updraft event
  63361. * @param _scene BabylonJS scene
  63362. * @param _origin The origin position of the updraft
  63363. * @param _options The options for the updraft event
  63364. */
  63365. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63366. /**
  63367. * Returns the data related to the updraft event (cylinder).
  63368. * @returns A physics updraft event
  63369. */
  63370. getData(): PhysicsUpdraftEventData;
  63371. /**
  63372. * Enables the updraft.
  63373. */
  63374. enable(): void;
  63375. /**
  63376. * Disables the updraft.
  63377. */
  63378. disable(): void;
  63379. /**
  63380. * Disposes the cylinder.
  63381. * @param force Specifies if the updraft should be disposed by force
  63382. */
  63383. dispose(force?: boolean): void;
  63384. private getImpostorHitData;
  63385. private _tick;
  63386. /*** Helpers ***/
  63387. private _prepareCylinder;
  63388. private _intersectsWithCylinder;
  63389. }
  63390. /**
  63391. * Represents a physics vortex event
  63392. */
  63393. class PhysicsVortexEvent {
  63394. private _scene;
  63395. private _origin;
  63396. private _options;
  63397. private _physicsEngine;
  63398. private _originTop;
  63399. private _tickCallback;
  63400. private _cylinder;
  63401. private _cylinderPosition;
  63402. private _dataFetched;
  63403. /**
  63404. * Initializes the physics vortex event
  63405. * @param _scene The BabylonJS scene
  63406. * @param _origin The origin position of the vortex
  63407. * @param _options The options for the vortex event
  63408. */
  63409. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63410. /**
  63411. * Returns the data related to the vortex event (cylinder).
  63412. * @returns The physics vortex event data
  63413. */
  63414. getData(): PhysicsVortexEventData;
  63415. /**
  63416. * Enables the vortex.
  63417. */
  63418. enable(): void;
  63419. /**
  63420. * Disables the cortex.
  63421. */
  63422. disable(): void;
  63423. /**
  63424. * Disposes the sphere.
  63425. * @param force
  63426. */
  63427. dispose(force?: boolean): void;
  63428. private getImpostorHitData;
  63429. private _tick;
  63430. /*** Helpers ***/
  63431. private _prepareCylinder;
  63432. private _intersectsWithCylinder;
  63433. }
  63434. /**
  63435. * Options fot the radial explosion event
  63436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63437. */
  63438. export class PhysicsRadialExplosionEventOptions {
  63439. /**
  63440. * The radius of the sphere for the radial explosion.
  63441. */
  63442. radius: number;
  63443. /**
  63444. * The strenth of the explosion.
  63445. */
  63446. strength: number;
  63447. /**
  63448. * The strenght of the force in correspondence to the distance of the affected object
  63449. */
  63450. falloff: PhysicsRadialImpulseFalloff;
  63451. /**
  63452. * Sphere options for the radial explosion.
  63453. */
  63454. sphere: {
  63455. segments: number;
  63456. diameter: number;
  63457. };
  63458. /**
  63459. * Sphere options for the radial explosion.
  63460. */
  63461. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63462. }
  63463. /**
  63464. * Options fot the updraft event
  63465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63466. */
  63467. export class PhysicsUpdraftEventOptions {
  63468. /**
  63469. * The radius of the cylinder for the vortex
  63470. */
  63471. radius: number;
  63472. /**
  63473. * The strenth of the updraft.
  63474. */
  63475. strength: number;
  63476. /**
  63477. * The height of the cylinder for the updraft.
  63478. */
  63479. height: number;
  63480. /**
  63481. * The mode for the the updraft.
  63482. */
  63483. updraftMode: PhysicsUpdraftMode;
  63484. }
  63485. /**
  63486. * Options fot the vortex event
  63487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63488. */
  63489. export class PhysicsVortexEventOptions {
  63490. /**
  63491. * The radius of the cylinder for the vortex
  63492. */
  63493. radius: number;
  63494. /**
  63495. * The strenth of the vortex.
  63496. */
  63497. strength: number;
  63498. /**
  63499. * The height of the cylinder for the vortex.
  63500. */
  63501. height: number;
  63502. /**
  63503. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63504. */
  63505. centripetalForceThreshold: number;
  63506. /**
  63507. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63508. */
  63509. centripetalForceMultiplier: number;
  63510. /**
  63511. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63512. */
  63513. centrifugalForceMultiplier: number;
  63514. /**
  63515. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63516. */
  63517. updraftForceMultiplier: number;
  63518. }
  63519. /**
  63520. * The strenght of the force in correspondence to the distance of the affected object
  63521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63522. */
  63523. export enum PhysicsRadialImpulseFalloff {
  63524. /** Defines that impulse is constant in strength across it's whole radius */
  63525. Constant = 0,
  63526. /** Defines that impulse gets weaker if it's further from the origin */
  63527. Linear = 1
  63528. }
  63529. /**
  63530. * The strength of the force in correspondence to the distance of the affected object
  63531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63532. */
  63533. export enum PhysicsUpdraftMode {
  63534. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63535. Center = 0,
  63536. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63537. Perpendicular = 1
  63538. }
  63539. /**
  63540. * Interface for a physics hit data
  63541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63542. */
  63543. export interface PhysicsHitData {
  63544. /**
  63545. * The force applied at the contact point
  63546. */
  63547. force: Vector3;
  63548. /**
  63549. * The contact point
  63550. */
  63551. contactPoint: Vector3;
  63552. /**
  63553. * The distance from the origin to the contact point
  63554. */
  63555. distanceFromOrigin: number;
  63556. }
  63557. /**
  63558. * Interface for radial explosion event data
  63559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63560. */
  63561. export interface PhysicsRadialExplosionEventData {
  63562. /**
  63563. * A sphere used for the radial explosion event
  63564. */
  63565. sphere: Mesh;
  63566. }
  63567. /**
  63568. * Interface for gravitational field event data
  63569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63570. */
  63571. export interface PhysicsGravitationalFieldEventData {
  63572. /**
  63573. * A sphere mesh used for the gravitational field event
  63574. */
  63575. sphere: Mesh;
  63576. }
  63577. /**
  63578. * Interface for updraft event data
  63579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63580. */
  63581. export interface PhysicsUpdraftEventData {
  63582. /**
  63583. * A cylinder used for the updraft event
  63584. */
  63585. cylinder: Mesh;
  63586. }
  63587. /**
  63588. * Interface for vortex event data
  63589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63590. */
  63591. export interface PhysicsVortexEventData {
  63592. /**
  63593. * A cylinder used for the vortex event
  63594. */
  63595. cylinder: Mesh;
  63596. }
  63597. /**
  63598. * Interface for an affected physics impostor
  63599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63600. */
  63601. export interface PhysicsAffectedImpostorWithData {
  63602. /**
  63603. * The impostor affected by the effect
  63604. */
  63605. impostor: PhysicsImpostor;
  63606. /**
  63607. * The data about the hit/horce from the explosion
  63608. */
  63609. hitData: PhysicsHitData;
  63610. }
  63611. }
  63612. declare module "babylonjs/Physics/Plugins/index" {
  63613. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63614. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63615. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63616. }
  63617. declare module "babylonjs/Physics/index" {
  63618. export * from "babylonjs/Physics/IPhysicsEngine";
  63619. export * from "babylonjs/Physics/physicsEngine";
  63620. export * from "babylonjs/Physics/physicsEngineComponent";
  63621. export * from "babylonjs/Physics/physicsHelper";
  63622. export * from "babylonjs/Physics/physicsImpostor";
  63623. export * from "babylonjs/Physics/physicsJoint";
  63624. export * from "babylonjs/Physics/Plugins/index";
  63625. }
  63626. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63627. /** @hidden */
  63628. export var blackAndWhitePixelShader: {
  63629. name: string;
  63630. shader: string;
  63631. };
  63632. }
  63633. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63634. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63635. import { Camera } from "babylonjs/Cameras/camera";
  63636. import { Engine } from "babylonjs/Engines/engine";
  63637. import "babylonjs/Shaders/blackAndWhite.fragment";
  63638. /**
  63639. * Post process used to render in black and white
  63640. */
  63641. export class BlackAndWhitePostProcess extends PostProcess {
  63642. /**
  63643. * Linear about to convert he result to black and white (default: 1)
  63644. */
  63645. degree: number;
  63646. /**
  63647. * Creates a black and white post process
  63648. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63649. * @param name The name of the effect.
  63650. * @param options The required width/height ratio to downsize to before computing the render pass.
  63651. * @param camera The camera to apply the render pass to.
  63652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63653. * @param engine The engine which the post process will be applied. (default: current engine)
  63654. * @param reusable If the post process can be reused on the same frame. (default: false)
  63655. */
  63656. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63657. }
  63658. }
  63659. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63660. import { Nullable } from "babylonjs/types";
  63661. import { Camera } from "babylonjs/Cameras/camera";
  63662. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63663. import { Engine } from "babylonjs/Engines/engine";
  63664. /**
  63665. * This represents a set of one or more post processes in Babylon.
  63666. * A post process can be used to apply a shader to a texture after it is rendered.
  63667. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63668. */
  63669. export class PostProcessRenderEffect {
  63670. private _postProcesses;
  63671. private _getPostProcesses;
  63672. private _singleInstance;
  63673. private _cameras;
  63674. private _indicesForCamera;
  63675. /**
  63676. * Name of the effect
  63677. * @hidden
  63678. */
  63679. _name: string;
  63680. /**
  63681. * Instantiates a post process render effect.
  63682. * A post process can be used to apply a shader to a texture after it is rendered.
  63683. * @param engine The engine the effect is tied to
  63684. * @param name The name of the effect
  63685. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63686. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63687. */
  63688. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63689. /**
  63690. * Checks if all the post processes in the effect are supported.
  63691. */
  63692. readonly isSupported: boolean;
  63693. /**
  63694. * Updates the current state of the effect
  63695. * @hidden
  63696. */
  63697. _update(): void;
  63698. /**
  63699. * Attaches the effect on cameras
  63700. * @param cameras The camera to attach to.
  63701. * @hidden
  63702. */
  63703. _attachCameras(cameras: Camera): void;
  63704. /**
  63705. * Attaches the effect on cameras
  63706. * @param cameras The camera to attach to.
  63707. * @hidden
  63708. */
  63709. _attachCameras(cameras: Camera[]): void;
  63710. /**
  63711. * Detaches the effect on cameras
  63712. * @param cameras The camera to detatch from.
  63713. * @hidden
  63714. */
  63715. _detachCameras(cameras: Camera): void;
  63716. /**
  63717. * Detatches the effect on cameras
  63718. * @param cameras The camera to detatch from.
  63719. * @hidden
  63720. */
  63721. _detachCameras(cameras: Camera[]): void;
  63722. /**
  63723. * Enables the effect on given cameras
  63724. * @param cameras The camera to enable.
  63725. * @hidden
  63726. */
  63727. _enable(cameras: Camera): void;
  63728. /**
  63729. * Enables the effect on given cameras
  63730. * @param cameras The camera to enable.
  63731. * @hidden
  63732. */
  63733. _enable(cameras: Nullable<Camera[]>): void;
  63734. /**
  63735. * Disables the effect on the given cameras
  63736. * @param cameras The camera to disable.
  63737. * @hidden
  63738. */
  63739. _disable(cameras: Camera): void;
  63740. /**
  63741. * Disables the effect on the given cameras
  63742. * @param cameras The camera to disable.
  63743. * @hidden
  63744. */
  63745. _disable(cameras: Nullable<Camera[]>): void;
  63746. /**
  63747. * Gets a list of the post processes contained in the effect.
  63748. * @param camera The camera to get the post processes on.
  63749. * @returns The list of the post processes in the effect.
  63750. */
  63751. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63752. }
  63753. }
  63754. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63755. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63756. /** @hidden */
  63757. export var extractHighlightsPixelShader: {
  63758. name: string;
  63759. shader: string;
  63760. };
  63761. }
  63762. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63763. import { Nullable } from "babylonjs/types";
  63764. import { Camera } from "babylonjs/Cameras/camera";
  63765. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63766. import { Engine } from "babylonjs/Engines/engine";
  63767. import "babylonjs/Shaders/extractHighlights.fragment";
  63768. /**
  63769. * 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.
  63770. */
  63771. export class ExtractHighlightsPostProcess extends PostProcess {
  63772. /**
  63773. * The luminance threshold, pixels below this value will be set to black.
  63774. */
  63775. threshold: number;
  63776. /** @hidden */
  63777. _exposure: number;
  63778. /**
  63779. * Post process which has the input texture to be used when performing highlight extraction
  63780. * @hidden
  63781. */
  63782. _inputPostProcess: Nullable<PostProcess>;
  63783. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63784. }
  63785. }
  63786. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63787. /** @hidden */
  63788. export var bloomMergePixelShader: {
  63789. name: string;
  63790. shader: string;
  63791. };
  63792. }
  63793. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63794. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63795. import { Nullable } from "babylonjs/types";
  63796. import { Engine } from "babylonjs/Engines/engine";
  63797. import { Camera } from "babylonjs/Cameras/camera";
  63798. import "babylonjs/Shaders/bloomMerge.fragment";
  63799. /**
  63800. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63801. */
  63802. export class BloomMergePostProcess extends PostProcess {
  63803. /** Weight of the bloom to be added to the original input. */
  63804. weight: number;
  63805. /**
  63806. * Creates a new instance of @see BloomMergePostProcess
  63807. * @param name The name of the effect.
  63808. * @param originalFromInput Post process which's input will be used for the merge.
  63809. * @param blurred Blurred highlights post process which's output will be used.
  63810. * @param weight Weight of the bloom to be added to the original input.
  63811. * @param options The required width/height ratio to downsize to before computing the render pass.
  63812. * @param camera The camera to apply the render pass to.
  63813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63814. * @param engine The engine which the post process will be applied. (default: current engine)
  63815. * @param reusable If the post process can be reused on the same frame. (default: false)
  63816. * @param textureType Type of textures used when performing the post process. (default: 0)
  63817. * @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)
  63818. */
  63819. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63820. /** Weight of the bloom to be added to the original input. */
  63821. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63822. }
  63823. }
  63824. declare module "babylonjs/PostProcesses/bloomEffect" {
  63825. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63826. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63827. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63828. import { Camera } from "babylonjs/Cameras/camera";
  63829. import { Scene } from "babylonjs/scene";
  63830. /**
  63831. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63832. */
  63833. export class BloomEffect extends PostProcessRenderEffect {
  63834. private bloomScale;
  63835. /**
  63836. * @hidden Internal
  63837. */
  63838. _effects: Array<PostProcess>;
  63839. /**
  63840. * @hidden Internal
  63841. */
  63842. _downscale: ExtractHighlightsPostProcess;
  63843. private _blurX;
  63844. private _blurY;
  63845. private _merge;
  63846. /**
  63847. * The luminance threshold to find bright areas of the image to bloom.
  63848. */
  63849. threshold: number;
  63850. /**
  63851. * The strength of the bloom.
  63852. */
  63853. weight: number;
  63854. /**
  63855. * Specifies the size of the bloom blur kernel, relative to the final output size
  63856. */
  63857. kernel: number;
  63858. /**
  63859. * Creates a new instance of @see BloomEffect
  63860. * @param scene The scene the effect belongs to.
  63861. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63862. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63863. * @param bloomWeight The the strength of bloom.
  63864. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63865. * @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)
  63866. */
  63867. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63868. /**
  63869. * Disposes each of the internal effects for a given camera.
  63870. * @param camera The camera to dispose the effect on.
  63871. */
  63872. disposeEffects(camera: Camera): void;
  63873. /**
  63874. * @hidden Internal
  63875. */
  63876. _updateEffects(): void;
  63877. /**
  63878. * Internal
  63879. * @returns if all the contained post processes are ready.
  63880. * @hidden
  63881. */
  63882. _isReady(): boolean;
  63883. }
  63884. }
  63885. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63886. /** @hidden */
  63887. export var chromaticAberrationPixelShader: {
  63888. name: string;
  63889. shader: string;
  63890. };
  63891. }
  63892. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63893. import { Vector2 } from "babylonjs/Maths/math.vector";
  63894. import { Nullable } from "babylonjs/types";
  63895. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63896. import { Camera } from "babylonjs/Cameras/camera";
  63897. import { Engine } from "babylonjs/Engines/engine";
  63898. import "babylonjs/Shaders/chromaticAberration.fragment";
  63899. /**
  63900. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63901. */
  63902. export class ChromaticAberrationPostProcess extends PostProcess {
  63903. /**
  63904. * The amount of seperation of rgb channels (default: 30)
  63905. */
  63906. aberrationAmount: number;
  63907. /**
  63908. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63909. */
  63910. radialIntensity: number;
  63911. /**
  63912. * 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))
  63913. */
  63914. direction: Vector2;
  63915. /**
  63916. * 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))
  63917. */
  63918. centerPosition: Vector2;
  63919. /**
  63920. * Creates a new instance ChromaticAberrationPostProcess
  63921. * @param name The name of the effect.
  63922. * @param screenWidth The width of the screen to apply the effect on.
  63923. * @param screenHeight The height of the screen to apply the effect on.
  63924. * @param options The required width/height ratio to downsize to before computing the render pass.
  63925. * @param camera The camera to apply the render pass to.
  63926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63927. * @param engine The engine which the post process will be applied. (default: current engine)
  63928. * @param reusable If the post process can be reused on the same frame. (default: false)
  63929. * @param textureType Type of textures used when performing the post process. (default: 0)
  63930. * @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)
  63931. */
  63932. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63933. }
  63934. }
  63935. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63936. /** @hidden */
  63937. export var circleOfConfusionPixelShader: {
  63938. name: string;
  63939. shader: string;
  63940. };
  63941. }
  63942. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63943. import { Nullable } from "babylonjs/types";
  63944. import { Engine } from "babylonjs/Engines/engine";
  63945. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63946. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63947. import { Camera } from "babylonjs/Cameras/camera";
  63948. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63949. /**
  63950. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63951. */
  63952. export class CircleOfConfusionPostProcess extends PostProcess {
  63953. /**
  63954. * 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.
  63955. */
  63956. lensSize: number;
  63957. /**
  63958. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63959. */
  63960. fStop: number;
  63961. /**
  63962. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63963. */
  63964. focusDistance: number;
  63965. /**
  63966. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63967. */
  63968. focalLength: number;
  63969. private _depthTexture;
  63970. /**
  63971. * Creates a new instance CircleOfConfusionPostProcess
  63972. * @param name The name of the effect.
  63973. * @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.
  63974. * @param options The required width/height ratio to downsize to before computing the render pass.
  63975. * @param camera The camera to apply the render pass to.
  63976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63977. * @param engine The engine which the post process will be applied. (default: current engine)
  63978. * @param reusable If the post process can be reused on the same frame. (default: false)
  63979. * @param textureType Type of textures used when performing the post process. (default: 0)
  63980. * @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)
  63981. */
  63982. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63983. /**
  63984. * 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.
  63985. */
  63986. depthTexture: RenderTargetTexture;
  63987. }
  63988. }
  63989. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63990. /** @hidden */
  63991. export var colorCorrectionPixelShader: {
  63992. name: string;
  63993. shader: string;
  63994. };
  63995. }
  63996. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63997. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63998. import { Engine } from "babylonjs/Engines/engine";
  63999. import { Camera } from "babylonjs/Cameras/camera";
  64000. import "babylonjs/Shaders/colorCorrection.fragment";
  64001. /**
  64002. *
  64003. * This post-process allows the modification of rendered colors by using
  64004. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64005. *
  64006. * The object needs to be provided an url to a texture containing the color
  64007. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64008. * Use an image editing software to tweak the LUT to match your needs.
  64009. *
  64010. * For an example of a color LUT, see here:
  64011. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64012. * For explanations on color grading, see here:
  64013. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64014. *
  64015. */
  64016. export class ColorCorrectionPostProcess extends PostProcess {
  64017. private _colorTableTexture;
  64018. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64019. }
  64020. }
  64021. declare module "babylonjs/Shaders/convolution.fragment" {
  64022. /** @hidden */
  64023. export var convolutionPixelShader: {
  64024. name: string;
  64025. shader: string;
  64026. };
  64027. }
  64028. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  64029. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64030. import { Nullable } from "babylonjs/types";
  64031. import { Camera } from "babylonjs/Cameras/camera";
  64032. import { Engine } from "babylonjs/Engines/engine";
  64033. import "babylonjs/Shaders/convolution.fragment";
  64034. /**
  64035. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64036. * input texture to perform effects such as edge detection or sharpening
  64037. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64038. */
  64039. export class ConvolutionPostProcess extends PostProcess {
  64040. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64041. kernel: number[];
  64042. /**
  64043. * Creates a new instance ConvolutionPostProcess
  64044. * @param name The name of the effect.
  64045. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64046. * @param options The required width/height ratio to downsize to before computing the render pass.
  64047. * @param camera The camera to apply the render pass to.
  64048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64049. * @param engine The engine which the post process will be applied. (default: current engine)
  64050. * @param reusable If the post process can be reused on the same frame. (default: false)
  64051. * @param textureType Type of textures used when performing the post process. (default: 0)
  64052. */
  64053. constructor(name: string,
  64054. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64055. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64056. /**
  64057. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64058. */
  64059. static EdgeDetect0Kernel: number[];
  64060. /**
  64061. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64062. */
  64063. static EdgeDetect1Kernel: number[];
  64064. /**
  64065. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64066. */
  64067. static EdgeDetect2Kernel: number[];
  64068. /**
  64069. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64070. */
  64071. static SharpenKernel: number[];
  64072. /**
  64073. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64074. */
  64075. static EmbossKernel: number[];
  64076. /**
  64077. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64078. */
  64079. static GaussianKernel: number[];
  64080. }
  64081. }
  64082. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  64083. import { Nullable } from "babylonjs/types";
  64084. import { Vector2 } from "babylonjs/Maths/math.vector";
  64085. import { Camera } from "babylonjs/Cameras/camera";
  64086. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64087. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64088. import { Engine } from "babylonjs/Engines/engine";
  64089. import { Scene } from "babylonjs/scene";
  64090. /**
  64091. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64092. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64093. * based on samples that have a large difference in distance than the center pixel.
  64094. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64095. */
  64096. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64097. direction: Vector2;
  64098. /**
  64099. * Creates a new instance CircleOfConfusionPostProcess
  64100. * @param name The name of the effect.
  64101. * @param scene The scene the effect belongs to.
  64102. * @param direction The direction the blur should be applied.
  64103. * @param kernel The size of the kernel used to blur.
  64104. * @param options The required width/height ratio to downsize to before computing the render pass.
  64105. * @param camera The camera to apply the render pass to.
  64106. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64107. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64109. * @param engine The engine which the post process will be applied. (default: current engine)
  64110. * @param reusable If the post process can be reused on the same frame. (default: false)
  64111. * @param textureType Type of textures used when performing the post process. (default: 0)
  64112. * @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)
  64113. */
  64114. 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);
  64115. }
  64116. }
  64117. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  64118. /** @hidden */
  64119. export var depthOfFieldMergePixelShader: {
  64120. name: string;
  64121. shader: string;
  64122. };
  64123. }
  64124. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  64125. import { Nullable } from "babylonjs/types";
  64126. import { Camera } from "babylonjs/Cameras/camera";
  64127. import { Effect } from "babylonjs/Materials/effect";
  64128. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64129. import { Engine } from "babylonjs/Engines/engine";
  64130. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  64131. /**
  64132. * Options to be set when merging outputs from the default pipeline.
  64133. */
  64134. export class DepthOfFieldMergePostProcessOptions {
  64135. /**
  64136. * The original image to merge on top of
  64137. */
  64138. originalFromInput: PostProcess;
  64139. /**
  64140. * Parameters to perform the merge of the depth of field effect
  64141. */
  64142. depthOfField?: {
  64143. circleOfConfusion: PostProcess;
  64144. blurSteps: Array<PostProcess>;
  64145. };
  64146. /**
  64147. * Parameters to perform the merge of bloom effect
  64148. */
  64149. bloom?: {
  64150. blurred: PostProcess;
  64151. weight: number;
  64152. };
  64153. }
  64154. /**
  64155. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64156. */
  64157. export class DepthOfFieldMergePostProcess extends PostProcess {
  64158. private blurSteps;
  64159. /**
  64160. * Creates a new instance of DepthOfFieldMergePostProcess
  64161. * @param name The name of the effect.
  64162. * @param originalFromInput Post process which's input will be used for the merge.
  64163. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64164. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64165. * @param options The required width/height ratio to downsize to before computing the render pass.
  64166. * @param camera The camera to apply the render pass to.
  64167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64168. * @param engine The engine which the post process will be applied. (default: current engine)
  64169. * @param reusable If the post process can be reused on the same frame. (default: false)
  64170. * @param textureType Type of textures used when performing the post process. (default: 0)
  64171. * @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)
  64172. */
  64173. 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);
  64174. /**
  64175. * Updates the effect with the current post process compile time values and recompiles the shader.
  64176. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64177. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64178. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64179. * @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
  64180. * @param onCompiled Called when the shader has been compiled.
  64181. * @param onError Called if there is an error when compiling a shader.
  64182. */
  64183. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64184. }
  64185. }
  64186. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  64187. import { Nullable } from "babylonjs/types";
  64188. import { Camera } from "babylonjs/Cameras/camera";
  64189. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64190. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64191. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64192. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64193. import { Scene } from "babylonjs/scene";
  64194. /**
  64195. * Specifies the level of max blur that should be applied when using the depth of field effect
  64196. */
  64197. export enum DepthOfFieldEffectBlurLevel {
  64198. /**
  64199. * Subtle blur
  64200. */
  64201. Low = 0,
  64202. /**
  64203. * Medium blur
  64204. */
  64205. Medium = 1,
  64206. /**
  64207. * Large blur
  64208. */
  64209. High = 2
  64210. }
  64211. /**
  64212. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64213. */
  64214. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64215. private _circleOfConfusion;
  64216. /**
  64217. * @hidden Internal, blurs from high to low
  64218. */
  64219. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64220. private _depthOfFieldBlurY;
  64221. private _dofMerge;
  64222. /**
  64223. * @hidden Internal post processes in depth of field effect
  64224. */
  64225. _effects: Array<PostProcess>;
  64226. /**
  64227. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64228. */
  64229. focalLength: number;
  64230. /**
  64231. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64232. */
  64233. fStop: number;
  64234. /**
  64235. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64236. */
  64237. focusDistance: number;
  64238. /**
  64239. * 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.
  64240. */
  64241. lensSize: number;
  64242. /**
  64243. * Creates a new instance DepthOfFieldEffect
  64244. * @param scene The scene the effect belongs to.
  64245. * @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.
  64246. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64247. * @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)
  64248. */
  64249. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64250. /**
  64251. * Get the current class name of the current effet
  64252. * @returns "DepthOfFieldEffect"
  64253. */
  64254. getClassName(): string;
  64255. /**
  64256. * 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.
  64257. */
  64258. depthTexture: RenderTargetTexture;
  64259. /**
  64260. * Disposes each of the internal effects for a given camera.
  64261. * @param camera The camera to dispose the effect on.
  64262. */
  64263. disposeEffects(camera: Camera): void;
  64264. /**
  64265. * @hidden Internal
  64266. */
  64267. _updateEffects(): void;
  64268. /**
  64269. * Internal
  64270. * @returns if all the contained post processes are ready.
  64271. * @hidden
  64272. */
  64273. _isReady(): boolean;
  64274. }
  64275. }
  64276. declare module "babylonjs/Shaders/displayPass.fragment" {
  64277. /** @hidden */
  64278. export var displayPassPixelShader: {
  64279. name: string;
  64280. shader: string;
  64281. };
  64282. }
  64283. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  64284. import { Nullable } from "babylonjs/types";
  64285. import { Camera } from "babylonjs/Cameras/camera";
  64286. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64287. import { Engine } from "babylonjs/Engines/engine";
  64288. import "babylonjs/Shaders/displayPass.fragment";
  64289. /**
  64290. * DisplayPassPostProcess which produces an output the same as it's input
  64291. */
  64292. export class DisplayPassPostProcess extends PostProcess {
  64293. /**
  64294. * Creates the DisplayPassPostProcess
  64295. * @param name The name of the effect.
  64296. * @param options The required width/height ratio to downsize to before computing the render pass.
  64297. * @param camera The camera to apply the render pass to.
  64298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64299. * @param engine The engine which the post process will be applied. (default: current engine)
  64300. * @param reusable If the post process can be reused on the same frame. (default: false)
  64301. */
  64302. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64303. }
  64304. }
  64305. declare module "babylonjs/Shaders/filter.fragment" {
  64306. /** @hidden */
  64307. export var filterPixelShader: {
  64308. name: string;
  64309. shader: string;
  64310. };
  64311. }
  64312. declare module "babylonjs/PostProcesses/filterPostProcess" {
  64313. import { Nullable } from "babylonjs/types";
  64314. import { Matrix } from "babylonjs/Maths/math.vector";
  64315. import { Camera } from "babylonjs/Cameras/camera";
  64316. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64317. import { Engine } from "babylonjs/Engines/engine";
  64318. import "babylonjs/Shaders/filter.fragment";
  64319. /**
  64320. * Applies a kernel filter to the image
  64321. */
  64322. export class FilterPostProcess extends PostProcess {
  64323. /** The matrix to be applied to the image */
  64324. kernelMatrix: Matrix;
  64325. /**
  64326. *
  64327. * @param name The name of the effect.
  64328. * @param kernelMatrix The matrix to be applied to the image
  64329. * @param options The required width/height ratio to downsize to before computing the render pass.
  64330. * @param camera The camera to apply the render pass to.
  64331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64332. * @param engine The engine which the post process will be applied. (default: current engine)
  64333. * @param reusable If the post process can be reused on the same frame. (default: false)
  64334. */
  64335. constructor(name: string,
  64336. /** The matrix to be applied to the image */
  64337. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64338. }
  64339. }
  64340. declare module "babylonjs/Shaders/fxaa.fragment" {
  64341. /** @hidden */
  64342. export var fxaaPixelShader: {
  64343. name: string;
  64344. shader: string;
  64345. };
  64346. }
  64347. declare module "babylonjs/Shaders/fxaa.vertex" {
  64348. /** @hidden */
  64349. export var fxaaVertexShader: {
  64350. name: string;
  64351. shader: string;
  64352. };
  64353. }
  64354. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64355. import { Nullable } from "babylonjs/types";
  64356. import { Camera } from "babylonjs/Cameras/camera";
  64357. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64358. import { Engine } from "babylonjs/Engines/engine";
  64359. import "babylonjs/Shaders/fxaa.fragment";
  64360. import "babylonjs/Shaders/fxaa.vertex";
  64361. /**
  64362. * Fxaa post process
  64363. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64364. */
  64365. export class FxaaPostProcess extends PostProcess {
  64366. /** @hidden */
  64367. texelWidth: number;
  64368. /** @hidden */
  64369. texelHeight: number;
  64370. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64371. private _getDefines;
  64372. }
  64373. }
  64374. declare module "babylonjs/Shaders/grain.fragment" {
  64375. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64376. /** @hidden */
  64377. export var grainPixelShader: {
  64378. name: string;
  64379. shader: string;
  64380. };
  64381. }
  64382. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64383. import { Nullable } from "babylonjs/types";
  64384. import { Camera } from "babylonjs/Cameras/camera";
  64385. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64386. import { Engine } from "babylonjs/Engines/engine";
  64387. import "babylonjs/Shaders/grain.fragment";
  64388. /**
  64389. * The GrainPostProcess adds noise to the image at mid luminance levels
  64390. */
  64391. export class GrainPostProcess extends PostProcess {
  64392. /**
  64393. * The intensity of the grain added (default: 30)
  64394. */
  64395. intensity: number;
  64396. /**
  64397. * If the grain should be randomized on every frame
  64398. */
  64399. animated: boolean;
  64400. /**
  64401. * Creates a new instance of @see GrainPostProcess
  64402. * @param name The name of the effect.
  64403. * @param options The required width/height ratio to downsize to before computing the render pass.
  64404. * @param camera The camera to apply the render pass to.
  64405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64406. * @param engine The engine which the post process will be applied. (default: current engine)
  64407. * @param reusable If the post process can be reused on the same frame. (default: false)
  64408. * @param textureType Type of textures used when performing the post process. (default: 0)
  64409. * @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)
  64410. */
  64411. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64412. }
  64413. }
  64414. declare module "babylonjs/Shaders/highlights.fragment" {
  64415. /** @hidden */
  64416. export var highlightsPixelShader: {
  64417. name: string;
  64418. shader: string;
  64419. };
  64420. }
  64421. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64422. import { Nullable } from "babylonjs/types";
  64423. import { Camera } from "babylonjs/Cameras/camera";
  64424. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64425. import { Engine } from "babylonjs/Engines/engine";
  64426. import "babylonjs/Shaders/highlights.fragment";
  64427. /**
  64428. * Extracts highlights from the image
  64429. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64430. */
  64431. export class HighlightsPostProcess extends PostProcess {
  64432. /**
  64433. * Extracts highlights from the image
  64434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64435. * @param name The name of the effect.
  64436. * @param options The required width/height ratio to downsize to before computing the render pass.
  64437. * @param camera The camera to apply the render pass to.
  64438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64439. * @param engine The engine which the post process will be applied. (default: current engine)
  64440. * @param reusable If the post process can be reused on the same frame. (default: false)
  64441. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64442. */
  64443. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64444. }
  64445. }
  64446. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64447. /** @hidden */
  64448. export var mrtFragmentDeclaration: {
  64449. name: string;
  64450. shader: string;
  64451. };
  64452. }
  64453. declare module "babylonjs/Shaders/geometry.fragment" {
  64454. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64455. /** @hidden */
  64456. export var geometryPixelShader: {
  64457. name: string;
  64458. shader: string;
  64459. };
  64460. }
  64461. declare module "babylonjs/Shaders/geometry.vertex" {
  64462. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64464. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64465. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64467. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64468. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64469. /** @hidden */
  64470. export var geometryVertexShader: {
  64471. name: string;
  64472. shader: string;
  64473. };
  64474. }
  64475. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64476. import { Matrix } from "babylonjs/Maths/math.vector";
  64477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64478. import { Mesh } from "babylonjs/Meshes/mesh";
  64479. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64480. import { Effect } from "babylonjs/Materials/effect";
  64481. import { Scene } from "babylonjs/scene";
  64482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64483. import "babylonjs/Shaders/geometry.fragment";
  64484. import "babylonjs/Shaders/geometry.vertex";
  64485. /** @hidden */
  64486. interface ISavedTransformationMatrix {
  64487. world: Matrix;
  64488. viewProjection: Matrix;
  64489. }
  64490. /**
  64491. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64492. */
  64493. export class GeometryBufferRenderer {
  64494. /**
  64495. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64496. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64497. */
  64498. static readonly POSITION_TEXTURE_TYPE: number;
  64499. /**
  64500. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64501. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64502. */
  64503. static readonly VELOCITY_TEXTURE_TYPE: number;
  64504. /**
  64505. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64506. * in order to compute objects velocities when enableVelocity is set to "true"
  64507. * @hidden
  64508. */
  64509. _previousTransformationMatrices: {
  64510. [index: number]: ISavedTransformationMatrix;
  64511. };
  64512. /**
  64513. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64514. * in order to compute objects velocities when enableVelocity is set to "true"
  64515. * @hidden
  64516. */
  64517. _previousBonesTransformationMatrices: {
  64518. [index: number]: Float32Array;
  64519. };
  64520. /**
  64521. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64522. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64523. */
  64524. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64525. private _scene;
  64526. private _multiRenderTarget;
  64527. private _ratio;
  64528. private _enablePosition;
  64529. private _enableVelocity;
  64530. private _positionIndex;
  64531. private _velocityIndex;
  64532. protected _effect: Effect;
  64533. protected _cachedDefines: string;
  64534. /**
  64535. * Set the render list (meshes to be rendered) used in the G buffer.
  64536. */
  64537. renderList: Mesh[];
  64538. /**
  64539. * Gets wether or not G buffer are supported by the running hardware.
  64540. * This requires draw buffer supports
  64541. */
  64542. readonly isSupported: boolean;
  64543. /**
  64544. * Returns the index of the given texture type in the G-Buffer textures array
  64545. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64546. * @returns the index of the given texture type in the G-Buffer textures array
  64547. */
  64548. getTextureIndex(textureType: number): number;
  64549. /**
  64550. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64551. */
  64552. /**
  64553. * Sets whether or not objects positions are enabled for the G buffer.
  64554. */
  64555. enablePosition: boolean;
  64556. /**
  64557. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64558. */
  64559. /**
  64560. * Sets wether or not objects velocities are enabled for the G buffer.
  64561. */
  64562. enableVelocity: boolean;
  64563. /**
  64564. * Gets the scene associated with the buffer.
  64565. */
  64566. readonly scene: Scene;
  64567. /**
  64568. * Gets the ratio used by the buffer during its creation.
  64569. * How big is the buffer related to the main canvas.
  64570. */
  64571. readonly ratio: number;
  64572. /** @hidden */
  64573. static _SceneComponentInitialization: (scene: Scene) => void;
  64574. /**
  64575. * Creates a new G Buffer for the scene
  64576. * @param scene The scene the buffer belongs to
  64577. * @param ratio How big is the buffer related to the main canvas.
  64578. */
  64579. constructor(scene: Scene, ratio?: number);
  64580. /**
  64581. * Checks wether everything is ready to render a submesh to the G buffer.
  64582. * @param subMesh the submesh to check readiness for
  64583. * @param useInstances is the mesh drawn using instance or not
  64584. * @returns true if ready otherwise false
  64585. */
  64586. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64587. /**
  64588. * Gets the current underlying G Buffer.
  64589. * @returns the buffer
  64590. */
  64591. getGBuffer(): MultiRenderTarget;
  64592. /**
  64593. * Gets the number of samples used to render the buffer (anti aliasing).
  64594. */
  64595. /**
  64596. * Sets the number of samples used to render the buffer (anti aliasing).
  64597. */
  64598. samples: number;
  64599. /**
  64600. * Disposes the renderer and frees up associated resources.
  64601. */
  64602. dispose(): void;
  64603. protected _createRenderTargets(): void;
  64604. private _copyBonesTransformationMatrices;
  64605. }
  64606. }
  64607. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64608. import { Nullable } from "babylonjs/types";
  64609. import { Scene } from "babylonjs/scene";
  64610. import { ISceneComponent } from "babylonjs/sceneComponent";
  64611. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64612. module "babylonjs/scene" {
  64613. interface Scene {
  64614. /** @hidden (Backing field) */
  64615. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64616. /**
  64617. * Gets or Sets the current geometry buffer associated to the scene.
  64618. */
  64619. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64620. /**
  64621. * Enables a GeometryBufferRender and associates it with the scene
  64622. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64623. * @returns the GeometryBufferRenderer
  64624. */
  64625. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64626. /**
  64627. * Disables the GeometryBufferRender associated with the scene
  64628. */
  64629. disableGeometryBufferRenderer(): void;
  64630. }
  64631. }
  64632. /**
  64633. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64634. * in several rendering techniques.
  64635. */
  64636. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64637. /**
  64638. * The component name helpful to identify the component in the list of scene components.
  64639. */
  64640. readonly name: string;
  64641. /**
  64642. * The scene the component belongs to.
  64643. */
  64644. scene: Scene;
  64645. /**
  64646. * Creates a new instance of the component for the given scene
  64647. * @param scene Defines the scene to register the component in
  64648. */
  64649. constructor(scene: Scene);
  64650. /**
  64651. * Registers the component in a given scene
  64652. */
  64653. register(): void;
  64654. /**
  64655. * Rebuilds the elements related to this component in case of
  64656. * context lost for instance.
  64657. */
  64658. rebuild(): void;
  64659. /**
  64660. * Disposes the component and the associated ressources
  64661. */
  64662. dispose(): void;
  64663. private _gatherRenderTargets;
  64664. }
  64665. }
  64666. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64667. /** @hidden */
  64668. export var motionBlurPixelShader: {
  64669. name: string;
  64670. shader: string;
  64671. };
  64672. }
  64673. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64674. import { Nullable } from "babylonjs/types";
  64675. import { Camera } from "babylonjs/Cameras/camera";
  64676. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64677. import { Scene } from "babylonjs/scene";
  64678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64679. import "babylonjs/Animations/animatable";
  64680. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64681. import "babylonjs/Shaders/motionBlur.fragment";
  64682. import { Engine } from "babylonjs/Engines/engine";
  64683. /**
  64684. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64685. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64686. * As an example, all you have to do is to create the post-process:
  64687. * var mb = new BABYLON.MotionBlurPostProcess(
  64688. * 'mb', // The name of the effect.
  64689. * scene, // The scene containing the objects to blur according to their velocity.
  64690. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64691. * camera // The camera to apply the render pass to.
  64692. * );
  64693. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64694. */
  64695. export class MotionBlurPostProcess extends PostProcess {
  64696. /**
  64697. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64698. */
  64699. motionStrength: number;
  64700. /**
  64701. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64702. */
  64703. /**
  64704. * Sets the number of iterations to be used for motion blur quality
  64705. */
  64706. motionBlurSamples: number;
  64707. private _motionBlurSamples;
  64708. private _geometryBufferRenderer;
  64709. /**
  64710. * Creates a new instance MotionBlurPostProcess
  64711. * @param name The name of the effect.
  64712. * @param scene The scene containing the objects to blur according to their velocity.
  64713. * @param options The required width/height ratio to downsize to before computing the render pass.
  64714. * @param camera The camera to apply the render pass to.
  64715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64716. * @param engine The engine which the post process will be applied. (default: current engine)
  64717. * @param reusable If the post process can be reused on the same frame. (default: false)
  64718. * @param textureType Type of textures used when performing the post process. (default: 0)
  64719. * @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)
  64720. */
  64721. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64722. /**
  64723. * Excludes the given skinned mesh from computing bones velocities.
  64724. * 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.
  64725. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64726. */
  64727. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64728. /**
  64729. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64730. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64731. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64732. */
  64733. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64734. /**
  64735. * Disposes the post process.
  64736. * @param camera The camera to dispose the post process on.
  64737. */
  64738. dispose(camera?: Camera): void;
  64739. }
  64740. }
  64741. declare module "babylonjs/Shaders/refraction.fragment" {
  64742. /** @hidden */
  64743. export var refractionPixelShader: {
  64744. name: string;
  64745. shader: string;
  64746. };
  64747. }
  64748. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64749. import { Color3 } from "babylonjs/Maths/math.color";
  64750. import { Camera } from "babylonjs/Cameras/camera";
  64751. import { Texture } from "babylonjs/Materials/Textures/texture";
  64752. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64753. import { Engine } from "babylonjs/Engines/engine";
  64754. import "babylonjs/Shaders/refraction.fragment";
  64755. /**
  64756. * Post process which applies a refractin texture
  64757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64758. */
  64759. export class RefractionPostProcess extends PostProcess {
  64760. /** the base color of the refraction (used to taint the rendering) */
  64761. color: Color3;
  64762. /** simulated refraction depth */
  64763. depth: number;
  64764. /** the coefficient of the base color (0 to remove base color tainting) */
  64765. colorLevel: number;
  64766. private _refTexture;
  64767. private _ownRefractionTexture;
  64768. /**
  64769. * Gets or sets the refraction texture
  64770. * Please note that you are responsible for disposing the texture if you set it manually
  64771. */
  64772. refractionTexture: Texture;
  64773. /**
  64774. * Initializes the RefractionPostProcess
  64775. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64776. * @param name The name of the effect.
  64777. * @param refractionTextureUrl Url of the refraction texture to use
  64778. * @param color the base color of the refraction (used to taint the rendering)
  64779. * @param depth simulated refraction depth
  64780. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64781. * @param camera The camera to apply the render pass to.
  64782. * @param options The required width/height ratio to downsize to before computing the render pass.
  64783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64784. * @param engine The engine which the post process will be applied. (default: current engine)
  64785. * @param reusable If the post process can be reused on the same frame. (default: false)
  64786. */
  64787. constructor(name: string, refractionTextureUrl: string,
  64788. /** the base color of the refraction (used to taint the rendering) */
  64789. color: Color3,
  64790. /** simulated refraction depth */
  64791. depth: number,
  64792. /** the coefficient of the base color (0 to remove base color tainting) */
  64793. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64794. /**
  64795. * Disposes of the post process
  64796. * @param camera Camera to dispose post process on
  64797. */
  64798. dispose(camera: Camera): void;
  64799. }
  64800. }
  64801. declare module "babylonjs/Shaders/sharpen.fragment" {
  64802. /** @hidden */
  64803. export var sharpenPixelShader: {
  64804. name: string;
  64805. shader: string;
  64806. };
  64807. }
  64808. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64809. import { Nullable } from "babylonjs/types";
  64810. import { Camera } from "babylonjs/Cameras/camera";
  64811. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64812. import "babylonjs/Shaders/sharpen.fragment";
  64813. import { Engine } from "babylonjs/Engines/engine";
  64814. /**
  64815. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64816. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64817. */
  64818. export class SharpenPostProcess extends PostProcess {
  64819. /**
  64820. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64821. */
  64822. colorAmount: number;
  64823. /**
  64824. * How much sharpness should be applied (default: 0.3)
  64825. */
  64826. edgeAmount: number;
  64827. /**
  64828. * Creates a new instance ConvolutionPostProcess
  64829. * @param name The name of the effect.
  64830. * @param options The required width/height ratio to downsize to before computing the render pass.
  64831. * @param camera The camera to apply the render pass to.
  64832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64833. * @param engine The engine which the post process will be applied. (default: current engine)
  64834. * @param reusable If the post process can be reused on the same frame. (default: false)
  64835. * @param textureType Type of textures used when performing the post process. (default: 0)
  64836. * @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)
  64837. */
  64838. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64839. }
  64840. }
  64841. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64842. import { Nullable } from "babylonjs/types";
  64843. import { Camera } from "babylonjs/Cameras/camera";
  64844. import { Engine } from "babylonjs/Engines/engine";
  64845. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64846. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64847. /**
  64848. * PostProcessRenderPipeline
  64849. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64850. */
  64851. export class PostProcessRenderPipeline {
  64852. private engine;
  64853. private _renderEffects;
  64854. private _renderEffectsForIsolatedPass;
  64855. /**
  64856. * List of inspectable custom properties (used by the Inspector)
  64857. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64858. */
  64859. inspectableCustomProperties: IInspectable[];
  64860. /**
  64861. * @hidden
  64862. */
  64863. protected _cameras: Camera[];
  64864. /** @hidden */
  64865. _name: string;
  64866. /**
  64867. * Gets pipeline name
  64868. */
  64869. readonly name: string;
  64870. /** Gets the list of attached cameras */
  64871. readonly cameras: Camera[];
  64872. /**
  64873. * Initializes a PostProcessRenderPipeline
  64874. * @param engine engine to add the pipeline to
  64875. * @param name name of the pipeline
  64876. */
  64877. constructor(engine: Engine, name: string);
  64878. /**
  64879. * Gets the class name
  64880. * @returns "PostProcessRenderPipeline"
  64881. */
  64882. getClassName(): string;
  64883. /**
  64884. * If all the render effects in the pipeline are supported
  64885. */
  64886. readonly isSupported: boolean;
  64887. /**
  64888. * Adds an effect to the pipeline
  64889. * @param renderEffect the effect to add
  64890. */
  64891. addEffect(renderEffect: PostProcessRenderEffect): void;
  64892. /** @hidden */
  64893. _rebuild(): void;
  64894. /** @hidden */
  64895. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64896. /** @hidden */
  64897. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64898. /** @hidden */
  64899. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64900. /** @hidden */
  64901. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64902. /** @hidden */
  64903. _attachCameras(cameras: Camera, unique: boolean): void;
  64904. /** @hidden */
  64905. _attachCameras(cameras: Camera[], unique: boolean): void;
  64906. /** @hidden */
  64907. _detachCameras(cameras: Camera): void;
  64908. /** @hidden */
  64909. _detachCameras(cameras: Nullable<Camera[]>): void;
  64910. /** @hidden */
  64911. _update(): void;
  64912. /** @hidden */
  64913. _reset(): void;
  64914. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64915. /**
  64916. * Disposes of the pipeline
  64917. */
  64918. dispose(): void;
  64919. }
  64920. }
  64921. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64922. import { Camera } from "babylonjs/Cameras/camera";
  64923. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64924. /**
  64925. * PostProcessRenderPipelineManager class
  64926. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64927. */
  64928. export class PostProcessRenderPipelineManager {
  64929. private _renderPipelines;
  64930. /**
  64931. * Initializes a PostProcessRenderPipelineManager
  64932. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64933. */
  64934. constructor();
  64935. /**
  64936. * Gets the list of supported render pipelines
  64937. */
  64938. readonly supportedPipelines: PostProcessRenderPipeline[];
  64939. /**
  64940. * Adds a pipeline to the manager
  64941. * @param renderPipeline The pipeline to add
  64942. */
  64943. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64944. /**
  64945. * Attaches a camera to the pipeline
  64946. * @param renderPipelineName The name of the pipeline to attach to
  64947. * @param cameras the camera to attach
  64948. * @param unique if the camera can be attached multiple times to the pipeline
  64949. */
  64950. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64951. /**
  64952. * Detaches a camera from the pipeline
  64953. * @param renderPipelineName The name of the pipeline to detach from
  64954. * @param cameras the camera to detach
  64955. */
  64956. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64957. /**
  64958. * Enables an effect by name on a pipeline
  64959. * @param renderPipelineName the name of the pipeline to enable the effect in
  64960. * @param renderEffectName the name of the effect to enable
  64961. * @param cameras the cameras that the effect should be enabled on
  64962. */
  64963. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64964. /**
  64965. * Disables an effect by name on a pipeline
  64966. * @param renderPipelineName the name of the pipeline to disable the effect in
  64967. * @param renderEffectName the name of the effect to disable
  64968. * @param cameras the cameras that the effect should be disabled on
  64969. */
  64970. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64971. /**
  64972. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64973. */
  64974. update(): void;
  64975. /** @hidden */
  64976. _rebuild(): void;
  64977. /**
  64978. * Disposes of the manager and pipelines
  64979. */
  64980. dispose(): void;
  64981. }
  64982. }
  64983. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64984. import { ISceneComponent } from "babylonjs/sceneComponent";
  64985. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64986. import { Scene } from "babylonjs/scene";
  64987. module "babylonjs/scene" {
  64988. interface Scene {
  64989. /** @hidden (Backing field) */
  64990. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64991. /**
  64992. * Gets the postprocess render pipeline manager
  64993. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64994. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64995. */
  64996. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64997. }
  64998. }
  64999. /**
  65000. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65001. */
  65002. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65003. /**
  65004. * The component name helpfull to identify the component in the list of scene components.
  65005. */
  65006. readonly name: string;
  65007. /**
  65008. * The scene the component belongs to.
  65009. */
  65010. scene: Scene;
  65011. /**
  65012. * Creates a new instance of the component for the given scene
  65013. * @param scene Defines the scene to register the component in
  65014. */
  65015. constructor(scene: Scene);
  65016. /**
  65017. * Registers the component in a given scene
  65018. */
  65019. register(): void;
  65020. /**
  65021. * Rebuilds the elements related to this component in case of
  65022. * context lost for instance.
  65023. */
  65024. rebuild(): void;
  65025. /**
  65026. * Disposes the component and the associated ressources
  65027. */
  65028. dispose(): void;
  65029. private _gatherRenderTargets;
  65030. }
  65031. }
  65032. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  65033. import { Nullable } from "babylonjs/types";
  65034. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65035. import { Camera } from "babylonjs/Cameras/camera";
  65036. import { IDisposable } from "babylonjs/scene";
  65037. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  65038. import { Scene } from "babylonjs/scene";
  65039. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  65040. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65041. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65042. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  65043. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65044. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65045. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  65046. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65047. import { Animation } from "babylonjs/Animations/animation";
  65048. /**
  65049. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65050. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65051. */
  65052. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65053. private _scene;
  65054. private _camerasToBeAttached;
  65055. /**
  65056. * ID of the sharpen post process,
  65057. */
  65058. private readonly SharpenPostProcessId;
  65059. /**
  65060. * @ignore
  65061. * ID of the image processing post process;
  65062. */
  65063. readonly ImageProcessingPostProcessId: string;
  65064. /**
  65065. * @ignore
  65066. * ID of the Fast Approximate Anti-Aliasing post process;
  65067. */
  65068. readonly FxaaPostProcessId: string;
  65069. /**
  65070. * ID of the chromatic aberration post process,
  65071. */
  65072. private readonly ChromaticAberrationPostProcessId;
  65073. /**
  65074. * ID of the grain post process
  65075. */
  65076. private readonly GrainPostProcessId;
  65077. /**
  65078. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65079. */
  65080. sharpen: SharpenPostProcess;
  65081. private _sharpenEffect;
  65082. private bloom;
  65083. /**
  65084. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65085. */
  65086. depthOfField: DepthOfFieldEffect;
  65087. /**
  65088. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65089. */
  65090. fxaa: FxaaPostProcess;
  65091. /**
  65092. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65093. */
  65094. imageProcessing: ImageProcessingPostProcess;
  65095. /**
  65096. * Chromatic aberration post process which will shift rgb colors in the image
  65097. */
  65098. chromaticAberration: ChromaticAberrationPostProcess;
  65099. private _chromaticAberrationEffect;
  65100. /**
  65101. * Grain post process which add noise to the image
  65102. */
  65103. grain: GrainPostProcess;
  65104. private _grainEffect;
  65105. /**
  65106. * Glow post process which adds a glow to emissive areas of the image
  65107. */
  65108. private _glowLayer;
  65109. /**
  65110. * Animations which can be used to tweak settings over a period of time
  65111. */
  65112. animations: Animation[];
  65113. private _imageProcessingConfigurationObserver;
  65114. private _sharpenEnabled;
  65115. private _bloomEnabled;
  65116. private _depthOfFieldEnabled;
  65117. private _depthOfFieldBlurLevel;
  65118. private _fxaaEnabled;
  65119. private _imageProcessingEnabled;
  65120. private _defaultPipelineTextureType;
  65121. private _bloomScale;
  65122. private _chromaticAberrationEnabled;
  65123. private _grainEnabled;
  65124. private _buildAllowed;
  65125. /**
  65126. * Gets active scene
  65127. */
  65128. readonly scene: Scene;
  65129. /**
  65130. * Enable or disable the sharpen process from the pipeline
  65131. */
  65132. sharpenEnabled: boolean;
  65133. private _resizeObserver;
  65134. private _hardwareScaleLevel;
  65135. private _bloomKernel;
  65136. /**
  65137. * Specifies the size of the bloom blur kernel, relative to the final output size
  65138. */
  65139. bloomKernel: number;
  65140. /**
  65141. * Specifies the weight of the bloom in the final rendering
  65142. */
  65143. private _bloomWeight;
  65144. /**
  65145. * Specifies the luma threshold for the area that will be blurred by the bloom
  65146. */
  65147. private _bloomThreshold;
  65148. private _hdr;
  65149. /**
  65150. * The strength of the bloom.
  65151. */
  65152. bloomWeight: number;
  65153. /**
  65154. * The strength of the bloom.
  65155. */
  65156. bloomThreshold: number;
  65157. /**
  65158. * The scale of the bloom, lower value will provide better performance.
  65159. */
  65160. bloomScale: number;
  65161. /**
  65162. * Enable or disable the bloom from the pipeline
  65163. */
  65164. bloomEnabled: boolean;
  65165. private _rebuildBloom;
  65166. /**
  65167. * If the depth of field is enabled.
  65168. */
  65169. depthOfFieldEnabled: boolean;
  65170. /**
  65171. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65172. */
  65173. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  65174. /**
  65175. * If the anti aliasing is enabled.
  65176. */
  65177. fxaaEnabled: boolean;
  65178. private _samples;
  65179. /**
  65180. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65181. */
  65182. samples: number;
  65183. /**
  65184. * If image processing is enabled.
  65185. */
  65186. imageProcessingEnabled: boolean;
  65187. /**
  65188. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65189. */
  65190. glowLayerEnabled: boolean;
  65191. /**
  65192. * Gets the glow layer (or null if not defined)
  65193. */
  65194. readonly glowLayer: Nullable<GlowLayer>;
  65195. /**
  65196. * Enable or disable the chromaticAberration process from the pipeline
  65197. */
  65198. chromaticAberrationEnabled: boolean;
  65199. /**
  65200. * Enable or disable the grain process from the pipeline
  65201. */
  65202. grainEnabled: boolean;
  65203. /**
  65204. * @constructor
  65205. * @param name - The rendering pipeline name (default: "")
  65206. * @param hdr - If high dynamic range textures should be used (default: true)
  65207. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65208. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65209. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65210. */
  65211. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65212. /**
  65213. * Get the class name
  65214. * @returns "DefaultRenderingPipeline"
  65215. */
  65216. getClassName(): string;
  65217. /**
  65218. * Force the compilation of the entire pipeline.
  65219. */
  65220. prepare(): void;
  65221. private _hasCleared;
  65222. private _prevPostProcess;
  65223. private _prevPrevPostProcess;
  65224. private _setAutoClearAndTextureSharing;
  65225. private _depthOfFieldSceneObserver;
  65226. private _buildPipeline;
  65227. private _disposePostProcesses;
  65228. /**
  65229. * Adds a camera to the pipeline
  65230. * @param camera the camera to be added
  65231. */
  65232. addCamera(camera: Camera): void;
  65233. /**
  65234. * Removes a camera from the pipeline
  65235. * @param camera the camera to remove
  65236. */
  65237. removeCamera(camera: Camera): void;
  65238. /**
  65239. * Dispose of the pipeline and stop all post processes
  65240. */
  65241. dispose(): void;
  65242. /**
  65243. * Serialize the rendering pipeline (Used when exporting)
  65244. * @returns the serialized object
  65245. */
  65246. serialize(): any;
  65247. /**
  65248. * Parse the serialized pipeline
  65249. * @param source Source pipeline.
  65250. * @param scene The scene to load the pipeline to.
  65251. * @param rootUrl The URL of the serialized pipeline.
  65252. * @returns An instantiated pipeline from the serialized object.
  65253. */
  65254. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65255. }
  65256. }
  65257. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  65258. /** @hidden */
  65259. export var lensHighlightsPixelShader: {
  65260. name: string;
  65261. shader: string;
  65262. };
  65263. }
  65264. declare module "babylonjs/Shaders/depthOfField.fragment" {
  65265. /** @hidden */
  65266. export var depthOfFieldPixelShader: {
  65267. name: string;
  65268. shader: string;
  65269. };
  65270. }
  65271. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  65272. import { Camera } from "babylonjs/Cameras/camera";
  65273. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65274. import { Scene } from "babylonjs/scene";
  65275. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65276. import "babylonjs/Shaders/chromaticAberration.fragment";
  65277. import "babylonjs/Shaders/lensHighlights.fragment";
  65278. import "babylonjs/Shaders/depthOfField.fragment";
  65279. /**
  65280. * BABYLON.JS Chromatic Aberration GLSL Shader
  65281. * Author: Olivier Guyot
  65282. * Separates very slightly R, G and B colors on the edges of the screen
  65283. * Inspired by Francois Tarlier & Martins Upitis
  65284. */
  65285. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65286. /**
  65287. * @ignore
  65288. * The chromatic aberration PostProcess id in the pipeline
  65289. */
  65290. LensChromaticAberrationEffect: string;
  65291. /**
  65292. * @ignore
  65293. * The highlights enhancing PostProcess id in the pipeline
  65294. */
  65295. HighlightsEnhancingEffect: string;
  65296. /**
  65297. * @ignore
  65298. * The depth-of-field PostProcess id in the pipeline
  65299. */
  65300. LensDepthOfFieldEffect: string;
  65301. private _scene;
  65302. private _depthTexture;
  65303. private _grainTexture;
  65304. private _chromaticAberrationPostProcess;
  65305. private _highlightsPostProcess;
  65306. private _depthOfFieldPostProcess;
  65307. private _edgeBlur;
  65308. private _grainAmount;
  65309. private _chromaticAberration;
  65310. private _distortion;
  65311. private _highlightsGain;
  65312. private _highlightsThreshold;
  65313. private _dofDistance;
  65314. private _dofAperture;
  65315. private _dofDarken;
  65316. private _dofPentagon;
  65317. private _blurNoise;
  65318. /**
  65319. * @constructor
  65320. *
  65321. * Effect parameters are as follow:
  65322. * {
  65323. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65324. * edge_blur: number; // from 0 to x (1 for realism)
  65325. * distortion: number; // from 0 to x (1 for realism)
  65326. * grain_amount: number; // from 0 to 1
  65327. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65328. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65329. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65330. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65331. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65332. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65333. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65334. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65335. * }
  65336. * Note: if an effect parameter is unset, effect is disabled
  65337. *
  65338. * @param name The rendering pipeline name
  65339. * @param parameters - An object containing all parameters (see above)
  65340. * @param scene The scene linked to this pipeline
  65341. * @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)
  65342. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65343. */
  65344. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65345. /**
  65346. * Get the class name
  65347. * @returns "LensRenderingPipeline"
  65348. */
  65349. getClassName(): string;
  65350. /**
  65351. * Gets associated scene
  65352. */
  65353. readonly scene: Scene;
  65354. /**
  65355. * Gets or sets the edge blur
  65356. */
  65357. edgeBlur: number;
  65358. /**
  65359. * Gets or sets the grain amount
  65360. */
  65361. grainAmount: number;
  65362. /**
  65363. * Gets or sets the chromatic aberration amount
  65364. */
  65365. chromaticAberration: number;
  65366. /**
  65367. * Gets or sets the depth of field aperture
  65368. */
  65369. dofAperture: number;
  65370. /**
  65371. * Gets or sets the edge distortion
  65372. */
  65373. edgeDistortion: number;
  65374. /**
  65375. * Gets or sets the depth of field distortion
  65376. */
  65377. dofDistortion: number;
  65378. /**
  65379. * Gets or sets the darken out of focus amount
  65380. */
  65381. darkenOutOfFocus: number;
  65382. /**
  65383. * Gets or sets a boolean indicating if blur noise is enabled
  65384. */
  65385. blurNoise: boolean;
  65386. /**
  65387. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65388. */
  65389. pentagonBokeh: boolean;
  65390. /**
  65391. * Gets or sets the highlight grain amount
  65392. */
  65393. highlightsGain: number;
  65394. /**
  65395. * Gets or sets the highlight threshold
  65396. */
  65397. highlightsThreshold: number;
  65398. /**
  65399. * Sets the amount of blur at the edges
  65400. * @param amount blur amount
  65401. */
  65402. setEdgeBlur(amount: number): void;
  65403. /**
  65404. * Sets edge blur to 0
  65405. */
  65406. disableEdgeBlur(): void;
  65407. /**
  65408. * Sets the amout of grain
  65409. * @param amount Amount of grain
  65410. */
  65411. setGrainAmount(amount: number): void;
  65412. /**
  65413. * Set grain amount to 0
  65414. */
  65415. disableGrain(): void;
  65416. /**
  65417. * Sets the chromatic aberration amount
  65418. * @param amount amount of chromatic aberration
  65419. */
  65420. setChromaticAberration(amount: number): void;
  65421. /**
  65422. * Sets chromatic aberration amount to 0
  65423. */
  65424. disableChromaticAberration(): void;
  65425. /**
  65426. * Sets the EdgeDistortion amount
  65427. * @param amount amount of EdgeDistortion
  65428. */
  65429. setEdgeDistortion(amount: number): void;
  65430. /**
  65431. * Sets edge distortion to 0
  65432. */
  65433. disableEdgeDistortion(): void;
  65434. /**
  65435. * Sets the FocusDistance amount
  65436. * @param amount amount of FocusDistance
  65437. */
  65438. setFocusDistance(amount: number): void;
  65439. /**
  65440. * Disables depth of field
  65441. */
  65442. disableDepthOfField(): void;
  65443. /**
  65444. * Sets the Aperture amount
  65445. * @param amount amount of Aperture
  65446. */
  65447. setAperture(amount: number): void;
  65448. /**
  65449. * Sets the DarkenOutOfFocus amount
  65450. * @param amount amount of DarkenOutOfFocus
  65451. */
  65452. setDarkenOutOfFocus(amount: number): void;
  65453. private _pentagonBokehIsEnabled;
  65454. /**
  65455. * Creates a pentagon bokeh effect
  65456. */
  65457. enablePentagonBokeh(): void;
  65458. /**
  65459. * Disables the pentagon bokeh effect
  65460. */
  65461. disablePentagonBokeh(): void;
  65462. /**
  65463. * Enables noise blur
  65464. */
  65465. enableNoiseBlur(): void;
  65466. /**
  65467. * Disables noise blur
  65468. */
  65469. disableNoiseBlur(): void;
  65470. /**
  65471. * Sets the HighlightsGain amount
  65472. * @param amount amount of HighlightsGain
  65473. */
  65474. setHighlightsGain(amount: number): void;
  65475. /**
  65476. * Sets the HighlightsThreshold amount
  65477. * @param amount amount of HighlightsThreshold
  65478. */
  65479. setHighlightsThreshold(amount: number): void;
  65480. /**
  65481. * Disables highlights
  65482. */
  65483. disableHighlights(): void;
  65484. /**
  65485. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65486. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65487. */
  65488. dispose(disableDepthRender?: boolean): void;
  65489. private _createChromaticAberrationPostProcess;
  65490. private _createHighlightsPostProcess;
  65491. private _createDepthOfFieldPostProcess;
  65492. private _createGrainTexture;
  65493. }
  65494. }
  65495. declare module "babylonjs/Shaders/ssao2.fragment" {
  65496. /** @hidden */
  65497. export var ssao2PixelShader: {
  65498. name: string;
  65499. shader: string;
  65500. };
  65501. }
  65502. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65503. /** @hidden */
  65504. export var ssaoCombinePixelShader: {
  65505. name: string;
  65506. shader: string;
  65507. };
  65508. }
  65509. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65510. import { Camera } from "babylonjs/Cameras/camera";
  65511. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65512. import { Scene } from "babylonjs/scene";
  65513. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65514. import "babylonjs/Shaders/ssao2.fragment";
  65515. import "babylonjs/Shaders/ssaoCombine.fragment";
  65516. /**
  65517. * Render pipeline to produce ssao effect
  65518. */
  65519. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65520. /**
  65521. * @ignore
  65522. * The PassPostProcess id in the pipeline that contains the original scene color
  65523. */
  65524. SSAOOriginalSceneColorEffect: string;
  65525. /**
  65526. * @ignore
  65527. * The SSAO PostProcess id in the pipeline
  65528. */
  65529. SSAORenderEffect: string;
  65530. /**
  65531. * @ignore
  65532. * The horizontal blur PostProcess id in the pipeline
  65533. */
  65534. SSAOBlurHRenderEffect: string;
  65535. /**
  65536. * @ignore
  65537. * The vertical blur PostProcess id in the pipeline
  65538. */
  65539. SSAOBlurVRenderEffect: string;
  65540. /**
  65541. * @ignore
  65542. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65543. */
  65544. SSAOCombineRenderEffect: string;
  65545. /**
  65546. * The output strength of the SSAO post-process. Default value is 1.0.
  65547. */
  65548. totalStrength: number;
  65549. /**
  65550. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65551. */
  65552. maxZ: number;
  65553. /**
  65554. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65555. */
  65556. minZAspect: number;
  65557. private _samples;
  65558. /**
  65559. * Number of samples used for the SSAO calculations. Default value is 8
  65560. */
  65561. samples: number;
  65562. private _textureSamples;
  65563. /**
  65564. * Number of samples to use for antialiasing
  65565. */
  65566. textureSamples: number;
  65567. /**
  65568. * Ratio object used for SSAO ratio and blur ratio
  65569. */
  65570. private _ratio;
  65571. /**
  65572. * Dynamically generated sphere sampler.
  65573. */
  65574. private _sampleSphere;
  65575. /**
  65576. * Blur filter offsets
  65577. */
  65578. private _samplerOffsets;
  65579. private _expensiveBlur;
  65580. /**
  65581. * If bilateral blur should be used
  65582. */
  65583. expensiveBlur: boolean;
  65584. /**
  65585. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65586. */
  65587. radius: number;
  65588. /**
  65589. * The base color of the SSAO post-process
  65590. * The final result is "base + ssao" between [0, 1]
  65591. */
  65592. base: number;
  65593. /**
  65594. * Support test.
  65595. */
  65596. static readonly IsSupported: boolean;
  65597. private _scene;
  65598. private _depthTexture;
  65599. private _normalTexture;
  65600. private _randomTexture;
  65601. private _originalColorPostProcess;
  65602. private _ssaoPostProcess;
  65603. private _blurHPostProcess;
  65604. private _blurVPostProcess;
  65605. private _ssaoCombinePostProcess;
  65606. /**
  65607. * Gets active scene
  65608. */
  65609. readonly scene: Scene;
  65610. /**
  65611. * @constructor
  65612. * @param name The rendering pipeline name
  65613. * @param scene The scene linked to this pipeline
  65614. * @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 }
  65615. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65616. */
  65617. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65618. /**
  65619. * Get the class name
  65620. * @returns "SSAO2RenderingPipeline"
  65621. */
  65622. getClassName(): string;
  65623. /**
  65624. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65625. */
  65626. dispose(disableGeometryBufferRenderer?: boolean): void;
  65627. private _createBlurPostProcess;
  65628. /** @hidden */
  65629. _rebuild(): void;
  65630. private _bits;
  65631. private _radicalInverse_VdC;
  65632. private _hammersley;
  65633. private _hemisphereSample_uniform;
  65634. private _generateHemisphere;
  65635. private _createSSAOPostProcess;
  65636. private _createSSAOCombinePostProcess;
  65637. private _createRandomTexture;
  65638. /**
  65639. * Serialize the rendering pipeline (Used when exporting)
  65640. * @returns the serialized object
  65641. */
  65642. serialize(): any;
  65643. /**
  65644. * Parse the serialized pipeline
  65645. * @param source Source pipeline.
  65646. * @param scene The scene to load the pipeline to.
  65647. * @param rootUrl The URL of the serialized pipeline.
  65648. * @returns An instantiated pipeline from the serialized object.
  65649. */
  65650. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65651. }
  65652. }
  65653. declare module "babylonjs/Shaders/ssao.fragment" {
  65654. /** @hidden */
  65655. export var ssaoPixelShader: {
  65656. name: string;
  65657. shader: string;
  65658. };
  65659. }
  65660. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65661. import { Camera } from "babylonjs/Cameras/camera";
  65662. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65663. import { Scene } from "babylonjs/scene";
  65664. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65665. import "babylonjs/Shaders/ssao.fragment";
  65666. import "babylonjs/Shaders/ssaoCombine.fragment";
  65667. /**
  65668. * Render pipeline to produce ssao effect
  65669. */
  65670. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65671. /**
  65672. * @ignore
  65673. * The PassPostProcess id in the pipeline that contains the original scene color
  65674. */
  65675. SSAOOriginalSceneColorEffect: string;
  65676. /**
  65677. * @ignore
  65678. * The SSAO PostProcess id in the pipeline
  65679. */
  65680. SSAORenderEffect: string;
  65681. /**
  65682. * @ignore
  65683. * The horizontal blur PostProcess id in the pipeline
  65684. */
  65685. SSAOBlurHRenderEffect: string;
  65686. /**
  65687. * @ignore
  65688. * The vertical blur PostProcess id in the pipeline
  65689. */
  65690. SSAOBlurVRenderEffect: string;
  65691. /**
  65692. * @ignore
  65693. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65694. */
  65695. SSAOCombineRenderEffect: string;
  65696. /**
  65697. * The output strength of the SSAO post-process. Default value is 1.0.
  65698. */
  65699. totalStrength: number;
  65700. /**
  65701. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65702. */
  65703. radius: number;
  65704. /**
  65705. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65706. * Must not be equal to fallOff and superior to fallOff.
  65707. * Default value is 0.0075
  65708. */
  65709. area: number;
  65710. /**
  65711. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65712. * Must not be equal to area and inferior to area.
  65713. * Default value is 0.000001
  65714. */
  65715. fallOff: number;
  65716. /**
  65717. * The base color of the SSAO post-process
  65718. * The final result is "base + ssao" between [0, 1]
  65719. */
  65720. base: number;
  65721. private _scene;
  65722. private _depthTexture;
  65723. private _randomTexture;
  65724. private _originalColorPostProcess;
  65725. private _ssaoPostProcess;
  65726. private _blurHPostProcess;
  65727. private _blurVPostProcess;
  65728. private _ssaoCombinePostProcess;
  65729. private _firstUpdate;
  65730. /**
  65731. * Gets active scene
  65732. */
  65733. readonly scene: Scene;
  65734. /**
  65735. * @constructor
  65736. * @param name - The rendering pipeline name
  65737. * @param scene - The scene linked to this pipeline
  65738. * @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 }
  65739. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65740. */
  65741. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65742. /**
  65743. * Get the class name
  65744. * @returns "SSAORenderingPipeline"
  65745. */
  65746. getClassName(): string;
  65747. /**
  65748. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65749. */
  65750. dispose(disableDepthRender?: boolean): void;
  65751. private _createBlurPostProcess;
  65752. /** @hidden */
  65753. _rebuild(): void;
  65754. private _createSSAOPostProcess;
  65755. private _createSSAOCombinePostProcess;
  65756. private _createRandomTexture;
  65757. }
  65758. }
  65759. declare module "babylonjs/Shaders/standard.fragment" {
  65760. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65761. /** @hidden */
  65762. export var standardPixelShader: {
  65763. name: string;
  65764. shader: string;
  65765. };
  65766. }
  65767. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65768. import { Nullable } from "babylonjs/types";
  65769. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65770. import { Camera } from "babylonjs/Cameras/camera";
  65771. import { Texture } from "babylonjs/Materials/Textures/texture";
  65772. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65773. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65774. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65775. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65776. import { IDisposable } from "babylonjs/scene";
  65777. import { SpotLight } from "babylonjs/Lights/spotLight";
  65778. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65779. import { Scene } from "babylonjs/scene";
  65780. import { Animation } from "babylonjs/Animations/animation";
  65781. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65782. import "babylonjs/Shaders/standard.fragment";
  65783. /**
  65784. * Standard rendering pipeline
  65785. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65786. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65787. */
  65788. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65789. /**
  65790. * Public members
  65791. */
  65792. /**
  65793. * Post-process which contains the original scene color before the pipeline applies all the effects
  65794. */
  65795. originalPostProcess: Nullable<PostProcess>;
  65796. /**
  65797. * Post-process used to down scale an image x4
  65798. */
  65799. downSampleX4PostProcess: Nullable<PostProcess>;
  65800. /**
  65801. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65802. */
  65803. brightPassPostProcess: Nullable<PostProcess>;
  65804. /**
  65805. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65806. */
  65807. blurHPostProcesses: PostProcess[];
  65808. /**
  65809. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65810. */
  65811. blurVPostProcesses: PostProcess[];
  65812. /**
  65813. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65814. */
  65815. textureAdderPostProcess: Nullable<PostProcess>;
  65816. /**
  65817. * Post-process used to create volumetric lighting effect
  65818. */
  65819. volumetricLightPostProcess: Nullable<PostProcess>;
  65820. /**
  65821. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65822. */
  65823. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65824. /**
  65825. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65826. */
  65827. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65828. /**
  65829. * Post-process used to merge the volumetric light effect and the real scene color
  65830. */
  65831. volumetricLightMergePostProces: Nullable<PostProcess>;
  65832. /**
  65833. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65834. */
  65835. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65836. /**
  65837. * Base post-process used to calculate the average luminance of the final image for HDR
  65838. */
  65839. luminancePostProcess: Nullable<PostProcess>;
  65840. /**
  65841. * Post-processes used to create down sample post-processes in order to get
  65842. * the average luminance of the final image for HDR
  65843. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65844. */
  65845. luminanceDownSamplePostProcesses: PostProcess[];
  65846. /**
  65847. * Post-process used to create a HDR effect (light adaptation)
  65848. */
  65849. hdrPostProcess: Nullable<PostProcess>;
  65850. /**
  65851. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65852. */
  65853. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65854. /**
  65855. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65856. */
  65857. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65858. /**
  65859. * Post-process used to merge the final HDR post-process and the real scene color
  65860. */
  65861. hdrFinalPostProcess: Nullable<PostProcess>;
  65862. /**
  65863. * Post-process used to create a lens flare effect
  65864. */
  65865. lensFlarePostProcess: Nullable<PostProcess>;
  65866. /**
  65867. * Post-process that merges the result of the lens flare post-process and the real scene color
  65868. */
  65869. lensFlareComposePostProcess: Nullable<PostProcess>;
  65870. /**
  65871. * Post-process used to create a motion blur effect
  65872. */
  65873. motionBlurPostProcess: Nullable<PostProcess>;
  65874. /**
  65875. * Post-process used to create a depth of field effect
  65876. */
  65877. depthOfFieldPostProcess: Nullable<PostProcess>;
  65878. /**
  65879. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65880. */
  65881. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65882. /**
  65883. * Represents the brightness threshold in order to configure the illuminated surfaces
  65884. */
  65885. brightThreshold: number;
  65886. /**
  65887. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65888. */
  65889. blurWidth: number;
  65890. /**
  65891. * Sets if the blur for highlighted surfaces must be only horizontal
  65892. */
  65893. horizontalBlur: boolean;
  65894. /**
  65895. * Gets the overall exposure used by the pipeline
  65896. */
  65897. /**
  65898. * Sets the overall exposure used by the pipeline
  65899. */
  65900. exposure: number;
  65901. /**
  65902. * Texture used typically to simulate "dirty" on camera lens
  65903. */
  65904. lensTexture: Nullable<Texture>;
  65905. /**
  65906. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65907. */
  65908. volumetricLightCoefficient: number;
  65909. /**
  65910. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65911. */
  65912. volumetricLightPower: number;
  65913. /**
  65914. * Used the set the blur intensity to smooth the volumetric lights
  65915. */
  65916. volumetricLightBlurScale: number;
  65917. /**
  65918. * Light (spot or directional) used to generate the volumetric lights rays
  65919. * The source light must have a shadow generate so the pipeline can get its
  65920. * depth map
  65921. */
  65922. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65923. /**
  65924. * For eye adaptation, represents the minimum luminance the eye can see
  65925. */
  65926. hdrMinimumLuminance: number;
  65927. /**
  65928. * For eye adaptation, represents the decrease luminance speed
  65929. */
  65930. hdrDecreaseRate: number;
  65931. /**
  65932. * For eye adaptation, represents the increase luminance speed
  65933. */
  65934. hdrIncreaseRate: number;
  65935. /**
  65936. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65937. */
  65938. /**
  65939. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65940. */
  65941. hdrAutoExposure: boolean;
  65942. /**
  65943. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65944. */
  65945. lensColorTexture: Nullable<Texture>;
  65946. /**
  65947. * The overall strengh for the lens flare effect
  65948. */
  65949. lensFlareStrength: number;
  65950. /**
  65951. * Dispersion coefficient for lens flare ghosts
  65952. */
  65953. lensFlareGhostDispersal: number;
  65954. /**
  65955. * Main lens flare halo width
  65956. */
  65957. lensFlareHaloWidth: number;
  65958. /**
  65959. * Based on the lens distortion effect, defines how much the lens flare result
  65960. * is distorted
  65961. */
  65962. lensFlareDistortionStrength: number;
  65963. /**
  65964. * Configures the blur intensity used for for lens flare (halo)
  65965. */
  65966. lensFlareBlurWidth: number;
  65967. /**
  65968. * Lens star texture must be used to simulate rays on the flares and is available
  65969. * in the documentation
  65970. */
  65971. lensStarTexture: Nullable<Texture>;
  65972. /**
  65973. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65974. * flare effect by taking account of the dirt texture
  65975. */
  65976. lensFlareDirtTexture: Nullable<Texture>;
  65977. /**
  65978. * Represents the focal length for the depth of field effect
  65979. */
  65980. depthOfFieldDistance: number;
  65981. /**
  65982. * Represents the blur intensity for the blurred part of the depth of field effect
  65983. */
  65984. depthOfFieldBlurWidth: number;
  65985. /**
  65986. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65987. */
  65988. /**
  65989. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65990. */
  65991. motionStrength: number;
  65992. /**
  65993. * Gets wether or not the motion blur post-process is object based or screen based.
  65994. */
  65995. /**
  65996. * Sets wether or not the motion blur post-process should be object based or screen based
  65997. */
  65998. objectBasedMotionBlur: boolean;
  65999. /**
  66000. * List of animations for the pipeline (IAnimatable implementation)
  66001. */
  66002. animations: Animation[];
  66003. /**
  66004. * Private members
  66005. */
  66006. private _scene;
  66007. private _currentDepthOfFieldSource;
  66008. private _basePostProcess;
  66009. private _fixedExposure;
  66010. private _currentExposure;
  66011. private _hdrAutoExposure;
  66012. private _hdrCurrentLuminance;
  66013. private _motionStrength;
  66014. private _isObjectBasedMotionBlur;
  66015. private _floatTextureType;
  66016. private _camerasToBeAttached;
  66017. private _ratio;
  66018. private _bloomEnabled;
  66019. private _depthOfFieldEnabled;
  66020. private _vlsEnabled;
  66021. private _lensFlareEnabled;
  66022. private _hdrEnabled;
  66023. private _motionBlurEnabled;
  66024. private _fxaaEnabled;
  66025. private _motionBlurSamples;
  66026. private _volumetricLightStepsCount;
  66027. private _samples;
  66028. /**
  66029. * @ignore
  66030. * Specifies if the bloom pipeline is enabled
  66031. */
  66032. BloomEnabled: boolean;
  66033. /**
  66034. * @ignore
  66035. * Specifies if the depth of field pipeline is enabed
  66036. */
  66037. DepthOfFieldEnabled: boolean;
  66038. /**
  66039. * @ignore
  66040. * Specifies if the lens flare pipeline is enabed
  66041. */
  66042. LensFlareEnabled: boolean;
  66043. /**
  66044. * @ignore
  66045. * Specifies if the HDR pipeline is enabled
  66046. */
  66047. HDREnabled: boolean;
  66048. /**
  66049. * @ignore
  66050. * Specifies if the volumetric lights scattering effect is enabled
  66051. */
  66052. VLSEnabled: boolean;
  66053. /**
  66054. * @ignore
  66055. * Specifies if the motion blur effect is enabled
  66056. */
  66057. MotionBlurEnabled: boolean;
  66058. /**
  66059. * Specifies if anti-aliasing is enabled
  66060. */
  66061. fxaaEnabled: boolean;
  66062. /**
  66063. * Specifies the number of steps used to calculate the volumetric lights
  66064. * Typically in interval [50, 200]
  66065. */
  66066. volumetricLightStepsCount: number;
  66067. /**
  66068. * Specifies the number of samples used for the motion blur effect
  66069. * Typically in interval [16, 64]
  66070. */
  66071. motionBlurSamples: number;
  66072. /**
  66073. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66074. */
  66075. samples: number;
  66076. /**
  66077. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66078. * @constructor
  66079. * @param name The rendering pipeline name
  66080. * @param scene The scene linked to this pipeline
  66081. * @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)
  66082. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66083. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66084. */
  66085. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66086. private _buildPipeline;
  66087. private _createDownSampleX4PostProcess;
  66088. private _createBrightPassPostProcess;
  66089. private _createBlurPostProcesses;
  66090. private _createTextureAdderPostProcess;
  66091. private _createVolumetricLightPostProcess;
  66092. private _createLuminancePostProcesses;
  66093. private _createHdrPostProcess;
  66094. private _createLensFlarePostProcess;
  66095. private _createDepthOfFieldPostProcess;
  66096. private _createMotionBlurPostProcess;
  66097. private _getDepthTexture;
  66098. private _disposePostProcesses;
  66099. /**
  66100. * Dispose of the pipeline and stop all post processes
  66101. */
  66102. dispose(): void;
  66103. /**
  66104. * Serialize the rendering pipeline (Used when exporting)
  66105. * @returns the serialized object
  66106. */
  66107. serialize(): any;
  66108. /**
  66109. * Parse the serialized pipeline
  66110. * @param source Source pipeline.
  66111. * @param scene The scene to load the pipeline to.
  66112. * @param rootUrl The URL of the serialized pipeline.
  66113. * @returns An instantiated pipeline from the serialized object.
  66114. */
  66115. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66116. /**
  66117. * Luminance steps
  66118. */
  66119. static LuminanceSteps: number;
  66120. }
  66121. }
  66122. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  66123. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  66124. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  66125. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  66126. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  66127. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  66128. }
  66129. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  66130. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  66131. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66132. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66133. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66134. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66135. }
  66136. declare module "babylonjs/Shaders/tonemap.fragment" {
  66137. /** @hidden */
  66138. export var tonemapPixelShader: {
  66139. name: string;
  66140. shader: string;
  66141. };
  66142. }
  66143. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  66144. import { Camera } from "babylonjs/Cameras/camera";
  66145. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66146. import "babylonjs/Shaders/tonemap.fragment";
  66147. import { Engine } from "babylonjs/Engines/engine";
  66148. /** Defines operator used for tonemapping */
  66149. export enum TonemappingOperator {
  66150. /** Hable */
  66151. Hable = 0,
  66152. /** Reinhard */
  66153. Reinhard = 1,
  66154. /** HejiDawson */
  66155. HejiDawson = 2,
  66156. /** Photographic */
  66157. Photographic = 3
  66158. }
  66159. /**
  66160. * Defines a post process to apply tone mapping
  66161. */
  66162. export class TonemapPostProcess extends PostProcess {
  66163. private _operator;
  66164. /** Defines the required exposure adjustement */
  66165. exposureAdjustment: number;
  66166. /**
  66167. * Creates a new TonemapPostProcess
  66168. * @param name defines the name of the postprocess
  66169. * @param _operator defines the operator to use
  66170. * @param exposureAdjustment defines the required exposure adjustement
  66171. * @param camera defines the camera to use (can be null)
  66172. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66173. * @param engine defines the hosting engine (can be ignore if camera is set)
  66174. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66175. */
  66176. constructor(name: string, _operator: TonemappingOperator,
  66177. /** Defines the required exposure adjustement */
  66178. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66179. }
  66180. }
  66181. declare module "babylonjs/Shaders/depth.vertex" {
  66182. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66183. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66184. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66185. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66186. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66187. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66188. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66189. /** @hidden */
  66190. export var depthVertexShader: {
  66191. name: string;
  66192. shader: string;
  66193. };
  66194. }
  66195. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  66196. /** @hidden */
  66197. export var volumetricLightScatteringPixelShader: {
  66198. name: string;
  66199. shader: string;
  66200. };
  66201. }
  66202. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  66203. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66204. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66205. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66206. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66207. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66208. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66209. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66210. /** @hidden */
  66211. export var volumetricLightScatteringPassVertexShader: {
  66212. name: string;
  66213. shader: string;
  66214. };
  66215. }
  66216. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  66217. /** @hidden */
  66218. export var volumetricLightScatteringPassPixelShader: {
  66219. name: string;
  66220. shader: string;
  66221. };
  66222. }
  66223. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  66224. import { Vector3 } from "babylonjs/Maths/math.vector";
  66225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66226. import { Mesh } from "babylonjs/Meshes/mesh";
  66227. import { Camera } from "babylonjs/Cameras/camera";
  66228. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66229. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66230. import { Scene } from "babylonjs/scene";
  66231. import "babylonjs/Meshes/Builders/planeBuilder";
  66232. import "babylonjs/Shaders/depth.vertex";
  66233. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  66234. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  66235. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  66236. import { Engine } from "babylonjs/Engines/engine";
  66237. /**
  66238. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66239. */
  66240. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66241. private _volumetricLightScatteringPass;
  66242. private _volumetricLightScatteringRTT;
  66243. private _viewPort;
  66244. private _screenCoordinates;
  66245. private _cachedDefines;
  66246. /**
  66247. * If not undefined, the mesh position is computed from the attached node position
  66248. */
  66249. attachedNode: {
  66250. position: Vector3;
  66251. };
  66252. /**
  66253. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66254. */
  66255. customMeshPosition: Vector3;
  66256. /**
  66257. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66258. */
  66259. useCustomMeshPosition: boolean;
  66260. /**
  66261. * If the post-process should inverse the light scattering direction
  66262. */
  66263. invert: boolean;
  66264. /**
  66265. * The internal mesh used by the post-process
  66266. */
  66267. mesh: Mesh;
  66268. /**
  66269. * @hidden
  66270. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66271. */
  66272. useDiffuseColor: boolean;
  66273. /**
  66274. * Array containing the excluded meshes not rendered in the internal pass
  66275. */
  66276. excludedMeshes: AbstractMesh[];
  66277. /**
  66278. * Controls the overall intensity of the post-process
  66279. */
  66280. exposure: number;
  66281. /**
  66282. * Dissipates each sample's contribution in range [0, 1]
  66283. */
  66284. decay: number;
  66285. /**
  66286. * Controls the overall intensity of each sample
  66287. */
  66288. weight: number;
  66289. /**
  66290. * Controls the density of each sample
  66291. */
  66292. density: number;
  66293. /**
  66294. * @constructor
  66295. * @param name The post-process name
  66296. * @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)
  66297. * @param camera The camera that the post-process will be attached to
  66298. * @param mesh The mesh used to create the light scattering
  66299. * @param samples The post-process quality, default 100
  66300. * @param samplingModeThe post-process filtering mode
  66301. * @param engine The babylon engine
  66302. * @param reusable If the post-process is reusable
  66303. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66304. */
  66305. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66306. /**
  66307. * Returns the string "VolumetricLightScatteringPostProcess"
  66308. * @returns "VolumetricLightScatteringPostProcess"
  66309. */
  66310. getClassName(): string;
  66311. private _isReady;
  66312. /**
  66313. * Sets the new light position for light scattering effect
  66314. * @param position The new custom light position
  66315. */
  66316. setCustomMeshPosition(position: Vector3): void;
  66317. /**
  66318. * Returns the light position for light scattering effect
  66319. * @return Vector3 The custom light position
  66320. */
  66321. getCustomMeshPosition(): Vector3;
  66322. /**
  66323. * Disposes the internal assets and detaches the post-process from the camera
  66324. */
  66325. dispose(camera: Camera): void;
  66326. /**
  66327. * Returns the render target texture used by the post-process
  66328. * @return the render target texture used by the post-process
  66329. */
  66330. getPass(): RenderTargetTexture;
  66331. private _meshExcluded;
  66332. private _createPass;
  66333. private _updateMeshScreenCoordinates;
  66334. /**
  66335. * Creates a default mesh for the Volumeric Light Scattering post-process
  66336. * @param name The mesh name
  66337. * @param scene The scene where to create the mesh
  66338. * @return the default mesh
  66339. */
  66340. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66341. }
  66342. }
  66343. declare module "babylonjs/PostProcesses/index" {
  66344. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  66345. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  66346. export * from "babylonjs/PostProcesses/bloomEffect";
  66347. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  66348. export * from "babylonjs/PostProcesses/blurPostProcess";
  66349. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66350. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66351. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66352. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66353. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66354. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66355. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66356. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66357. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66358. export * from "babylonjs/PostProcesses/filterPostProcess";
  66359. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66360. export * from "babylonjs/PostProcesses/grainPostProcess";
  66361. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66362. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66363. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66364. export * from "babylonjs/PostProcesses/passPostProcess";
  66365. export * from "babylonjs/PostProcesses/postProcess";
  66366. export * from "babylonjs/PostProcesses/postProcessManager";
  66367. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66368. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66369. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66370. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66371. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66372. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66373. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66374. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66375. }
  66376. declare module "babylonjs/Probes/index" {
  66377. export * from "babylonjs/Probes/reflectionProbe";
  66378. }
  66379. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66380. import { Scene } from "babylonjs/scene";
  66381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66382. import { SmartArray } from "babylonjs/Misc/smartArray";
  66383. import { ISceneComponent } from "babylonjs/sceneComponent";
  66384. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66385. import "babylonjs/Meshes/Builders/boxBuilder";
  66386. import "babylonjs/Shaders/color.fragment";
  66387. import "babylonjs/Shaders/color.vertex";
  66388. import { Color3 } from "babylonjs/Maths/math.color";
  66389. module "babylonjs/scene" {
  66390. interface Scene {
  66391. /** @hidden (Backing field) */
  66392. _boundingBoxRenderer: BoundingBoxRenderer;
  66393. /** @hidden (Backing field) */
  66394. _forceShowBoundingBoxes: boolean;
  66395. /**
  66396. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66397. */
  66398. forceShowBoundingBoxes: boolean;
  66399. /**
  66400. * Gets the bounding box renderer associated with the scene
  66401. * @returns a BoundingBoxRenderer
  66402. */
  66403. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66404. }
  66405. }
  66406. module "babylonjs/Meshes/abstractMesh" {
  66407. interface AbstractMesh {
  66408. /** @hidden (Backing field) */
  66409. _showBoundingBox: boolean;
  66410. /**
  66411. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66412. */
  66413. showBoundingBox: boolean;
  66414. }
  66415. }
  66416. /**
  66417. * Component responsible of rendering the bounding box of the meshes in a scene.
  66418. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66419. */
  66420. export class BoundingBoxRenderer implements ISceneComponent {
  66421. /**
  66422. * The component name helpfull to identify the component in the list of scene components.
  66423. */
  66424. readonly name: string;
  66425. /**
  66426. * The scene the component belongs to.
  66427. */
  66428. scene: Scene;
  66429. /**
  66430. * Color of the bounding box lines placed in front of an object
  66431. */
  66432. frontColor: Color3;
  66433. /**
  66434. * Color of the bounding box lines placed behind an object
  66435. */
  66436. backColor: Color3;
  66437. /**
  66438. * Defines if the renderer should show the back lines or not
  66439. */
  66440. showBackLines: boolean;
  66441. /**
  66442. * @hidden
  66443. */
  66444. renderList: SmartArray<BoundingBox>;
  66445. private _colorShader;
  66446. private _vertexBuffers;
  66447. private _indexBuffer;
  66448. private _fillIndexBuffer;
  66449. private _fillIndexData;
  66450. /**
  66451. * Instantiates a new bounding box renderer in a scene.
  66452. * @param scene the scene the renderer renders in
  66453. */
  66454. constructor(scene: Scene);
  66455. /**
  66456. * Registers the component in a given scene
  66457. */
  66458. register(): void;
  66459. private _evaluateSubMesh;
  66460. private _activeMesh;
  66461. private _prepareRessources;
  66462. private _createIndexBuffer;
  66463. /**
  66464. * Rebuilds the elements related to this component in case of
  66465. * context lost for instance.
  66466. */
  66467. rebuild(): void;
  66468. /**
  66469. * @hidden
  66470. */
  66471. reset(): void;
  66472. /**
  66473. * Render the bounding boxes of a specific rendering group
  66474. * @param renderingGroupId defines the rendering group to render
  66475. */
  66476. render(renderingGroupId: number): void;
  66477. /**
  66478. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66479. * @param mesh Define the mesh to render the occlusion bounding box for
  66480. */
  66481. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66482. /**
  66483. * Dispose and release the resources attached to this renderer.
  66484. */
  66485. dispose(): void;
  66486. }
  66487. }
  66488. declare module "babylonjs/Shaders/depth.fragment" {
  66489. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66490. /** @hidden */
  66491. export var depthPixelShader: {
  66492. name: string;
  66493. shader: string;
  66494. };
  66495. }
  66496. declare module "babylonjs/Rendering/depthRenderer" {
  66497. import { Nullable } from "babylonjs/types";
  66498. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66499. import { Scene } from "babylonjs/scene";
  66500. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66501. import { Camera } from "babylonjs/Cameras/camera";
  66502. import "babylonjs/Shaders/depth.fragment";
  66503. import "babylonjs/Shaders/depth.vertex";
  66504. /**
  66505. * This represents a depth renderer in Babylon.
  66506. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66507. */
  66508. export class DepthRenderer {
  66509. private _scene;
  66510. private _depthMap;
  66511. private _effect;
  66512. private readonly _storeNonLinearDepth;
  66513. private readonly _clearColor;
  66514. /** Get if the depth renderer is using packed depth or not */
  66515. readonly isPacked: boolean;
  66516. private _cachedDefines;
  66517. private _camera;
  66518. /**
  66519. * Specifiess that the depth renderer will only be used within
  66520. * the camera it is created for.
  66521. * This can help forcing its rendering during the camera processing.
  66522. */
  66523. useOnlyInActiveCamera: boolean;
  66524. /** @hidden */
  66525. static _SceneComponentInitialization: (scene: Scene) => void;
  66526. /**
  66527. * Instantiates a depth renderer
  66528. * @param scene The scene the renderer belongs to
  66529. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66530. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66531. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66532. */
  66533. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66534. /**
  66535. * Creates the depth rendering effect and checks if the effect is ready.
  66536. * @param subMesh The submesh to be used to render the depth map of
  66537. * @param useInstances If multiple world instances should be used
  66538. * @returns if the depth renderer is ready to render the depth map
  66539. */
  66540. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66541. /**
  66542. * Gets the texture which the depth map will be written to.
  66543. * @returns The depth map texture
  66544. */
  66545. getDepthMap(): RenderTargetTexture;
  66546. /**
  66547. * Disposes of the depth renderer.
  66548. */
  66549. dispose(): void;
  66550. }
  66551. }
  66552. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66553. import { Nullable } from "babylonjs/types";
  66554. import { Scene } from "babylonjs/scene";
  66555. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66556. import { Camera } from "babylonjs/Cameras/camera";
  66557. import { ISceneComponent } from "babylonjs/sceneComponent";
  66558. module "babylonjs/scene" {
  66559. interface Scene {
  66560. /** @hidden (Backing field) */
  66561. _depthRenderer: {
  66562. [id: string]: DepthRenderer;
  66563. };
  66564. /**
  66565. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66566. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66567. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66568. * @returns the created depth renderer
  66569. */
  66570. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66571. /**
  66572. * Disables a depth renderer for a given camera
  66573. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66574. */
  66575. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66576. }
  66577. }
  66578. /**
  66579. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66580. * in several rendering techniques.
  66581. */
  66582. export class DepthRendererSceneComponent implements ISceneComponent {
  66583. /**
  66584. * The component name helpfull to identify the component in the list of scene components.
  66585. */
  66586. readonly name: string;
  66587. /**
  66588. * The scene the component belongs to.
  66589. */
  66590. scene: Scene;
  66591. /**
  66592. * Creates a new instance of the component for the given scene
  66593. * @param scene Defines the scene to register the component in
  66594. */
  66595. constructor(scene: Scene);
  66596. /**
  66597. * Registers the component in a given scene
  66598. */
  66599. register(): void;
  66600. /**
  66601. * Rebuilds the elements related to this component in case of
  66602. * context lost for instance.
  66603. */
  66604. rebuild(): void;
  66605. /**
  66606. * Disposes the component and the associated ressources
  66607. */
  66608. dispose(): void;
  66609. private _gatherRenderTargets;
  66610. private _gatherActiveCameraRenderTargets;
  66611. }
  66612. }
  66613. declare module "babylonjs/Shaders/outline.fragment" {
  66614. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66615. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66616. /** @hidden */
  66617. export var outlinePixelShader: {
  66618. name: string;
  66619. shader: string;
  66620. };
  66621. }
  66622. declare module "babylonjs/Shaders/outline.vertex" {
  66623. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66624. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66625. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66626. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66627. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66629. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66630. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66631. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66632. /** @hidden */
  66633. export var outlineVertexShader: {
  66634. name: string;
  66635. shader: string;
  66636. };
  66637. }
  66638. declare module "babylonjs/Rendering/outlineRenderer" {
  66639. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66640. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66641. import { Scene } from "babylonjs/scene";
  66642. import { ISceneComponent } from "babylonjs/sceneComponent";
  66643. import "babylonjs/Shaders/outline.fragment";
  66644. import "babylonjs/Shaders/outline.vertex";
  66645. module "babylonjs/scene" {
  66646. interface Scene {
  66647. /** @hidden */
  66648. _outlineRenderer: OutlineRenderer;
  66649. /**
  66650. * Gets the outline renderer associated with the scene
  66651. * @returns a OutlineRenderer
  66652. */
  66653. getOutlineRenderer(): OutlineRenderer;
  66654. }
  66655. }
  66656. module "babylonjs/Meshes/abstractMesh" {
  66657. interface AbstractMesh {
  66658. /** @hidden (Backing field) */
  66659. _renderOutline: boolean;
  66660. /**
  66661. * Gets or sets a boolean indicating if the outline must be rendered as well
  66662. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66663. */
  66664. renderOutline: boolean;
  66665. /** @hidden (Backing field) */
  66666. _renderOverlay: boolean;
  66667. /**
  66668. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66669. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66670. */
  66671. renderOverlay: boolean;
  66672. }
  66673. }
  66674. /**
  66675. * This class is responsible to draw bothe outline/overlay of meshes.
  66676. * It should not be used directly but through the available method on mesh.
  66677. */
  66678. export class OutlineRenderer implements ISceneComponent {
  66679. /**
  66680. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66681. */
  66682. private static _StencilReference;
  66683. /**
  66684. * The name of the component. Each component must have a unique name.
  66685. */
  66686. name: string;
  66687. /**
  66688. * The scene the component belongs to.
  66689. */
  66690. scene: Scene;
  66691. /**
  66692. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66693. */
  66694. zOffset: number;
  66695. private _engine;
  66696. private _effect;
  66697. private _cachedDefines;
  66698. private _savedDepthWrite;
  66699. /**
  66700. * Instantiates a new outline renderer. (There could be only one per scene).
  66701. * @param scene Defines the scene it belongs to
  66702. */
  66703. constructor(scene: Scene);
  66704. /**
  66705. * Register the component to one instance of a scene.
  66706. */
  66707. register(): void;
  66708. /**
  66709. * Rebuilds the elements related to this component in case of
  66710. * context lost for instance.
  66711. */
  66712. rebuild(): void;
  66713. /**
  66714. * Disposes the component and the associated ressources.
  66715. */
  66716. dispose(): void;
  66717. /**
  66718. * Renders the outline in the canvas.
  66719. * @param subMesh Defines the sumesh to render
  66720. * @param batch Defines the batch of meshes in case of instances
  66721. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66722. */
  66723. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66724. /**
  66725. * Returns whether or not the outline renderer is ready for a given submesh.
  66726. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66727. * @param subMesh Defines the submesh to check readyness for
  66728. * @param useInstances Defines wheter wee are trying to render instances or not
  66729. * @returns true if ready otherwise false
  66730. */
  66731. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66732. private _beforeRenderingMesh;
  66733. private _afterRenderingMesh;
  66734. }
  66735. }
  66736. declare module "babylonjs/Rendering/index" {
  66737. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66738. export * from "babylonjs/Rendering/depthRenderer";
  66739. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66740. export * from "babylonjs/Rendering/edgesRenderer";
  66741. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66742. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66743. export * from "babylonjs/Rendering/outlineRenderer";
  66744. export * from "babylonjs/Rendering/renderingGroup";
  66745. export * from "babylonjs/Rendering/renderingManager";
  66746. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66747. }
  66748. declare module "babylonjs/Sprites/spritePackedManager" {
  66749. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66750. import { Scene } from "babylonjs/scene";
  66751. /**
  66752. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66753. * @see http://doc.babylonjs.com/babylon101/sprites
  66754. */
  66755. export class SpritePackedManager extends SpriteManager {
  66756. /** defines the packed manager's name */
  66757. name: string;
  66758. /**
  66759. * Creates a new sprite manager from a packed sprite sheet
  66760. * @param name defines the manager's name
  66761. * @param imgUrl defines the sprite sheet url
  66762. * @param capacity defines the maximum allowed number of sprites
  66763. * @param scene defines the hosting scene
  66764. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66765. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66766. * @param samplingMode defines the smapling mode to use with spritesheet
  66767. * @param fromPacked set to true; do not alter
  66768. */
  66769. constructor(
  66770. /** defines the packed manager's name */
  66771. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66772. }
  66773. }
  66774. declare module "babylonjs/Sprites/index" {
  66775. export * from "babylonjs/Sprites/sprite";
  66776. export * from "babylonjs/Sprites/spriteManager";
  66777. export * from "babylonjs/Sprites/spritePackedManager";
  66778. export * from "babylonjs/Sprites/spriteSceneComponent";
  66779. }
  66780. declare module "babylonjs/States/index" {
  66781. export * from "babylonjs/States/alphaCullingState";
  66782. export * from "babylonjs/States/depthCullingState";
  66783. export * from "babylonjs/States/stencilState";
  66784. }
  66785. declare module "babylonjs/Misc/assetsManager" {
  66786. import { Scene } from "babylonjs/scene";
  66787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66788. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66789. import { Skeleton } from "babylonjs/Bones/skeleton";
  66790. import { Observable } from "babylonjs/Misc/observable";
  66791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66792. import { Texture } from "babylonjs/Materials/Textures/texture";
  66793. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66794. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66795. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66796. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66797. /**
  66798. * Defines the list of states available for a task inside a AssetsManager
  66799. */
  66800. export enum AssetTaskState {
  66801. /**
  66802. * Initialization
  66803. */
  66804. INIT = 0,
  66805. /**
  66806. * Running
  66807. */
  66808. RUNNING = 1,
  66809. /**
  66810. * Done
  66811. */
  66812. DONE = 2,
  66813. /**
  66814. * Error
  66815. */
  66816. ERROR = 3
  66817. }
  66818. /**
  66819. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66820. */
  66821. export abstract class AbstractAssetTask {
  66822. /**
  66823. * Task name
  66824. */ name: string;
  66825. /**
  66826. * Callback called when the task is successful
  66827. */
  66828. onSuccess: (task: any) => void;
  66829. /**
  66830. * Callback called when the task is not successful
  66831. */
  66832. onError: (task: any, message?: string, exception?: any) => void;
  66833. /**
  66834. * Creates a new AssetsManager
  66835. * @param name defines the name of the task
  66836. */
  66837. constructor(
  66838. /**
  66839. * Task name
  66840. */ name: string);
  66841. private _isCompleted;
  66842. private _taskState;
  66843. private _errorObject;
  66844. /**
  66845. * Get if the task is completed
  66846. */
  66847. readonly isCompleted: boolean;
  66848. /**
  66849. * Gets the current state of the task
  66850. */
  66851. readonly taskState: AssetTaskState;
  66852. /**
  66853. * Gets the current error object (if task is in error)
  66854. */
  66855. readonly errorObject: {
  66856. message?: string;
  66857. exception?: any;
  66858. };
  66859. /**
  66860. * Internal only
  66861. * @hidden
  66862. */
  66863. _setErrorObject(message?: string, exception?: any): void;
  66864. /**
  66865. * Execute the current task
  66866. * @param scene defines the scene where you want your assets to be loaded
  66867. * @param onSuccess is a callback called when the task is successfully executed
  66868. * @param onError is a callback called if an error occurs
  66869. */
  66870. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66871. /**
  66872. * Execute the current task
  66873. * @param scene defines the scene where you want your assets to be loaded
  66874. * @param onSuccess is a callback called when the task is successfully executed
  66875. * @param onError is a callback called if an error occurs
  66876. */
  66877. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66878. /**
  66879. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66880. * This can be used with failed tasks that have the reason for failure fixed.
  66881. */
  66882. reset(): void;
  66883. private onErrorCallback;
  66884. private onDoneCallback;
  66885. }
  66886. /**
  66887. * Define the interface used by progress events raised during assets loading
  66888. */
  66889. export interface IAssetsProgressEvent {
  66890. /**
  66891. * Defines the number of remaining tasks to process
  66892. */
  66893. remainingCount: number;
  66894. /**
  66895. * Defines the total number of tasks
  66896. */
  66897. totalCount: number;
  66898. /**
  66899. * Defines the task that was just processed
  66900. */
  66901. task: AbstractAssetTask;
  66902. }
  66903. /**
  66904. * Class used to share progress information about assets loading
  66905. */
  66906. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66907. /**
  66908. * Defines the number of remaining tasks to process
  66909. */
  66910. remainingCount: number;
  66911. /**
  66912. * Defines the total number of tasks
  66913. */
  66914. totalCount: number;
  66915. /**
  66916. * Defines the task that was just processed
  66917. */
  66918. task: AbstractAssetTask;
  66919. /**
  66920. * Creates a AssetsProgressEvent
  66921. * @param remainingCount defines the number of remaining tasks to process
  66922. * @param totalCount defines the total number of tasks
  66923. * @param task defines the task that was just processed
  66924. */
  66925. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66926. }
  66927. /**
  66928. * Define a task used by AssetsManager to load meshes
  66929. */
  66930. export class MeshAssetTask extends AbstractAssetTask {
  66931. /**
  66932. * Defines the name of the task
  66933. */
  66934. name: string;
  66935. /**
  66936. * Defines the list of mesh's names you want to load
  66937. */
  66938. meshesNames: any;
  66939. /**
  66940. * Defines the root url to use as a base to load your meshes and associated resources
  66941. */
  66942. rootUrl: string;
  66943. /**
  66944. * Defines the filename of the scene to load from
  66945. */
  66946. sceneFilename: string;
  66947. /**
  66948. * Gets the list of loaded meshes
  66949. */
  66950. loadedMeshes: Array<AbstractMesh>;
  66951. /**
  66952. * Gets the list of loaded particle systems
  66953. */
  66954. loadedParticleSystems: Array<IParticleSystem>;
  66955. /**
  66956. * Gets the list of loaded skeletons
  66957. */
  66958. loadedSkeletons: Array<Skeleton>;
  66959. /**
  66960. * Gets the list of loaded animation groups
  66961. */
  66962. loadedAnimationGroups: Array<AnimationGroup>;
  66963. /**
  66964. * Callback called when the task is successful
  66965. */
  66966. onSuccess: (task: MeshAssetTask) => void;
  66967. /**
  66968. * Callback called when the task is successful
  66969. */
  66970. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66971. /**
  66972. * Creates a new MeshAssetTask
  66973. * @param name defines the name of the task
  66974. * @param meshesNames defines the list of mesh's names you want to load
  66975. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66976. * @param sceneFilename defines the filename of the scene to load from
  66977. */
  66978. constructor(
  66979. /**
  66980. * Defines the name of the task
  66981. */
  66982. name: string,
  66983. /**
  66984. * Defines the list of mesh's names you want to load
  66985. */
  66986. meshesNames: any,
  66987. /**
  66988. * Defines the root url to use as a base to load your meshes and associated resources
  66989. */
  66990. rootUrl: string,
  66991. /**
  66992. * Defines the filename of the scene to load from
  66993. */
  66994. sceneFilename: string);
  66995. /**
  66996. * Execute the current task
  66997. * @param scene defines the scene where you want your assets to be loaded
  66998. * @param onSuccess is a callback called when the task is successfully executed
  66999. * @param onError is a callback called if an error occurs
  67000. */
  67001. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67002. }
  67003. /**
  67004. * Define a task used by AssetsManager to load text content
  67005. */
  67006. export class TextFileAssetTask extends AbstractAssetTask {
  67007. /**
  67008. * Defines the name of the task
  67009. */
  67010. name: string;
  67011. /**
  67012. * Defines the location of the file to load
  67013. */
  67014. url: string;
  67015. /**
  67016. * Gets the loaded text string
  67017. */
  67018. text: string;
  67019. /**
  67020. * Callback called when the task is successful
  67021. */
  67022. onSuccess: (task: TextFileAssetTask) => void;
  67023. /**
  67024. * Callback called when the task is successful
  67025. */
  67026. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67027. /**
  67028. * Creates a new TextFileAssetTask object
  67029. * @param name defines the name of the task
  67030. * @param url defines the location of the file to load
  67031. */
  67032. constructor(
  67033. /**
  67034. * Defines the name of the task
  67035. */
  67036. name: string,
  67037. /**
  67038. * Defines the location of the file to load
  67039. */
  67040. url: string);
  67041. /**
  67042. * Execute the current task
  67043. * @param scene defines the scene where you want your assets to be loaded
  67044. * @param onSuccess is a callback called when the task is successfully executed
  67045. * @param onError is a callback called if an error occurs
  67046. */
  67047. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67048. }
  67049. /**
  67050. * Define a task used by AssetsManager to load binary data
  67051. */
  67052. export class BinaryFileAssetTask extends AbstractAssetTask {
  67053. /**
  67054. * Defines the name of the task
  67055. */
  67056. name: string;
  67057. /**
  67058. * Defines the location of the file to load
  67059. */
  67060. url: string;
  67061. /**
  67062. * Gets the lodaded data (as an array buffer)
  67063. */
  67064. data: ArrayBuffer;
  67065. /**
  67066. * Callback called when the task is successful
  67067. */
  67068. onSuccess: (task: BinaryFileAssetTask) => void;
  67069. /**
  67070. * Callback called when the task is successful
  67071. */
  67072. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67073. /**
  67074. * Creates a new BinaryFileAssetTask object
  67075. * @param name defines the name of the new task
  67076. * @param url defines the location of the file to load
  67077. */
  67078. constructor(
  67079. /**
  67080. * Defines the name of the task
  67081. */
  67082. name: string,
  67083. /**
  67084. * Defines the location of the file to load
  67085. */
  67086. url: string);
  67087. /**
  67088. * Execute the current task
  67089. * @param scene defines the scene where you want your assets to be loaded
  67090. * @param onSuccess is a callback called when the task is successfully executed
  67091. * @param onError is a callback called if an error occurs
  67092. */
  67093. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67094. }
  67095. /**
  67096. * Define a task used by AssetsManager to load images
  67097. */
  67098. export class ImageAssetTask extends AbstractAssetTask {
  67099. /**
  67100. * Defines the name of the task
  67101. */
  67102. name: string;
  67103. /**
  67104. * Defines the location of the image to load
  67105. */
  67106. url: string;
  67107. /**
  67108. * Gets the loaded images
  67109. */
  67110. image: HTMLImageElement;
  67111. /**
  67112. * Callback called when the task is successful
  67113. */
  67114. onSuccess: (task: ImageAssetTask) => void;
  67115. /**
  67116. * Callback called when the task is successful
  67117. */
  67118. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67119. /**
  67120. * Creates a new ImageAssetTask
  67121. * @param name defines the name of the task
  67122. * @param url defines the location of the image to load
  67123. */
  67124. constructor(
  67125. /**
  67126. * Defines the name of the task
  67127. */
  67128. name: string,
  67129. /**
  67130. * Defines the location of the image to load
  67131. */
  67132. url: string);
  67133. /**
  67134. * Execute the current task
  67135. * @param scene defines the scene where you want your assets to be loaded
  67136. * @param onSuccess is a callback called when the task is successfully executed
  67137. * @param onError is a callback called if an error occurs
  67138. */
  67139. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67140. }
  67141. /**
  67142. * Defines the interface used by texture loading tasks
  67143. */
  67144. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67145. /**
  67146. * Gets the loaded texture
  67147. */
  67148. texture: TEX;
  67149. }
  67150. /**
  67151. * Define a task used by AssetsManager to load 2D textures
  67152. */
  67153. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67154. /**
  67155. * Defines the name of the task
  67156. */
  67157. name: string;
  67158. /**
  67159. * Defines the location of the file to load
  67160. */
  67161. url: string;
  67162. /**
  67163. * Defines if mipmap should not be generated (default is false)
  67164. */
  67165. noMipmap?: boolean | undefined;
  67166. /**
  67167. * Defines if texture must be inverted on Y axis (default is false)
  67168. */
  67169. invertY?: boolean | undefined;
  67170. /**
  67171. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67172. */
  67173. samplingMode: number;
  67174. /**
  67175. * Gets the loaded texture
  67176. */
  67177. texture: Texture;
  67178. /**
  67179. * Callback called when the task is successful
  67180. */
  67181. onSuccess: (task: TextureAssetTask) => void;
  67182. /**
  67183. * Callback called when the task is successful
  67184. */
  67185. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67186. /**
  67187. * Creates a new TextureAssetTask object
  67188. * @param name defines the name of the task
  67189. * @param url defines the location of the file to load
  67190. * @param noMipmap defines if mipmap should not be generated (default is false)
  67191. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67192. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67193. */
  67194. constructor(
  67195. /**
  67196. * Defines the name of the task
  67197. */
  67198. name: string,
  67199. /**
  67200. * Defines the location of the file to load
  67201. */
  67202. url: string,
  67203. /**
  67204. * Defines if mipmap should not be generated (default is false)
  67205. */
  67206. noMipmap?: boolean | undefined,
  67207. /**
  67208. * Defines if texture must be inverted on Y axis (default is false)
  67209. */
  67210. invertY?: boolean | undefined,
  67211. /**
  67212. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67213. */
  67214. samplingMode?: number);
  67215. /**
  67216. * Execute the current task
  67217. * @param scene defines the scene where you want your assets to be loaded
  67218. * @param onSuccess is a callback called when the task is successfully executed
  67219. * @param onError is a callback called if an error occurs
  67220. */
  67221. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67222. }
  67223. /**
  67224. * Define a task used by AssetsManager to load cube textures
  67225. */
  67226. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67227. /**
  67228. * Defines the name of the task
  67229. */
  67230. name: string;
  67231. /**
  67232. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67233. */
  67234. url: string;
  67235. /**
  67236. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67237. */
  67238. extensions?: string[] | undefined;
  67239. /**
  67240. * Defines if mipmaps should not be generated (default is false)
  67241. */
  67242. noMipmap?: boolean | undefined;
  67243. /**
  67244. * Defines the explicit list of files (undefined by default)
  67245. */
  67246. files?: string[] | undefined;
  67247. /**
  67248. * Gets the loaded texture
  67249. */
  67250. texture: CubeTexture;
  67251. /**
  67252. * Callback called when the task is successful
  67253. */
  67254. onSuccess: (task: CubeTextureAssetTask) => void;
  67255. /**
  67256. * Callback called when the task is successful
  67257. */
  67258. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67259. /**
  67260. * Creates a new CubeTextureAssetTask
  67261. * @param name defines the name of the task
  67262. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67263. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67264. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67265. * @param files defines the explicit list of files (undefined by default)
  67266. */
  67267. constructor(
  67268. /**
  67269. * Defines the name of the task
  67270. */
  67271. name: string,
  67272. /**
  67273. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67274. */
  67275. url: string,
  67276. /**
  67277. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67278. */
  67279. extensions?: string[] | undefined,
  67280. /**
  67281. * Defines if mipmaps should not be generated (default is false)
  67282. */
  67283. noMipmap?: boolean | undefined,
  67284. /**
  67285. * Defines the explicit list of files (undefined by default)
  67286. */
  67287. files?: string[] | undefined);
  67288. /**
  67289. * Execute the current task
  67290. * @param scene defines the scene where you want your assets to be loaded
  67291. * @param onSuccess is a callback called when the task is successfully executed
  67292. * @param onError is a callback called if an error occurs
  67293. */
  67294. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67295. }
  67296. /**
  67297. * Define a task used by AssetsManager to load HDR cube textures
  67298. */
  67299. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67300. /**
  67301. * Defines the name of the task
  67302. */
  67303. name: string;
  67304. /**
  67305. * Defines the location of the file to load
  67306. */
  67307. url: string;
  67308. /**
  67309. * Defines the desired size (the more it increases the longer the generation will be)
  67310. */
  67311. size: number;
  67312. /**
  67313. * Defines if mipmaps should not be generated (default is false)
  67314. */
  67315. noMipmap: boolean;
  67316. /**
  67317. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67318. */
  67319. generateHarmonics: boolean;
  67320. /**
  67321. * 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)
  67322. */
  67323. gammaSpace: boolean;
  67324. /**
  67325. * Internal Use Only
  67326. */
  67327. reserved: boolean;
  67328. /**
  67329. * Gets the loaded texture
  67330. */
  67331. texture: HDRCubeTexture;
  67332. /**
  67333. * Callback called when the task is successful
  67334. */
  67335. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67336. /**
  67337. * Callback called when the task is successful
  67338. */
  67339. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67340. /**
  67341. * Creates a new HDRCubeTextureAssetTask object
  67342. * @param name defines the name of the task
  67343. * @param url defines the location of the file to load
  67344. * @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.
  67345. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67346. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67347. * @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)
  67348. * @param reserved Internal use only
  67349. */
  67350. constructor(
  67351. /**
  67352. * Defines the name of the task
  67353. */
  67354. name: string,
  67355. /**
  67356. * Defines the location of the file to load
  67357. */
  67358. url: string,
  67359. /**
  67360. * Defines the desired size (the more it increases the longer the generation will be)
  67361. */
  67362. size: number,
  67363. /**
  67364. * Defines if mipmaps should not be generated (default is false)
  67365. */
  67366. noMipmap?: boolean,
  67367. /**
  67368. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67369. */
  67370. generateHarmonics?: boolean,
  67371. /**
  67372. * 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)
  67373. */
  67374. gammaSpace?: boolean,
  67375. /**
  67376. * Internal Use Only
  67377. */
  67378. reserved?: boolean);
  67379. /**
  67380. * Execute the current task
  67381. * @param scene defines the scene where you want your assets to be loaded
  67382. * @param onSuccess is a callback called when the task is successfully executed
  67383. * @param onError is a callback called if an error occurs
  67384. */
  67385. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67386. }
  67387. /**
  67388. * Define a task used by AssetsManager to load Equirectangular cube textures
  67389. */
  67390. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67391. /**
  67392. * Defines the name of the task
  67393. */
  67394. name: string;
  67395. /**
  67396. * Defines the location of the file to load
  67397. */
  67398. url: string;
  67399. /**
  67400. * Defines the desired size (the more it increases the longer the generation will be)
  67401. */
  67402. size: number;
  67403. /**
  67404. * Defines if mipmaps should not be generated (default is false)
  67405. */
  67406. noMipmap: boolean;
  67407. /**
  67408. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67409. * but the standard material would require them in Gamma space) (default is true)
  67410. */
  67411. gammaSpace: boolean;
  67412. /**
  67413. * Gets the loaded texture
  67414. */
  67415. texture: EquiRectangularCubeTexture;
  67416. /**
  67417. * Callback called when the task is successful
  67418. */
  67419. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67420. /**
  67421. * Callback called when the task is successful
  67422. */
  67423. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67424. /**
  67425. * Creates a new EquiRectangularCubeTextureAssetTask object
  67426. * @param name defines the name of the task
  67427. * @param url defines the location of the file to load
  67428. * @param size defines the desired size (the more it increases the longer the generation will be)
  67429. * If the size is omitted this implies you are using a preprocessed cubemap.
  67430. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67431. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67432. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67433. * (default is true)
  67434. */
  67435. constructor(
  67436. /**
  67437. * Defines the name of the task
  67438. */
  67439. name: string,
  67440. /**
  67441. * Defines the location of the file to load
  67442. */
  67443. url: string,
  67444. /**
  67445. * Defines the desired size (the more it increases the longer the generation will be)
  67446. */
  67447. size: number,
  67448. /**
  67449. * Defines if mipmaps should not be generated (default is false)
  67450. */
  67451. noMipmap?: boolean,
  67452. /**
  67453. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67454. * but the standard material would require them in Gamma space) (default is true)
  67455. */
  67456. gammaSpace?: boolean);
  67457. /**
  67458. * Execute the current task
  67459. * @param scene defines the scene where you want your assets to be loaded
  67460. * @param onSuccess is a callback called when the task is successfully executed
  67461. * @param onError is a callback called if an error occurs
  67462. */
  67463. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67464. }
  67465. /**
  67466. * This class can be used to easily import assets into a scene
  67467. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67468. */
  67469. export class AssetsManager {
  67470. private _scene;
  67471. private _isLoading;
  67472. protected _tasks: AbstractAssetTask[];
  67473. protected _waitingTasksCount: number;
  67474. protected _totalTasksCount: number;
  67475. /**
  67476. * Callback called when all tasks are processed
  67477. */
  67478. onFinish: (tasks: AbstractAssetTask[]) => void;
  67479. /**
  67480. * Callback called when a task is successful
  67481. */
  67482. onTaskSuccess: (task: AbstractAssetTask) => void;
  67483. /**
  67484. * Callback called when a task had an error
  67485. */
  67486. onTaskError: (task: AbstractAssetTask) => void;
  67487. /**
  67488. * Callback called when a task is done (whatever the result is)
  67489. */
  67490. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67491. /**
  67492. * Observable called when all tasks are processed
  67493. */
  67494. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67495. /**
  67496. * Observable called when a task had an error
  67497. */
  67498. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67499. /**
  67500. * Observable called when all tasks were executed
  67501. */
  67502. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67503. /**
  67504. * Observable called when a task is done (whatever the result is)
  67505. */
  67506. onProgressObservable: Observable<IAssetsProgressEvent>;
  67507. /**
  67508. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67509. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67510. */
  67511. useDefaultLoadingScreen: boolean;
  67512. /**
  67513. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67514. * when all assets have been downloaded.
  67515. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67516. */
  67517. autoHideLoadingUI: boolean;
  67518. /**
  67519. * Creates a new AssetsManager
  67520. * @param scene defines the scene to work on
  67521. */
  67522. constructor(scene: Scene);
  67523. /**
  67524. * Add a MeshAssetTask to the list of active tasks
  67525. * @param taskName defines the name of the new task
  67526. * @param meshesNames defines the name of meshes to load
  67527. * @param rootUrl defines the root url to use to locate files
  67528. * @param sceneFilename defines the filename of the scene file
  67529. * @returns a new MeshAssetTask object
  67530. */
  67531. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67532. /**
  67533. * Add a TextFileAssetTask to the list of active tasks
  67534. * @param taskName defines the name of the new task
  67535. * @param url defines the url of the file to load
  67536. * @returns a new TextFileAssetTask object
  67537. */
  67538. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67539. /**
  67540. * Add a BinaryFileAssetTask to the list of active tasks
  67541. * @param taskName defines the name of the new task
  67542. * @param url defines the url of the file to load
  67543. * @returns a new BinaryFileAssetTask object
  67544. */
  67545. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67546. /**
  67547. * Add a ImageAssetTask to the list of active tasks
  67548. * @param taskName defines the name of the new task
  67549. * @param url defines the url of the file to load
  67550. * @returns a new ImageAssetTask object
  67551. */
  67552. addImageTask(taskName: string, url: string): ImageAssetTask;
  67553. /**
  67554. * Add a TextureAssetTask to the list of active tasks
  67555. * @param taskName defines the name of the new task
  67556. * @param url defines the url of the file to load
  67557. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67558. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67559. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67560. * @returns a new TextureAssetTask object
  67561. */
  67562. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67563. /**
  67564. * Add a CubeTextureAssetTask to the list of active tasks
  67565. * @param taskName defines the name of the new task
  67566. * @param url defines the url of the file to load
  67567. * @param extensions defines the extension to use to load the cube map (can be null)
  67568. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67569. * @param files defines the list of files to load (can be null)
  67570. * @returns a new CubeTextureAssetTask object
  67571. */
  67572. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67573. /**
  67574. *
  67575. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67576. * @param taskName defines the name of the new task
  67577. * @param url defines the url of the file to load
  67578. * @param size defines the size you want for the cubemap (can be null)
  67579. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67580. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67581. * @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)
  67582. * @param reserved Internal use only
  67583. * @returns a new HDRCubeTextureAssetTask object
  67584. */
  67585. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67586. /**
  67587. *
  67588. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67589. * @param taskName defines the name of the new task
  67590. * @param url defines the url of the file to load
  67591. * @param size defines the size you want for the cubemap (can be null)
  67592. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67593. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67594. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67595. * @returns a new EquiRectangularCubeTextureAssetTask object
  67596. */
  67597. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67598. /**
  67599. * Remove a task from the assets manager.
  67600. * @param task the task to remove
  67601. */
  67602. removeTask(task: AbstractAssetTask): void;
  67603. private _decreaseWaitingTasksCount;
  67604. private _runTask;
  67605. /**
  67606. * Reset the AssetsManager and remove all tasks
  67607. * @return the current instance of the AssetsManager
  67608. */
  67609. reset(): AssetsManager;
  67610. /**
  67611. * Start the loading process
  67612. * @return the current instance of the AssetsManager
  67613. */
  67614. load(): AssetsManager;
  67615. /**
  67616. * Start the loading process as an async operation
  67617. * @return a promise returning the list of failed tasks
  67618. */
  67619. loadAsync(): Promise<void>;
  67620. }
  67621. }
  67622. declare module "babylonjs/Misc/deferred" {
  67623. /**
  67624. * Wrapper class for promise with external resolve and reject.
  67625. */
  67626. export class Deferred<T> {
  67627. /**
  67628. * The promise associated with this deferred object.
  67629. */
  67630. readonly promise: Promise<T>;
  67631. private _resolve;
  67632. private _reject;
  67633. /**
  67634. * The resolve method of the promise associated with this deferred object.
  67635. */
  67636. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67637. /**
  67638. * The reject method of the promise associated with this deferred object.
  67639. */
  67640. readonly reject: (reason?: any) => void;
  67641. /**
  67642. * Constructor for this deferred object.
  67643. */
  67644. constructor();
  67645. }
  67646. }
  67647. declare module "babylonjs/Misc/meshExploder" {
  67648. import { Mesh } from "babylonjs/Meshes/mesh";
  67649. /**
  67650. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67651. */
  67652. export class MeshExploder {
  67653. private _centerMesh;
  67654. private _meshes;
  67655. private _meshesOrigins;
  67656. private _toCenterVectors;
  67657. private _scaledDirection;
  67658. private _newPosition;
  67659. private _centerPosition;
  67660. /**
  67661. * Explodes meshes from a center mesh.
  67662. * @param meshes The meshes to explode.
  67663. * @param centerMesh The mesh to be center of explosion.
  67664. */
  67665. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67666. private _setCenterMesh;
  67667. /**
  67668. * Get class name
  67669. * @returns "MeshExploder"
  67670. */
  67671. getClassName(): string;
  67672. /**
  67673. * "Exploded meshes"
  67674. * @returns Array of meshes with the centerMesh at index 0.
  67675. */
  67676. getMeshes(): Array<Mesh>;
  67677. /**
  67678. * Explodes meshes giving a specific direction
  67679. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67680. */
  67681. explode(direction?: number): void;
  67682. }
  67683. }
  67684. declare module "babylonjs/Misc/filesInput" {
  67685. import { Engine } from "babylonjs/Engines/engine";
  67686. import { Scene } from "babylonjs/scene";
  67687. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67688. /**
  67689. * Class used to help managing file picking and drag'n'drop
  67690. */
  67691. export class FilesInput {
  67692. /**
  67693. * List of files ready to be loaded
  67694. */
  67695. static readonly FilesToLoad: {
  67696. [key: string]: File;
  67697. };
  67698. /**
  67699. * Callback called when a file is processed
  67700. */
  67701. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67702. private _engine;
  67703. private _currentScene;
  67704. private _sceneLoadedCallback;
  67705. private _progressCallback;
  67706. private _additionalRenderLoopLogicCallback;
  67707. private _textureLoadingCallback;
  67708. private _startingProcessingFilesCallback;
  67709. private _onReloadCallback;
  67710. private _errorCallback;
  67711. private _elementToMonitor;
  67712. private _sceneFileToLoad;
  67713. private _filesToLoad;
  67714. /**
  67715. * Creates a new FilesInput
  67716. * @param engine defines the rendering engine
  67717. * @param scene defines the hosting scene
  67718. * @param sceneLoadedCallback callback called when scene is loaded
  67719. * @param progressCallback callback called to track progress
  67720. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67721. * @param textureLoadingCallback callback called when a texture is loading
  67722. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67723. * @param onReloadCallback callback called when a reload is requested
  67724. * @param errorCallback callback call if an error occurs
  67725. */
  67726. 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);
  67727. private _dragEnterHandler;
  67728. private _dragOverHandler;
  67729. private _dropHandler;
  67730. /**
  67731. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67732. * @param elementToMonitor defines the DOM element to track
  67733. */
  67734. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67735. /**
  67736. * Release all associated resources
  67737. */
  67738. dispose(): void;
  67739. private renderFunction;
  67740. private drag;
  67741. private drop;
  67742. private _traverseFolder;
  67743. private _processFiles;
  67744. /**
  67745. * Load files from a drop event
  67746. * @param event defines the drop event to use as source
  67747. */
  67748. loadFiles(event: any): void;
  67749. private _processReload;
  67750. /**
  67751. * Reload the current scene from the loaded files
  67752. */
  67753. reload(): void;
  67754. }
  67755. }
  67756. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67757. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67758. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67759. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67760. }
  67761. declare module "babylonjs/Misc/sceneOptimizer" {
  67762. import { Scene, IDisposable } from "babylonjs/scene";
  67763. import { Observable } from "babylonjs/Misc/observable";
  67764. /**
  67765. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67766. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67767. */
  67768. export class SceneOptimization {
  67769. /**
  67770. * Defines the priority of this optimization (0 by default which means first in the list)
  67771. */
  67772. priority: number;
  67773. /**
  67774. * Gets a string describing the action executed by the current optimization
  67775. * @returns description string
  67776. */
  67777. getDescription(): string;
  67778. /**
  67779. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67780. * @param scene defines the current scene where to apply this optimization
  67781. * @param optimizer defines the current optimizer
  67782. * @returns true if everything that can be done was applied
  67783. */
  67784. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67785. /**
  67786. * Creates the SceneOptimization object
  67787. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67788. * @param desc defines the description associated with the optimization
  67789. */
  67790. constructor(
  67791. /**
  67792. * Defines the priority of this optimization (0 by default which means first in the list)
  67793. */
  67794. priority?: number);
  67795. }
  67796. /**
  67797. * Defines an optimization used to reduce the size of render target textures
  67798. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67799. */
  67800. export class TextureOptimization extends SceneOptimization {
  67801. /**
  67802. * Defines the priority of this optimization (0 by default which means first in the list)
  67803. */
  67804. priority: number;
  67805. /**
  67806. * 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
  67807. */
  67808. maximumSize: number;
  67809. /**
  67810. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67811. */
  67812. step: number;
  67813. /**
  67814. * Gets a string describing the action executed by the current optimization
  67815. * @returns description string
  67816. */
  67817. getDescription(): string;
  67818. /**
  67819. * Creates the TextureOptimization object
  67820. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67821. * @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
  67822. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67823. */
  67824. constructor(
  67825. /**
  67826. * Defines the priority of this optimization (0 by default which means first in the list)
  67827. */
  67828. priority?: number,
  67829. /**
  67830. * 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
  67831. */
  67832. maximumSize?: number,
  67833. /**
  67834. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67835. */
  67836. step?: number);
  67837. /**
  67838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67839. * @param scene defines the current scene where to apply this optimization
  67840. * @param optimizer defines the current optimizer
  67841. * @returns true if everything that can be done was applied
  67842. */
  67843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67844. }
  67845. /**
  67846. * Defines an optimization used to increase or decrease the rendering resolution
  67847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67848. */
  67849. export class HardwareScalingOptimization extends SceneOptimization {
  67850. /**
  67851. * Defines the priority of this optimization (0 by default which means first in the list)
  67852. */
  67853. priority: number;
  67854. /**
  67855. * Defines the maximum scale to use (2 by default)
  67856. */
  67857. maximumScale: number;
  67858. /**
  67859. * Defines the step to use between two passes (0.5 by default)
  67860. */
  67861. step: number;
  67862. private _currentScale;
  67863. private _directionOffset;
  67864. /**
  67865. * Gets a string describing the action executed by the current optimization
  67866. * @return description string
  67867. */
  67868. getDescription(): string;
  67869. /**
  67870. * Creates the HardwareScalingOptimization object
  67871. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67872. * @param maximumScale defines the maximum scale to use (2 by default)
  67873. * @param step defines the step to use between two passes (0.5 by default)
  67874. */
  67875. constructor(
  67876. /**
  67877. * Defines the priority of this optimization (0 by default which means first in the list)
  67878. */
  67879. priority?: number,
  67880. /**
  67881. * Defines the maximum scale to use (2 by default)
  67882. */
  67883. maximumScale?: number,
  67884. /**
  67885. * Defines the step to use between two passes (0.5 by default)
  67886. */
  67887. step?: number);
  67888. /**
  67889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67890. * @param scene defines the current scene where to apply this optimization
  67891. * @param optimizer defines the current optimizer
  67892. * @returns true if everything that can be done was applied
  67893. */
  67894. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67895. }
  67896. /**
  67897. * Defines an optimization used to remove shadows
  67898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67899. */
  67900. export class ShadowsOptimization extends SceneOptimization {
  67901. /**
  67902. * Gets a string describing the action executed by the current optimization
  67903. * @return description string
  67904. */
  67905. getDescription(): string;
  67906. /**
  67907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67908. * @param scene defines the current scene where to apply this optimization
  67909. * @param optimizer defines the current optimizer
  67910. * @returns true if everything that can be done was applied
  67911. */
  67912. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67913. }
  67914. /**
  67915. * Defines an optimization used to turn post-processes off
  67916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67917. */
  67918. export class PostProcessesOptimization extends SceneOptimization {
  67919. /**
  67920. * Gets a string describing the action executed by the current optimization
  67921. * @return description string
  67922. */
  67923. getDescription(): string;
  67924. /**
  67925. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67926. * @param scene defines the current scene where to apply this optimization
  67927. * @param optimizer defines the current optimizer
  67928. * @returns true if everything that can be done was applied
  67929. */
  67930. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67931. }
  67932. /**
  67933. * Defines an optimization used to turn lens flares off
  67934. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67935. */
  67936. export class LensFlaresOptimization extends SceneOptimization {
  67937. /**
  67938. * Gets a string describing the action executed by the current optimization
  67939. * @return description string
  67940. */
  67941. getDescription(): string;
  67942. /**
  67943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67944. * @param scene defines the current scene where to apply this optimization
  67945. * @param optimizer defines the current optimizer
  67946. * @returns true if everything that can be done was applied
  67947. */
  67948. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67949. }
  67950. /**
  67951. * Defines an optimization based on user defined callback.
  67952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67953. */
  67954. export class CustomOptimization extends SceneOptimization {
  67955. /**
  67956. * Callback called to apply the custom optimization.
  67957. */
  67958. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67959. /**
  67960. * Callback called to get custom description
  67961. */
  67962. onGetDescription: () => string;
  67963. /**
  67964. * Gets a string describing the action executed by the current optimization
  67965. * @returns description string
  67966. */
  67967. getDescription(): string;
  67968. /**
  67969. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67970. * @param scene defines the current scene where to apply this optimization
  67971. * @param optimizer defines the current optimizer
  67972. * @returns true if everything that can be done was applied
  67973. */
  67974. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67975. }
  67976. /**
  67977. * Defines an optimization used to turn particles off
  67978. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67979. */
  67980. export class ParticlesOptimization extends SceneOptimization {
  67981. /**
  67982. * Gets a string describing the action executed by the current optimization
  67983. * @return description string
  67984. */
  67985. getDescription(): string;
  67986. /**
  67987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67988. * @param scene defines the current scene where to apply this optimization
  67989. * @param optimizer defines the current optimizer
  67990. * @returns true if everything that can be done was applied
  67991. */
  67992. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67993. }
  67994. /**
  67995. * Defines an optimization used to turn render targets off
  67996. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67997. */
  67998. export class RenderTargetsOptimization extends SceneOptimization {
  67999. /**
  68000. * Gets a string describing the action executed by the current optimization
  68001. * @return description string
  68002. */
  68003. getDescription(): string;
  68004. /**
  68005. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68006. * @param scene defines the current scene where to apply this optimization
  68007. * @param optimizer defines the current optimizer
  68008. * @returns true if everything that can be done was applied
  68009. */
  68010. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68011. }
  68012. /**
  68013. * Defines an optimization used to merge meshes with compatible materials
  68014. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68015. */
  68016. export class MergeMeshesOptimization extends SceneOptimization {
  68017. private static _UpdateSelectionTree;
  68018. /**
  68019. * Gets or sets a boolean which defines if optimization octree has to be updated
  68020. */
  68021. /**
  68022. * Gets or sets a boolean which defines if optimization octree has to be updated
  68023. */
  68024. static UpdateSelectionTree: boolean;
  68025. /**
  68026. * Gets a string describing the action executed by the current optimization
  68027. * @return description string
  68028. */
  68029. getDescription(): string;
  68030. private _canBeMerged;
  68031. /**
  68032. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68033. * @param scene defines the current scene where to apply this optimization
  68034. * @param optimizer defines the current optimizer
  68035. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68036. * @returns true if everything that can be done was applied
  68037. */
  68038. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68039. }
  68040. /**
  68041. * Defines a list of options used by SceneOptimizer
  68042. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68043. */
  68044. export class SceneOptimizerOptions {
  68045. /**
  68046. * Defines the target frame rate to reach (60 by default)
  68047. */
  68048. targetFrameRate: number;
  68049. /**
  68050. * Defines the interval between two checkes (2000ms by default)
  68051. */
  68052. trackerDuration: number;
  68053. /**
  68054. * Gets the list of optimizations to apply
  68055. */
  68056. optimizations: SceneOptimization[];
  68057. /**
  68058. * Creates a new list of options used by SceneOptimizer
  68059. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68060. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68061. */
  68062. constructor(
  68063. /**
  68064. * Defines the target frame rate to reach (60 by default)
  68065. */
  68066. targetFrameRate?: number,
  68067. /**
  68068. * Defines the interval between two checkes (2000ms by default)
  68069. */
  68070. trackerDuration?: number);
  68071. /**
  68072. * Add a new optimization
  68073. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68074. * @returns the current SceneOptimizerOptions
  68075. */
  68076. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68077. /**
  68078. * Add a new custom optimization
  68079. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68080. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68081. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68082. * @returns the current SceneOptimizerOptions
  68083. */
  68084. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68085. /**
  68086. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68087. * @param targetFrameRate defines the target frame rate (60 by default)
  68088. * @returns a SceneOptimizerOptions object
  68089. */
  68090. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68091. /**
  68092. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68093. * @param targetFrameRate defines the target frame rate (60 by default)
  68094. * @returns a SceneOptimizerOptions object
  68095. */
  68096. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68097. /**
  68098. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68099. * @param targetFrameRate defines the target frame rate (60 by default)
  68100. * @returns a SceneOptimizerOptions object
  68101. */
  68102. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68103. }
  68104. /**
  68105. * Class used to run optimizations in order to reach a target frame rate
  68106. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68107. */
  68108. export class SceneOptimizer implements IDisposable {
  68109. private _isRunning;
  68110. private _options;
  68111. private _scene;
  68112. private _currentPriorityLevel;
  68113. private _targetFrameRate;
  68114. private _trackerDuration;
  68115. private _currentFrameRate;
  68116. private _sceneDisposeObserver;
  68117. private _improvementMode;
  68118. /**
  68119. * Defines an observable called when the optimizer reaches the target frame rate
  68120. */
  68121. onSuccessObservable: Observable<SceneOptimizer>;
  68122. /**
  68123. * Defines an observable called when the optimizer enables an optimization
  68124. */
  68125. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68126. /**
  68127. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68128. */
  68129. onFailureObservable: Observable<SceneOptimizer>;
  68130. /**
  68131. * Gets a boolean indicating if the optimizer is in improvement mode
  68132. */
  68133. readonly isInImprovementMode: boolean;
  68134. /**
  68135. * Gets the current priority level (0 at start)
  68136. */
  68137. readonly currentPriorityLevel: number;
  68138. /**
  68139. * Gets the current frame rate checked by the SceneOptimizer
  68140. */
  68141. readonly currentFrameRate: number;
  68142. /**
  68143. * Gets or sets the current target frame rate (60 by default)
  68144. */
  68145. /**
  68146. * Gets or sets the current target frame rate (60 by default)
  68147. */
  68148. targetFrameRate: number;
  68149. /**
  68150. * Gets or sets the current interval between two checks (every 2000ms by default)
  68151. */
  68152. /**
  68153. * Gets or sets the current interval between two checks (every 2000ms by default)
  68154. */
  68155. trackerDuration: number;
  68156. /**
  68157. * Gets the list of active optimizations
  68158. */
  68159. readonly optimizations: SceneOptimization[];
  68160. /**
  68161. * Creates a new SceneOptimizer
  68162. * @param scene defines the scene to work on
  68163. * @param options defines the options to use with the SceneOptimizer
  68164. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68165. * @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)
  68166. */
  68167. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68168. /**
  68169. * Stops the current optimizer
  68170. */
  68171. stop(): void;
  68172. /**
  68173. * Reset the optimizer to initial step (current priority level = 0)
  68174. */
  68175. reset(): void;
  68176. /**
  68177. * Start the optimizer. By default it will try to reach a specific framerate
  68178. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68179. */
  68180. start(): void;
  68181. private _checkCurrentState;
  68182. /**
  68183. * Release all resources
  68184. */
  68185. dispose(): void;
  68186. /**
  68187. * Helper function to create a SceneOptimizer with one single line of code
  68188. * @param scene defines the scene to work on
  68189. * @param options defines the options to use with the SceneOptimizer
  68190. * @param onSuccess defines a callback to call on success
  68191. * @param onFailure defines a callback to call on failure
  68192. * @returns the new SceneOptimizer object
  68193. */
  68194. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68195. }
  68196. }
  68197. declare module "babylonjs/Misc/sceneSerializer" {
  68198. import { Scene } from "babylonjs/scene";
  68199. /**
  68200. * Class used to serialize a scene into a string
  68201. */
  68202. export class SceneSerializer {
  68203. /**
  68204. * Clear cache used by a previous serialization
  68205. */
  68206. static ClearCache(): void;
  68207. /**
  68208. * Serialize a scene into a JSON compatible object
  68209. * @param scene defines the scene to serialize
  68210. * @returns a JSON compatible object
  68211. */
  68212. static Serialize(scene: Scene): any;
  68213. /**
  68214. * Serialize a mesh into a JSON compatible object
  68215. * @param toSerialize defines the mesh to serialize
  68216. * @param withParents defines if parents must be serialized as well
  68217. * @param withChildren defines if children must be serialized as well
  68218. * @returns a JSON compatible object
  68219. */
  68220. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68221. }
  68222. }
  68223. declare module "babylonjs/Misc/textureTools" {
  68224. import { Texture } from "babylonjs/Materials/Textures/texture";
  68225. /**
  68226. * Class used to host texture specific utilities
  68227. */
  68228. export class TextureTools {
  68229. /**
  68230. * Uses the GPU to create a copy texture rescaled at a given size
  68231. * @param texture Texture to copy from
  68232. * @param width defines the desired width
  68233. * @param height defines the desired height
  68234. * @param useBilinearMode defines if bilinear mode has to be used
  68235. * @return the generated texture
  68236. */
  68237. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68238. }
  68239. }
  68240. declare module "babylonjs/Misc/videoRecorder" {
  68241. import { Nullable } from "babylonjs/types";
  68242. import { Engine } from "babylonjs/Engines/engine";
  68243. /**
  68244. * This represents the different options available for the video capture.
  68245. */
  68246. export interface VideoRecorderOptions {
  68247. /** Defines the mime type of the video. */
  68248. mimeType: string;
  68249. /** Defines the FPS the video should be recorded at. */
  68250. fps: number;
  68251. /** Defines the chunk size for the recording data. */
  68252. recordChunckSize: number;
  68253. /** The audio tracks to attach to the recording. */
  68254. audioTracks?: MediaStreamTrack[];
  68255. }
  68256. /**
  68257. * This can help with recording videos from BabylonJS.
  68258. * This is based on the available WebRTC functionalities of the browser.
  68259. *
  68260. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68261. */
  68262. export class VideoRecorder {
  68263. private static readonly _defaultOptions;
  68264. /**
  68265. * Returns whether or not the VideoRecorder is available in your browser.
  68266. * @param engine Defines the Babylon Engine.
  68267. * @returns true if supported otherwise false.
  68268. */
  68269. static IsSupported(engine: Engine): boolean;
  68270. private readonly _options;
  68271. private _canvas;
  68272. private _mediaRecorder;
  68273. private _recordedChunks;
  68274. private _fileName;
  68275. private _resolve;
  68276. private _reject;
  68277. /**
  68278. * True when a recording is already in progress.
  68279. */
  68280. readonly isRecording: boolean;
  68281. /**
  68282. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68283. * @param engine Defines the BabylonJS Engine you wish to record.
  68284. * @param options Defines options that can be used to customize the capture.
  68285. */
  68286. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68287. /**
  68288. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68289. */
  68290. stopRecording(): void;
  68291. /**
  68292. * Starts recording the canvas for a max duration specified in parameters.
  68293. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68294. * If null no automatic download will start and you can rely on the promise to get the data back.
  68295. * @param maxDuration Defines the maximum recording time in seconds.
  68296. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68297. * @return A promise callback at the end of the recording with the video data in Blob.
  68298. */
  68299. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68300. /**
  68301. * Releases internal resources used during the recording.
  68302. */
  68303. dispose(): void;
  68304. private _handleDataAvailable;
  68305. private _handleError;
  68306. private _handleStop;
  68307. }
  68308. }
  68309. declare module "babylonjs/Misc/screenshotTools" {
  68310. import { Camera } from "babylonjs/Cameras/camera";
  68311. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  68312. import { Engine } from "babylonjs/Engines/engine";
  68313. /**
  68314. * Class containing a set of static utilities functions for screenshots
  68315. */
  68316. export class ScreenshotTools {
  68317. /**
  68318. * Captures a screenshot of the current rendering
  68319. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68320. * @param engine defines the rendering engine
  68321. * @param camera defines the source camera
  68322. * @param size This parameter can be set to a single number or to an object with the
  68323. * following (optional) properties: precision, width, height. If a single number is passed,
  68324. * it will be used for both width and height. If an object is passed, the screenshot size
  68325. * will be derived from the parameters. The precision property is a multiplier allowing
  68326. * rendering at a higher or lower resolution
  68327. * @param successCallback defines the callback receives a single parameter which contains the
  68328. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68329. * src parameter of an <img> to display it
  68330. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68331. * Check your browser for supported MIME types
  68332. */
  68333. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68334. /**
  68335. * Captures a screenshot of the current rendering
  68336. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68337. * @param engine defines the rendering engine
  68338. * @param camera defines the source camera
  68339. * @param size This parameter can be set to a single number or to an object with the
  68340. * following (optional) properties: precision, width, height. If a single number is passed,
  68341. * it will be used for both width and height. If an object is passed, the screenshot size
  68342. * will be derived from the parameters. The precision property is a multiplier allowing
  68343. * rendering at a higher or lower resolution
  68344. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68345. * Check your browser for supported MIME types
  68346. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68347. * to the src parameter of an <img> to display it
  68348. */
  68349. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68350. /**
  68351. * Generates an image screenshot from the specified camera.
  68352. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68353. * @param engine The engine to use for rendering
  68354. * @param camera The camera to use for rendering
  68355. * @param size This parameter can be set to a single number or to an object with the
  68356. * following (optional) properties: precision, width, height. If a single number is passed,
  68357. * it will be used for both width and height. If an object is passed, the screenshot size
  68358. * will be derived from the parameters. The precision property is a multiplier allowing
  68359. * rendering at a higher or lower resolution
  68360. * @param successCallback The callback receives a single parameter which contains the
  68361. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68362. * src parameter of an <img> to display it
  68363. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68364. * Check your browser for supported MIME types
  68365. * @param samples Texture samples (default: 1)
  68366. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68367. * @param fileName A name for for the downloaded file.
  68368. */
  68369. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68370. /**
  68371. * Generates an image screenshot from the specified camera.
  68372. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68373. * @param engine The engine to use for rendering
  68374. * @param camera The camera to use for rendering
  68375. * @param size This parameter can be set to a single number or to an object with the
  68376. * following (optional) properties: precision, width, height. If a single number is passed,
  68377. * it will be used for both width and height. If an object is passed, the screenshot size
  68378. * will be derived from the parameters. The precision property is a multiplier allowing
  68379. * rendering at a higher or lower resolution
  68380. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68381. * Check your browser for supported MIME types
  68382. * @param samples Texture samples (default: 1)
  68383. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68384. * @param fileName A name for for the downloaded file.
  68385. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68386. * to the src parameter of an <img> to display it
  68387. */
  68388. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68389. /**
  68390. * Gets height and width for screenshot size
  68391. * @private
  68392. */
  68393. private static _getScreenshotSize;
  68394. }
  68395. }
  68396. declare module "babylonjs/Misc/dataReader" {
  68397. /**
  68398. * Interface for a data buffer
  68399. */
  68400. export interface IDataBuffer {
  68401. /**
  68402. * Reads bytes from the data buffer.
  68403. * @param byteOffset The byte offset to read
  68404. * @param byteLength The byte length to read
  68405. * @returns A promise that resolves when the bytes are read
  68406. */
  68407. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68408. /**
  68409. * The byte length of the buffer.
  68410. */
  68411. readonly byteLength: number;
  68412. }
  68413. /**
  68414. * Utility class for reading from a data buffer
  68415. */
  68416. export class DataReader {
  68417. /**
  68418. * The data buffer associated with this data reader.
  68419. */
  68420. readonly buffer: IDataBuffer;
  68421. /**
  68422. * The current byte offset from the beginning of the data buffer.
  68423. */
  68424. byteOffset: number;
  68425. private _dataView;
  68426. private _dataByteOffset;
  68427. /**
  68428. * Constructor
  68429. * @param buffer The buffer to read
  68430. */
  68431. constructor(buffer: IDataBuffer);
  68432. /**
  68433. * Loads the given byte length.
  68434. * @param byteLength The byte length to load
  68435. * @returns A promise that resolves when the load is complete
  68436. */
  68437. loadAsync(byteLength: number): Promise<void>;
  68438. /**
  68439. * Read a unsigned 32-bit integer from the currently loaded data range.
  68440. * @returns The 32-bit integer read
  68441. */
  68442. readUint32(): number;
  68443. /**
  68444. * Read a byte array from the currently loaded data range.
  68445. * @param byteLength The byte length to read
  68446. * @returns The byte array read
  68447. */
  68448. readUint8Array(byteLength: number): Uint8Array;
  68449. /**
  68450. * Read a string from the currently loaded data range.
  68451. * @param byteLength The byte length to read
  68452. * @returns The string read
  68453. */
  68454. readString(byteLength: number): string;
  68455. /**
  68456. * Skips the given byte length the currently loaded data range.
  68457. * @param byteLength The byte length to skip
  68458. */
  68459. skipBytes(byteLength: number): void;
  68460. }
  68461. }
  68462. declare module "babylonjs/Misc/index" {
  68463. export * from "babylonjs/Misc/andOrNotEvaluator";
  68464. export * from "babylonjs/Misc/assetsManager";
  68465. export * from "babylonjs/Misc/dds";
  68466. export * from "babylonjs/Misc/decorators";
  68467. export * from "babylonjs/Misc/deferred";
  68468. export * from "babylonjs/Misc/environmentTextureTools";
  68469. export * from "babylonjs/Misc/meshExploder";
  68470. export * from "babylonjs/Misc/filesInput";
  68471. export * from "babylonjs/Misc/HighDynamicRange/index";
  68472. export * from "babylonjs/Misc/khronosTextureContainer";
  68473. export * from "babylonjs/Misc/observable";
  68474. export * from "babylonjs/Misc/performanceMonitor";
  68475. export * from "babylonjs/Misc/promise";
  68476. export * from "babylonjs/Misc/sceneOptimizer";
  68477. export * from "babylonjs/Misc/sceneSerializer";
  68478. export * from "babylonjs/Misc/smartArray";
  68479. export * from "babylonjs/Misc/stringDictionary";
  68480. export * from "babylonjs/Misc/tags";
  68481. export * from "babylonjs/Misc/textureTools";
  68482. export * from "babylonjs/Misc/tga";
  68483. export * from "babylonjs/Misc/tools";
  68484. export * from "babylonjs/Misc/videoRecorder";
  68485. export * from "babylonjs/Misc/virtualJoystick";
  68486. export * from "babylonjs/Misc/workerPool";
  68487. export * from "babylonjs/Misc/logger";
  68488. export * from "babylonjs/Misc/typeStore";
  68489. export * from "babylonjs/Misc/filesInputStore";
  68490. export * from "babylonjs/Misc/deepCopier";
  68491. export * from "babylonjs/Misc/pivotTools";
  68492. export * from "babylonjs/Misc/precisionDate";
  68493. export * from "babylonjs/Misc/screenshotTools";
  68494. export * from "babylonjs/Misc/typeStore";
  68495. export * from "babylonjs/Misc/webRequest";
  68496. export * from "babylonjs/Misc/iInspectable";
  68497. export * from "babylonjs/Misc/brdfTextureTools";
  68498. export * from "babylonjs/Misc/rgbdTextureTools";
  68499. export * from "babylonjs/Misc/gradients";
  68500. export * from "babylonjs/Misc/perfCounter";
  68501. export * from "babylonjs/Misc/fileRequest";
  68502. export * from "babylonjs/Misc/customAnimationFrameRequester";
  68503. export * from "babylonjs/Misc/retryStrategy";
  68504. export * from "babylonjs/Misc/interfaces/screenshotSize";
  68505. export * from "babylonjs/Misc/canvasGenerator";
  68506. export * from "babylonjs/Misc/fileTools";
  68507. export * from "babylonjs/Misc/stringTools";
  68508. export * from "babylonjs/Misc/dataReader";
  68509. }
  68510. declare module "babylonjs/index" {
  68511. export * from "babylonjs/abstractScene";
  68512. export * from "babylonjs/Actions/index";
  68513. export * from "babylonjs/Animations/index";
  68514. export * from "babylonjs/assetContainer";
  68515. export * from "babylonjs/Audio/index";
  68516. export * from "babylonjs/Behaviors/index";
  68517. export * from "babylonjs/Bones/index";
  68518. export * from "babylonjs/Cameras/index";
  68519. export * from "babylonjs/Collisions/index";
  68520. export * from "babylonjs/Culling/index";
  68521. export * from "babylonjs/Debug/index";
  68522. export * from "babylonjs/Engines/index";
  68523. export * from "babylonjs/Events/index";
  68524. export * from "babylonjs/Gamepads/index";
  68525. export * from "babylonjs/Gizmos/index";
  68526. export * from "babylonjs/Helpers/index";
  68527. export * from "babylonjs/Instrumentation/index";
  68528. export * from "babylonjs/Layers/index";
  68529. export * from "babylonjs/LensFlares/index";
  68530. export * from "babylonjs/Lights/index";
  68531. export * from "babylonjs/Loading/index";
  68532. export * from "babylonjs/Materials/index";
  68533. export * from "babylonjs/Maths/index";
  68534. export * from "babylonjs/Meshes/index";
  68535. export * from "babylonjs/Morph/index";
  68536. export * from "babylonjs/Navigation/index";
  68537. export * from "babylonjs/node";
  68538. export * from "babylonjs/Offline/index";
  68539. export * from "babylonjs/Particles/index";
  68540. export * from "babylonjs/Physics/index";
  68541. export * from "babylonjs/PostProcesses/index";
  68542. export * from "babylonjs/Probes/index";
  68543. export * from "babylonjs/Rendering/index";
  68544. export * from "babylonjs/scene";
  68545. export * from "babylonjs/sceneComponent";
  68546. export * from "babylonjs/Sprites/index";
  68547. export * from "babylonjs/States/index";
  68548. export * from "babylonjs/Misc/index";
  68549. export * from "babylonjs/types";
  68550. }
  68551. declare module "babylonjs/Animations/pathCursor" {
  68552. import { Vector3 } from "babylonjs/Maths/math.vector";
  68553. import { Path2 } from "babylonjs/Maths/math.path";
  68554. /**
  68555. * A cursor which tracks a point on a path
  68556. */
  68557. export class PathCursor {
  68558. private path;
  68559. /**
  68560. * Stores path cursor callbacks for when an onchange event is triggered
  68561. */
  68562. private _onchange;
  68563. /**
  68564. * The value of the path cursor
  68565. */
  68566. value: number;
  68567. /**
  68568. * The animation array of the path cursor
  68569. */
  68570. animations: Animation[];
  68571. /**
  68572. * Initializes the path cursor
  68573. * @param path The path to track
  68574. */
  68575. constructor(path: Path2);
  68576. /**
  68577. * Gets the cursor point on the path
  68578. * @returns A point on the path cursor at the cursor location
  68579. */
  68580. getPoint(): Vector3;
  68581. /**
  68582. * Moves the cursor ahead by the step amount
  68583. * @param step The amount to move the cursor forward
  68584. * @returns This path cursor
  68585. */
  68586. moveAhead(step?: number): PathCursor;
  68587. /**
  68588. * Moves the cursor behind by the step amount
  68589. * @param step The amount to move the cursor back
  68590. * @returns This path cursor
  68591. */
  68592. moveBack(step?: number): PathCursor;
  68593. /**
  68594. * Moves the cursor by the step amount
  68595. * If the step amount is greater than one, an exception is thrown
  68596. * @param step The amount to move the cursor
  68597. * @returns This path cursor
  68598. */
  68599. move(step: number): PathCursor;
  68600. /**
  68601. * Ensures that the value is limited between zero and one
  68602. * @returns This path cursor
  68603. */
  68604. private ensureLimits;
  68605. /**
  68606. * Runs onchange callbacks on change (used by the animation engine)
  68607. * @returns This path cursor
  68608. */
  68609. private raiseOnChange;
  68610. /**
  68611. * Executes a function on change
  68612. * @param f A path cursor onchange callback
  68613. * @returns This path cursor
  68614. */
  68615. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68616. }
  68617. }
  68618. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68619. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68620. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68621. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68622. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68623. }
  68624. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68625. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68626. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68627. }
  68628. declare module "babylonjs/Engines/Processors/index" {
  68629. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68630. export * from "babylonjs/Engines/Processors/Expressions/index";
  68631. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68632. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68633. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68634. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68635. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68636. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68637. }
  68638. declare module "babylonjs/Legacy/legacy" {
  68639. import * as Babylon from "babylonjs/index";
  68640. export * from "babylonjs/index";
  68641. }
  68642. declare module "babylonjs/Shaders/blur.fragment" {
  68643. /** @hidden */
  68644. export var blurPixelShader: {
  68645. name: string;
  68646. shader: string;
  68647. };
  68648. }
  68649. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68650. /** @hidden */
  68651. export var pointCloudVertexDeclaration: {
  68652. name: string;
  68653. shader: string;
  68654. };
  68655. }
  68656. declare module "babylonjs" {
  68657. export * from "babylonjs/Legacy/legacy";
  68658. }
  68659. declare module BABYLON {
  68660. /** Alias type for value that can be null */
  68661. export type Nullable<T> = T | null;
  68662. /**
  68663. * Alias type for number that are floats
  68664. * @ignorenaming
  68665. */
  68666. export type float = number;
  68667. /**
  68668. * Alias type for number that are doubles.
  68669. * @ignorenaming
  68670. */
  68671. export type double = number;
  68672. /**
  68673. * Alias type for number that are integer
  68674. * @ignorenaming
  68675. */
  68676. export type int = number;
  68677. /** Alias type for number array or Float32Array */
  68678. export type FloatArray = number[] | Float32Array;
  68679. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68680. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68681. /**
  68682. * Alias for types that can be used by a Buffer or VertexBuffer.
  68683. */
  68684. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68685. /**
  68686. * Alias type for primitive types
  68687. * @ignorenaming
  68688. */
  68689. type Primitive = undefined | null | boolean | string | number | Function;
  68690. /**
  68691. * Type modifier to make all the properties of an object Readonly
  68692. */
  68693. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68694. /**
  68695. * Type modifier to make all the properties of an object Readonly recursively
  68696. */
  68697. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68698. /**
  68699. * Type modifier to make object properties readonly.
  68700. */
  68701. export type DeepImmutableObject<T> = {
  68702. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68703. };
  68704. /** @hidden */
  68705. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68706. }
  68707. }
  68708. declare module BABYLON {
  68709. /**
  68710. * A class serves as a medium between the observable and its observers
  68711. */
  68712. export class EventState {
  68713. /**
  68714. * Create a new EventState
  68715. * @param mask defines the mask associated with this state
  68716. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68717. * @param target defines the original target of the state
  68718. * @param currentTarget defines the current target of the state
  68719. */
  68720. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68721. /**
  68722. * Initialize the current event state
  68723. * @param mask defines the mask associated with this state
  68724. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68725. * @param target defines the original target of the state
  68726. * @param currentTarget defines the current target of the state
  68727. * @returns the current event state
  68728. */
  68729. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68730. /**
  68731. * An Observer can set this property to true to prevent subsequent observers of being notified
  68732. */
  68733. skipNextObservers: boolean;
  68734. /**
  68735. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68736. */
  68737. mask: number;
  68738. /**
  68739. * The object that originally notified the event
  68740. */
  68741. target?: any;
  68742. /**
  68743. * The current object in the bubbling phase
  68744. */
  68745. currentTarget?: any;
  68746. /**
  68747. * This will be populated with the return value of the last function that was executed.
  68748. * If it is the first function in the callback chain it will be the event data.
  68749. */
  68750. lastReturnValue?: any;
  68751. }
  68752. /**
  68753. * Represent an Observer registered to a given Observable object.
  68754. */
  68755. export class Observer<T> {
  68756. /**
  68757. * Defines the callback to call when the observer is notified
  68758. */
  68759. callback: (eventData: T, eventState: EventState) => void;
  68760. /**
  68761. * Defines the mask of the observer (used to filter notifications)
  68762. */
  68763. mask: number;
  68764. /**
  68765. * Defines the current scope used to restore the JS context
  68766. */
  68767. scope: any;
  68768. /** @hidden */
  68769. _willBeUnregistered: boolean;
  68770. /**
  68771. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68772. */
  68773. unregisterOnNextCall: boolean;
  68774. /**
  68775. * Creates a new observer
  68776. * @param callback defines the callback to call when the observer is notified
  68777. * @param mask defines the mask of the observer (used to filter notifications)
  68778. * @param scope defines the current scope used to restore the JS context
  68779. */
  68780. constructor(
  68781. /**
  68782. * Defines the callback to call when the observer is notified
  68783. */
  68784. callback: (eventData: T, eventState: EventState) => void,
  68785. /**
  68786. * Defines the mask of the observer (used to filter notifications)
  68787. */
  68788. mask: number,
  68789. /**
  68790. * Defines the current scope used to restore the JS context
  68791. */
  68792. scope?: any);
  68793. }
  68794. /**
  68795. * Represent a list of observers registered to multiple Observables object.
  68796. */
  68797. export class MultiObserver<T> {
  68798. private _observers;
  68799. private _observables;
  68800. /**
  68801. * Release associated resources
  68802. */
  68803. dispose(): void;
  68804. /**
  68805. * Raise a callback when one of the observable will notify
  68806. * @param observables defines a list of observables to watch
  68807. * @param callback defines the callback to call on notification
  68808. * @param mask defines the mask used to filter notifications
  68809. * @param scope defines the current scope used to restore the JS context
  68810. * @returns the new MultiObserver
  68811. */
  68812. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68813. }
  68814. /**
  68815. * The Observable class is a simple implementation of the Observable pattern.
  68816. *
  68817. * 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.
  68818. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68819. * 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).
  68820. * 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.
  68821. */
  68822. export class Observable<T> {
  68823. private _observers;
  68824. private _eventState;
  68825. private _onObserverAdded;
  68826. /**
  68827. * Gets the list of observers
  68828. */
  68829. readonly observers: Array<Observer<T>>;
  68830. /**
  68831. * Creates a new observable
  68832. * @param onObserverAdded defines a callback to call when a new observer is added
  68833. */
  68834. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68835. /**
  68836. * Create a new Observer with the specified callback
  68837. * @param callback the callback that will be executed for that Observer
  68838. * @param mask the mask used to filter observers
  68839. * @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.
  68840. * @param scope optional scope for the callback to be called from
  68841. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68842. * @returns the new observer created for the callback
  68843. */
  68844. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68845. /**
  68846. * Create a new Observer with the specified callback and unregisters after the next notification
  68847. * @param callback the callback that will be executed for that Observer
  68848. * @returns the new observer created for the callback
  68849. */
  68850. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68851. /**
  68852. * Remove an Observer from the Observable object
  68853. * @param observer the instance of the Observer to remove
  68854. * @returns false if it doesn't belong to this Observable
  68855. */
  68856. remove(observer: Nullable<Observer<T>>): boolean;
  68857. /**
  68858. * Remove a callback from the Observable object
  68859. * @param callback the callback to remove
  68860. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68861. * @returns false if it doesn't belong to this Observable
  68862. */
  68863. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68864. private _deferUnregister;
  68865. private _remove;
  68866. /**
  68867. * Moves the observable to the top of the observer list making it get called first when notified
  68868. * @param observer the observer to move
  68869. */
  68870. makeObserverTopPriority(observer: Observer<T>): void;
  68871. /**
  68872. * Moves the observable to the bottom of the observer list making it get called last when notified
  68873. * @param observer the observer to move
  68874. */
  68875. makeObserverBottomPriority(observer: Observer<T>): void;
  68876. /**
  68877. * Notify all Observers by calling their respective callback with the given data
  68878. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68879. * @param eventData defines the data to send to all observers
  68880. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68881. * @param target defines the original target of the state
  68882. * @param currentTarget defines the current target of the state
  68883. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68884. */
  68885. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68886. /**
  68887. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68888. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68889. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68890. * and it is crucial that all callbacks will be executed.
  68891. * The order of the callbacks is kept, callbacks are not executed parallel.
  68892. *
  68893. * @param eventData The data to be sent to each callback
  68894. * @param mask is used to filter observers defaults to -1
  68895. * @param target defines the callback target (see EventState)
  68896. * @param currentTarget defines he current object in the bubbling phase
  68897. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68898. */
  68899. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68900. /**
  68901. * Notify a specific observer
  68902. * @param observer defines the observer to notify
  68903. * @param eventData defines the data to be sent to each callback
  68904. * @param mask is used to filter observers defaults to -1
  68905. */
  68906. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68907. /**
  68908. * Gets a boolean indicating if the observable has at least one observer
  68909. * @returns true is the Observable has at least one Observer registered
  68910. */
  68911. hasObservers(): boolean;
  68912. /**
  68913. * Clear the list of observers
  68914. */
  68915. clear(): void;
  68916. /**
  68917. * Clone the current observable
  68918. * @returns a new observable
  68919. */
  68920. clone(): Observable<T>;
  68921. /**
  68922. * Does this observable handles observer registered with a given mask
  68923. * @param mask defines the mask to be tested
  68924. * @return whether or not one observer registered with the given mask is handeled
  68925. **/
  68926. hasSpecificMask(mask?: number): boolean;
  68927. }
  68928. }
  68929. declare module BABYLON {
  68930. /**
  68931. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68932. * Babylon.js
  68933. */
  68934. export class DomManagement {
  68935. /**
  68936. * Checks if the window object exists
  68937. * @returns true if the window object exists
  68938. */
  68939. static IsWindowObjectExist(): boolean;
  68940. /**
  68941. * Checks if the navigator object exists
  68942. * @returns true if the navigator object exists
  68943. */
  68944. static IsNavigatorAvailable(): boolean;
  68945. /**
  68946. * Extracts text content from a DOM element hierarchy
  68947. * @param element defines the root element
  68948. * @returns a string
  68949. */
  68950. static GetDOMTextContent(element: HTMLElement): string;
  68951. }
  68952. }
  68953. declare module BABYLON {
  68954. /**
  68955. * Logger used througouht the application to allow configuration of
  68956. * the log level required for the messages.
  68957. */
  68958. export class Logger {
  68959. /**
  68960. * No log
  68961. */
  68962. static readonly NoneLogLevel: number;
  68963. /**
  68964. * Only message logs
  68965. */
  68966. static readonly MessageLogLevel: number;
  68967. /**
  68968. * Only warning logs
  68969. */
  68970. static readonly WarningLogLevel: number;
  68971. /**
  68972. * Only error logs
  68973. */
  68974. static readonly ErrorLogLevel: number;
  68975. /**
  68976. * All logs
  68977. */
  68978. static readonly AllLogLevel: number;
  68979. private static _LogCache;
  68980. /**
  68981. * Gets a value indicating the number of loading errors
  68982. * @ignorenaming
  68983. */
  68984. static errorsCount: number;
  68985. /**
  68986. * Callback called when a new log is added
  68987. */
  68988. static OnNewCacheEntry: (entry: string) => void;
  68989. private static _AddLogEntry;
  68990. private static _FormatMessage;
  68991. private static _LogDisabled;
  68992. private static _LogEnabled;
  68993. private static _WarnDisabled;
  68994. private static _WarnEnabled;
  68995. private static _ErrorDisabled;
  68996. private static _ErrorEnabled;
  68997. /**
  68998. * Log a message to the console
  68999. */
  69000. static Log: (message: string) => void;
  69001. /**
  69002. * Write a warning message to the console
  69003. */
  69004. static Warn: (message: string) => void;
  69005. /**
  69006. * Write an error message to the console
  69007. */
  69008. static Error: (message: string) => void;
  69009. /**
  69010. * Gets current log cache (list of logs)
  69011. */
  69012. static readonly LogCache: string;
  69013. /**
  69014. * Clears the log cache
  69015. */
  69016. static ClearLogCache(): void;
  69017. /**
  69018. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  69019. */
  69020. static LogLevels: number;
  69021. }
  69022. }
  69023. declare module BABYLON {
  69024. /** @hidden */
  69025. export class _TypeStore {
  69026. /** @hidden */
  69027. static RegisteredTypes: {
  69028. [key: string]: Object;
  69029. };
  69030. /** @hidden */
  69031. static GetClass(fqdn: string): any;
  69032. }
  69033. }
  69034. declare module BABYLON {
  69035. /**
  69036. * Helper to manipulate strings
  69037. */
  69038. export class StringTools {
  69039. /**
  69040. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69041. * @param str Source string
  69042. * @param suffix Suffix to search for in the source string
  69043. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69044. */
  69045. static EndsWith(str: string, suffix: string): boolean;
  69046. /**
  69047. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69048. * @param str Source string
  69049. * @param suffix Suffix to search for in the source string
  69050. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69051. */
  69052. static StartsWith(str: string, suffix: string): boolean;
  69053. /**
  69054. * Decodes a buffer into a string
  69055. * @param buffer The buffer to decode
  69056. * @returns The decoded string
  69057. */
  69058. static Decode(buffer: Uint8Array | Uint16Array): string;
  69059. /**
  69060. * Encode a buffer to a base64 string
  69061. * @param buffer defines the buffer to encode
  69062. * @returns the encoded string
  69063. */
  69064. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  69065. }
  69066. }
  69067. declare module BABYLON {
  69068. /**
  69069. * Class containing a set of static utilities functions for deep copy.
  69070. */
  69071. export class DeepCopier {
  69072. /**
  69073. * Tries to copy an object by duplicating every property
  69074. * @param source defines the source object
  69075. * @param destination defines the target object
  69076. * @param doNotCopyList defines a list of properties to avoid
  69077. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  69078. */
  69079. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  69080. }
  69081. }
  69082. declare module BABYLON {
  69083. /**
  69084. * Class containing a set of static utilities functions for precision date
  69085. */
  69086. export class PrecisionDate {
  69087. /**
  69088. * Gets either window.performance.now() if supported or Date.now() else
  69089. */
  69090. static readonly Now: number;
  69091. }
  69092. }
  69093. declare module BABYLON {
  69094. /** @hidden */
  69095. export class _DevTools {
  69096. static WarnImport(name: string): string;
  69097. }
  69098. }
  69099. declare module BABYLON {
  69100. /**
  69101. * Interface used to define the mechanism to get data from the network
  69102. */
  69103. export interface IWebRequest {
  69104. /**
  69105. * Returns client's response url
  69106. */
  69107. responseURL: string;
  69108. /**
  69109. * Returns client's status
  69110. */
  69111. status: number;
  69112. /**
  69113. * Returns client's status as a text
  69114. */
  69115. statusText: string;
  69116. }
  69117. }
  69118. declare module BABYLON {
  69119. /**
  69120. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  69121. */
  69122. export class WebRequest implements IWebRequest {
  69123. private _xhr;
  69124. /**
  69125. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  69126. * i.e. when loading files, where the server/service expects an Authorization header
  69127. */
  69128. static CustomRequestHeaders: {
  69129. [key: string]: string;
  69130. };
  69131. /**
  69132. * Add callback functions in this array to update all the requests before they get sent to the network
  69133. */
  69134. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  69135. private _injectCustomRequestHeaders;
  69136. /**
  69137. * Gets or sets a function to be called when loading progress changes
  69138. */
  69139. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  69140. /**
  69141. * Returns client's state
  69142. */
  69143. readonly readyState: number;
  69144. /**
  69145. * Returns client's status
  69146. */
  69147. readonly status: number;
  69148. /**
  69149. * Returns client's status as a text
  69150. */
  69151. readonly statusText: string;
  69152. /**
  69153. * Returns client's response
  69154. */
  69155. readonly response: any;
  69156. /**
  69157. * Returns client's response url
  69158. */
  69159. readonly responseURL: string;
  69160. /**
  69161. * Returns client's response as text
  69162. */
  69163. readonly responseText: string;
  69164. /**
  69165. * Gets or sets the expected response type
  69166. */
  69167. responseType: XMLHttpRequestResponseType;
  69168. /** @hidden */
  69169. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  69170. /** @hidden */
  69171. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  69172. /**
  69173. * Cancels any network activity
  69174. */
  69175. abort(): void;
  69176. /**
  69177. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  69178. * @param body defines an optional request body
  69179. */
  69180. send(body?: Document | BodyInit | null): void;
  69181. /**
  69182. * Sets the request method, request URL
  69183. * @param method defines the method to use (GET, POST, etc..)
  69184. * @param url defines the url to connect with
  69185. */
  69186. open(method: string, url: string): void;
  69187. /**
  69188. * Sets the value of a request header.
  69189. * @param name The name of the header whose value is to be set
  69190. * @param value The value to set as the body of the header
  69191. */
  69192. setRequestHeader(name: string, value: string): void;
  69193. /**
  69194. * Get the string containing the text of a particular header's value.
  69195. * @param name The name of the header
  69196. * @returns The string containing the text of the given header name
  69197. */
  69198. getResponseHeader(name: string): Nullable<string>;
  69199. }
  69200. }
  69201. declare module BABYLON {
  69202. /**
  69203. * File request interface
  69204. */
  69205. export interface IFileRequest {
  69206. /**
  69207. * Raised when the request is complete (success or error).
  69208. */
  69209. onCompleteObservable: Observable<IFileRequest>;
  69210. /**
  69211. * Aborts the request for a file.
  69212. */
  69213. abort: () => void;
  69214. }
  69215. }
  69216. declare module BABYLON {
  69217. /**
  69218. * Define options used to create a render target texture
  69219. */
  69220. export class RenderTargetCreationOptions {
  69221. /**
  69222. * Specifies is mipmaps must be generated
  69223. */
  69224. generateMipMaps?: boolean;
  69225. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69226. generateDepthBuffer?: boolean;
  69227. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69228. generateStencilBuffer?: boolean;
  69229. /** Defines texture type (int by default) */
  69230. type?: number;
  69231. /** Defines sampling mode (trilinear by default) */
  69232. samplingMode?: number;
  69233. /** Defines format (RGBA by default) */
  69234. format?: number;
  69235. }
  69236. }
  69237. declare module BABYLON {
  69238. /**
  69239. * @hidden
  69240. **/
  69241. export class _TimeToken {
  69242. _startTimeQuery: Nullable<WebGLQuery>;
  69243. _endTimeQuery: Nullable<WebGLQuery>;
  69244. _timeElapsedQuery: Nullable<WebGLQuery>;
  69245. _timeElapsedQueryEnded: boolean;
  69246. }
  69247. }
  69248. declare module BABYLON {
  69249. /** Defines the cross module used constants to avoid circular dependncies */
  69250. export class Constants {
  69251. /** Defines that alpha blending is disabled */
  69252. static readonly ALPHA_DISABLE: number;
  69253. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69254. static readonly ALPHA_ADD: number;
  69255. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69256. static readonly ALPHA_COMBINE: number;
  69257. /** Defines that alpha blending to DEST - SRC * DEST */
  69258. static readonly ALPHA_SUBTRACT: number;
  69259. /** Defines that alpha blending to SRC * DEST */
  69260. static readonly ALPHA_MULTIPLY: number;
  69261. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69262. static readonly ALPHA_MAXIMIZED: number;
  69263. /** Defines that alpha blending to SRC + DEST */
  69264. static readonly ALPHA_ONEONE: number;
  69265. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69266. static readonly ALPHA_PREMULTIPLIED: number;
  69267. /**
  69268. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69269. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69270. */
  69271. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69272. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69273. static readonly ALPHA_INTERPOLATE: number;
  69274. /**
  69275. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69276. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69277. */
  69278. static readonly ALPHA_SCREENMODE: number;
  69279. /**
  69280. * Defines that alpha blending to SRC + DST
  69281. * Alpha will be set to SRC ALPHA + DST ALPHA
  69282. */
  69283. static readonly ALPHA_ONEONE_ONEONE: number;
  69284. /**
  69285. * Defines that alpha blending to SRC * DST ALPHA + DST
  69286. * Alpha will be set to 0
  69287. */
  69288. static readonly ALPHA_ALPHATOCOLOR: number;
  69289. /**
  69290. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69291. */
  69292. static readonly ALPHA_REVERSEONEMINUS: number;
  69293. /**
  69294. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69295. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69296. */
  69297. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69298. /**
  69299. * Defines that alpha blending to SRC + DST
  69300. * Alpha will be set to SRC ALPHA
  69301. */
  69302. static readonly ALPHA_ONEONE_ONEZERO: number;
  69303. /** Defines that alpha blending equation a SUM */
  69304. static readonly ALPHA_EQUATION_ADD: number;
  69305. /** Defines that alpha blending equation a SUBSTRACTION */
  69306. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69307. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69308. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  69309. /** Defines that alpha blending equation a MAX operation */
  69310. static readonly ALPHA_EQUATION_MAX: number;
  69311. /** Defines that alpha blending equation a MIN operation */
  69312. static readonly ALPHA_EQUATION_MIN: number;
  69313. /**
  69314. * Defines that alpha blending equation a DARKEN operation:
  69315. * It takes the min of the src and sums the alpha channels.
  69316. */
  69317. static readonly ALPHA_EQUATION_DARKEN: number;
  69318. /** Defines that the ressource is not delayed*/
  69319. static readonly DELAYLOADSTATE_NONE: number;
  69320. /** Defines that the ressource was successfully delay loaded */
  69321. static readonly DELAYLOADSTATE_LOADED: number;
  69322. /** Defines that the ressource is currently delay loading */
  69323. static readonly DELAYLOADSTATE_LOADING: number;
  69324. /** Defines that the ressource is delayed and has not started loading */
  69325. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69326. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69327. static readonly NEVER: number;
  69328. /** 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 */
  69329. static readonly ALWAYS: number;
  69330. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69331. static readonly LESS: number;
  69332. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69333. static readonly EQUAL: number;
  69334. /** 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 */
  69335. static readonly LEQUAL: number;
  69336. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69337. static readonly GREATER: number;
  69338. /** 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 */
  69339. static readonly GEQUAL: number;
  69340. /** 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 */
  69341. static readonly NOTEQUAL: number;
  69342. /** Passed to stencilOperation to specify that stencil value must be kept */
  69343. static readonly KEEP: number;
  69344. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69345. static readonly REPLACE: number;
  69346. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69347. static readonly INCR: number;
  69348. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69349. static readonly DECR: number;
  69350. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69351. static readonly INVERT: number;
  69352. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69353. static readonly INCR_WRAP: number;
  69354. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69355. static readonly DECR_WRAP: number;
  69356. /** Texture is not repeating outside of 0..1 UVs */
  69357. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69358. /** Texture is repeating outside of 0..1 UVs */
  69359. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69360. /** Texture is repeating and mirrored */
  69361. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69362. /** ALPHA */
  69363. static readonly TEXTUREFORMAT_ALPHA: number;
  69364. /** LUMINANCE */
  69365. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69366. /** LUMINANCE_ALPHA */
  69367. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69368. /** RGB */
  69369. static readonly TEXTUREFORMAT_RGB: number;
  69370. /** RGBA */
  69371. static readonly TEXTUREFORMAT_RGBA: number;
  69372. /** RED */
  69373. static readonly TEXTUREFORMAT_RED: number;
  69374. /** RED (2nd reference) */
  69375. static readonly TEXTUREFORMAT_R: number;
  69376. /** RG */
  69377. static readonly TEXTUREFORMAT_RG: number;
  69378. /** RED_INTEGER */
  69379. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69380. /** RED_INTEGER (2nd reference) */
  69381. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69382. /** RG_INTEGER */
  69383. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69384. /** RGB_INTEGER */
  69385. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69386. /** RGBA_INTEGER */
  69387. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69388. /** UNSIGNED_BYTE */
  69389. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69390. /** UNSIGNED_BYTE (2nd reference) */
  69391. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69392. /** FLOAT */
  69393. static readonly TEXTURETYPE_FLOAT: number;
  69394. /** HALF_FLOAT */
  69395. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69396. /** BYTE */
  69397. static readonly TEXTURETYPE_BYTE: number;
  69398. /** SHORT */
  69399. static readonly TEXTURETYPE_SHORT: number;
  69400. /** UNSIGNED_SHORT */
  69401. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69402. /** INT */
  69403. static readonly TEXTURETYPE_INT: number;
  69404. /** UNSIGNED_INT */
  69405. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69406. /** UNSIGNED_SHORT_4_4_4_4 */
  69407. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69408. /** UNSIGNED_SHORT_5_5_5_1 */
  69409. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69410. /** UNSIGNED_SHORT_5_6_5 */
  69411. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69412. /** UNSIGNED_INT_2_10_10_10_REV */
  69413. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69414. /** UNSIGNED_INT_24_8 */
  69415. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69416. /** UNSIGNED_INT_10F_11F_11F_REV */
  69417. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69418. /** UNSIGNED_INT_5_9_9_9_REV */
  69419. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69420. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69421. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69422. /** nearest is mag = nearest and min = nearest and mip = nearest */
  69423. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69424. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69425. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69426. /** Trilinear is mag = linear and min = linear and mip = linear */
  69427. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69428. /** nearest is mag = nearest and min = nearest and mip = linear */
  69429. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69430. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69431. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69432. /** Trilinear is mag = linear and min = linear and mip = linear */
  69433. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69434. /** mag = nearest and min = nearest and mip = nearest */
  69435. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69436. /** mag = nearest and min = linear and mip = nearest */
  69437. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69438. /** mag = nearest and min = linear and mip = linear */
  69439. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69440. /** mag = nearest and min = linear and mip = none */
  69441. static readonly TEXTURE_NEAREST_LINEAR: number;
  69442. /** mag = nearest and min = nearest and mip = none */
  69443. static readonly TEXTURE_NEAREST_NEAREST: number;
  69444. /** mag = linear and min = nearest and mip = nearest */
  69445. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69446. /** mag = linear and min = nearest and mip = linear */
  69447. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69448. /** mag = linear and min = linear and mip = none */
  69449. static readonly TEXTURE_LINEAR_LINEAR: number;
  69450. /** mag = linear and min = nearest and mip = none */
  69451. static readonly TEXTURE_LINEAR_NEAREST: number;
  69452. /** Explicit coordinates mode */
  69453. static readonly TEXTURE_EXPLICIT_MODE: number;
  69454. /** Spherical coordinates mode */
  69455. static readonly TEXTURE_SPHERICAL_MODE: number;
  69456. /** Planar coordinates mode */
  69457. static readonly TEXTURE_PLANAR_MODE: number;
  69458. /** Cubic coordinates mode */
  69459. static readonly TEXTURE_CUBIC_MODE: number;
  69460. /** Projection coordinates mode */
  69461. static readonly TEXTURE_PROJECTION_MODE: number;
  69462. /** Skybox coordinates mode */
  69463. static readonly TEXTURE_SKYBOX_MODE: number;
  69464. /** Inverse Cubic coordinates mode */
  69465. static readonly TEXTURE_INVCUBIC_MODE: number;
  69466. /** Equirectangular coordinates mode */
  69467. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69468. /** Equirectangular Fixed coordinates mode */
  69469. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69470. /** Equirectangular Fixed Mirrored coordinates mode */
  69471. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69472. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69473. static readonly SCALEMODE_FLOOR: number;
  69474. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69475. static readonly SCALEMODE_NEAREST: number;
  69476. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69477. static readonly SCALEMODE_CEILING: number;
  69478. /**
  69479. * The dirty texture flag value
  69480. */
  69481. static readonly MATERIAL_TextureDirtyFlag: number;
  69482. /**
  69483. * The dirty light flag value
  69484. */
  69485. static readonly MATERIAL_LightDirtyFlag: number;
  69486. /**
  69487. * The dirty fresnel flag value
  69488. */
  69489. static readonly MATERIAL_FresnelDirtyFlag: number;
  69490. /**
  69491. * The dirty attribute flag value
  69492. */
  69493. static readonly MATERIAL_AttributesDirtyFlag: number;
  69494. /**
  69495. * The dirty misc flag value
  69496. */
  69497. static readonly MATERIAL_MiscDirtyFlag: number;
  69498. /**
  69499. * The all dirty flag value
  69500. */
  69501. static readonly MATERIAL_AllDirtyFlag: number;
  69502. /**
  69503. * Returns the triangle fill mode
  69504. */
  69505. static readonly MATERIAL_TriangleFillMode: number;
  69506. /**
  69507. * Returns the wireframe mode
  69508. */
  69509. static readonly MATERIAL_WireFrameFillMode: number;
  69510. /**
  69511. * Returns the point fill mode
  69512. */
  69513. static readonly MATERIAL_PointFillMode: number;
  69514. /**
  69515. * Returns the point list draw mode
  69516. */
  69517. static readonly MATERIAL_PointListDrawMode: number;
  69518. /**
  69519. * Returns the line list draw mode
  69520. */
  69521. static readonly MATERIAL_LineListDrawMode: number;
  69522. /**
  69523. * Returns the line loop draw mode
  69524. */
  69525. static readonly MATERIAL_LineLoopDrawMode: number;
  69526. /**
  69527. * Returns the line strip draw mode
  69528. */
  69529. static readonly MATERIAL_LineStripDrawMode: number;
  69530. /**
  69531. * Returns the triangle strip draw mode
  69532. */
  69533. static readonly MATERIAL_TriangleStripDrawMode: number;
  69534. /**
  69535. * Returns the triangle fan draw mode
  69536. */
  69537. static readonly MATERIAL_TriangleFanDrawMode: number;
  69538. /**
  69539. * Stores the clock-wise side orientation
  69540. */
  69541. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69542. /**
  69543. * Stores the counter clock-wise side orientation
  69544. */
  69545. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69546. /**
  69547. * Nothing
  69548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69549. */
  69550. static readonly ACTION_NothingTrigger: number;
  69551. /**
  69552. * On pick
  69553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69554. */
  69555. static readonly ACTION_OnPickTrigger: number;
  69556. /**
  69557. * On left pick
  69558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69559. */
  69560. static readonly ACTION_OnLeftPickTrigger: number;
  69561. /**
  69562. * On right pick
  69563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69564. */
  69565. static readonly ACTION_OnRightPickTrigger: number;
  69566. /**
  69567. * On center pick
  69568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69569. */
  69570. static readonly ACTION_OnCenterPickTrigger: number;
  69571. /**
  69572. * On pick down
  69573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69574. */
  69575. static readonly ACTION_OnPickDownTrigger: number;
  69576. /**
  69577. * On double pick
  69578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69579. */
  69580. static readonly ACTION_OnDoublePickTrigger: number;
  69581. /**
  69582. * On pick up
  69583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69584. */
  69585. static readonly ACTION_OnPickUpTrigger: number;
  69586. /**
  69587. * On pick out.
  69588. * This trigger will only be raised if you also declared a OnPickDown
  69589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69590. */
  69591. static readonly ACTION_OnPickOutTrigger: number;
  69592. /**
  69593. * On long press
  69594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69595. */
  69596. static readonly ACTION_OnLongPressTrigger: number;
  69597. /**
  69598. * On pointer over
  69599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69600. */
  69601. static readonly ACTION_OnPointerOverTrigger: number;
  69602. /**
  69603. * On pointer out
  69604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69605. */
  69606. static readonly ACTION_OnPointerOutTrigger: number;
  69607. /**
  69608. * On every frame
  69609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69610. */
  69611. static readonly ACTION_OnEveryFrameTrigger: number;
  69612. /**
  69613. * On intersection enter
  69614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69615. */
  69616. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69617. /**
  69618. * On intersection exit
  69619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69620. */
  69621. static readonly ACTION_OnIntersectionExitTrigger: number;
  69622. /**
  69623. * On key down
  69624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69625. */
  69626. static readonly ACTION_OnKeyDownTrigger: number;
  69627. /**
  69628. * On key up
  69629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69630. */
  69631. static readonly ACTION_OnKeyUpTrigger: number;
  69632. /**
  69633. * Billboard mode will only apply to Y axis
  69634. */
  69635. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69636. /**
  69637. * Billboard mode will apply to all axes
  69638. */
  69639. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69640. /**
  69641. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69642. */
  69643. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69644. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69645. * Test order :
  69646. * Is the bounding sphere outside the frustum ?
  69647. * If not, are the bounding box vertices outside the frustum ?
  69648. * It not, then the cullable object is in the frustum.
  69649. */
  69650. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69651. /** Culling strategy : Bounding Sphere Only.
  69652. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69653. * It's also less accurate than the standard because some not visible objects can still be selected.
  69654. * Test : is the bounding sphere outside the frustum ?
  69655. * If not, then the cullable object is in the frustum.
  69656. */
  69657. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69658. /** Culling strategy : Optimistic Inclusion.
  69659. * This in an inclusion test first, then the standard exclusion test.
  69660. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69661. * 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.
  69662. * Anyway, it's as accurate as the standard strategy.
  69663. * Test :
  69664. * Is the cullable object bounding sphere center in the frustum ?
  69665. * If not, apply the default culling strategy.
  69666. */
  69667. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69668. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69669. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69670. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69671. * 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.
  69672. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69673. * Test :
  69674. * Is the cullable object bounding sphere center in the frustum ?
  69675. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69676. */
  69677. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69678. /**
  69679. * No logging while loading
  69680. */
  69681. static readonly SCENELOADER_NO_LOGGING: number;
  69682. /**
  69683. * Minimal logging while loading
  69684. */
  69685. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69686. /**
  69687. * Summary logging while loading
  69688. */
  69689. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69690. /**
  69691. * Detailled logging while loading
  69692. */
  69693. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69694. }
  69695. }
  69696. declare module BABYLON {
  69697. /**
  69698. * This represents the required contract to create a new type of texture loader.
  69699. */
  69700. export interface IInternalTextureLoader {
  69701. /**
  69702. * Defines wether the loader supports cascade loading the different faces.
  69703. */
  69704. supportCascades: boolean;
  69705. /**
  69706. * This returns if the loader support the current file information.
  69707. * @param extension defines the file extension of the file being loaded
  69708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69709. * @param fallback defines the fallback internal texture if any
  69710. * @param isBase64 defines whether the texture is encoded as a base64
  69711. * @param isBuffer defines whether the texture data are stored as a buffer
  69712. * @returns true if the loader can load the specified file
  69713. */
  69714. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69715. /**
  69716. * Transform the url before loading if required.
  69717. * @param rootUrl the url of the texture
  69718. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69719. * @returns the transformed texture
  69720. */
  69721. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69722. /**
  69723. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69724. * @param rootUrl the url of the texture
  69725. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69726. * @returns the fallback texture
  69727. */
  69728. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69729. /**
  69730. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69731. * @param data contains the texture data
  69732. * @param texture defines the BabylonJS internal texture
  69733. * @param createPolynomials will be true if polynomials have been requested
  69734. * @param onLoad defines the callback to trigger once the texture is ready
  69735. * @param onError defines the callback to trigger in case of error
  69736. */
  69737. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69738. /**
  69739. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69740. * @param data contains the texture data
  69741. * @param texture defines the BabylonJS internal texture
  69742. * @param callback defines the method to call once ready to upload
  69743. */
  69744. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69745. }
  69746. }
  69747. declare module BABYLON {
  69748. /**
  69749. * Class used to store and describe the pipeline context associated with an effect
  69750. */
  69751. export interface IPipelineContext {
  69752. /**
  69753. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69754. */
  69755. isAsync: boolean;
  69756. /**
  69757. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69758. */
  69759. isReady: boolean;
  69760. /** @hidden */
  69761. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69762. }
  69763. }
  69764. declare module BABYLON {
  69765. /**
  69766. * Class used to store gfx data (like WebGLBuffer)
  69767. */
  69768. export class DataBuffer {
  69769. /**
  69770. * Gets or sets the number of objects referencing this buffer
  69771. */
  69772. references: number;
  69773. /** Gets or sets the size of the underlying buffer */
  69774. capacity: number;
  69775. /**
  69776. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69777. */
  69778. is32Bits: boolean;
  69779. /**
  69780. * Gets the underlying buffer
  69781. */
  69782. readonly underlyingResource: any;
  69783. }
  69784. }
  69785. declare module BABYLON {
  69786. /** @hidden */
  69787. export interface IShaderProcessor {
  69788. attributeProcessor?: (attribute: string) => string;
  69789. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69790. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69791. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69792. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69793. lineProcessor?: (line: string, isFragment: boolean) => string;
  69794. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69795. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69796. }
  69797. }
  69798. declare module BABYLON {
  69799. /** @hidden */
  69800. export interface ProcessingOptions {
  69801. defines: string[];
  69802. indexParameters: any;
  69803. isFragment: boolean;
  69804. shouldUseHighPrecisionShader: boolean;
  69805. supportsUniformBuffers: boolean;
  69806. shadersRepository: string;
  69807. includesShadersStore: {
  69808. [key: string]: string;
  69809. };
  69810. processor?: IShaderProcessor;
  69811. version: string;
  69812. platformName: string;
  69813. lookForClosingBracketForUniformBuffer?: boolean;
  69814. }
  69815. }
  69816. declare module BABYLON {
  69817. /** @hidden */
  69818. export class ShaderCodeNode {
  69819. line: string;
  69820. children: ShaderCodeNode[];
  69821. additionalDefineKey?: string;
  69822. additionalDefineValue?: string;
  69823. isValid(preprocessors: {
  69824. [key: string]: string;
  69825. }): boolean;
  69826. process(preprocessors: {
  69827. [key: string]: string;
  69828. }, options: ProcessingOptions): string;
  69829. }
  69830. }
  69831. declare module BABYLON {
  69832. /** @hidden */
  69833. export class ShaderCodeCursor {
  69834. private _lines;
  69835. lineIndex: number;
  69836. readonly currentLine: string;
  69837. readonly canRead: boolean;
  69838. lines: string[];
  69839. }
  69840. }
  69841. declare module BABYLON {
  69842. /** @hidden */
  69843. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69844. process(preprocessors: {
  69845. [key: string]: string;
  69846. }, options: ProcessingOptions): string;
  69847. }
  69848. }
  69849. declare module BABYLON {
  69850. /** @hidden */
  69851. export class ShaderDefineExpression {
  69852. isTrue(preprocessors: {
  69853. [key: string]: string;
  69854. }): boolean;
  69855. }
  69856. }
  69857. declare module BABYLON {
  69858. /** @hidden */
  69859. export class ShaderCodeTestNode extends ShaderCodeNode {
  69860. testExpression: ShaderDefineExpression;
  69861. isValid(preprocessors: {
  69862. [key: string]: string;
  69863. }): boolean;
  69864. }
  69865. }
  69866. declare module BABYLON {
  69867. /** @hidden */
  69868. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69869. define: string;
  69870. not: boolean;
  69871. constructor(define: string, not?: boolean);
  69872. isTrue(preprocessors: {
  69873. [key: string]: string;
  69874. }): boolean;
  69875. }
  69876. }
  69877. declare module BABYLON {
  69878. /** @hidden */
  69879. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69880. leftOperand: ShaderDefineExpression;
  69881. rightOperand: ShaderDefineExpression;
  69882. isTrue(preprocessors: {
  69883. [key: string]: string;
  69884. }): boolean;
  69885. }
  69886. }
  69887. declare module BABYLON {
  69888. /** @hidden */
  69889. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69890. leftOperand: ShaderDefineExpression;
  69891. rightOperand: ShaderDefineExpression;
  69892. isTrue(preprocessors: {
  69893. [key: string]: string;
  69894. }): boolean;
  69895. }
  69896. }
  69897. declare module BABYLON {
  69898. /** @hidden */
  69899. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69900. define: string;
  69901. operand: string;
  69902. testValue: string;
  69903. constructor(define: string, operand: string, testValue: string);
  69904. isTrue(preprocessors: {
  69905. [key: string]: string;
  69906. }): boolean;
  69907. }
  69908. }
  69909. declare module BABYLON {
  69910. /**
  69911. * Class used to enable access to offline support
  69912. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69913. */
  69914. export interface IOfflineProvider {
  69915. /**
  69916. * Gets a boolean indicating if scene must be saved in the database
  69917. */
  69918. enableSceneOffline: boolean;
  69919. /**
  69920. * Gets a boolean indicating if textures must be saved in the database
  69921. */
  69922. enableTexturesOffline: boolean;
  69923. /**
  69924. * Open the offline support and make it available
  69925. * @param successCallback defines the callback to call on success
  69926. * @param errorCallback defines the callback to call on error
  69927. */
  69928. open(successCallback: () => void, errorCallback: () => void): void;
  69929. /**
  69930. * Loads an image from the offline support
  69931. * @param url defines the url to load from
  69932. * @param image defines the target DOM image
  69933. */
  69934. loadImage(url: string, image: HTMLImageElement): void;
  69935. /**
  69936. * Loads a file from offline support
  69937. * @param url defines the URL to load from
  69938. * @param sceneLoaded defines a callback to call on success
  69939. * @param progressCallBack defines a callback to call when progress changed
  69940. * @param errorCallback defines a callback to call on error
  69941. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69942. */
  69943. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69944. }
  69945. }
  69946. declare module BABYLON {
  69947. /**
  69948. * Class used to help managing file picking and drag'n'drop
  69949. * File Storage
  69950. */
  69951. export class FilesInputStore {
  69952. /**
  69953. * List of files ready to be loaded
  69954. */
  69955. static FilesToLoad: {
  69956. [key: string]: File;
  69957. };
  69958. }
  69959. }
  69960. declare module BABYLON {
  69961. /**
  69962. * Class used to define a retry strategy when error happens while loading assets
  69963. */
  69964. export class RetryStrategy {
  69965. /**
  69966. * Function used to defines an exponential back off strategy
  69967. * @param maxRetries defines the maximum number of retries (3 by default)
  69968. * @param baseInterval defines the interval between retries
  69969. * @returns the strategy function to use
  69970. */
  69971. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69972. }
  69973. }
  69974. declare module BABYLON {
  69975. /**
  69976. * @ignore
  69977. * Application error to support additional information when loading a file
  69978. */
  69979. export abstract class BaseError extends Error {
  69980. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69981. }
  69982. }
  69983. declare module BABYLON {
  69984. /** @ignore */
  69985. export class LoadFileError extends BaseError {
  69986. request?: WebRequest;
  69987. file?: File;
  69988. /**
  69989. * Creates a new LoadFileError
  69990. * @param message defines the message of the error
  69991. * @param request defines the optional web request
  69992. * @param file defines the optional file
  69993. */
  69994. constructor(message: string, object?: WebRequest | File);
  69995. }
  69996. /** @ignore */
  69997. export class RequestFileError extends BaseError {
  69998. request: WebRequest;
  69999. /**
  70000. * Creates a new LoadFileError
  70001. * @param message defines the message of the error
  70002. * @param request defines the optional web request
  70003. */
  70004. constructor(message: string, request: WebRequest);
  70005. }
  70006. /** @ignore */
  70007. export class ReadFileError extends BaseError {
  70008. file: File;
  70009. /**
  70010. * Creates a new ReadFileError
  70011. * @param message defines the message of the error
  70012. * @param file defines the optional file
  70013. */
  70014. constructor(message: string, file: File);
  70015. }
  70016. /**
  70017. * @hidden
  70018. */
  70019. export class FileTools {
  70020. /**
  70021. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70022. */
  70023. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70024. /**
  70025. * Gets or sets the base URL to use to load assets
  70026. */
  70027. static BaseUrl: string;
  70028. /**
  70029. * Default behaviour for cors in the application.
  70030. * It can be a string if the expected behavior is identical in the entire app.
  70031. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70032. */
  70033. static CorsBehavior: string | ((url: string | string[]) => string);
  70034. /**
  70035. * Gets or sets a function used to pre-process url before using them to load assets
  70036. */
  70037. static PreprocessUrl: (url: string) => string;
  70038. /**
  70039. * Removes unwanted characters from an url
  70040. * @param url defines the url to clean
  70041. * @returns the cleaned url
  70042. */
  70043. private static _CleanUrl;
  70044. /**
  70045. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70046. * @param url define the url we are trying
  70047. * @param element define the dom element where to configure the cors policy
  70048. */
  70049. static SetCorsBehavior(url: string | string[], element: {
  70050. crossOrigin: string | null;
  70051. }): void;
  70052. /**
  70053. * Loads an image as an HTMLImageElement.
  70054. * @param input url string, ArrayBuffer, or Blob to load
  70055. * @param onLoad callback called when the image successfully loads
  70056. * @param onError callback called when the image fails to load
  70057. * @param offlineProvider offline provider for caching
  70058. * @param mimeType optional mime type
  70059. * @returns the HTMLImageElement of the loaded image
  70060. */
  70061. 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>;
  70062. /**
  70063. * Reads a file from a File object
  70064. * @param file defines the file to load
  70065. * @param onSuccess defines the callback to call when data is loaded
  70066. * @param onProgress defines the callback to call during loading process
  70067. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70068. * @param onError defines the callback to call when an error occurs
  70069. * @returns a file request object
  70070. */
  70071. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  70072. /**
  70073. * Loads a file from a url
  70074. * @param url url to load
  70075. * @param onSuccess callback called when the file successfully loads
  70076. * @param onProgress callback called while file is loading (if the server supports this mode)
  70077. * @param offlineProvider defines the offline provider for caching
  70078. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70079. * @param onError callback called when the file fails to load
  70080. * @returns a file request object
  70081. */
  70082. 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;
  70083. /**
  70084. * Loads a file
  70085. * @param url url to load
  70086. * @param onSuccess callback called when the file successfully loads
  70087. * @param onProgress callback called while file is loading (if the server supports this mode)
  70088. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70089. * @param onError callback called when the file fails to load
  70090. * @param onOpened callback called when the web request is opened
  70091. * @returns a file request object
  70092. */
  70093. 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;
  70094. /**
  70095. * Checks if the loaded document was accessed via `file:`-Protocol.
  70096. * @returns boolean
  70097. */
  70098. static IsFileURL(): boolean;
  70099. }
  70100. }
  70101. declare module BABYLON {
  70102. /** @hidden */
  70103. export class ShaderProcessor {
  70104. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70105. private static _ProcessPrecision;
  70106. private static _ExtractOperation;
  70107. private static _BuildSubExpression;
  70108. private static _BuildExpression;
  70109. private static _MoveCursorWithinIf;
  70110. private static _MoveCursor;
  70111. private static _EvaluatePreProcessors;
  70112. private static _PreparePreProcessors;
  70113. private static _ProcessShaderConversion;
  70114. private static _ProcessIncludes;
  70115. }
  70116. }
  70117. declare module BABYLON {
  70118. /**
  70119. * @hidden
  70120. */
  70121. export interface IColor4Like {
  70122. r: float;
  70123. g: float;
  70124. b: float;
  70125. a: float;
  70126. }
  70127. /**
  70128. * @hidden
  70129. */
  70130. export interface IColor3Like {
  70131. r: float;
  70132. g: float;
  70133. b: float;
  70134. }
  70135. /**
  70136. * @hidden
  70137. */
  70138. export interface IVector4Like {
  70139. x: float;
  70140. y: float;
  70141. z: float;
  70142. w: float;
  70143. }
  70144. /**
  70145. * @hidden
  70146. */
  70147. export interface IVector3Like {
  70148. x: float;
  70149. y: float;
  70150. z: float;
  70151. }
  70152. /**
  70153. * @hidden
  70154. */
  70155. export interface IVector2Like {
  70156. x: float;
  70157. y: float;
  70158. }
  70159. /**
  70160. * @hidden
  70161. */
  70162. export interface IMatrixLike {
  70163. toArray(): DeepImmutable<Float32Array>;
  70164. updateFlag: int;
  70165. }
  70166. /**
  70167. * @hidden
  70168. */
  70169. export interface IViewportLike {
  70170. x: float;
  70171. y: float;
  70172. width: float;
  70173. height: float;
  70174. }
  70175. /**
  70176. * @hidden
  70177. */
  70178. export interface IPlaneLike {
  70179. normal: IVector3Like;
  70180. d: float;
  70181. normalize(): void;
  70182. }
  70183. }
  70184. declare module BABYLON {
  70185. /**
  70186. * Interface used to define common properties for effect fallbacks
  70187. */
  70188. export interface IEffectFallbacks {
  70189. /**
  70190. * Removes the defines that should be removed when falling back.
  70191. * @param currentDefines defines the current define statements for the shader.
  70192. * @param effect defines the current effect we try to compile
  70193. * @returns The resulting defines with defines of the current rank removed.
  70194. */
  70195. reduce(currentDefines: string, effect: Effect): string;
  70196. /**
  70197. * Removes the fallback from the bound mesh.
  70198. */
  70199. unBindMesh(): void;
  70200. /**
  70201. * Checks to see if more fallbacks are still availible.
  70202. */
  70203. hasMoreFallbacks: boolean;
  70204. }
  70205. }
  70206. declare module BABYLON {
  70207. /**
  70208. * Class used to evalaute queries containing `and` and `or` operators
  70209. */
  70210. export class AndOrNotEvaluator {
  70211. /**
  70212. * Evaluate a query
  70213. * @param query defines the query to evaluate
  70214. * @param evaluateCallback defines the callback used to filter result
  70215. * @returns true if the query matches
  70216. */
  70217. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70218. private static _HandleParenthesisContent;
  70219. private static _SimplifyNegation;
  70220. }
  70221. }
  70222. declare module BABYLON {
  70223. /**
  70224. * Class used to store custom tags
  70225. */
  70226. export class Tags {
  70227. /**
  70228. * Adds support for tags on the given object
  70229. * @param obj defines the object to use
  70230. */
  70231. static EnableFor(obj: any): void;
  70232. /**
  70233. * Removes tags support
  70234. * @param obj defines the object to use
  70235. */
  70236. static DisableFor(obj: any): void;
  70237. /**
  70238. * Gets a boolean indicating if the given object has tags
  70239. * @param obj defines the object to use
  70240. * @returns a boolean
  70241. */
  70242. static HasTags(obj: any): boolean;
  70243. /**
  70244. * Gets the tags available on a given object
  70245. * @param obj defines the object to use
  70246. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70247. * @returns the tags
  70248. */
  70249. static GetTags(obj: any, asString?: boolean): any;
  70250. /**
  70251. * Adds tags to an object
  70252. * @param obj defines the object to use
  70253. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70254. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70255. */
  70256. static AddTagsTo(obj: any, tagsString: string): void;
  70257. /**
  70258. * @hidden
  70259. */
  70260. static _AddTagTo(obj: any, tag: string): void;
  70261. /**
  70262. * Removes specific tags from a specific object
  70263. * @param obj defines the object to use
  70264. * @param tagsString defines the tags to remove
  70265. */
  70266. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70267. /**
  70268. * @hidden
  70269. */
  70270. static _RemoveTagFrom(obj: any, tag: string): void;
  70271. /**
  70272. * Defines if tags hosted on an object match a given query
  70273. * @param obj defines the object to use
  70274. * @param tagsQuery defines the tag query
  70275. * @returns a boolean
  70276. */
  70277. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70278. }
  70279. }
  70280. declare module BABYLON {
  70281. /**
  70282. * Scalar computation library
  70283. */
  70284. export class Scalar {
  70285. /**
  70286. * Two pi constants convenient for computation.
  70287. */
  70288. static TwoPi: number;
  70289. /**
  70290. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70291. * @param a number
  70292. * @param b number
  70293. * @param epsilon (default = 1.401298E-45)
  70294. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70295. */
  70296. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  70297. /**
  70298. * Returns a string : the upper case translation of the number i to hexadecimal.
  70299. * @param i number
  70300. * @returns the upper case translation of the number i to hexadecimal.
  70301. */
  70302. static ToHex(i: number): string;
  70303. /**
  70304. * Returns -1 if value is negative and +1 is value is positive.
  70305. * @param value the value
  70306. * @returns the value itself if it's equal to zero.
  70307. */
  70308. static Sign(value: number): number;
  70309. /**
  70310. * Returns the value itself if it's between min and max.
  70311. * Returns min if the value is lower than min.
  70312. * Returns max if the value is greater than max.
  70313. * @param value the value to clmap
  70314. * @param min the min value to clamp to (default: 0)
  70315. * @param max the max value to clamp to (default: 1)
  70316. * @returns the clamped value
  70317. */
  70318. static Clamp(value: number, min?: number, max?: number): number;
  70319. /**
  70320. * the log2 of value.
  70321. * @param value the value to compute log2 of
  70322. * @returns the log2 of value.
  70323. */
  70324. static Log2(value: number): number;
  70325. /**
  70326. * Loops the value, so that it is never larger than length and never smaller than 0.
  70327. *
  70328. * This is similar to the modulo operator but it works with floating point numbers.
  70329. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70330. * With t = 5 and length = 2.5, the result would be 0.0.
  70331. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70332. * @param value the value
  70333. * @param length the length
  70334. * @returns the looped value
  70335. */
  70336. static Repeat(value: number, length: number): number;
  70337. /**
  70338. * Normalize the value between 0.0 and 1.0 using min and max values
  70339. * @param value value to normalize
  70340. * @param min max to normalize between
  70341. * @param max min to normalize between
  70342. * @returns the normalized value
  70343. */
  70344. static Normalize(value: number, min: number, max: number): number;
  70345. /**
  70346. * Denormalize the value from 0.0 and 1.0 using min and max values
  70347. * @param normalized value to denormalize
  70348. * @param min max to denormalize between
  70349. * @param max min to denormalize between
  70350. * @returns the denormalized value
  70351. */
  70352. static Denormalize(normalized: number, min: number, max: number): number;
  70353. /**
  70354. * Calculates the shortest difference between two given angles given in degrees.
  70355. * @param current current angle in degrees
  70356. * @param target target angle in degrees
  70357. * @returns the delta
  70358. */
  70359. static DeltaAngle(current: number, target: number): number;
  70360. /**
  70361. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70362. * @param tx value
  70363. * @param length length
  70364. * @returns The returned value will move back and forth between 0 and length
  70365. */
  70366. static PingPong(tx: number, length: number): number;
  70367. /**
  70368. * Interpolates between min and max with smoothing at the limits.
  70369. *
  70370. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70371. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70372. * @param from from
  70373. * @param to to
  70374. * @param tx value
  70375. * @returns the smooth stepped value
  70376. */
  70377. static SmoothStep(from: number, to: number, tx: number): number;
  70378. /**
  70379. * Moves a value current towards target.
  70380. *
  70381. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70382. * Negative values of maxDelta pushes the value away from target.
  70383. * @param current current value
  70384. * @param target target value
  70385. * @param maxDelta max distance to move
  70386. * @returns resulting value
  70387. */
  70388. static MoveTowards(current: number, target: number, maxDelta: number): number;
  70389. /**
  70390. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70391. *
  70392. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70393. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70394. * @param current current value
  70395. * @param target target value
  70396. * @param maxDelta max distance to move
  70397. * @returns resulting angle
  70398. */
  70399. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  70400. /**
  70401. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70402. * @param start start value
  70403. * @param end target value
  70404. * @param amount amount to lerp between
  70405. * @returns the lerped value
  70406. */
  70407. static Lerp(start: number, end: number, amount: number): number;
  70408. /**
  70409. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70410. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70411. * @param start start value
  70412. * @param end target value
  70413. * @param amount amount to lerp between
  70414. * @returns the lerped value
  70415. */
  70416. static LerpAngle(start: number, end: number, amount: number): number;
  70417. /**
  70418. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70419. * @param a start value
  70420. * @param b target value
  70421. * @param value value between a and b
  70422. * @returns the inverseLerp value
  70423. */
  70424. static InverseLerp(a: number, b: number, value: number): number;
  70425. /**
  70426. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70427. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70428. * @param value1 spline value
  70429. * @param tangent1 spline value
  70430. * @param value2 spline value
  70431. * @param tangent2 spline value
  70432. * @param amount input value
  70433. * @returns hermite result
  70434. */
  70435. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  70436. /**
  70437. * Returns a random float number between and min and max values
  70438. * @param min min value of random
  70439. * @param max max value of random
  70440. * @returns random value
  70441. */
  70442. static RandomRange(min: number, max: number): number;
  70443. /**
  70444. * This function returns percentage of a number in a given range.
  70445. *
  70446. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70447. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70448. * @param number to convert to percentage
  70449. * @param min min range
  70450. * @param max max range
  70451. * @returns the percentage
  70452. */
  70453. static RangeToPercent(number: number, min: number, max: number): number;
  70454. /**
  70455. * This function returns number that corresponds to the percentage in a given range.
  70456. *
  70457. * PercentToRange(0.34,0,100) will return 34.
  70458. * @param percent to convert to number
  70459. * @param min min range
  70460. * @param max max range
  70461. * @returns the number
  70462. */
  70463. static PercentToRange(percent: number, min: number, max: number): number;
  70464. /**
  70465. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70466. * @param angle The angle to normalize in radian.
  70467. * @return The converted angle.
  70468. */
  70469. static NormalizeRadians(angle: number): number;
  70470. }
  70471. }
  70472. declare module BABYLON {
  70473. /**
  70474. * Constant used to convert a value to gamma space
  70475. * @ignorenaming
  70476. */
  70477. export const ToGammaSpace: number;
  70478. /**
  70479. * Constant used to convert a value to linear space
  70480. * @ignorenaming
  70481. */
  70482. export const ToLinearSpace = 2.2;
  70483. /**
  70484. * Constant used to define the minimal number value in Babylon.js
  70485. * @ignorenaming
  70486. */
  70487. let Epsilon: number;
  70488. }
  70489. declare module BABYLON {
  70490. /**
  70491. * Class used to represent a viewport on screen
  70492. */
  70493. export class Viewport {
  70494. /** viewport left coordinate */
  70495. x: number;
  70496. /** viewport top coordinate */
  70497. y: number;
  70498. /**viewport width */
  70499. width: number;
  70500. /** viewport height */
  70501. height: number;
  70502. /**
  70503. * Creates a Viewport object located at (x, y) and sized (width, height)
  70504. * @param x defines viewport left coordinate
  70505. * @param y defines viewport top coordinate
  70506. * @param width defines the viewport width
  70507. * @param height defines the viewport height
  70508. */
  70509. constructor(
  70510. /** viewport left coordinate */
  70511. x: number,
  70512. /** viewport top coordinate */
  70513. y: number,
  70514. /**viewport width */
  70515. width: number,
  70516. /** viewport height */
  70517. height: number);
  70518. /**
  70519. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70520. * @param renderWidth defines the rendering width
  70521. * @param renderHeight defines the rendering height
  70522. * @returns a new Viewport
  70523. */
  70524. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70525. /**
  70526. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70527. * @param renderWidth defines the rendering width
  70528. * @param renderHeight defines the rendering height
  70529. * @param ref defines the target viewport
  70530. * @returns the current viewport
  70531. */
  70532. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70533. /**
  70534. * Returns a new Viewport copied from the current one
  70535. * @returns a new Viewport
  70536. */
  70537. clone(): Viewport;
  70538. }
  70539. }
  70540. declare module BABYLON {
  70541. /**
  70542. * Class containing a set of static utilities functions for arrays.
  70543. */
  70544. export class ArrayTools {
  70545. /**
  70546. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70547. * @param size the number of element to construct and put in the array
  70548. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70549. * @returns a new array filled with new objects
  70550. */
  70551. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70552. }
  70553. }
  70554. declare module BABYLON {
  70555. /**
  70556. * Class representing a vector containing 2 coordinates
  70557. */
  70558. export class Vector2 {
  70559. /** defines the first coordinate */
  70560. x: number;
  70561. /** defines the second coordinate */
  70562. y: number;
  70563. /**
  70564. * Creates a new Vector2 from the given x and y coordinates
  70565. * @param x defines the first coordinate
  70566. * @param y defines the second coordinate
  70567. */
  70568. constructor(
  70569. /** defines the first coordinate */
  70570. x?: number,
  70571. /** defines the second coordinate */
  70572. y?: number);
  70573. /**
  70574. * Gets a string with the Vector2 coordinates
  70575. * @returns a string with the Vector2 coordinates
  70576. */
  70577. toString(): string;
  70578. /**
  70579. * Gets class name
  70580. * @returns the string "Vector2"
  70581. */
  70582. getClassName(): string;
  70583. /**
  70584. * Gets current vector hash code
  70585. * @returns the Vector2 hash code as a number
  70586. */
  70587. getHashCode(): number;
  70588. /**
  70589. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70590. * @param array defines the source array
  70591. * @param index defines the offset in source array
  70592. * @returns the current Vector2
  70593. */
  70594. toArray(array: FloatArray, index?: number): Vector2;
  70595. /**
  70596. * Copy the current vector to an array
  70597. * @returns a new array with 2 elements: the Vector2 coordinates.
  70598. */
  70599. asArray(): number[];
  70600. /**
  70601. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70602. * @param source defines the source Vector2
  70603. * @returns the current updated Vector2
  70604. */
  70605. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70606. /**
  70607. * Sets the Vector2 coordinates with the given floats
  70608. * @param x defines the first coordinate
  70609. * @param y defines the second coordinate
  70610. * @returns the current updated Vector2
  70611. */
  70612. copyFromFloats(x: number, y: number): Vector2;
  70613. /**
  70614. * Sets the Vector2 coordinates with the given floats
  70615. * @param x defines the first coordinate
  70616. * @param y defines the second coordinate
  70617. * @returns the current updated Vector2
  70618. */
  70619. set(x: number, y: number): Vector2;
  70620. /**
  70621. * Add another vector with the current one
  70622. * @param otherVector defines the other vector
  70623. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70624. */
  70625. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70626. /**
  70627. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70628. * @param otherVector defines the other vector
  70629. * @param result defines the target vector
  70630. * @returns the unmodified current Vector2
  70631. */
  70632. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70633. /**
  70634. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70635. * @param otherVector defines the other vector
  70636. * @returns the current updated Vector2
  70637. */
  70638. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70639. /**
  70640. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70641. * @param otherVector defines the other vector
  70642. * @returns a new Vector2
  70643. */
  70644. addVector3(otherVector: Vector3): Vector2;
  70645. /**
  70646. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70647. * @param otherVector defines the other vector
  70648. * @returns a new Vector2
  70649. */
  70650. subtract(otherVector: Vector2): Vector2;
  70651. /**
  70652. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70653. * @param otherVector defines the other vector
  70654. * @param result defines the target vector
  70655. * @returns the unmodified current Vector2
  70656. */
  70657. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70658. /**
  70659. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70660. * @param otherVector defines the other vector
  70661. * @returns the current updated Vector2
  70662. */
  70663. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70664. /**
  70665. * Multiplies in place the current Vector2 coordinates by the given ones
  70666. * @param otherVector defines the other vector
  70667. * @returns the current updated Vector2
  70668. */
  70669. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70670. /**
  70671. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70672. * @param otherVector defines the other vector
  70673. * @returns a new Vector2
  70674. */
  70675. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70676. /**
  70677. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70678. * @param otherVector defines the other vector
  70679. * @param result defines the target vector
  70680. * @returns the unmodified current Vector2
  70681. */
  70682. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70683. /**
  70684. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70685. * @param x defines the first coordinate
  70686. * @param y defines the second coordinate
  70687. * @returns a new Vector2
  70688. */
  70689. multiplyByFloats(x: number, y: number): Vector2;
  70690. /**
  70691. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70692. * @param otherVector defines the other vector
  70693. * @returns a new Vector2
  70694. */
  70695. divide(otherVector: Vector2): Vector2;
  70696. /**
  70697. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70698. * @param otherVector defines the other vector
  70699. * @param result defines the target vector
  70700. * @returns the unmodified current Vector2
  70701. */
  70702. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70703. /**
  70704. * Divides the current Vector2 coordinates by the given ones
  70705. * @param otherVector defines the other vector
  70706. * @returns the current updated Vector2
  70707. */
  70708. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70709. /**
  70710. * Gets a new Vector2 with current Vector2 negated coordinates
  70711. * @returns a new Vector2
  70712. */
  70713. negate(): Vector2;
  70714. /**
  70715. * Multiply the Vector2 coordinates by scale
  70716. * @param scale defines the scaling factor
  70717. * @returns the current updated Vector2
  70718. */
  70719. scaleInPlace(scale: number): Vector2;
  70720. /**
  70721. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70722. * @param scale defines the scaling factor
  70723. * @returns a new Vector2
  70724. */
  70725. scale(scale: number): Vector2;
  70726. /**
  70727. * Scale the current Vector2 values by a factor to a given Vector2
  70728. * @param scale defines the scale factor
  70729. * @param result defines the Vector2 object where to store the result
  70730. * @returns the unmodified current Vector2
  70731. */
  70732. scaleToRef(scale: number, result: Vector2): Vector2;
  70733. /**
  70734. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70735. * @param scale defines the scale factor
  70736. * @param result defines the Vector2 object where to store the result
  70737. * @returns the unmodified current Vector2
  70738. */
  70739. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70740. /**
  70741. * Gets a boolean if two vectors are equals
  70742. * @param otherVector defines the other vector
  70743. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70744. */
  70745. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70746. /**
  70747. * Gets a boolean if two vectors are equals (using an epsilon value)
  70748. * @param otherVector defines the other vector
  70749. * @param epsilon defines the minimal distance to consider equality
  70750. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70751. */
  70752. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70753. /**
  70754. * Gets a new Vector2 from current Vector2 floored values
  70755. * @returns a new Vector2
  70756. */
  70757. floor(): Vector2;
  70758. /**
  70759. * Gets a new Vector2 from current Vector2 floored values
  70760. * @returns a new Vector2
  70761. */
  70762. fract(): Vector2;
  70763. /**
  70764. * Gets the length of the vector
  70765. * @returns the vector length (float)
  70766. */
  70767. length(): number;
  70768. /**
  70769. * Gets the vector squared length
  70770. * @returns the vector squared length (float)
  70771. */
  70772. lengthSquared(): number;
  70773. /**
  70774. * Normalize the vector
  70775. * @returns the current updated Vector2
  70776. */
  70777. normalize(): Vector2;
  70778. /**
  70779. * Gets a new Vector2 copied from the Vector2
  70780. * @returns a new Vector2
  70781. */
  70782. clone(): Vector2;
  70783. /**
  70784. * Gets a new Vector2(0, 0)
  70785. * @returns a new Vector2
  70786. */
  70787. static Zero(): Vector2;
  70788. /**
  70789. * Gets a new Vector2(1, 1)
  70790. * @returns a new Vector2
  70791. */
  70792. static One(): Vector2;
  70793. /**
  70794. * Gets a new Vector2 set from the given index element of the given array
  70795. * @param array defines the data source
  70796. * @param offset defines the offset in the data source
  70797. * @returns a new Vector2
  70798. */
  70799. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70800. /**
  70801. * Sets "result" from the given index element of the given array
  70802. * @param array defines the data source
  70803. * @param offset defines the offset in the data source
  70804. * @param result defines the target vector
  70805. */
  70806. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70807. /**
  70808. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70809. * @param value1 defines 1st point of control
  70810. * @param value2 defines 2nd point of control
  70811. * @param value3 defines 3rd point of control
  70812. * @param value4 defines 4th point of control
  70813. * @param amount defines the interpolation factor
  70814. * @returns a new Vector2
  70815. */
  70816. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70817. /**
  70818. * 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".
  70819. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70820. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70821. * @param value defines the value to clamp
  70822. * @param min defines the lower limit
  70823. * @param max defines the upper limit
  70824. * @returns a new Vector2
  70825. */
  70826. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70827. /**
  70828. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70829. * @param value1 defines the 1st control point
  70830. * @param tangent1 defines the outgoing tangent
  70831. * @param value2 defines the 2nd control point
  70832. * @param tangent2 defines the incoming tangent
  70833. * @param amount defines the interpolation factor
  70834. * @returns a new Vector2
  70835. */
  70836. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70837. /**
  70838. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70839. * @param start defines the start vector
  70840. * @param end defines the end vector
  70841. * @param amount defines the interpolation factor
  70842. * @returns a new Vector2
  70843. */
  70844. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70845. /**
  70846. * Gets the dot product of the vector "left" and the vector "right"
  70847. * @param left defines first vector
  70848. * @param right defines second vector
  70849. * @returns the dot product (float)
  70850. */
  70851. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70852. /**
  70853. * Returns a new Vector2 equal to the normalized given vector
  70854. * @param vector defines the vector to normalize
  70855. * @returns a new Vector2
  70856. */
  70857. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70858. /**
  70859. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70860. * @param left defines 1st vector
  70861. * @param right defines 2nd vector
  70862. * @returns a new Vector2
  70863. */
  70864. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70865. /**
  70866. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70867. * @param left defines 1st vector
  70868. * @param right defines 2nd vector
  70869. * @returns a new Vector2
  70870. */
  70871. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70872. /**
  70873. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70874. * @param vector defines the vector to transform
  70875. * @param transformation defines the matrix to apply
  70876. * @returns a new Vector2
  70877. */
  70878. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70879. /**
  70880. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70881. * @param vector defines the vector to transform
  70882. * @param transformation defines the matrix to apply
  70883. * @param result defines the target vector
  70884. */
  70885. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70886. /**
  70887. * Determines if a given vector is included in a triangle
  70888. * @param p defines the vector to test
  70889. * @param p0 defines 1st triangle point
  70890. * @param p1 defines 2nd triangle point
  70891. * @param p2 defines 3rd triangle point
  70892. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70893. */
  70894. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70895. /**
  70896. * Gets the distance between the vectors "value1" and "value2"
  70897. * @param value1 defines first vector
  70898. * @param value2 defines second vector
  70899. * @returns the distance between vectors
  70900. */
  70901. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70902. /**
  70903. * Returns the squared distance between the vectors "value1" and "value2"
  70904. * @param value1 defines first vector
  70905. * @param value2 defines second vector
  70906. * @returns the squared distance between vectors
  70907. */
  70908. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70909. /**
  70910. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70911. * @param value1 defines first vector
  70912. * @param value2 defines second vector
  70913. * @returns a new Vector2
  70914. */
  70915. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70916. /**
  70917. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70918. * @param p defines the middle point
  70919. * @param segA defines one point of the segment
  70920. * @param segB defines the other point of the segment
  70921. * @returns the shortest distance
  70922. */
  70923. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70924. }
  70925. /**
  70926. * Classed used to store (x,y,z) vector representation
  70927. * A Vector3 is the main object used in 3D geometry
  70928. * It can represent etiher the coordinates of a point the space, either a direction
  70929. * Reminder: js uses a left handed forward facing system
  70930. */
  70931. export class Vector3 {
  70932. /**
  70933. * Defines the first coordinates (on X axis)
  70934. */
  70935. x: number;
  70936. /**
  70937. * Defines the second coordinates (on Y axis)
  70938. */
  70939. y: number;
  70940. /**
  70941. * Defines the third coordinates (on Z axis)
  70942. */
  70943. z: number;
  70944. private static _UpReadOnly;
  70945. private static _ZeroReadOnly;
  70946. /**
  70947. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70948. * @param x defines the first coordinates (on X axis)
  70949. * @param y defines the second coordinates (on Y axis)
  70950. * @param z defines the third coordinates (on Z axis)
  70951. */
  70952. constructor(
  70953. /**
  70954. * Defines the first coordinates (on X axis)
  70955. */
  70956. x?: number,
  70957. /**
  70958. * Defines the second coordinates (on Y axis)
  70959. */
  70960. y?: number,
  70961. /**
  70962. * Defines the third coordinates (on Z axis)
  70963. */
  70964. z?: number);
  70965. /**
  70966. * Creates a string representation of the Vector3
  70967. * @returns a string with the Vector3 coordinates.
  70968. */
  70969. toString(): string;
  70970. /**
  70971. * Gets the class name
  70972. * @returns the string "Vector3"
  70973. */
  70974. getClassName(): string;
  70975. /**
  70976. * Creates the Vector3 hash code
  70977. * @returns a number which tends to be unique between Vector3 instances
  70978. */
  70979. getHashCode(): number;
  70980. /**
  70981. * Creates an array containing three elements : the coordinates of the Vector3
  70982. * @returns a new array of numbers
  70983. */
  70984. asArray(): number[];
  70985. /**
  70986. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70987. * @param array defines the destination array
  70988. * @param index defines the offset in the destination array
  70989. * @returns the current Vector3
  70990. */
  70991. toArray(array: FloatArray, index?: number): Vector3;
  70992. /**
  70993. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70994. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70995. */
  70996. toQuaternion(): Quaternion;
  70997. /**
  70998. * Adds the given vector to the current Vector3
  70999. * @param otherVector defines the second operand
  71000. * @returns the current updated Vector3
  71001. */
  71002. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71003. /**
  71004. * Adds the given coordinates to the current Vector3
  71005. * @param x defines the x coordinate of the operand
  71006. * @param y defines the y coordinate of the operand
  71007. * @param z defines the z coordinate of the operand
  71008. * @returns the current updated Vector3
  71009. */
  71010. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71011. /**
  71012. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71013. * @param otherVector defines the second operand
  71014. * @returns the resulting Vector3
  71015. */
  71016. add(otherVector: DeepImmutable<Vector3>): Vector3;
  71017. /**
  71018. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71019. * @param otherVector defines the second operand
  71020. * @param result defines the Vector3 object where to store the result
  71021. * @returns the current Vector3
  71022. */
  71023. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71024. /**
  71025. * Subtract the given vector from the current Vector3
  71026. * @param otherVector defines the second operand
  71027. * @returns the current updated Vector3
  71028. */
  71029. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71030. /**
  71031. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71032. * @param otherVector defines the second operand
  71033. * @returns the resulting Vector3
  71034. */
  71035. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  71036. /**
  71037. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71038. * @param otherVector defines the second operand
  71039. * @param result defines the Vector3 object where to store the result
  71040. * @returns the current Vector3
  71041. */
  71042. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71043. /**
  71044. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71045. * @param x defines the x coordinate of the operand
  71046. * @param y defines the y coordinate of the operand
  71047. * @param z defines the z coordinate of the operand
  71048. * @returns the resulting Vector3
  71049. */
  71050. subtractFromFloats(x: number, y: number, z: number): Vector3;
  71051. /**
  71052. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71053. * @param x defines the x coordinate of the operand
  71054. * @param y defines the y coordinate of the operand
  71055. * @param z defines the z coordinate of the operand
  71056. * @param result defines the Vector3 object where to store the result
  71057. * @returns the current Vector3
  71058. */
  71059. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  71060. /**
  71061. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71062. * @returns a new Vector3
  71063. */
  71064. negate(): Vector3;
  71065. /**
  71066. * Multiplies the Vector3 coordinates by the float "scale"
  71067. * @param scale defines the multiplier factor
  71068. * @returns the current updated Vector3
  71069. */
  71070. scaleInPlace(scale: number): Vector3;
  71071. /**
  71072. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71073. * @param scale defines the multiplier factor
  71074. * @returns a new Vector3
  71075. */
  71076. scale(scale: number): Vector3;
  71077. /**
  71078. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71079. * @param scale defines the multiplier factor
  71080. * @param result defines the Vector3 object where to store the result
  71081. * @returns the current Vector3
  71082. */
  71083. scaleToRef(scale: number, result: Vector3): Vector3;
  71084. /**
  71085. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71086. * @param scale defines the scale factor
  71087. * @param result defines the Vector3 object where to store the result
  71088. * @returns the unmodified current Vector3
  71089. */
  71090. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  71091. /**
  71092. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71093. * @param otherVector defines the second operand
  71094. * @returns true if both vectors are equals
  71095. */
  71096. equals(otherVector: DeepImmutable<Vector3>): boolean;
  71097. /**
  71098. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71099. * @param otherVector defines the second operand
  71100. * @param epsilon defines the minimal distance to define values as equals
  71101. * @returns true if both vectors are distant less than epsilon
  71102. */
  71103. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  71104. /**
  71105. * Returns true if the current Vector3 coordinates equals the given floats
  71106. * @param x defines the x coordinate of the operand
  71107. * @param y defines the y coordinate of the operand
  71108. * @param z defines the z coordinate of the operand
  71109. * @returns true if both vectors are equals
  71110. */
  71111. equalsToFloats(x: number, y: number, z: number): boolean;
  71112. /**
  71113. * Multiplies the current Vector3 coordinates by the given ones
  71114. * @param otherVector defines the second operand
  71115. * @returns the current updated Vector3
  71116. */
  71117. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71118. /**
  71119. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71120. * @param otherVector defines the second operand
  71121. * @returns the new Vector3
  71122. */
  71123. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  71124. /**
  71125. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71126. * @param otherVector defines the second operand
  71127. * @param result defines the Vector3 object where to store the result
  71128. * @returns the current Vector3
  71129. */
  71130. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71131. /**
  71132. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71133. * @param x defines the x coordinate of the operand
  71134. * @param y defines the y coordinate of the operand
  71135. * @param z defines the z coordinate of the operand
  71136. * @returns the new Vector3
  71137. */
  71138. multiplyByFloats(x: number, y: number, z: number): Vector3;
  71139. /**
  71140. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71141. * @param otherVector defines the second operand
  71142. * @returns the new Vector3
  71143. */
  71144. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  71145. /**
  71146. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71147. * @param otherVector defines the second operand
  71148. * @param result defines the Vector3 object where to store the result
  71149. * @returns the current Vector3
  71150. */
  71151. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71152. /**
  71153. * Divides the current Vector3 coordinates by the given ones.
  71154. * @param otherVector defines the second operand
  71155. * @returns the current updated Vector3
  71156. */
  71157. divideInPlace(otherVector: Vector3): Vector3;
  71158. /**
  71159. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71160. * @param other defines the second operand
  71161. * @returns the current updated Vector3
  71162. */
  71163. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71164. /**
  71165. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71166. * @param other defines the second operand
  71167. * @returns the current updated Vector3
  71168. */
  71169. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71170. /**
  71171. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71172. * @param x defines the x coordinate of the operand
  71173. * @param y defines the y coordinate of the operand
  71174. * @param z defines the z coordinate of the operand
  71175. * @returns the current updated Vector3
  71176. */
  71177. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71178. /**
  71179. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71180. * @param x defines the x coordinate of the operand
  71181. * @param y defines the y coordinate of the operand
  71182. * @param z defines the z coordinate of the operand
  71183. * @returns the current updated Vector3
  71184. */
  71185. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71186. /**
  71187. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71188. * Check if is non uniform within a certain amount of decimal places to account for this
  71189. * @param epsilon the amount the values can differ
  71190. * @returns if the the vector is non uniform to a certain number of decimal places
  71191. */
  71192. isNonUniformWithinEpsilon(epsilon: number): boolean;
  71193. /**
  71194. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71195. */
  71196. readonly isNonUniform: boolean;
  71197. /**
  71198. * Gets a new Vector3 from current Vector3 floored values
  71199. * @returns a new Vector3
  71200. */
  71201. floor(): Vector3;
  71202. /**
  71203. * Gets a new Vector3 from current Vector3 floored values
  71204. * @returns a new Vector3
  71205. */
  71206. fract(): Vector3;
  71207. /**
  71208. * Gets the length of the Vector3
  71209. * @returns the length of the Vector3
  71210. */
  71211. length(): number;
  71212. /**
  71213. * Gets the squared length of the Vector3
  71214. * @returns squared length of the Vector3
  71215. */
  71216. lengthSquared(): number;
  71217. /**
  71218. * Normalize the current Vector3.
  71219. * Please note that this is an in place operation.
  71220. * @returns the current updated Vector3
  71221. */
  71222. normalize(): Vector3;
  71223. /**
  71224. * Reorders the x y z properties of the vector in place
  71225. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71226. * @returns the current updated vector
  71227. */
  71228. reorderInPlace(order: string): this;
  71229. /**
  71230. * Rotates the vector around 0,0,0 by a quaternion
  71231. * @param quaternion the rotation quaternion
  71232. * @param result vector to store the result
  71233. * @returns the resulting vector
  71234. */
  71235. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  71236. /**
  71237. * Rotates a vector around a given point
  71238. * @param quaternion the rotation quaternion
  71239. * @param point the point to rotate around
  71240. * @param result vector to store the result
  71241. * @returns the resulting vector
  71242. */
  71243. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  71244. /**
  71245. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  71246. * The cross product is then orthogonal to both current and "other"
  71247. * @param other defines the right operand
  71248. * @returns the cross product
  71249. */
  71250. cross(other: Vector3): Vector3;
  71251. /**
  71252. * Normalize the current Vector3 with the given input length.
  71253. * Please note that this is an in place operation.
  71254. * @param len the length of the vector
  71255. * @returns the current updated Vector3
  71256. */
  71257. normalizeFromLength(len: number): Vector3;
  71258. /**
  71259. * Normalize the current Vector3 to a new vector
  71260. * @returns the new Vector3
  71261. */
  71262. normalizeToNew(): Vector3;
  71263. /**
  71264. * Normalize the current Vector3 to the reference
  71265. * @param reference define the Vector3 to update
  71266. * @returns the updated Vector3
  71267. */
  71268. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  71269. /**
  71270. * Creates a new Vector3 copied from the current Vector3
  71271. * @returns the new Vector3
  71272. */
  71273. clone(): Vector3;
  71274. /**
  71275. * Copies the given vector coordinates to the current Vector3 ones
  71276. * @param source defines the source Vector3
  71277. * @returns the current updated Vector3
  71278. */
  71279. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  71280. /**
  71281. * Copies the given floats to the current Vector3 coordinates
  71282. * @param x defines the x coordinate of the operand
  71283. * @param y defines the y coordinate of the operand
  71284. * @param z defines the z coordinate of the operand
  71285. * @returns the current updated Vector3
  71286. */
  71287. copyFromFloats(x: number, y: number, z: number): Vector3;
  71288. /**
  71289. * Copies the given floats to the current Vector3 coordinates
  71290. * @param x defines the x coordinate of the operand
  71291. * @param y defines the y coordinate of the operand
  71292. * @param z defines the z coordinate of the operand
  71293. * @returns the current updated Vector3
  71294. */
  71295. set(x: number, y: number, z: number): Vector3;
  71296. /**
  71297. * Copies the given float to the current Vector3 coordinates
  71298. * @param v defines the x, y and z coordinates of the operand
  71299. * @returns the current updated Vector3
  71300. */
  71301. setAll(v: number): Vector3;
  71302. /**
  71303. * Get the clip factor between two vectors
  71304. * @param vector0 defines the first operand
  71305. * @param vector1 defines the second operand
  71306. * @param axis defines the axis to use
  71307. * @param size defines the size along the axis
  71308. * @returns the clip factor
  71309. */
  71310. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  71311. /**
  71312. * Get angle between two vectors
  71313. * @param vector0 angle between vector0 and vector1
  71314. * @param vector1 angle between vector0 and vector1
  71315. * @param normal direction of the normal
  71316. * @return the angle between vector0 and vector1
  71317. */
  71318. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  71319. /**
  71320. * Returns a new Vector3 set from the index "offset" of the given array
  71321. * @param array defines the source array
  71322. * @param offset defines the offset in the source array
  71323. * @returns the new Vector3
  71324. */
  71325. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  71326. /**
  71327. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71328. * This function is deprecated. Use FromArray instead
  71329. * @param array defines the source array
  71330. * @param offset defines the offset in the source array
  71331. * @returns the new Vector3
  71332. */
  71333. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  71334. /**
  71335. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71336. * @param array defines the source array
  71337. * @param offset defines the offset in the source array
  71338. * @param result defines the Vector3 where to store the result
  71339. */
  71340. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  71341. /**
  71342. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71343. * This function is deprecated. Use FromArrayToRef instead.
  71344. * @param array defines the source array
  71345. * @param offset defines the offset in the source array
  71346. * @param result defines the Vector3 where to store the result
  71347. */
  71348. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  71349. /**
  71350. * Sets the given vector "result" with the given floats.
  71351. * @param x defines the x coordinate of the source
  71352. * @param y defines the y coordinate of the source
  71353. * @param z defines the z coordinate of the source
  71354. * @param result defines the Vector3 where to store the result
  71355. */
  71356. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  71357. /**
  71358. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71359. * @returns a new empty Vector3
  71360. */
  71361. static Zero(): Vector3;
  71362. /**
  71363. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71364. * @returns a new unit Vector3
  71365. */
  71366. static One(): Vector3;
  71367. /**
  71368. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71369. * @returns a new up Vector3
  71370. */
  71371. static Up(): Vector3;
  71372. /**
  71373. * Gets a up Vector3 that must not be updated
  71374. */
  71375. static readonly UpReadOnly: DeepImmutable<Vector3>;
  71376. /**
  71377. * Gets a zero Vector3 that must not be updated
  71378. */
  71379. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  71380. /**
  71381. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71382. * @returns a new down Vector3
  71383. */
  71384. static Down(): Vector3;
  71385. /**
  71386. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71387. * @returns a new forward Vector3
  71388. */
  71389. static Forward(): Vector3;
  71390. /**
  71391. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71392. * @returns a new forward Vector3
  71393. */
  71394. static Backward(): Vector3;
  71395. /**
  71396. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71397. * @returns a new right Vector3
  71398. */
  71399. static Right(): Vector3;
  71400. /**
  71401. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71402. * @returns a new left Vector3
  71403. */
  71404. static Left(): Vector3;
  71405. /**
  71406. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71407. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71408. * @param vector defines the Vector3 to transform
  71409. * @param transformation defines the transformation matrix
  71410. * @returns the transformed Vector3
  71411. */
  71412. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71413. /**
  71414. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71415. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71416. * @param vector defines the Vector3 to transform
  71417. * @param transformation defines the transformation matrix
  71418. * @param result defines the Vector3 where to store the result
  71419. */
  71420. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71421. /**
  71422. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71423. * This method computes tranformed coordinates only, not transformed direction vectors
  71424. * @param x define the x coordinate of the source vector
  71425. * @param y define the y coordinate of the source vector
  71426. * @param z define the z coordinate of the source vector
  71427. * @param transformation defines the transformation matrix
  71428. * @param result defines the Vector3 where to store the result
  71429. */
  71430. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71431. /**
  71432. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71433. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71434. * @param vector defines the Vector3 to transform
  71435. * @param transformation defines the transformation matrix
  71436. * @returns the new Vector3
  71437. */
  71438. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71439. /**
  71440. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71441. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71442. * @param vector defines the Vector3 to transform
  71443. * @param transformation defines the transformation matrix
  71444. * @param result defines the Vector3 where to store the result
  71445. */
  71446. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71447. /**
  71448. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71449. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71450. * @param x define the x coordinate of the source vector
  71451. * @param y define the y coordinate of the source vector
  71452. * @param z define the z coordinate of the source vector
  71453. * @param transformation defines the transformation matrix
  71454. * @param result defines the Vector3 where to store the result
  71455. */
  71456. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71457. /**
  71458. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71459. * @param value1 defines the first control point
  71460. * @param value2 defines the second control point
  71461. * @param value3 defines the third control point
  71462. * @param value4 defines the fourth control point
  71463. * @param amount defines the amount on the spline to use
  71464. * @returns the new Vector3
  71465. */
  71466. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  71467. /**
  71468. * 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"
  71469. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71470. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71471. * @param value defines the current value
  71472. * @param min defines the lower range value
  71473. * @param max defines the upper range value
  71474. * @returns the new Vector3
  71475. */
  71476. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  71477. /**
  71478. * 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"
  71479. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71480. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71481. * @param value defines the current value
  71482. * @param min defines the lower range value
  71483. * @param max defines the upper range value
  71484. * @param result defines the Vector3 where to store the result
  71485. */
  71486. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  71487. /**
  71488. * Checks if a given vector is inside a specific range
  71489. * @param v defines the vector to test
  71490. * @param min defines the minimum range
  71491. * @param max defines the maximum range
  71492. */
  71493. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  71494. /**
  71495. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71496. * @param value1 defines the first control point
  71497. * @param tangent1 defines the first tangent vector
  71498. * @param value2 defines the second control point
  71499. * @param tangent2 defines the second tangent vector
  71500. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71501. * @returns the new Vector3
  71502. */
  71503. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  71504. /**
  71505. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71506. * @param start defines the start value
  71507. * @param end defines the end value
  71508. * @param amount max defines amount between both (between 0 and 1)
  71509. * @returns the new Vector3
  71510. */
  71511. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71512. /**
  71513. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71514. * @param start defines the start value
  71515. * @param end defines the end value
  71516. * @param amount max defines amount between both (between 0 and 1)
  71517. * @param result defines the Vector3 where to store the result
  71518. */
  71519. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71520. /**
  71521. * Returns the dot product (float) between the vectors "left" and "right"
  71522. * @param left defines the left operand
  71523. * @param right defines the right operand
  71524. * @returns the dot product
  71525. */
  71526. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71527. /**
  71528. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71529. * The cross product is then orthogonal to both "left" and "right"
  71530. * @param left defines the left operand
  71531. * @param right defines the right operand
  71532. * @returns the cross product
  71533. */
  71534. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71535. /**
  71536. * Sets the given vector "result" with the cross product of "left" and "right"
  71537. * The cross product is then orthogonal to both "left" and "right"
  71538. * @param left defines the left operand
  71539. * @param right defines the right operand
  71540. * @param result defines the Vector3 where to store the result
  71541. */
  71542. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71543. /**
  71544. * Returns a new Vector3 as the normalization of the given vector
  71545. * @param vector defines the Vector3 to normalize
  71546. * @returns the new Vector3
  71547. */
  71548. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71549. /**
  71550. * Sets the given vector "result" with the normalization of the given first vector
  71551. * @param vector defines the Vector3 to normalize
  71552. * @param result defines the Vector3 where to store the result
  71553. */
  71554. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71555. /**
  71556. * Project a Vector3 onto screen space
  71557. * @param vector defines the Vector3 to project
  71558. * @param world defines the world matrix to use
  71559. * @param transform defines the transform (view x projection) matrix to use
  71560. * @param viewport defines the screen viewport to use
  71561. * @returns the new Vector3
  71562. */
  71563. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71564. /** @hidden */
  71565. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71566. /**
  71567. * Unproject from screen space to object space
  71568. * @param source defines the screen space Vector3 to use
  71569. * @param viewportWidth defines the current width of the viewport
  71570. * @param viewportHeight defines the current height of the viewport
  71571. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71572. * @param transform defines the transform (view x projection) matrix to use
  71573. * @returns the new Vector3
  71574. */
  71575. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71576. /**
  71577. * Unproject from screen space to object space
  71578. * @param source defines the screen space Vector3 to use
  71579. * @param viewportWidth defines the current width of the viewport
  71580. * @param viewportHeight defines the current height of the viewport
  71581. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71582. * @param view defines the view matrix to use
  71583. * @param projection defines the projection matrix to use
  71584. * @returns the new Vector3
  71585. */
  71586. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71587. /**
  71588. * Unproject from screen space to object space
  71589. * @param source defines the screen space Vector3 to use
  71590. * @param viewportWidth defines the current width of the viewport
  71591. * @param viewportHeight defines the current height of the viewport
  71592. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71593. * @param view defines the view matrix to use
  71594. * @param projection defines the projection matrix to use
  71595. * @param result defines the Vector3 where to store the result
  71596. */
  71597. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71598. /**
  71599. * Unproject from screen space to object space
  71600. * @param sourceX defines the screen space x coordinate to use
  71601. * @param sourceY defines the screen space y coordinate to use
  71602. * @param sourceZ defines the screen space z coordinate to use
  71603. * @param viewportWidth defines the current width of the viewport
  71604. * @param viewportHeight defines the current height of the viewport
  71605. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71606. * @param view defines the view matrix to use
  71607. * @param projection defines the projection matrix to use
  71608. * @param result defines the Vector3 where to store the result
  71609. */
  71610. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71611. /**
  71612. * Gets the minimal coordinate values between two Vector3
  71613. * @param left defines the first operand
  71614. * @param right defines the second operand
  71615. * @returns the new Vector3
  71616. */
  71617. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71618. /**
  71619. * Gets the maximal coordinate values between two Vector3
  71620. * @param left defines the first operand
  71621. * @param right defines the second operand
  71622. * @returns the new Vector3
  71623. */
  71624. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71625. /**
  71626. * Returns the distance between the vectors "value1" and "value2"
  71627. * @param value1 defines the first operand
  71628. * @param value2 defines the second operand
  71629. * @returns the distance
  71630. */
  71631. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71632. /**
  71633. * Returns the squared distance between the vectors "value1" and "value2"
  71634. * @param value1 defines the first operand
  71635. * @param value2 defines the second operand
  71636. * @returns the squared distance
  71637. */
  71638. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71639. /**
  71640. * Returns a new Vector3 located at the center between "value1" and "value2"
  71641. * @param value1 defines the first operand
  71642. * @param value2 defines the second operand
  71643. * @returns the new Vector3
  71644. */
  71645. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71646. /**
  71647. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71648. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71649. * to something in order to rotate it from its local system to the given target system
  71650. * Note: axis1, axis2 and axis3 are normalized during this operation
  71651. * @param axis1 defines the first axis
  71652. * @param axis2 defines the second axis
  71653. * @param axis3 defines the third axis
  71654. * @returns a new Vector3
  71655. */
  71656. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71657. /**
  71658. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71659. * @param axis1 defines the first axis
  71660. * @param axis2 defines the second axis
  71661. * @param axis3 defines the third axis
  71662. * @param ref defines the Vector3 where to store the result
  71663. */
  71664. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71665. }
  71666. /**
  71667. * Vector4 class created for EulerAngle class conversion to Quaternion
  71668. */
  71669. export class Vector4 {
  71670. /** x value of the vector */
  71671. x: number;
  71672. /** y value of the vector */
  71673. y: number;
  71674. /** z value of the vector */
  71675. z: number;
  71676. /** w value of the vector */
  71677. w: number;
  71678. /**
  71679. * Creates a Vector4 object from the given floats.
  71680. * @param x x value of the vector
  71681. * @param y y value of the vector
  71682. * @param z z value of the vector
  71683. * @param w w value of the vector
  71684. */
  71685. constructor(
  71686. /** x value of the vector */
  71687. x: number,
  71688. /** y value of the vector */
  71689. y: number,
  71690. /** z value of the vector */
  71691. z: number,
  71692. /** w value of the vector */
  71693. w: number);
  71694. /**
  71695. * Returns the string with the Vector4 coordinates.
  71696. * @returns a string containing all the vector values
  71697. */
  71698. toString(): string;
  71699. /**
  71700. * Returns the string "Vector4".
  71701. * @returns "Vector4"
  71702. */
  71703. getClassName(): string;
  71704. /**
  71705. * Returns the Vector4 hash code.
  71706. * @returns a unique hash code
  71707. */
  71708. getHashCode(): number;
  71709. /**
  71710. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71711. * @returns the resulting array
  71712. */
  71713. asArray(): number[];
  71714. /**
  71715. * Populates the given array from the given index with the Vector4 coordinates.
  71716. * @param array array to populate
  71717. * @param index index of the array to start at (default: 0)
  71718. * @returns the Vector4.
  71719. */
  71720. toArray(array: FloatArray, index?: number): Vector4;
  71721. /**
  71722. * Adds the given vector to the current Vector4.
  71723. * @param otherVector the vector to add
  71724. * @returns the updated Vector4.
  71725. */
  71726. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71727. /**
  71728. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71729. * @param otherVector the vector to add
  71730. * @returns the resulting vector
  71731. */
  71732. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71733. /**
  71734. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71735. * @param otherVector the vector to add
  71736. * @param result the vector to store the result
  71737. * @returns the current Vector4.
  71738. */
  71739. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71740. /**
  71741. * Subtract in place the given vector from the current Vector4.
  71742. * @param otherVector the vector to subtract
  71743. * @returns the updated Vector4.
  71744. */
  71745. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71746. /**
  71747. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71748. * @param otherVector the vector to add
  71749. * @returns the new vector with the result
  71750. */
  71751. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71752. /**
  71753. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71754. * @param otherVector the vector to subtract
  71755. * @param result the vector to store the result
  71756. * @returns the current Vector4.
  71757. */
  71758. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71759. /**
  71760. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71761. */
  71762. /**
  71763. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71764. * @param x value to subtract
  71765. * @param y value to subtract
  71766. * @param z value to subtract
  71767. * @param w value to subtract
  71768. * @returns new vector containing the result
  71769. */
  71770. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71771. /**
  71772. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71773. * @param x value to subtract
  71774. * @param y value to subtract
  71775. * @param z value to subtract
  71776. * @param w value to subtract
  71777. * @param result the vector to store the result in
  71778. * @returns the current Vector4.
  71779. */
  71780. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71781. /**
  71782. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71783. * @returns a new vector with the negated values
  71784. */
  71785. negate(): Vector4;
  71786. /**
  71787. * Multiplies the current Vector4 coordinates by scale (float).
  71788. * @param scale the number to scale with
  71789. * @returns the updated Vector4.
  71790. */
  71791. scaleInPlace(scale: number): Vector4;
  71792. /**
  71793. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71794. * @param scale the number to scale with
  71795. * @returns a new vector with the result
  71796. */
  71797. scale(scale: number): Vector4;
  71798. /**
  71799. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71800. * @param scale the number to scale with
  71801. * @param result a vector to store the result in
  71802. * @returns the current Vector4.
  71803. */
  71804. scaleToRef(scale: number, result: Vector4): Vector4;
  71805. /**
  71806. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71807. * @param scale defines the scale factor
  71808. * @param result defines the Vector4 object where to store the result
  71809. * @returns the unmodified current Vector4
  71810. */
  71811. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71812. /**
  71813. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71814. * @param otherVector the vector to compare against
  71815. * @returns true if they are equal
  71816. */
  71817. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71818. /**
  71819. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71820. * @param otherVector vector to compare against
  71821. * @param epsilon (Default: very small number)
  71822. * @returns true if they are equal
  71823. */
  71824. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71825. /**
  71826. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71827. * @param x x value to compare against
  71828. * @param y y value to compare against
  71829. * @param z z value to compare against
  71830. * @param w w value to compare against
  71831. * @returns true if equal
  71832. */
  71833. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71834. /**
  71835. * Multiplies in place the current Vector4 by the given one.
  71836. * @param otherVector vector to multiple with
  71837. * @returns the updated Vector4.
  71838. */
  71839. multiplyInPlace(otherVector: Vector4): Vector4;
  71840. /**
  71841. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71842. * @param otherVector vector to multiple with
  71843. * @returns resulting new vector
  71844. */
  71845. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71846. /**
  71847. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71848. * @param otherVector vector to multiple with
  71849. * @param result vector to store the result
  71850. * @returns the current Vector4.
  71851. */
  71852. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71853. /**
  71854. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71855. * @param x x value multiply with
  71856. * @param y y value multiply with
  71857. * @param z z value multiply with
  71858. * @param w w value multiply with
  71859. * @returns resulting new vector
  71860. */
  71861. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71862. /**
  71863. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71864. * @param otherVector vector to devide with
  71865. * @returns resulting new vector
  71866. */
  71867. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71868. /**
  71869. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71870. * @param otherVector vector to devide with
  71871. * @param result vector to store the result
  71872. * @returns the current Vector4.
  71873. */
  71874. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71875. /**
  71876. * Divides the current Vector3 coordinates by the given ones.
  71877. * @param otherVector vector to devide with
  71878. * @returns the updated Vector3.
  71879. */
  71880. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71881. /**
  71882. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71883. * @param other defines the second operand
  71884. * @returns the current updated Vector4
  71885. */
  71886. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71887. /**
  71888. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71889. * @param other defines the second operand
  71890. * @returns the current updated Vector4
  71891. */
  71892. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71893. /**
  71894. * Gets a new Vector4 from current Vector4 floored values
  71895. * @returns a new Vector4
  71896. */
  71897. floor(): Vector4;
  71898. /**
  71899. * Gets a new Vector4 from current Vector3 floored values
  71900. * @returns a new Vector4
  71901. */
  71902. fract(): Vector4;
  71903. /**
  71904. * Returns the Vector4 length (float).
  71905. * @returns the length
  71906. */
  71907. length(): number;
  71908. /**
  71909. * Returns the Vector4 squared length (float).
  71910. * @returns the length squared
  71911. */
  71912. lengthSquared(): number;
  71913. /**
  71914. * Normalizes in place the Vector4.
  71915. * @returns the updated Vector4.
  71916. */
  71917. normalize(): Vector4;
  71918. /**
  71919. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71920. * @returns this converted to a new vector3
  71921. */
  71922. toVector3(): Vector3;
  71923. /**
  71924. * Returns a new Vector4 copied from the current one.
  71925. * @returns the new cloned vector
  71926. */
  71927. clone(): Vector4;
  71928. /**
  71929. * Updates the current Vector4 with the given one coordinates.
  71930. * @param source the source vector to copy from
  71931. * @returns the updated Vector4.
  71932. */
  71933. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71934. /**
  71935. * Updates the current Vector4 coordinates with the given floats.
  71936. * @param x float to copy from
  71937. * @param y float to copy from
  71938. * @param z float to copy from
  71939. * @param w float to copy from
  71940. * @returns the updated Vector4.
  71941. */
  71942. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71943. /**
  71944. * Updates the current Vector4 coordinates with the given floats.
  71945. * @param x float to set from
  71946. * @param y float to set from
  71947. * @param z float to set from
  71948. * @param w float to set from
  71949. * @returns the updated Vector4.
  71950. */
  71951. set(x: number, y: number, z: number, w: number): Vector4;
  71952. /**
  71953. * Copies the given float to the current Vector3 coordinates
  71954. * @param v defines the x, y, z and w coordinates of the operand
  71955. * @returns the current updated Vector3
  71956. */
  71957. setAll(v: number): Vector4;
  71958. /**
  71959. * Returns a new Vector4 set from the starting index of the given array.
  71960. * @param array the array to pull values from
  71961. * @param offset the offset into the array to start at
  71962. * @returns the new vector
  71963. */
  71964. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71965. /**
  71966. * Updates the given vector "result" from the starting index of the given array.
  71967. * @param array the array to pull values from
  71968. * @param offset the offset into the array to start at
  71969. * @param result the vector to store the result in
  71970. */
  71971. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71972. /**
  71973. * Updates the given vector "result" from the starting index of the given Float32Array.
  71974. * @param array the array to pull values from
  71975. * @param offset the offset into the array to start at
  71976. * @param result the vector to store the result in
  71977. */
  71978. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71979. /**
  71980. * Updates the given vector "result" coordinates from the given floats.
  71981. * @param x float to set from
  71982. * @param y float to set from
  71983. * @param z float to set from
  71984. * @param w float to set from
  71985. * @param result the vector to the floats in
  71986. */
  71987. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71988. /**
  71989. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71990. * @returns the new vector
  71991. */
  71992. static Zero(): Vector4;
  71993. /**
  71994. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71995. * @returns the new vector
  71996. */
  71997. static One(): Vector4;
  71998. /**
  71999. * Returns a new normalized Vector4 from the given one.
  72000. * @param vector the vector to normalize
  72001. * @returns the vector
  72002. */
  72003. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  72004. /**
  72005. * Updates the given vector "result" from the normalization of the given one.
  72006. * @param vector the vector to normalize
  72007. * @param result the vector to store the result in
  72008. */
  72009. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  72010. /**
  72011. * Returns a vector with the minimum values from the left and right vectors
  72012. * @param left left vector to minimize
  72013. * @param right right vector to minimize
  72014. * @returns a new vector with the minimum of the left and right vector values
  72015. */
  72016. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72017. /**
  72018. * Returns a vector with the maximum values from the left and right vectors
  72019. * @param left left vector to maximize
  72020. * @param right right vector to maximize
  72021. * @returns a new vector with the maximum of the left and right vector values
  72022. */
  72023. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72024. /**
  72025. * Returns the distance (float) between the vectors "value1" and "value2".
  72026. * @param value1 value to calulate the distance between
  72027. * @param value2 value to calulate the distance between
  72028. * @return the distance between the two vectors
  72029. */
  72030. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72031. /**
  72032. * Returns the squared distance (float) between the vectors "value1" and "value2".
  72033. * @param value1 value to calulate the distance between
  72034. * @param value2 value to calulate the distance between
  72035. * @return the distance between the two vectors squared
  72036. */
  72037. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72038. /**
  72039. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  72040. * @param value1 value to calulate the center between
  72041. * @param value2 value to calulate the center between
  72042. * @return the center between the two vectors
  72043. */
  72044. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  72045. /**
  72046. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  72047. * This methods computes transformed normalized direction vectors only.
  72048. * @param vector the vector to transform
  72049. * @param transformation the transformation matrix to apply
  72050. * @returns the new vector
  72051. */
  72052. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  72053. /**
  72054. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  72055. * This methods computes transformed normalized direction vectors only.
  72056. * @param vector the vector to transform
  72057. * @param transformation the transformation matrix to apply
  72058. * @param result the vector to store the result in
  72059. */
  72060. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72061. /**
  72062. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  72063. * This methods computes transformed normalized direction vectors only.
  72064. * @param x value to transform
  72065. * @param y value to transform
  72066. * @param z value to transform
  72067. * @param w value to transform
  72068. * @param transformation the transformation matrix to apply
  72069. * @param result the vector to store the results in
  72070. */
  72071. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72072. /**
  72073. * Creates a new Vector4 from a Vector3
  72074. * @param source defines the source data
  72075. * @param w defines the 4th component (default is 0)
  72076. * @returns a new Vector4
  72077. */
  72078. static FromVector3(source: Vector3, w?: number): Vector4;
  72079. }
  72080. /**
  72081. * Class used to store quaternion data
  72082. * @see https://en.wikipedia.org/wiki/Quaternion
  72083. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  72084. */
  72085. export class Quaternion {
  72086. /** defines the first component (0 by default) */
  72087. x: number;
  72088. /** defines the second component (0 by default) */
  72089. y: number;
  72090. /** defines the third component (0 by default) */
  72091. z: number;
  72092. /** defines the fourth component (1.0 by default) */
  72093. w: number;
  72094. /**
  72095. * Creates a new Quaternion from the given floats
  72096. * @param x defines the first component (0 by default)
  72097. * @param y defines the second component (0 by default)
  72098. * @param z defines the third component (0 by default)
  72099. * @param w defines the fourth component (1.0 by default)
  72100. */
  72101. constructor(
  72102. /** defines the first component (0 by default) */
  72103. x?: number,
  72104. /** defines the second component (0 by default) */
  72105. y?: number,
  72106. /** defines the third component (0 by default) */
  72107. z?: number,
  72108. /** defines the fourth component (1.0 by default) */
  72109. w?: number);
  72110. /**
  72111. * Gets a string representation for the current quaternion
  72112. * @returns a string with the Quaternion coordinates
  72113. */
  72114. toString(): string;
  72115. /**
  72116. * Gets the class name of the quaternion
  72117. * @returns the string "Quaternion"
  72118. */
  72119. getClassName(): string;
  72120. /**
  72121. * Gets a hash code for this quaternion
  72122. * @returns the quaternion hash code
  72123. */
  72124. getHashCode(): number;
  72125. /**
  72126. * Copy the quaternion to an array
  72127. * @returns a new array populated with 4 elements from the quaternion coordinates
  72128. */
  72129. asArray(): number[];
  72130. /**
  72131. * Check if two quaternions are equals
  72132. * @param otherQuaternion defines the second operand
  72133. * @return true if the current quaternion and the given one coordinates are strictly equals
  72134. */
  72135. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  72136. /**
  72137. * Clone the current quaternion
  72138. * @returns a new quaternion copied from the current one
  72139. */
  72140. clone(): Quaternion;
  72141. /**
  72142. * Copy a quaternion to the current one
  72143. * @param other defines the other quaternion
  72144. * @returns the updated current quaternion
  72145. */
  72146. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  72147. /**
  72148. * Updates the current quaternion with the given float coordinates
  72149. * @param x defines the x coordinate
  72150. * @param y defines the y coordinate
  72151. * @param z defines the z coordinate
  72152. * @param w defines the w coordinate
  72153. * @returns the updated current quaternion
  72154. */
  72155. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  72156. /**
  72157. * Updates the current quaternion from the given float coordinates
  72158. * @param x defines the x coordinate
  72159. * @param y defines the y coordinate
  72160. * @param z defines the z coordinate
  72161. * @param w defines the w coordinate
  72162. * @returns the updated current quaternion
  72163. */
  72164. set(x: number, y: number, z: number, w: number): Quaternion;
  72165. /**
  72166. * Adds two quaternions
  72167. * @param other defines the second operand
  72168. * @returns a new quaternion as the addition result of the given one and the current quaternion
  72169. */
  72170. add(other: DeepImmutable<Quaternion>): Quaternion;
  72171. /**
  72172. * Add a quaternion to the current one
  72173. * @param other defines the quaternion to add
  72174. * @returns the current quaternion
  72175. */
  72176. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  72177. /**
  72178. * Subtract two quaternions
  72179. * @param other defines the second operand
  72180. * @returns a new quaternion as the subtraction result of the given one from the current one
  72181. */
  72182. subtract(other: Quaternion): Quaternion;
  72183. /**
  72184. * Multiplies the current quaternion by a scale factor
  72185. * @param value defines the scale factor
  72186. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  72187. */
  72188. scale(value: number): Quaternion;
  72189. /**
  72190. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  72191. * @param scale defines the scale factor
  72192. * @param result defines the Quaternion object where to store the result
  72193. * @returns the unmodified current quaternion
  72194. */
  72195. scaleToRef(scale: number, result: Quaternion): Quaternion;
  72196. /**
  72197. * Multiplies in place the current quaternion by a scale factor
  72198. * @param value defines the scale factor
  72199. * @returns the current modified quaternion
  72200. */
  72201. scaleInPlace(value: number): Quaternion;
  72202. /**
  72203. * Scale the current quaternion values by a factor and add the result to a given quaternion
  72204. * @param scale defines the scale factor
  72205. * @param result defines the Quaternion object where to store the result
  72206. * @returns the unmodified current quaternion
  72207. */
  72208. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  72209. /**
  72210. * Multiplies two quaternions
  72211. * @param q1 defines the second operand
  72212. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  72213. */
  72214. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  72215. /**
  72216. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  72217. * @param q1 defines the second operand
  72218. * @param result defines the target quaternion
  72219. * @returns the current quaternion
  72220. */
  72221. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  72222. /**
  72223. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  72224. * @param q1 defines the second operand
  72225. * @returns the currentupdated quaternion
  72226. */
  72227. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  72228. /**
  72229. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  72230. * @param ref defines the target quaternion
  72231. * @returns the current quaternion
  72232. */
  72233. conjugateToRef(ref: Quaternion): Quaternion;
  72234. /**
  72235. * Conjugates in place (1-q) the current quaternion
  72236. * @returns the current updated quaternion
  72237. */
  72238. conjugateInPlace(): Quaternion;
  72239. /**
  72240. * Conjugates in place (1-q) the current quaternion
  72241. * @returns a new quaternion
  72242. */
  72243. conjugate(): Quaternion;
  72244. /**
  72245. * Gets length of current quaternion
  72246. * @returns the quaternion length (float)
  72247. */
  72248. length(): number;
  72249. /**
  72250. * Normalize in place the current quaternion
  72251. * @returns the current updated quaternion
  72252. */
  72253. normalize(): Quaternion;
  72254. /**
  72255. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  72256. * @param order is a reserved parameter and is ignore for now
  72257. * @returns a new Vector3 containing the Euler angles
  72258. */
  72259. toEulerAngles(order?: string): Vector3;
  72260. /**
  72261. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  72262. * @param result defines the vector which will be filled with the Euler angles
  72263. * @param order is a reserved parameter and is ignore for now
  72264. * @returns the current unchanged quaternion
  72265. */
  72266. toEulerAnglesToRef(result: Vector3): Quaternion;
  72267. /**
  72268. * Updates the given rotation matrix with the current quaternion values
  72269. * @param result defines the target matrix
  72270. * @returns the current unchanged quaternion
  72271. */
  72272. toRotationMatrix(result: Matrix): Quaternion;
  72273. /**
  72274. * Updates the current quaternion from the given rotation matrix values
  72275. * @param matrix defines the source matrix
  72276. * @returns the current updated quaternion
  72277. */
  72278. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72279. /**
  72280. * Creates a new quaternion from a rotation matrix
  72281. * @param matrix defines the source matrix
  72282. * @returns a new quaternion created from the given rotation matrix values
  72283. */
  72284. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72285. /**
  72286. * Updates the given quaternion with the given rotation matrix values
  72287. * @param matrix defines the source matrix
  72288. * @param result defines the target quaternion
  72289. */
  72290. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  72291. /**
  72292. * Returns the dot product (float) between the quaternions "left" and "right"
  72293. * @param left defines the left operand
  72294. * @param right defines the right operand
  72295. * @returns the dot product
  72296. */
  72297. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  72298. /**
  72299. * Checks if the two quaternions are close to each other
  72300. * @param quat0 defines the first quaternion to check
  72301. * @param quat1 defines the second quaternion to check
  72302. * @returns true if the two quaternions are close to each other
  72303. */
  72304. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  72305. /**
  72306. * Creates an empty quaternion
  72307. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  72308. */
  72309. static Zero(): Quaternion;
  72310. /**
  72311. * Inverse a given quaternion
  72312. * @param q defines the source quaternion
  72313. * @returns a new quaternion as the inverted current quaternion
  72314. */
  72315. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  72316. /**
  72317. * Inverse a given quaternion
  72318. * @param q defines the source quaternion
  72319. * @param result the quaternion the result will be stored in
  72320. * @returns the result quaternion
  72321. */
  72322. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  72323. /**
  72324. * Creates an identity quaternion
  72325. * @returns the identity quaternion
  72326. */
  72327. static Identity(): Quaternion;
  72328. /**
  72329. * Gets a boolean indicating if the given quaternion is identity
  72330. * @param quaternion defines the quaternion to check
  72331. * @returns true if the quaternion is identity
  72332. */
  72333. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  72334. /**
  72335. * Creates a quaternion from a rotation around an axis
  72336. * @param axis defines the axis to use
  72337. * @param angle defines the angle to use
  72338. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  72339. */
  72340. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  72341. /**
  72342. * Creates a rotation around an axis and stores it into the given quaternion
  72343. * @param axis defines the axis to use
  72344. * @param angle defines the angle to use
  72345. * @param result defines the target quaternion
  72346. * @returns the target quaternion
  72347. */
  72348. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  72349. /**
  72350. * Creates a new quaternion from data stored into an array
  72351. * @param array defines the data source
  72352. * @param offset defines the offset in the source array where the data starts
  72353. * @returns a new quaternion
  72354. */
  72355. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  72356. /**
  72357. * Create a quaternion from Euler rotation angles
  72358. * @param x Pitch
  72359. * @param y Yaw
  72360. * @param z Roll
  72361. * @returns the new Quaternion
  72362. */
  72363. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  72364. /**
  72365. * Updates a quaternion from Euler rotation angles
  72366. * @param x Pitch
  72367. * @param y Yaw
  72368. * @param z Roll
  72369. * @param result the quaternion to store the result
  72370. * @returns the updated quaternion
  72371. */
  72372. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  72373. /**
  72374. * Create a quaternion from Euler rotation vector
  72375. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72376. * @returns the new Quaternion
  72377. */
  72378. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  72379. /**
  72380. * Updates a quaternion from Euler rotation vector
  72381. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72382. * @param result the quaternion to store the result
  72383. * @returns the updated quaternion
  72384. */
  72385. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  72386. /**
  72387. * Creates a new quaternion from the given Euler float angles (y, x, z)
  72388. * @param yaw defines the rotation around Y axis
  72389. * @param pitch defines the rotation around X axis
  72390. * @param roll defines the rotation around Z axis
  72391. * @returns the new quaternion
  72392. */
  72393. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  72394. /**
  72395. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72396. * @param yaw defines the rotation around Y axis
  72397. * @param pitch defines the rotation around X axis
  72398. * @param roll defines the rotation around Z axis
  72399. * @param result defines the target quaternion
  72400. */
  72401. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  72402. /**
  72403. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  72404. * @param alpha defines the rotation around first axis
  72405. * @param beta defines the rotation around second axis
  72406. * @param gamma defines the rotation around third axis
  72407. * @returns the new quaternion
  72408. */
  72409. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  72410. /**
  72411. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  72412. * @param alpha defines the rotation around first axis
  72413. * @param beta defines the rotation around second axis
  72414. * @param gamma defines the rotation around third axis
  72415. * @param result defines the target quaternion
  72416. */
  72417. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  72418. /**
  72419. * 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)
  72420. * @param axis1 defines the first axis
  72421. * @param axis2 defines the second axis
  72422. * @param axis3 defines the third axis
  72423. * @returns the new quaternion
  72424. */
  72425. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  72426. /**
  72427. * 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
  72428. * @param axis1 defines the first axis
  72429. * @param axis2 defines the second axis
  72430. * @param axis3 defines the third axis
  72431. * @param ref defines the target quaternion
  72432. */
  72433. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  72434. /**
  72435. * Interpolates between two quaternions
  72436. * @param left defines first quaternion
  72437. * @param right defines second quaternion
  72438. * @param amount defines the gradient to use
  72439. * @returns the new interpolated quaternion
  72440. */
  72441. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72442. /**
  72443. * Interpolates between two quaternions and stores it into a target quaternion
  72444. * @param left defines first quaternion
  72445. * @param right defines second quaternion
  72446. * @param amount defines the gradient to use
  72447. * @param result defines the target quaternion
  72448. */
  72449. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  72450. /**
  72451. * Interpolate between two quaternions using Hermite interpolation
  72452. * @param value1 defines first quaternion
  72453. * @param tangent1 defines the incoming tangent
  72454. * @param value2 defines second quaternion
  72455. * @param tangent2 defines the outgoing tangent
  72456. * @param amount defines the target quaternion
  72457. * @returns the new interpolated quaternion
  72458. */
  72459. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72460. }
  72461. /**
  72462. * Class used to store matrix data (4x4)
  72463. */
  72464. export class Matrix {
  72465. private static _updateFlagSeed;
  72466. private static _identityReadOnly;
  72467. private _isIdentity;
  72468. private _isIdentityDirty;
  72469. private _isIdentity3x2;
  72470. private _isIdentity3x2Dirty;
  72471. /**
  72472. * Gets the update flag of the matrix which is an unique number for the matrix.
  72473. * It will be incremented every time the matrix data change.
  72474. * You can use it to speed the comparison between two versions of the same matrix.
  72475. */
  72476. updateFlag: number;
  72477. private readonly _m;
  72478. /**
  72479. * Gets the internal data of the matrix
  72480. */
  72481. readonly m: DeepImmutable<Float32Array>;
  72482. /** @hidden */
  72483. _markAsUpdated(): void;
  72484. /** @hidden */
  72485. private _updateIdentityStatus;
  72486. /**
  72487. * Creates an empty matrix (filled with zeros)
  72488. */
  72489. constructor();
  72490. /**
  72491. * Check if the current matrix is identity
  72492. * @returns true is the matrix is the identity matrix
  72493. */
  72494. isIdentity(): boolean;
  72495. /**
  72496. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72497. * @returns true is the matrix is the identity matrix
  72498. */
  72499. isIdentityAs3x2(): boolean;
  72500. /**
  72501. * Gets the determinant of the matrix
  72502. * @returns the matrix determinant
  72503. */
  72504. determinant(): number;
  72505. /**
  72506. * Returns the matrix as a Float32Array
  72507. * @returns the matrix underlying array
  72508. */
  72509. toArray(): DeepImmutable<Float32Array>;
  72510. /**
  72511. * Returns the matrix as a Float32Array
  72512. * @returns the matrix underlying array.
  72513. */
  72514. asArray(): DeepImmutable<Float32Array>;
  72515. /**
  72516. * Inverts the current matrix in place
  72517. * @returns the current inverted matrix
  72518. */
  72519. invert(): Matrix;
  72520. /**
  72521. * Sets all the matrix elements to zero
  72522. * @returns the current matrix
  72523. */
  72524. reset(): Matrix;
  72525. /**
  72526. * Adds the current matrix with a second one
  72527. * @param other defines the matrix to add
  72528. * @returns a new matrix as the addition of the current matrix and the given one
  72529. */
  72530. add(other: DeepImmutable<Matrix>): Matrix;
  72531. /**
  72532. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72533. * @param other defines the matrix to add
  72534. * @param result defines the target matrix
  72535. * @returns the current matrix
  72536. */
  72537. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72538. /**
  72539. * Adds in place the given matrix to the current matrix
  72540. * @param other defines the second operand
  72541. * @returns the current updated matrix
  72542. */
  72543. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72544. /**
  72545. * Sets the given matrix to the current inverted Matrix
  72546. * @param other defines the target matrix
  72547. * @returns the unmodified current matrix
  72548. */
  72549. invertToRef(other: Matrix): Matrix;
  72550. /**
  72551. * add a value at the specified position in the current Matrix
  72552. * @param index the index of the value within the matrix. between 0 and 15.
  72553. * @param value the value to be added
  72554. * @returns the current updated matrix
  72555. */
  72556. addAtIndex(index: number, value: number): Matrix;
  72557. /**
  72558. * mutiply the specified position in the current Matrix by a value
  72559. * @param index the index of the value within the matrix. between 0 and 15.
  72560. * @param value the value to be added
  72561. * @returns the current updated matrix
  72562. */
  72563. multiplyAtIndex(index: number, value: number): Matrix;
  72564. /**
  72565. * Inserts the translation vector (using 3 floats) in the current matrix
  72566. * @param x defines the 1st component of the translation
  72567. * @param y defines the 2nd component of the translation
  72568. * @param z defines the 3rd component of the translation
  72569. * @returns the current updated matrix
  72570. */
  72571. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72572. /**
  72573. * Adds the translation vector (using 3 floats) in the current matrix
  72574. * @param x defines the 1st component of the translation
  72575. * @param y defines the 2nd component of the translation
  72576. * @param z defines the 3rd component of the translation
  72577. * @returns the current updated matrix
  72578. */
  72579. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72580. /**
  72581. * Inserts the translation vector in the current matrix
  72582. * @param vector3 defines the translation to insert
  72583. * @returns the current updated matrix
  72584. */
  72585. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72586. /**
  72587. * Gets the translation value of the current matrix
  72588. * @returns a new Vector3 as the extracted translation from the matrix
  72589. */
  72590. getTranslation(): Vector3;
  72591. /**
  72592. * Fill a Vector3 with the extracted translation from the matrix
  72593. * @param result defines the Vector3 where to store the translation
  72594. * @returns the current matrix
  72595. */
  72596. getTranslationToRef(result: Vector3): Matrix;
  72597. /**
  72598. * Remove rotation and scaling part from the matrix
  72599. * @returns the updated matrix
  72600. */
  72601. removeRotationAndScaling(): Matrix;
  72602. /**
  72603. * Multiply two matrices
  72604. * @param other defines the second operand
  72605. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72606. */
  72607. multiply(other: DeepImmutable<Matrix>): Matrix;
  72608. /**
  72609. * Copy the current matrix from the given one
  72610. * @param other defines the source matrix
  72611. * @returns the current updated matrix
  72612. */
  72613. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72614. /**
  72615. * Populates the given array from the starting index with the current matrix values
  72616. * @param array defines the target array
  72617. * @param offset defines the offset in the target array where to start storing values
  72618. * @returns the current matrix
  72619. */
  72620. copyToArray(array: Float32Array, offset?: number): Matrix;
  72621. /**
  72622. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72623. * @param other defines the second operand
  72624. * @param result defines the matrix where to store the multiplication
  72625. * @returns the current matrix
  72626. */
  72627. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72628. /**
  72629. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72630. * @param other defines the second operand
  72631. * @param result defines the array where to store the multiplication
  72632. * @param offset defines the offset in the target array where to start storing values
  72633. * @returns the current matrix
  72634. */
  72635. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72636. /**
  72637. * Check equality between this matrix and a second one
  72638. * @param value defines the second matrix to compare
  72639. * @returns true is the current matrix and the given one values are strictly equal
  72640. */
  72641. equals(value: DeepImmutable<Matrix>): boolean;
  72642. /**
  72643. * Clone the current matrix
  72644. * @returns a new matrix from the current matrix
  72645. */
  72646. clone(): Matrix;
  72647. /**
  72648. * Returns the name of the current matrix class
  72649. * @returns the string "Matrix"
  72650. */
  72651. getClassName(): string;
  72652. /**
  72653. * Gets the hash code of the current matrix
  72654. * @returns the hash code
  72655. */
  72656. getHashCode(): number;
  72657. /**
  72658. * Decomposes the current Matrix into a translation, rotation and scaling components
  72659. * @param scale defines the scale vector3 given as a reference to update
  72660. * @param rotation defines the rotation quaternion given as a reference to update
  72661. * @param translation defines the translation vector3 given as a reference to update
  72662. * @returns true if operation was successful
  72663. */
  72664. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72665. /**
  72666. * Gets specific row of the matrix
  72667. * @param index defines the number of the row to get
  72668. * @returns the index-th row of the current matrix as a new Vector4
  72669. */
  72670. getRow(index: number): Nullable<Vector4>;
  72671. /**
  72672. * Sets the index-th row of the current matrix to the vector4 values
  72673. * @param index defines the number of the row to set
  72674. * @param row defines the target vector4
  72675. * @returns the updated current matrix
  72676. */
  72677. setRow(index: number, row: Vector4): Matrix;
  72678. /**
  72679. * Compute the transpose of the matrix
  72680. * @returns the new transposed matrix
  72681. */
  72682. transpose(): Matrix;
  72683. /**
  72684. * Compute the transpose of the matrix and store it in a given matrix
  72685. * @param result defines the target matrix
  72686. * @returns the current matrix
  72687. */
  72688. transposeToRef(result: Matrix): Matrix;
  72689. /**
  72690. * Sets the index-th row of the current matrix with the given 4 x float values
  72691. * @param index defines the row index
  72692. * @param x defines the x component to set
  72693. * @param y defines the y component to set
  72694. * @param z defines the z component to set
  72695. * @param w defines the w component to set
  72696. * @returns the updated current matrix
  72697. */
  72698. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72699. /**
  72700. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72701. * @param scale defines the scale factor
  72702. * @returns a new matrix
  72703. */
  72704. scale(scale: number): Matrix;
  72705. /**
  72706. * Scale the current matrix values by a factor to a given result matrix
  72707. * @param scale defines the scale factor
  72708. * @param result defines the matrix to store the result
  72709. * @returns the current matrix
  72710. */
  72711. scaleToRef(scale: number, result: Matrix): Matrix;
  72712. /**
  72713. * Scale the current matrix values by a factor and add the result to a given matrix
  72714. * @param scale defines the scale factor
  72715. * @param result defines the Matrix to store the result
  72716. * @returns the current matrix
  72717. */
  72718. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72719. /**
  72720. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72721. * @param ref matrix to store the result
  72722. */
  72723. toNormalMatrix(ref: Matrix): void;
  72724. /**
  72725. * Gets only rotation part of the current matrix
  72726. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72727. */
  72728. getRotationMatrix(): Matrix;
  72729. /**
  72730. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72731. * @param result defines the target matrix to store data to
  72732. * @returns the current matrix
  72733. */
  72734. getRotationMatrixToRef(result: Matrix): Matrix;
  72735. /**
  72736. * Toggles model matrix from being right handed to left handed in place and vice versa
  72737. */
  72738. toggleModelMatrixHandInPlace(): void;
  72739. /**
  72740. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72741. */
  72742. toggleProjectionMatrixHandInPlace(): void;
  72743. /**
  72744. * Creates a matrix from an array
  72745. * @param array defines the source array
  72746. * @param offset defines an offset in the source array
  72747. * @returns a new Matrix set from the starting index of the given array
  72748. */
  72749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72750. /**
  72751. * Copy the content of an array into a given matrix
  72752. * @param array defines the source array
  72753. * @param offset defines an offset in the source array
  72754. * @param result defines the target matrix
  72755. */
  72756. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72757. /**
  72758. * Stores an array into a matrix after having multiplied each component by a given factor
  72759. * @param array defines the source array
  72760. * @param offset defines the offset in the source array
  72761. * @param scale defines the scaling factor
  72762. * @param result defines the target matrix
  72763. */
  72764. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72765. /**
  72766. * Gets an identity matrix that must not be updated
  72767. */
  72768. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72769. /**
  72770. * Stores a list of values (16) inside a given matrix
  72771. * @param initialM11 defines 1st value of 1st row
  72772. * @param initialM12 defines 2nd value of 1st row
  72773. * @param initialM13 defines 3rd value of 1st row
  72774. * @param initialM14 defines 4th value of 1st row
  72775. * @param initialM21 defines 1st value of 2nd row
  72776. * @param initialM22 defines 2nd value of 2nd row
  72777. * @param initialM23 defines 3rd value of 2nd row
  72778. * @param initialM24 defines 4th value of 2nd row
  72779. * @param initialM31 defines 1st value of 3rd row
  72780. * @param initialM32 defines 2nd value of 3rd row
  72781. * @param initialM33 defines 3rd value of 3rd row
  72782. * @param initialM34 defines 4th value of 3rd row
  72783. * @param initialM41 defines 1st value of 4th row
  72784. * @param initialM42 defines 2nd value of 4th row
  72785. * @param initialM43 defines 3rd value of 4th row
  72786. * @param initialM44 defines 4th value of 4th row
  72787. * @param result defines the target matrix
  72788. */
  72789. 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;
  72790. /**
  72791. * Creates new matrix from a list of values (16)
  72792. * @param initialM11 defines 1st value of 1st row
  72793. * @param initialM12 defines 2nd value of 1st row
  72794. * @param initialM13 defines 3rd value of 1st row
  72795. * @param initialM14 defines 4th value of 1st row
  72796. * @param initialM21 defines 1st value of 2nd row
  72797. * @param initialM22 defines 2nd value of 2nd row
  72798. * @param initialM23 defines 3rd value of 2nd row
  72799. * @param initialM24 defines 4th value of 2nd row
  72800. * @param initialM31 defines 1st value of 3rd row
  72801. * @param initialM32 defines 2nd value of 3rd row
  72802. * @param initialM33 defines 3rd value of 3rd row
  72803. * @param initialM34 defines 4th value of 3rd row
  72804. * @param initialM41 defines 1st value of 4th row
  72805. * @param initialM42 defines 2nd value of 4th row
  72806. * @param initialM43 defines 3rd value of 4th row
  72807. * @param initialM44 defines 4th value of 4th row
  72808. * @returns the new matrix
  72809. */
  72810. 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;
  72811. /**
  72812. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72813. * @param scale defines the scale vector3
  72814. * @param rotation defines the rotation quaternion
  72815. * @param translation defines the translation vector3
  72816. * @returns a new matrix
  72817. */
  72818. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72819. /**
  72820. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72821. * @param scale defines the scale vector3
  72822. * @param rotation defines the rotation quaternion
  72823. * @param translation defines the translation vector3
  72824. * @param result defines the target matrix
  72825. */
  72826. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72827. /**
  72828. * Creates a new identity matrix
  72829. * @returns a new identity matrix
  72830. */
  72831. static Identity(): Matrix;
  72832. /**
  72833. * Creates a new identity matrix and stores the result in a given matrix
  72834. * @param result defines the target matrix
  72835. */
  72836. static IdentityToRef(result: Matrix): void;
  72837. /**
  72838. * Creates a new zero matrix
  72839. * @returns a new zero matrix
  72840. */
  72841. static Zero(): Matrix;
  72842. /**
  72843. * Creates a new rotation matrix for "angle" radians around the X axis
  72844. * @param angle defines the angle (in radians) to use
  72845. * @return the new matrix
  72846. */
  72847. static RotationX(angle: number): Matrix;
  72848. /**
  72849. * Creates a new matrix as the invert of a given matrix
  72850. * @param source defines the source matrix
  72851. * @returns the new matrix
  72852. */
  72853. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72854. /**
  72855. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72856. * @param angle defines the angle (in radians) to use
  72857. * @param result defines the target matrix
  72858. */
  72859. static RotationXToRef(angle: number, result: Matrix): void;
  72860. /**
  72861. * Creates a new rotation matrix for "angle" radians around the Y axis
  72862. * @param angle defines the angle (in radians) to use
  72863. * @return the new matrix
  72864. */
  72865. static RotationY(angle: number): Matrix;
  72866. /**
  72867. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72868. * @param angle defines the angle (in radians) to use
  72869. * @param result defines the target matrix
  72870. */
  72871. static RotationYToRef(angle: number, result: Matrix): void;
  72872. /**
  72873. * Creates a new rotation matrix for "angle" radians around the Z axis
  72874. * @param angle defines the angle (in radians) to use
  72875. * @return the new matrix
  72876. */
  72877. static RotationZ(angle: number): Matrix;
  72878. /**
  72879. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72880. * @param angle defines the angle (in radians) to use
  72881. * @param result defines the target matrix
  72882. */
  72883. static RotationZToRef(angle: number, result: Matrix): void;
  72884. /**
  72885. * Creates a new rotation matrix for "angle" radians around the given axis
  72886. * @param axis defines the axis to use
  72887. * @param angle defines the angle (in radians) to use
  72888. * @return the new matrix
  72889. */
  72890. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72891. /**
  72892. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72893. * @param axis defines the axis to use
  72894. * @param angle defines the angle (in radians) to use
  72895. * @param result defines the target matrix
  72896. */
  72897. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72898. /**
  72899. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72900. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72901. * @param from defines the vector to align
  72902. * @param to defines the vector to align to
  72903. * @param result defines the target matrix
  72904. */
  72905. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72906. /**
  72907. * Creates a rotation matrix
  72908. * @param yaw defines the yaw angle in radians (Y axis)
  72909. * @param pitch defines the pitch angle in radians (X axis)
  72910. * @param roll defines the roll angle in radians (X axis)
  72911. * @returns the new rotation matrix
  72912. */
  72913. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72914. /**
  72915. * Creates a rotation matrix and stores it in a given matrix
  72916. * @param yaw defines the yaw angle in radians (Y axis)
  72917. * @param pitch defines the pitch angle in radians (X axis)
  72918. * @param roll defines the roll angle in radians (X axis)
  72919. * @param result defines the target matrix
  72920. */
  72921. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72922. /**
  72923. * Creates a scaling matrix
  72924. * @param x defines the scale factor on X axis
  72925. * @param y defines the scale factor on Y axis
  72926. * @param z defines the scale factor on Z axis
  72927. * @returns the new matrix
  72928. */
  72929. static Scaling(x: number, y: number, z: number): Matrix;
  72930. /**
  72931. * Creates a scaling matrix and stores it in a given matrix
  72932. * @param x defines the scale factor on X axis
  72933. * @param y defines the scale factor on Y axis
  72934. * @param z defines the scale factor on Z axis
  72935. * @param result defines the target matrix
  72936. */
  72937. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72938. /**
  72939. * Creates a translation matrix
  72940. * @param x defines the translation on X axis
  72941. * @param y defines the translation on Y axis
  72942. * @param z defines the translationon Z axis
  72943. * @returns the new matrix
  72944. */
  72945. static Translation(x: number, y: number, z: number): Matrix;
  72946. /**
  72947. * Creates a translation matrix and stores it in a given matrix
  72948. * @param x defines the translation on X axis
  72949. * @param y defines the translation on Y axis
  72950. * @param z defines the translationon Z axis
  72951. * @param result defines the target matrix
  72952. */
  72953. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72954. /**
  72955. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72956. * @param startValue defines the start value
  72957. * @param endValue defines the end value
  72958. * @param gradient defines the gradient factor
  72959. * @returns the new matrix
  72960. */
  72961. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72962. /**
  72963. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72964. * @param startValue defines the start value
  72965. * @param endValue defines the end value
  72966. * @param gradient defines the gradient factor
  72967. * @param result defines the Matrix object where to store data
  72968. */
  72969. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72970. /**
  72971. * Builds a new matrix whose values are computed by:
  72972. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72973. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72974. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72975. * @param startValue defines the first matrix
  72976. * @param endValue defines the second matrix
  72977. * @param gradient defines the gradient between the two matrices
  72978. * @returns the new matrix
  72979. */
  72980. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72981. /**
  72982. * Update a matrix to values which are computed by:
  72983. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72984. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72985. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72986. * @param startValue defines the first matrix
  72987. * @param endValue defines the second matrix
  72988. * @param gradient defines the gradient between the two matrices
  72989. * @param result defines the target matrix
  72990. */
  72991. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72992. /**
  72993. * 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"
  72994. * This function works in left handed mode
  72995. * @param eye defines the final position of the entity
  72996. * @param target defines where the entity should look at
  72997. * @param up defines the up vector for the entity
  72998. * @returns the new matrix
  72999. */
  73000. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73001. /**
  73002. * 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".
  73003. * This function works in left handed mode
  73004. * @param eye defines the final position of the entity
  73005. * @param target defines where the entity should look at
  73006. * @param up defines the up vector for the entity
  73007. * @param result defines the target matrix
  73008. */
  73009. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73010. /**
  73011. * 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"
  73012. * This function works in right handed mode
  73013. * @param eye defines the final position of the entity
  73014. * @param target defines where the entity should look at
  73015. * @param up defines the up vector for the entity
  73016. * @returns the new matrix
  73017. */
  73018. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73019. /**
  73020. * 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".
  73021. * This function works in right handed mode
  73022. * @param eye defines the final position of the entity
  73023. * @param target defines where the entity should look at
  73024. * @param up defines the up vector for the entity
  73025. * @param result defines the target matrix
  73026. */
  73027. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73028. /**
  73029. * Create a left-handed orthographic projection matrix
  73030. * @param width defines the viewport width
  73031. * @param height defines the viewport height
  73032. * @param znear defines the near clip plane
  73033. * @param zfar defines the far clip plane
  73034. * @returns a new matrix as a left-handed orthographic projection matrix
  73035. */
  73036. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73037. /**
  73038. * Store a left-handed orthographic projection to a given matrix
  73039. * @param width defines the viewport width
  73040. * @param height defines the viewport height
  73041. * @param znear defines the near clip plane
  73042. * @param zfar defines the far clip plane
  73043. * @param result defines the target matrix
  73044. */
  73045. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  73046. /**
  73047. * Create a left-handed orthographic projection matrix
  73048. * @param left defines the viewport left coordinate
  73049. * @param right defines the viewport right coordinate
  73050. * @param bottom defines the viewport bottom coordinate
  73051. * @param top defines the viewport top coordinate
  73052. * @param znear defines the near clip plane
  73053. * @param zfar defines the far clip plane
  73054. * @returns a new matrix as a left-handed orthographic projection matrix
  73055. */
  73056. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73057. /**
  73058. * Stores a left-handed orthographic projection into a given matrix
  73059. * @param left defines the viewport left coordinate
  73060. * @param right defines the viewport right coordinate
  73061. * @param bottom defines the viewport bottom coordinate
  73062. * @param top defines the viewport top coordinate
  73063. * @param znear defines the near clip plane
  73064. * @param zfar defines the far clip plane
  73065. * @param result defines the target matrix
  73066. */
  73067. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73068. /**
  73069. * Creates a right-handed orthographic projection matrix
  73070. * @param left defines the viewport left coordinate
  73071. * @param right defines the viewport right coordinate
  73072. * @param bottom defines the viewport bottom coordinate
  73073. * @param top defines the viewport top coordinate
  73074. * @param znear defines the near clip plane
  73075. * @param zfar defines the far clip plane
  73076. * @returns a new matrix as a right-handed orthographic projection matrix
  73077. */
  73078. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73079. /**
  73080. * Stores a right-handed orthographic projection into a given matrix
  73081. * @param left defines the viewport left coordinate
  73082. * @param right defines the viewport right coordinate
  73083. * @param bottom defines the viewport bottom coordinate
  73084. * @param top defines the viewport top coordinate
  73085. * @param znear defines the near clip plane
  73086. * @param zfar defines the far clip plane
  73087. * @param result defines the target matrix
  73088. */
  73089. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73090. /**
  73091. * Creates a left-handed perspective projection matrix
  73092. * @param width defines the viewport width
  73093. * @param height defines the viewport height
  73094. * @param znear defines the near clip plane
  73095. * @param zfar defines the far clip plane
  73096. * @returns a new matrix as a left-handed perspective projection matrix
  73097. */
  73098. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73099. /**
  73100. * Creates a left-handed perspective projection matrix
  73101. * @param fov defines the horizontal field of view
  73102. * @param aspect defines the aspect ratio
  73103. * @param znear defines the near clip plane
  73104. * @param zfar defines the far clip plane
  73105. * @returns a new matrix as a left-handed perspective projection matrix
  73106. */
  73107. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73108. /**
  73109. * Stores a left-handed perspective projection into a given matrix
  73110. * @param fov defines the horizontal field of view
  73111. * @param aspect defines the aspect ratio
  73112. * @param znear defines the near clip plane
  73113. * @param zfar defines the far clip plane
  73114. * @param result defines the target matrix
  73115. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73116. */
  73117. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73118. /**
  73119. * Stores a left-handed perspective projection into a given matrix with depth reversed
  73120. * @param fov defines the horizontal field of view
  73121. * @param aspect defines the aspect ratio
  73122. * @param znear defines the near clip plane
  73123. * @param zfar not used as infinity is used as far clip
  73124. * @param result defines the target matrix
  73125. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73126. */
  73127. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73128. /**
  73129. * Creates a right-handed perspective projection matrix
  73130. * @param fov defines the horizontal field of view
  73131. * @param aspect defines the aspect ratio
  73132. * @param znear defines the near clip plane
  73133. * @param zfar defines the far clip plane
  73134. * @returns a new matrix as a right-handed perspective projection matrix
  73135. */
  73136. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73137. /**
  73138. * Stores a right-handed perspective projection into a given matrix
  73139. * @param fov defines the horizontal field of view
  73140. * @param aspect defines the aspect ratio
  73141. * @param znear defines the near clip plane
  73142. * @param zfar defines the far clip plane
  73143. * @param result defines the target matrix
  73144. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73145. */
  73146. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73147. /**
  73148. * Stores a right-handed perspective projection into a given matrix
  73149. * @param fov defines the horizontal field of view
  73150. * @param aspect defines the aspect ratio
  73151. * @param znear defines the near clip plane
  73152. * @param zfar not used as infinity is used as far clip
  73153. * @param result defines the target matrix
  73154. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73155. */
  73156. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73157. /**
  73158. * Stores a perspective projection for WebVR info a given matrix
  73159. * @param fov defines the field of view
  73160. * @param znear defines the near clip plane
  73161. * @param zfar defines the far clip plane
  73162. * @param result defines the target matrix
  73163. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73164. */
  73165. static PerspectiveFovWebVRToRef(fov: {
  73166. upDegrees: number;
  73167. downDegrees: number;
  73168. leftDegrees: number;
  73169. rightDegrees: number;
  73170. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  73171. /**
  73172. * Computes a complete transformation matrix
  73173. * @param viewport defines the viewport to use
  73174. * @param world defines the world matrix
  73175. * @param view defines the view matrix
  73176. * @param projection defines the projection matrix
  73177. * @param zmin defines the near clip plane
  73178. * @param zmax defines the far clip plane
  73179. * @returns the transformation matrix
  73180. */
  73181. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  73182. /**
  73183. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73184. * @param matrix defines the matrix to use
  73185. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73186. */
  73187. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  73188. /**
  73189. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73190. * @param matrix defines the matrix to use
  73191. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73192. */
  73193. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  73194. /**
  73195. * Compute the transpose of a given matrix
  73196. * @param matrix defines the matrix to transpose
  73197. * @returns the new matrix
  73198. */
  73199. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  73200. /**
  73201. * Compute the transpose of a matrix and store it in a target matrix
  73202. * @param matrix defines the matrix to transpose
  73203. * @param result defines the target matrix
  73204. */
  73205. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  73206. /**
  73207. * Computes a reflection matrix from a plane
  73208. * @param plane defines the reflection plane
  73209. * @returns a new matrix
  73210. */
  73211. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  73212. /**
  73213. * Computes a reflection matrix from a plane
  73214. * @param plane defines the reflection plane
  73215. * @param result defines the target matrix
  73216. */
  73217. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  73218. /**
  73219. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73220. * @param xaxis defines the value of the 1st axis
  73221. * @param yaxis defines the value of the 2nd axis
  73222. * @param zaxis defines the value of the 3rd axis
  73223. * @param result defines the target matrix
  73224. */
  73225. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  73226. /**
  73227. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73228. * @param quat defines the quaternion to use
  73229. * @param result defines the target matrix
  73230. */
  73231. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  73232. }
  73233. /**
  73234. * @hidden
  73235. */
  73236. export class TmpVectors {
  73237. static Vector2: Vector2[];
  73238. static Vector3: Vector3[];
  73239. static Vector4: Vector4[];
  73240. static Quaternion: Quaternion[];
  73241. static Matrix: Matrix[];
  73242. }
  73243. }
  73244. declare module BABYLON {
  73245. /**
  73246. * Defines potential orientation for back face culling
  73247. */
  73248. export enum Orientation {
  73249. /**
  73250. * Clockwise
  73251. */
  73252. CW = 0,
  73253. /** Counter clockwise */
  73254. CCW = 1
  73255. }
  73256. /** Class used to represent a Bezier curve */
  73257. export class BezierCurve {
  73258. /**
  73259. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73260. * @param t defines the time
  73261. * @param x1 defines the left coordinate on X axis
  73262. * @param y1 defines the left coordinate on Y axis
  73263. * @param x2 defines the right coordinate on X axis
  73264. * @param y2 defines the right coordinate on Y axis
  73265. * @returns the interpolated value
  73266. */
  73267. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  73268. }
  73269. /**
  73270. * Defines angle representation
  73271. */
  73272. export class Angle {
  73273. private _radians;
  73274. /**
  73275. * Creates an Angle object of "radians" radians (float).
  73276. * @param radians the angle in radians
  73277. */
  73278. constructor(radians: number);
  73279. /**
  73280. * Get value in degrees
  73281. * @returns the Angle value in degrees (float)
  73282. */
  73283. degrees(): number;
  73284. /**
  73285. * Get value in radians
  73286. * @returns the Angle value in radians (float)
  73287. */
  73288. radians(): number;
  73289. /**
  73290. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73291. * @param a defines first vector
  73292. * @param b defines second vector
  73293. * @returns a new Angle
  73294. */
  73295. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  73296. /**
  73297. * Gets a new Angle object from the given float in radians
  73298. * @param radians defines the angle value in radians
  73299. * @returns a new Angle
  73300. */
  73301. static FromRadians(radians: number): Angle;
  73302. /**
  73303. * Gets a new Angle object from the given float in degrees
  73304. * @param degrees defines the angle value in degrees
  73305. * @returns a new Angle
  73306. */
  73307. static FromDegrees(degrees: number): Angle;
  73308. }
  73309. /**
  73310. * This represents an arc in a 2d space.
  73311. */
  73312. export class Arc2 {
  73313. /** Defines the start point of the arc */
  73314. startPoint: Vector2;
  73315. /** Defines the mid point of the arc */
  73316. midPoint: Vector2;
  73317. /** Defines the end point of the arc */
  73318. endPoint: Vector2;
  73319. /**
  73320. * Defines the center point of the arc.
  73321. */
  73322. centerPoint: Vector2;
  73323. /**
  73324. * Defines the radius of the arc.
  73325. */
  73326. radius: number;
  73327. /**
  73328. * Defines the angle of the arc (from mid point to end point).
  73329. */
  73330. angle: Angle;
  73331. /**
  73332. * Defines the start angle of the arc (from start point to middle point).
  73333. */
  73334. startAngle: Angle;
  73335. /**
  73336. * Defines the orientation of the arc (clock wise/counter clock wise).
  73337. */
  73338. orientation: Orientation;
  73339. /**
  73340. * Creates an Arc object from the three given points : start, middle and end.
  73341. * @param startPoint Defines the start point of the arc
  73342. * @param midPoint Defines the midlle point of the arc
  73343. * @param endPoint Defines the end point of the arc
  73344. */
  73345. constructor(
  73346. /** Defines the start point of the arc */
  73347. startPoint: Vector2,
  73348. /** Defines the mid point of the arc */
  73349. midPoint: Vector2,
  73350. /** Defines the end point of the arc */
  73351. endPoint: Vector2);
  73352. }
  73353. /**
  73354. * Represents a 2D path made up of multiple 2D points
  73355. */
  73356. export class Path2 {
  73357. private _points;
  73358. private _length;
  73359. /**
  73360. * If the path start and end point are the same
  73361. */
  73362. closed: boolean;
  73363. /**
  73364. * Creates a Path2 object from the starting 2D coordinates x and y.
  73365. * @param x the starting points x value
  73366. * @param y the starting points y value
  73367. */
  73368. constructor(x: number, y: number);
  73369. /**
  73370. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73371. * @param x the added points x value
  73372. * @param y the added points y value
  73373. * @returns the updated Path2.
  73374. */
  73375. addLineTo(x: number, y: number): Path2;
  73376. /**
  73377. * 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.
  73378. * @param midX middle point x value
  73379. * @param midY middle point y value
  73380. * @param endX end point x value
  73381. * @param endY end point y value
  73382. * @param numberOfSegments (default: 36)
  73383. * @returns the updated Path2.
  73384. */
  73385. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  73386. /**
  73387. * Closes the Path2.
  73388. * @returns the Path2.
  73389. */
  73390. close(): Path2;
  73391. /**
  73392. * Gets the sum of the distance between each sequential point in the path
  73393. * @returns the Path2 total length (float).
  73394. */
  73395. length(): number;
  73396. /**
  73397. * Gets the points which construct the path
  73398. * @returns the Path2 internal array of points.
  73399. */
  73400. getPoints(): Vector2[];
  73401. /**
  73402. * Retreives the point at the distance aways from the starting point
  73403. * @param normalizedLengthPosition the length along the path to retreive the point from
  73404. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73405. */
  73406. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  73407. /**
  73408. * Creates a new path starting from an x and y position
  73409. * @param x starting x value
  73410. * @param y starting y value
  73411. * @returns a new Path2 starting at the coordinates (x, y).
  73412. */
  73413. static StartingAt(x: number, y: number): Path2;
  73414. }
  73415. /**
  73416. * Represents a 3D path made up of multiple 3D points
  73417. */
  73418. export class Path3D {
  73419. /**
  73420. * an array of Vector3, the curve axis of the Path3D
  73421. */
  73422. path: Vector3[];
  73423. private _curve;
  73424. private _distances;
  73425. private _tangents;
  73426. private _normals;
  73427. private _binormals;
  73428. private _raw;
  73429. private _alignTangentsWithPath;
  73430. private readonly _pointAtData;
  73431. /**
  73432. * new Path3D(path, normal, raw)
  73433. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73434. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73435. * @param path an array of Vector3, the curve axis of the Path3D
  73436. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73437. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73438. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  73439. */
  73440. constructor(
  73441. /**
  73442. * an array of Vector3, the curve axis of the Path3D
  73443. */
  73444. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  73445. /**
  73446. * Returns the Path3D array of successive Vector3 designing its curve.
  73447. * @returns the Path3D array of successive Vector3 designing its curve.
  73448. */
  73449. getCurve(): Vector3[];
  73450. /**
  73451. * Returns the Path3D array of successive Vector3 designing its curve.
  73452. * @returns the Path3D array of successive Vector3 designing its curve.
  73453. */
  73454. getPoints(): Vector3[];
  73455. /**
  73456. * @returns the computed length (float) of the path.
  73457. */
  73458. length(): number;
  73459. /**
  73460. * Returns an array populated with tangent vectors on each Path3D curve point.
  73461. * @returns an array populated with tangent vectors on each Path3D curve point.
  73462. */
  73463. getTangents(): Vector3[];
  73464. /**
  73465. * Returns an array populated with normal vectors on each Path3D curve point.
  73466. * @returns an array populated with normal vectors on each Path3D curve point.
  73467. */
  73468. getNormals(): Vector3[];
  73469. /**
  73470. * Returns an array populated with binormal vectors on each Path3D curve point.
  73471. * @returns an array populated with binormal vectors on each Path3D curve point.
  73472. */
  73473. getBinormals(): Vector3[];
  73474. /**
  73475. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73476. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73477. */
  73478. getDistances(): number[];
  73479. /**
  73480. * Returns an interpolated point along this path
  73481. * @param position the position of the point along this path, from 0.0 to 1.0
  73482. * @returns a new Vector3 as the point
  73483. */
  73484. getPointAt(position: number): Vector3;
  73485. /**
  73486. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73487. * @param position the position of the point along this path, from 0.0 to 1.0
  73488. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  73489. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  73490. */
  73491. getTangentAt(position: number, interpolated?: boolean): Vector3;
  73492. /**
  73493. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73494. * @param position the position of the point along this path, from 0.0 to 1.0
  73495. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  73496. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  73497. */
  73498. getNormalAt(position: number, interpolated?: boolean): Vector3;
  73499. /**
  73500. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  73501. * @param position the position of the point along this path, from 0.0 to 1.0
  73502. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  73503. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  73504. */
  73505. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  73506. /**
  73507. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  73508. * @param position the position of the point along this path, from 0.0 to 1.0
  73509. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  73510. */
  73511. getDistanceAt(position: number): number;
  73512. /**
  73513. * Returns the array index of the previous point of an interpolated point along this path
  73514. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73515. * @returns the array index
  73516. */
  73517. getPreviousPointIndexAt(position: number): number;
  73518. /**
  73519. * 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)
  73520. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73521. * @returns the sub position
  73522. */
  73523. getSubPositionAt(position: number): number;
  73524. /**
  73525. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  73526. * @param target the vector of which to get the closest position to
  73527. * @returns the position of the closest virtual point on this path to the target vector
  73528. */
  73529. getClosestPositionTo(target: Vector3): number;
  73530. /**
  73531. * Returns a sub path (slice) of this path
  73532. * @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
  73533. * @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
  73534. * @returns a sub path (slice) of this path
  73535. */
  73536. slice(start?: number, end?: number): Path3D;
  73537. /**
  73538. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73539. * @param path path which all values are copied into the curves points
  73540. * @param firstNormal which should be projected onto the curve
  73541. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73542. * @returns the same object updated.
  73543. */
  73544. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73545. private _compute;
  73546. private _getFirstNonNullVector;
  73547. private _getLastNonNullVector;
  73548. private _normalVector;
  73549. /**
  73550. * Updates the point at data for an interpolated point along this curve
  73551. * @param position the position of the point along this curve, from 0.0 to 1.0
  73552. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73553. * @returns the (updated) point at data
  73554. */
  73555. private _updatePointAtData;
  73556. /**
  73557. * Updates the point at data from the specified parameters
  73558. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73559. * @param point the interpolated point
  73560. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73561. */
  73562. private _setPointAtData;
  73563. /**
  73564. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73565. */
  73566. private _updateInterpolationMatrix;
  73567. }
  73568. /**
  73569. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73570. * A Curve3 is designed from a series of successive Vector3.
  73571. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73572. */
  73573. export class Curve3 {
  73574. private _points;
  73575. private _length;
  73576. /**
  73577. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73578. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73579. * @param v1 (Vector3) the control point
  73580. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73581. * @param nbPoints (integer) the wanted number of points in the curve
  73582. * @returns the created Curve3
  73583. */
  73584. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73585. /**
  73586. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73587. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73588. * @param v1 (Vector3) the first control point
  73589. * @param v2 (Vector3) the second control point
  73590. * @param v3 (Vector3) the end point of the Cubic Bezier
  73591. * @param nbPoints (integer) the wanted number of points in the curve
  73592. * @returns the created Curve3
  73593. */
  73594. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73595. /**
  73596. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73597. * @param p1 (Vector3) the origin point of the Hermite Spline
  73598. * @param t1 (Vector3) the tangent vector at the origin point
  73599. * @param p2 (Vector3) the end point of the Hermite Spline
  73600. * @param t2 (Vector3) the tangent vector at the end point
  73601. * @param nbPoints (integer) the wanted number of points in the curve
  73602. * @returns the created Curve3
  73603. */
  73604. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73605. /**
  73606. * Returns a Curve3 object along a CatmullRom Spline curve :
  73607. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73608. * @param nbPoints (integer) the wanted number of points between each curve control points
  73609. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73610. * @returns the created Curve3
  73611. */
  73612. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73613. /**
  73614. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73615. * A Curve3 is designed from a series of successive Vector3.
  73616. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73617. * @param points points which make up the curve
  73618. */
  73619. constructor(points: Vector3[]);
  73620. /**
  73621. * @returns the Curve3 stored array of successive Vector3
  73622. */
  73623. getPoints(): Vector3[];
  73624. /**
  73625. * @returns the computed length (float) of the curve.
  73626. */
  73627. length(): number;
  73628. /**
  73629. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73630. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73631. * curveA and curveB keep unchanged.
  73632. * @param curve the curve to continue from this curve
  73633. * @returns the newly constructed curve
  73634. */
  73635. continue(curve: DeepImmutable<Curve3>): Curve3;
  73636. private _computeLength;
  73637. }
  73638. }
  73639. declare module BABYLON {
  73640. /**
  73641. * This represents the main contract an easing function should follow.
  73642. * Easing functions are used throughout the animation system.
  73643. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73644. */
  73645. export interface IEasingFunction {
  73646. /**
  73647. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73648. * of the easing function.
  73649. * The link below provides some of the most common examples of easing functions.
  73650. * @see https://easings.net/
  73651. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73652. * @returns the corresponding value on the curve defined by the easing function
  73653. */
  73654. ease(gradient: number): number;
  73655. }
  73656. /**
  73657. * Base class used for every default easing function.
  73658. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73659. */
  73660. export class EasingFunction implements IEasingFunction {
  73661. /**
  73662. * Interpolation follows the mathematical formula associated with the easing function.
  73663. */
  73664. static readonly EASINGMODE_EASEIN: number;
  73665. /**
  73666. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73667. */
  73668. static readonly EASINGMODE_EASEOUT: number;
  73669. /**
  73670. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73671. */
  73672. static readonly EASINGMODE_EASEINOUT: number;
  73673. private _easingMode;
  73674. /**
  73675. * Sets the easing mode of the current function.
  73676. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73677. */
  73678. setEasingMode(easingMode: number): void;
  73679. /**
  73680. * Gets the current easing mode.
  73681. * @returns the easing mode
  73682. */
  73683. getEasingMode(): number;
  73684. /**
  73685. * @hidden
  73686. */
  73687. easeInCore(gradient: number): number;
  73688. /**
  73689. * Given an input gradient between 0 and 1, this returns the corresponding value
  73690. * of the easing function.
  73691. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73692. * @returns the corresponding value on the curve defined by the easing function
  73693. */
  73694. ease(gradient: number): number;
  73695. }
  73696. /**
  73697. * Easing function with a circle shape (see link below).
  73698. * @see https://easings.net/#easeInCirc
  73699. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73700. */
  73701. export class CircleEase extends EasingFunction implements IEasingFunction {
  73702. /** @hidden */
  73703. easeInCore(gradient: number): number;
  73704. }
  73705. /**
  73706. * Easing function with a ease back shape (see link below).
  73707. * @see https://easings.net/#easeInBack
  73708. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73709. */
  73710. export class BackEase extends EasingFunction implements IEasingFunction {
  73711. /** Defines the amplitude of the function */
  73712. amplitude: number;
  73713. /**
  73714. * Instantiates a back ease easing
  73715. * @see https://easings.net/#easeInBack
  73716. * @param amplitude Defines the amplitude of the function
  73717. */
  73718. constructor(
  73719. /** Defines the amplitude of the function */
  73720. amplitude?: number);
  73721. /** @hidden */
  73722. easeInCore(gradient: number): number;
  73723. }
  73724. /**
  73725. * Easing function with a bouncing shape (see link below).
  73726. * @see https://easings.net/#easeInBounce
  73727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73728. */
  73729. export class BounceEase extends EasingFunction implements IEasingFunction {
  73730. /** Defines the number of bounces */
  73731. bounces: number;
  73732. /** Defines the amplitude of the bounce */
  73733. bounciness: number;
  73734. /**
  73735. * Instantiates a bounce easing
  73736. * @see https://easings.net/#easeInBounce
  73737. * @param bounces Defines the number of bounces
  73738. * @param bounciness Defines the amplitude of the bounce
  73739. */
  73740. constructor(
  73741. /** Defines the number of bounces */
  73742. bounces?: number,
  73743. /** Defines the amplitude of the bounce */
  73744. bounciness?: number);
  73745. /** @hidden */
  73746. easeInCore(gradient: number): number;
  73747. }
  73748. /**
  73749. * Easing function with a power of 3 shape (see link below).
  73750. * @see https://easings.net/#easeInCubic
  73751. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73752. */
  73753. export class CubicEase extends EasingFunction implements IEasingFunction {
  73754. /** @hidden */
  73755. easeInCore(gradient: number): number;
  73756. }
  73757. /**
  73758. * Easing function with an elastic shape (see link below).
  73759. * @see https://easings.net/#easeInElastic
  73760. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73761. */
  73762. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73763. /** Defines the number of oscillations*/
  73764. oscillations: number;
  73765. /** Defines the amplitude of the oscillations*/
  73766. springiness: number;
  73767. /**
  73768. * Instantiates an elastic easing function
  73769. * @see https://easings.net/#easeInElastic
  73770. * @param oscillations Defines the number of oscillations
  73771. * @param springiness Defines the amplitude of the oscillations
  73772. */
  73773. constructor(
  73774. /** Defines the number of oscillations*/
  73775. oscillations?: number,
  73776. /** Defines the amplitude of the oscillations*/
  73777. springiness?: number);
  73778. /** @hidden */
  73779. easeInCore(gradient: number): number;
  73780. }
  73781. /**
  73782. * Easing function with an exponential shape (see link below).
  73783. * @see https://easings.net/#easeInExpo
  73784. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73785. */
  73786. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73787. /** Defines the exponent of the function */
  73788. exponent: number;
  73789. /**
  73790. * Instantiates an exponential easing function
  73791. * @see https://easings.net/#easeInExpo
  73792. * @param exponent Defines the exponent of the function
  73793. */
  73794. constructor(
  73795. /** Defines the exponent of the function */
  73796. exponent?: number);
  73797. /** @hidden */
  73798. easeInCore(gradient: number): number;
  73799. }
  73800. /**
  73801. * Easing function with a power shape (see link below).
  73802. * @see https://easings.net/#easeInQuad
  73803. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73804. */
  73805. export class PowerEase extends EasingFunction implements IEasingFunction {
  73806. /** Defines the power of the function */
  73807. power: number;
  73808. /**
  73809. * Instantiates an power base easing function
  73810. * @see https://easings.net/#easeInQuad
  73811. * @param power Defines the power of the function
  73812. */
  73813. constructor(
  73814. /** Defines the power of the function */
  73815. power?: number);
  73816. /** @hidden */
  73817. easeInCore(gradient: number): number;
  73818. }
  73819. /**
  73820. * Easing function with a power of 2 shape (see link below).
  73821. * @see https://easings.net/#easeInQuad
  73822. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73823. */
  73824. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73825. /** @hidden */
  73826. easeInCore(gradient: number): number;
  73827. }
  73828. /**
  73829. * Easing function with a power of 4 shape (see link below).
  73830. * @see https://easings.net/#easeInQuart
  73831. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73832. */
  73833. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73834. /** @hidden */
  73835. easeInCore(gradient: number): number;
  73836. }
  73837. /**
  73838. * Easing function with a power of 5 shape (see link below).
  73839. * @see https://easings.net/#easeInQuint
  73840. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73841. */
  73842. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73843. /** @hidden */
  73844. easeInCore(gradient: number): number;
  73845. }
  73846. /**
  73847. * Easing function with a sin shape (see link below).
  73848. * @see https://easings.net/#easeInSine
  73849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73850. */
  73851. export class SineEase extends EasingFunction implements IEasingFunction {
  73852. /** @hidden */
  73853. easeInCore(gradient: number): number;
  73854. }
  73855. /**
  73856. * Easing function with a bezier shape (see link below).
  73857. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73858. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73859. */
  73860. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73861. /** Defines the x component of the start tangent in the bezier curve */
  73862. x1: number;
  73863. /** Defines the y component of the start tangent in the bezier curve */
  73864. y1: number;
  73865. /** Defines the x component of the end tangent in the bezier curve */
  73866. x2: number;
  73867. /** Defines the y component of the end tangent in the bezier curve */
  73868. y2: number;
  73869. /**
  73870. * Instantiates a bezier function
  73871. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73872. * @param x1 Defines the x component of the start tangent in the bezier curve
  73873. * @param y1 Defines the y component of the start tangent in the bezier curve
  73874. * @param x2 Defines the x component of the end tangent in the bezier curve
  73875. * @param y2 Defines the y component of the end tangent in the bezier curve
  73876. */
  73877. constructor(
  73878. /** Defines the x component of the start tangent in the bezier curve */
  73879. x1?: number,
  73880. /** Defines the y component of the start tangent in the bezier curve */
  73881. y1?: number,
  73882. /** Defines the x component of the end tangent in the bezier curve */
  73883. x2?: number,
  73884. /** Defines the y component of the end tangent in the bezier curve */
  73885. y2?: number);
  73886. /** @hidden */
  73887. easeInCore(gradient: number): number;
  73888. }
  73889. }
  73890. declare module BABYLON {
  73891. /**
  73892. * Class used to hold a RBG color
  73893. */
  73894. export class Color3 {
  73895. /**
  73896. * Defines the red component (between 0 and 1, default is 0)
  73897. */
  73898. r: number;
  73899. /**
  73900. * Defines the green component (between 0 and 1, default is 0)
  73901. */
  73902. g: number;
  73903. /**
  73904. * Defines the blue component (between 0 and 1, default is 0)
  73905. */
  73906. b: number;
  73907. /**
  73908. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73909. * @param r defines the red component (between 0 and 1, default is 0)
  73910. * @param g defines the green component (between 0 and 1, default is 0)
  73911. * @param b defines the blue component (between 0 and 1, default is 0)
  73912. */
  73913. constructor(
  73914. /**
  73915. * Defines the red component (between 0 and 1, default is 0)
  73916. */
  73917. r?: number,
  73918. /**
  73919. * Defines the green component (between 0 and 1, default is 0)
  73920. */
  73921. g?: number,
  73922. /**
  73923. * Defines the blue component (between 0 and 1, default is 0)
  73924. */
  73925. b?: number);
  73926. /**
  73927. * Creates a string with the Color3 current values
  73928. * @returns the string representation of the Color3 object
  73929. */
  73930. toString(): string;
  73931. /**
  73932. * Returns the string "Color3"
  73933. * @returns "Color3"
  73934. */
  73935. getClassName(): string;
  73936. /**
  73937. * Compute the Color3 hash code
  73938. * @returns an unique number that can be used to hash Color3 objects
  73939. */
  73940. getHashCode(): number;
  73941. /**
  73942. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73943. * @param array defines the array where to store the r,g,b components
  73944. * @param index defines an optional index in the target array to define where to start storing values
  73945. * @returns the current Color3 object
  73946. */
  73947. toArray(array: FloatArray, index?: number): Color3;
  73948. /**
  73949. * Returns a new Color4 object from the current Color3 and the given alpha
  73950. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73951. * @returns a new Color4 object
  73952. */
  73953. toColor4(alpha?: number): Color4;
  73954. /**
  73955. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73956. * @returns the new array
  73957. */
  73958. asArray(): number[];
  73959. /**
  73960. * Returns the luminance value
  73961. * @returns a float value
  73962. */
  73963. toLuminance(): number;
  73964. /**
  73965. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73966. * @param otherColor defines the second operand
  73967. * @returns the new Color3 object
  73968. */
  73969. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73970. /**
  73971. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73972. * @param otherColor defines the second operand
  73973. * @param result defines the Color3 object where to store the result
  73974. * @returns the current Color3
  73975. */
  73976. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73977. /**
  73978. * Determines equality between Color3 objects
  73979. * @param otherColor defines the second operand
  73980. * @returns true if the rgb values are equal to the given ones
  73981. */
  73982. equals(otherColor: DeepImmutable<Color3>): boolean;
  73983. /**
  73984. * Determines equality between the current Color3 object and a set of r,b,g values
  73985. * @param r defines the red component to check
  73986. * @param g defines the green component to check
  73987. * @param b defines the blue component to check
  73988. * @returns true if the rgb values are equal to the given ones
  73989. */
  73990. equalsFloats(r: number, g: number, b: number): boolean;
  73991. /**
  73992. * Multiplies in place each rgb value by scale
  73993. * @param scale defines the scaling factor
  73994. * @returns the updated Color3
  73995. */
  73996. scale(scale: number): Color3;
  73997. /**
  73998. * Multiplies the rgb values by scale and stores the result into "result"
  73999. * @param scale defines the scaling factor
  74000. * @param result defines the Color3 object where to store the result
  74001. * @returns the unmodified current Color3
  74002. */
  74003. scaleToRef(scale: number, result: Color3): Color3;
  74004. /**
  74005. * Scale the current Color3 values by a factor and add the result to a given Color3
  74006. * @param scale defines the scale factor
  74007. * @param result defines color to store the result into
  74008. * @returns the unmodified current Color3
  74009. */
  74010. scaleAndAddToRef(scale: number, result: Color3): Color3;
  74011. /**
  74012. * Clamps the rgb values by the min and max values and stores the result into "result"
  74013. * @param min defines minimum clamping value (default is 0)
  74014. * @param max defines maximum clamping value (default is 1)
  74015. * @param result defines color to store the result into
  74016. * @returns the original Color3
  74017. */
  74018. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  74019. /**
  74020. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  74021. * @param otherColor defines the second operand
  74022. * @returns the new Color3
  74023. */
  74024. add(otherColor: DeepImmutable<Color3>): Color3;
  74025. /**
  74026. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  74027. * @param otherColor defines the second operand
  74028. * @param result defines Color3 object to store the result into
  74029. * @returns the unmodified current Color3
  74030. */
  74031. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74032. /**
  74033. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  74034. * @param otherColor defines the second operand
  74035. * @returns the new Color3
  74036. */
  74037. subtract(otherColor: DeepImmutable<Color3>): Color3;
  74038. /**
  74039. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  74040. * @param otherColor defines the second operand
  74041. * @param result defines Color3 object to store the result into
  74042. * @returns the unmodified current Color3
  74043. */
  74044. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74045. /**
  74046. * Copy the current object
  74047. * @returns a new Color3 copied the current one
  74048. */
  74049. clone(): Color3;
  74050. /**
  74051. * Copies the rgb values from the source in the current Color3
  74052. * @param source defines the source Color3 object
  74053. * @returns the updated Color3 object
  74054. */
  74055. copyFrom(source: DeepImmutable<Color3>): Color3;
  74056. /**
  74057. * Updates the Color3 rgb values from the given floats
  74058. * @param r defines the red component to read from
  74059. * @param g defines the green component to read from
  74060. * @param b defines the blue component to read from
  74061. * @returns the current Color3 object
  74062. */
  74063. copyFromFloats(r: number, g: number, b: number): Color3;
  74064. /**
  74065. * Updates the Color3 rgb values from the given floats
  74066. * @param r defines the red component to read from
  74067. * @param g defines the green component to read from
  74068. * @param b defines the blue component to read from
  74069. * @returns the current Color3 object
  74070. */
  74071. set(r: number, g: number, b: number): Color3;
  74072. /**
  74073. * Compute the Color3 hexadecimal code as a string
  74074. * @returns a string containing the hexadecimal representation of the Color3 object
  74075. */
  74076. toHexString(): string;
  74077. /**
  74078. * Computes a new Color3 converted from the current one to linear space
  74079. * @returns a new Color3 object
  74080. */
  74081. toLinearSpace(): Color3;
  74082. /**
  74083. * Converts current color in rgb space to HSV values
  74084. * @returns a new color3 representing the HSV values
  74085. */
  74086. toHSV(): Color3;
  74087. /**
  74088. * Converts current color in rgb space to HSV values
  74089. * @param result defines the Color3 where to store the HSV values
  74090. */
  74091. toHSVToRef(result: Color3): void;
  74092. /**
  74093. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  74094. * @param convertedColor defines the Color3 object where to store the linear space version
  74095. * @returns the unmodified Color3
  74096. */
  74097. toLinearSpaceToRef(convertedColor: Color3): Color3;
  74098. /**
  74099. * Computes a new Color3 converted from the current one to gamma space
  74100. * @returns a new Color3 object
  74101. */
  74102. toGammaSpace(): Color3;
  74103. /**
  74104. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  74105. * @param convertedColor defines the Color3 object where to store the gamma space version
  74106. * @returns the unmodified Color3
  74107. */
  74108. toGammaSpaceToRef(convertedColor: Color3): Color3;
  74109. private static _BlackReadOnly;
  74110. /**
  74111. * Convert Hue, saturation and value to a Color3 (RGB)
  74112. * @param hue defines the hue
  74113. * @param saturation defines the saturation
  74114. * @param value defines the value
  74115. * @param result defines the Color3 where to store the RGB values
  74116. */
  74117. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  74118. /**
  74119. * Creates a new Color3 from the string containing valid hexadecimal values
  74120. * @param hex defines a string containing valid hexadecimal values
  74121. * @returns a new Color3 object
  74122. */
  74123. static FromHexString(hex: string): Color3;
  74124. /**
  74125. * Creates a new Color3 from the starting index of the given array
  74126. * @param array defines the source array
  74127. * @param offset defines an offset in the source array
  74128. * @returns a new Color3 object
  74129. */
  74130. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  74131. /**
  74132. * Creates a new Color3 from integer values (< 256)
  74133. * @param r defines the red component to read from (value between 0 and 255)
  74134. * @param g defines the green component to read from (value between 0 and 255)
  74135. * @param b defines the blue component to read from (value between 0 and 255)
  74136. * @returns a new Color3 object
  74137. */
  74138. static FromInts(r: number, g: number, b: number): Color3;
  74139. /**
  74140. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74141. * @param start defines the start Color3 value
  74142. * @param end defines the end Color3 value
  74143. * @param amount defines the gradient value between start and end
  74144. * @returns a new Color3 object
  74145. */
  74146. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  74147. /**
  74148. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74149. * @param left defines the start value
  74150. * @param right defines the end value
  74151. * @param amount defines the gradient factor
  74152. * @param result defines the Color3 object where to store the result
  74153. */
  74154. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  74155. /**
  74156. * Returns a Color3 value containing a red color
  74157. * @returns a new Color3 object
  74158. */
  74159. static Red(): Color3;
  74160. /**
  74161. * Returns a Color3 value containing a green color
  74162. * @returns a new Color3 object
  74163. */
  74164. static Green(): Color3;
  74165. /**
  74166. * Returns a Color3 value containing a blue color
  74167. * @returns a new Color3 object
  74168. */
  74169. static Blue(): Color3;
  74170. /**
  74171. * Returns a Color3 value containing a black color
  74172. * @returns a new Color3 object
  74173. */
  74174. static Black(): Color3;
  74175. /**
  74176. * Gets a Color3 value containing a black color that must not be updated
  74177. */
  74178. static readonly BlackReadOnly: DeepImmutable<Color3>;
  74179. /**
  74180. * Returns a Color3 value containing a white color
  74181. * @returns a new Color3 object
  74182. */
  74183. static White(): Color3;
  74184. /**
  74185. * Returns a Color3 value containing a purple color
  74186. * @returns a new Color3 object
  74187. */
  74188. static Purple(): Color3;
  74189. /**
  74190. * Returns a Color3 value containing a magenta color
  74191. * @returns a new Color3 object
  74192. */
  74193. static Magenta(): Color3;
  74194. /**
  74195. * Returns a Color3 value containing a yellow color
  74196. * @returns a new Color3 object
  74197. */
  74198. static Yellow(): Color3;
  74199. /**
  74200. * Returns a Color3 value containing a gray color
  74201. * @returns a new Color3 object
  74202. */
  74203. static Gray(): Color3;
  74204. /**
  74205. * Returns a Color3 value containing a teal color
  74206. * @returns a new Color3 object
  74207. */
  74208. static Teal(): Color3;
  74209. /**
  74210. * Returns a Color3 value containing a random color
  74211. * @returns a new Color3 object
  74212. */
  74213. static Random(): Color3;
  74214. }
  74215. /**
  74216. * Class used to hold a RBGA color
  74217. */
  74218. export class Color4 {
  74219. /**
  74220. * Defines the red component (between 0 and 1, default is 0)
  74221. */
  74222. r: number;
  74223. /**
  74224. * Defines the green component (between 0 and 1, default is 0)
  74225. */
  74226. g: number;
  74227. /**
  74228. * Defines the blue component (between 0 and 1, default is 0)
  74229. */
  74230. b: number;
  74231. /**
  74232. * Defines the alpha component (between 0 and 1, default is 1)
  74233. */
  74234. a: number;
  74235. /**
  74236. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  74237. * @param r defines the red component (between 0 and 1, default is 0)
  74238. * @param g defines the green component (between 0 and 1, default is 0)
  74239. * @param b defines the blue component (between 0 and 1, default is 0)
  74240. * @param a defines the alpha component (between 0 and 1, default is 1)
  74241. */
  74242. constructor(
  74243. /**
  74244. * Defines the red component (between 0 and 1, default is 0)
  74245. */
  74246. r?: number,
  74247. /**
  74248. * Defines the green component (between 0 and 1, default is 0)
  74249. */
  74250. g?: number,
  74251. /**
  74252. * Defines the blue component (between 0 and 1, default is 0)
  74253. */
  74254. b?: number,
  74255. /**
  74256. * Defines the alpha component (between 0 and 1, default is 1)
  74257. */
  74258. a?: number);
  74259. /**
  74260. * Adds in place the given Color4 values to the current Color4 object
  74261. * @param right defines the second operand
  74262. * @returns the current updated Color4 object
  74263. */
  74264. addInPlace(right: DeepImmutable<Color4>): Color4;
  74265. /**
  74266. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  74267. * @returns the new array
  74268. */
  74269. asArray(): number[];
  74270. /**
  74271. * Stores from the starting index in the given array the Color4 successive values
  74272. * @param array defines the array where to store the r,g,b components
  74273. * @param index defines an optional index in the target array to define where to start storing values
  74274. * @returns the current Color4 object
  74275. */
  74276. toArray(array: number[], index?: number): Color4;
  74277. /**
  74278. * Determines equality between Color4 objects
  74279. * @param otherColor defines the second operand
  74280. * @returns true if the rgba values are equal to the given ones
  74281. */
  74282. equals(otherColor: DeepImmutable<Color4>): boolean;
  74283. /**
  74284. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  74285. * @param right defines the second operand
  74286. * @returns a new Color4 object
  74287. */
  74288. add(right: DeepImmutable<Color4>): Color4;
  74289. /**
  74290. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  74291. * @param right defines the second operand
  74292. * @returns a new Color4 object
  74293. */
  74294. subtract(right: DeepImmutable<Color4>): Color4;
  74295. /**
  74296. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  74297. * @param right defines the second operand
  74298. * @param result defines the Color4 object where to store the result
  74299. * @returns the current Color4 object
  74300. */
  74301. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  74302. /**
  74303. * Creates a new Color4 with the current Color4 values multiplied by scale
  74304. * @param scale defines the scaling factor to apply
  74305. * @returns a new Color4 object
  74306. */
  74307. scale(scale: number): Color4;
  74308. /**
  74309. * Multiplies the current Color4 values by scale and stores the result in "result"
  74310. * @param scale defines the scaling factor to apply
  74311. * @param result defines the Color4 object where to store the result
  74312. * @returns the current unmodified Color4
  74313. */
  74314. scaleToRef(scale: number, result: Color4): Color4;
  74315. /**
  74316. * Scale the current Color4 values by a factor and add the result to a given Color4
  74317. * @param scale defines the scale factor
  74318. * @param result defines the Color4 object where to store the result
  74319. * @returns the unmodified current Color4
  74320. */
  74321. scaleAndAddToRef(scale: number, result: Color4): Color4;
  74322. /**
  74323. * Clamps the rgb values by the min and max values and stores the result into "result"
  74324. * @param min defines minimum clamping value (default is 0)
  74325. * @param max defines maximum clamping value (default is 1)
  74326. * @param result defines color to store the result into.
  74327. * @returns the cuurent Color4
  74328. */
  74329. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  74330. /**
  74331. * Multipy an Color4 value by another and return a new Color4 object
  74332. * @param color defines the Color4 value to multiply by
  74333. * @returns a new Color4 object
  74334. */
  74335. multiply(color: Color4): Color4;
  74336. /**
  74337. * Multipy a Color4 value by another and push the result in a reference value
  74338. * @param color defines the Color4 value to multiply by
  74339. * @param result defines the Color4 to fill the result in
  74340. * @returns the result Color4
  74341. */
  74342. multiplyToRef(color: Color4, result: Color4): Color4;
  74343. /**
  74344. * Creates a string with the Color4 current values
  74345. * @returns the string representation of the Color4 object
  74346. */
  74347. toString(): string;
  74348. /**
  74349. * Returns the string "Color4"
  74350. * @returns "Color4"
  74351. */
  74352. getClassName(): string;
  74353. /**
  74354. * Compute the Color4 hash code
  74355. * @returns an unique number that can be used to hash Color4 objects
  74356. */
  74357. getHashCode(): number;
  74358. /**
  74359. * Creates a new Color4 copied from the current one
  74360. * @returns a new Color4 object
  74361. */
  74362. clone(): Color4;
  74363. /**
  74364. * Copies the given Color4 values into the current one
  74365. * @param source defines the source Color4 object
  74366. * @returns the current updated Color4 object
  74367. */
  74368. copyFrom(source: Color4): Color4;
  74369. /**
  74370. * Copies the given float values into the current one
  74371. * @param r defines the red component to read from
  74372. * @param g defines the green component to read from
  74373. * @param b defines the blue component to read from
  74374. * @param a defines the alpha component to read from
  74375. * @returns the current updated Color4 object
  74376. */
  74377. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  74378. /**
  74379. * Copies the given float values into the current one
  74380. * @param r defines the red component to read from
  74381. * @param g defines the green component to read from
  74382. * @param b defines the blue component to read from
  74383. * @param a defines the alpha component to read from
  74384. * @returns the current updated Color4 object
  74385. */
  74386. set(r: number, g: number, b: number, a: number): Color4;
  74387. /**
  74388. * Compute the Color4 hexadecimal code as a string
  74389. * @returns a string containing the hexadecimal representation of the Color4 object
  74390. */
  74391. toHexString(): string;
  74392. /**
  74393. * Computes a new Color4 converted from the current one to linear space
  74394. * @returns a new Color4 object
  74395. */
  74396. toLinearSpace(): Color4;
  74397. /**
  74398. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  74399. * @param convertedColor defines the Color4 object where to store the linear space version
  74400. * @returns the unmodified Color4
  74401. */
  74402. toLinearSpaceToRef(convertedColor: Color4): Color4;
  74403. /**
  74404. * Computes a new Color4 converted from the current one to gamma space
  74405. * @returns a new Color4 object
  74406. */
  74407. toGammaSpace(): Color4;
  74408. /**
  74409. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  74410. * @param convertedColor defines the Color4 object where to store the gamma space version
  74411. * @returns the unmodified Color4
  74412. */
  74413. toGammaSpaceToRef(convertedColor: Color4): Color4;
  74414. /**
  74415. * Creates a new Color4 from the string containing valid hexadecimal values
  74416. * @param hex defines a string containing valid hexadecimal values
  74417. * @returns a new Color4 object
  74418. */
  74419. static FromHexString(hex: string): Color4;
  74420. /**
  74421. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74422. * @param left defines the start value
  74423. * @param right defines the end value
  74424. * @param amount defines the gradient factor
  74425. * @returns a new Color4 object
  74426. */
  74427. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  74428. /**
  74429. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74430. * @param left defines the start value
  74431. * @param right defines the end value
  74432. * @param amount defines the gradient factor
  74433. * @param result defines the Color4 object where to store data
  74434. */
  74435. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  74436. /**
  74437. * Creates a new Color4 from a Color3 and an alpha value
  74438. * @param color3 defines the source Color3 to read from
  74439. * @param alpha defines the alpha component (1.0 by default)
  74440. * @returns a new Color4 object
  74441. */
  74442. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  74443. /**
  74444. * Creates a new Color4 from the starting index element of the given array
  74445. * @param array defines the source array to read from
  74446. * @param offset defines the offset in the source array
  74447. * @returns a new Color4 object
  74448. */
  74449. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  74450. /**
  74451. * Creates a new Color3 from integer values (< 256)
  74452. * @param r defines the red component to read from (value between 0 and 255)
  74453. * @param g defines the green component to read from (value between 0 and 255)
  74454. * @param b defines the blue component to read from (value between 0 and 255)
  74455. * @param a defines the alpha component to read from (value between 0 and 255)
  74456. * @returns a new Color3 object
  74457. */
  74458. static FromInts(r: number, g: number, b: number, a: number): Color4;
  74459. /**
  74460. * Check the content of a given array and convert it to an array containing RGBA data
  74461. * If the original array was already containing count * 4 values then it is returned directly
  74462. * @param colors defines the array to check
  74463. * @param count defines the number of RGBA data to expect
  74464. * @returns an array containing count * 4 values (RGBA)
  74465. */
  74466. static CheckColors4(colors: number[], count: number): number[];
  74467. }
  74468. /**
  74469. * @hidden
  74470. */
  74471. export class TmpColors {
  74472. static Color3: Color3[];
  74473. static Color4: Color4[];
  74474. }
  74475. }
  74476. declare module BABYLON {
  74477. /**
  74478. * Defines an interface which represents an animation key frame
  74479. */
  74480. export interface IAnimationKey {
  74481. /**
  74482. * Frame of the key frame
  74483. */
  74484. frame: number;
  74485. /**
  74486. * Value at the specifies key frame
  74487. */
  74488. value: any;
  74489. /**
  74490. * The input tangent for the cubic hermite spline
  74491. */
  74492. inTangent?: any;
  74493. /**
  74494. * The output tangent for the cubic hermite spline
  74495. */
  74496. outTangent?: any;
  74497. /**
  74498. * The animation interpolation type
  74499. */
  74500. interpolation?: AnimationKeyInterpolation;
  74501. }
  74502. /**
  74503. * Enum for the animation key frame interpolation type
  74504. */
  74505. export enum AnimationKeyInterpolation {
  74506. /**
  74507. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  74508. */
  74509. STEP = 1
  74510. }
  74511. }
  74512. declare module BABYLON {
  74513. /**
  74514. * Represents the range of an animation
  74515. */
  74516. export class AnimationRange {
  74517. /**The name of the animation range**/
  74518. name: string;
  74519. /**The starting frame of the animation */
  74520. from: number;
  74521. /**The ending frame of the animation*/
  74522. to: number;
  74523. /**
  74524. * Initializes the range of an animation
  74525. * @param name The name of the animation range
  74526. * @param from The starting frame of the animation
  74527. * @param to The ending frame of the animation
  74528. */
  74529. constructor(
  74530. /**The name of the animation range**/
  74531. name: string,
  74532. /**The starting frame of the animation */
  74533. from: number,
  74534. /**The ending frame of the animation*/
  74535. to: number);
  74536. /**
  74537. * Makes a copy of the animation range
  74538. * @returns A copy of the animation range
  74539. */
  74540. clone(): AnimationRange;
  74541. }
  74542. }
  74543. declare module BABYLON {
  74544. /**
  74545. * Composed of a frame, and an action function
  74546. */
  74547. export class AnimationEvent {
  74548. /** The frame for which the event is triggered **/
  74549. frame: number;
  74550. /** The event to perform when triggered **/
  74551. action: (currentFrame: number) => void;
  74552. /** Specifies if the event should be triggered only once**/
  74553. onlyOnce?: boolean | undefined;
  74554. /**
  74555. * Specifies if the animation event is done
  74556. */
  74557. isDone: boolean;
  74558. /**
  74559. * Initializes the animation event
  74560. * @param frame The frame for which the event is triggered
  74561. * @param action The event to perform when triggered
  74562. * @param onlyOnce Specifies if the event should be triggered only once
  74563. */
  74564. constructor(
  74565. /** The frame for which the event is triggered **/
  74566. frame: number,
  74567. /** The event to perform when triggered **/
  74568. action: (currentFrame: number) => void,
  74569. /** Specifies if the event should be triggered only once**/
  74570. onlyOnce?: boolean | undefined);
  74571. /** @hidden */
  74572. _clone(): AnimationEvent;
  74573. }
  74574. }
  74575. declare module BABYLON {
  74576. /**
  74577. * Interface used to define a behavior
  74578. */
  74579. export interface Behavior<T> {
  74580. /** gets or sets behavior's name */
  74581. name: string;
  74582. /**
  74583. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74584. */
  74585. init(): void;
  74586. /**
  74587. * Called when the behavior is attached to a target
  74588. * @param target defines the target where the behavior is attached to
  74589. */
  74590. attach(target: T): void;
  74591. /**
  74592. * Called when the behavior is detached from its target
  74593. */
  74594. detach(): void;
  74595. }
  74596. /**
  74597. * Interface implemented by classes supporting behaviors
  74598. */
  74599. export interface IBehaviorAware<T> {
  74600. /**
  74601. * Attach a behavior
  74602. * @param behavior defines the behavior to attach
  74603. * @returns the current host
  74604. */
  74605. addBehavior(behavior: Behavior<T>): T;
  74606. /**
  74607. * Remove a behavior from the current object
  74608. * @param behavior defines the behavior to detach
  74609. * @returns the current host
  74610. */
  74611. removeBehavior(behavior: Behavior<T>): T;
  74612. /**
  74613. * Gets a behavior using its name to search
  74614. * @param name defines the name to search
  74615. * @returns the behavior or null if not found
  74616. */
  74617. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74618. }
  74619. }
  74620. declare module BABYLON {
  74621. /**
  74622. * Defines an array and its length.
  74623. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74624. */
  74625. export interface ISmartArrayLike<T> {
  74626. /**
  74627. * The data of the array.
  74628. */
  74629. data: Array<T>;
  74630. /**
  74631. * The active length of the array.
  74632. */
  74633. length: number;
  74634. }
  74635. /**
  74636. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74637. */
  74638. export class SmartArray<T> implements ISmartArrayLike<T> {
  74639. /**
  74640. * The full set of data from the array.
  74641. */
  74642. data: Array<T>;
  74643. /**
  74644. * The active length of the array.
  74645. */
  74646. length: number;
  74647. protected _id: number;
  74648. /**
  74649. * Instantiates a Smart Array.
  74650. * @param capacity defines the default capacity of the array.
  74651. */
  74652. constructor(capacity: number);
  74653. /**
  74654. * Pushes a value at the end of the active data.
  74655. * @param value defines the object to push in the array.
  74656. */
  74657. push(value: T): void;
  74658. /**
  74659. * Iterates over the active data and apply the lambda to them.
  74660. * @param func defines the action to apply on each value.
  74661. */
  74662. forEach(func: (content: T) => void): void;
  74663. /**
  74664. * Sorts the full sets of data.
  74665. * @param compareFn defines the comparison function to apply.
  74666. */
  74667. sort(compareFn: (a: T, b: T) => number): void;
  74668. /**
  74669. * Resets the active data to an empty array.
  74670. */
  74671. reset(): void;
  74672. /**
  74673. * Releases all the data from the array as well as the array.
  74674. */
  74675. dispose(): void;
  74676. /**
  74677. * Concats the active data with a given array.
  74678. * @param array defines the data to concatenate with.
  74679. */
  74680. concat(array: any): void;
  74681. /**
  74682. * Returns the position of a value in the active data.
  74683. * @param value defines the value to find the index for
  74684. * @returns the index if found in the active data otherwise -1
  74685. */
  74686. indexOf(value: T): number;
  74687. /**
  74688. * Returns whether an element is part of the active data.
  74689. * @param value defines the value to look for
  74690. * @returns true if found in the active data otherwise false
  74691. */
  74692. contains(value: T): boolean;
  74693. private static _GlobalId;
  74694. }
  74695. /**
  74696. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74697. * The data in this array can only be present once
  74698. */
  74699. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  74700. private _duplicateId;
  74701. /**
  74702. * Pushes a value at the end of the active data.
  74703. * THIS DOES NOT PREVENT DUPPLICATE DATA
  74704. * @param value defines the object to push in the array.
  74705. */
  74706. push(value: T): void;
  74707. /**
  74708. * Pushes a value at the end of the active data.
  74709. * If the data is already present, it won t be added again
  74710. * @param value defines the object to push in the array.
  74711. * @returns true if added false if it was already present
  74712. */
  74713. pushNoDuplicate(value: T): boolean;
  74714. /**
  74715. * Resets the active data to an empty array.
  74716. */
  74717. reset(): void;
  74718. /**
  74719. * Concats the active data with a given array.
  74720. * This ensures no dupplicate will be present in the result.
  74721. * @param array defines the data to concatenate with.
  74722. */
  74723. concatWithNoDuplicate(array: any): void;
  74724. }
  74725. }
  74726. declare module BABYLON {
  74727. /**
  74728. * @ignore
  74729. * This is a list of all the different input types that are available in the application.
  74730. * Fo instance: ArcRotateCameraGamepadInput...
  74731. */
  74732. export var CameraInputTypes: {};
  74733. /**
  74734. * This is the contract to implement in order to create a new input class.
  74735. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74736. */
  74737. export interface ICameraInput<TCamera extends Camera> {
  74738. /**
  74739. * Defines the camera the input is attached to.
  74740. */
  74741. camera: Nullable<TCamera>;
  74742. /**
  74743. * Gets the class name of the current intput.
  74744. * @returns the class name
  74745. */
  74746. getClassName(): string;
  74747. /**
  74748. * Get the friendly name associated with the input class.
  74749. * @returns the input friendly name
  74750. */
  74751. getSimpleName(): string;
  74752. /**
  74753. * Attach the input controls to a specific dom element to get the input from.
  74754. * @param element Defines the element the controls should be listened from
  74755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74756. */
  74757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74758. /**
  74759. * Detach the current controls from the specified dom element.
  74760. * @param element Defines the element to stop listening the inputs from
  74761. */
  74762. detachControl(element: Nullable<HTMLElement>): void;
  74763. /**
  74764. * Update the current camera state depending on the inputs that have been used this frame.
  74765. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74766. */
  74767. checkInputs?: () => void;
  74768. }
  74769. /**
  74770. * Represents a map of input types to input instance or input index to input instance.
  74771. */
  74772. export interface CameraInputsMap<TCamera extends Camera> {
  74773. /**
  74774. * Accessor to the input by input type.
  74775. */
  74776. [name: string]: ICameraInput<TCamera>;
  74777. /**
  74778. * Accessor to the input by input index.
  74779. */
  74780. [idx: number]: ICameraInput<TCamera>;
  74781. }
  74782. /**
  74783. * This represents the input manager used within a camera.
  74784. * It helps dealing with all the different kind of input attached to a camera.
  74785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74786. */
  74787. export class CameraInputsManager<TCamera extends Camera> {
  74788. /**
  74789. * Defines the list of inputs attahed to the camera.
  74790. */
  74791. attached: CameraInputsMap<TCamera>;
  74792. /**
  74793. * Defines the dom element the camera is collecting inputs from.
  74794. * This is null if the controls have not been attached.
  74795. */
  74796. attachedElement: Nullable<HTMLElement>;
  74797. /**
  74798. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74799. */
  74800. noPreventDefault: boolean;
  74801. /**
  74802. * Defined the camera the input manager belongs to.
  74803. */
  74804. camera: TCamera;
  74805. /**
  74806. * Update the current camera state depending on the inputs that have been used this frame.
  74807. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74808. */
  74809. checkInputs: () => void;
  74810. /**
  74811. * Instantiate a new Camera Input Manager.
  74812. * @param camera Defines the camera the input manager blongs to
  74813. */
  74814. constructor(camera: TCamera);
  74815. /**
  74816. * Add an input method to a camera
  74817. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74818. * @param input camera input method
  74819. */
  74820. add(input: ICameraInput<TCamera>): void;
  74821. /**
  74822. * Remove a specific input method from a camera
  74823. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74824. * @param inputToRemove camera input method
  74825. */
  74826. remove(inputToRemove: ICameraInput<TCamera>): void;
  74827. /**
  74828. * Remove a specific input type from a camera
  74829. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74830. * @param inputType the type of the input to remove
  74831. */
  74832. removeByType(inputType: string): void;
  74833. private _addCheckInputs;
  74834. /**
  74835. * Attach the input controls to the currently attached dom element to listen the events from.
  74836. * @param input Defines the input to attach
  74837. */
  74838. attachInput(input: ICameraInput<TCamera>): void;
  74839. /**
  74840. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74841. * @param element Defines the dom element to collect the events from
  74842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74843. */
  74844. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74845. /**
  74846. * Detach the current manager inputs controls from a specific dom element.
  74847. * @param element Defines the dom element to collect the events from
  74848. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74849. */
  74850. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74851. /**
  74852. * Rebuild the dynamic inputCheck function from the current list of
  74853. * defined inputs in the manager.
  74854. */
  74855. rebuildInputCheck(): void;
  74856. /**
  74857. * Remove all attached input methods from a camera
  74858. */
  74859. clear(): void;
  74860. /**
  74861. * Serialize the current input manager attached to a camera.
  74862. * This ensures than once parsed,
  74863. * the input associated to the camera will be identical to the current ones
  74864. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74865. */
  74866. serialize(serializedCamera: any): void;
  74867. /**
  74868. * Parses an input manager serialized JSON to restore the previous list of inputs
  74869. * and states associated to a camera.
  74870. * @param parsedCamera Defines the JSON to parse
  74871. */
  74872. parse(parsedCamera: any): void;
  74873. }
  74874. }
  74875. declare module BABYLON {
  74876. /**
  74877. * Class used to store data that will be store in GPU memory
  74878. */
  74879. export class Buffer {
  74880. private _engine;
  74881. private _buffer;
  74882. /** @hidden */
  74883. _data: Nullable<DataArray>;
  74884. private _updatable;
  74885. private _instanced;
  74886. private _divisor;
  74887. /**
  74888. * Gets the byte stride.
  74889. */
  74890. readonly byteStride: number;
  74891. /**
  74892. * Constructor
  74893. * @param engine the engine
  74894. * @param data the data to use for this buffer
  74895. * @param updatable whether the data is updatable
  74896. * @param stride the stride (optional)
  74897. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74898. * @param instanced whether the buffer is instanced (optional)
  74899. * @param useBytes set to true if the stride in in bytes (optional)
  74900. * @param divisor sets an optional divisor for instances (1 by default)
  74901. */
  74902. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74903. /**
  74904. * Create a new VertexBuffer based on the current buffer
  74905. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74906. * @param offset defines offset in the buffer (0 by default)
  74907. * @param size defines the size in floats of attributes (position is 3 for instance)
  74908. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74909. * @param instanced defines if the vertex buffer contains indexed data
  74910. * @param useBytes defines if the offset and stride are in bytes *
  74911. * @param divisor sets an optional divisor for instances (1 by default)
  74912. * @returns the new vertex buffer
  74913. */
  74914. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74915. /**
  74916. * Gets a boolean indicating if the Buffer is updatable?
  74917. * @returns true if the buffer is updatable
  74918. */
  74919. isUpdatable(): boolean;
  74920. /**
  74921. * Gets current buffer's data
  74922. * @returns a DataArray or null
  74923. */
  74924. getData(): Nullable<DataArray>;
  74925. /**
  74926. * Gets underlying native buffer
  74927. * @returns underlying native buffer
  74928. */
  74929. getBuffer(): Nullable<DataBuffer>;
  74930. /**
  74931. * Gets the stride in float32 units (i.e. byte stride / 4).
  74932. * May not be an integer if the byte stride is not divisible by 4.
  74933. * DEPRECATED. Use byteStride instead.
  74934. * @returns the stride in float32 units
  74935. */
  74936. getStrideSize(): number;
  74937. /**
  74938. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74939. * @param data defines the data to store
  74940. */
  74941. create(data?: Nullable<DataArray>): void;
  74942. /** @hidden */
  74943. _rebuild(): void;
  74944. /**
  74945. * Update current buffer data
  74946. * @param data defines the data to store
  74947. */
  74948. update(data: DataArray): void;
  74949. /**
  74950. * Updates the data directly.
  74951. * @param data the new data
  74952. * @param offset the new offset
  74953. * @param vertexCount the vertex count (optional)
  74954. * @param useBytes set to true if the offset is in bytes
  74955. */
  74956. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74957. /**
  74958. * Release all resources
  74959. */
  74960. dispose(): void;
  74961. }
  74962. /**
  74963. * Specialized buffer used to store vertex data
  74964. */
  74965. export class VertexBuffer {
  74966. /** @hidden */
  74967. _buffer: Buffer;
  74968. private _kind;
  74969. private _size;
  74970. private _ownsBuffer;
  74971. private _instanced;
  74972. private _instanceDivisor;
  74973. /**
  74974. * The byte type.
  74975. */
  74976. static readonly BYTE: number;
  74977. /**
  74978. * The unsigned byte type.
  74979. */
  74980. static readonly UNSIGNED_BYTE: number;
  74981. /**
  74982. * The short type.
  74983. */
  74984. static readonly SHORT: number;
  74985. /**
  74986. * The unsigned short type.
  74987. */
  74988. static readonly UNSIGNED_SHORT: number;
  74989. /**
  74990. * The integer type.
  74991. */
  74992. static readonly INT: number;
  74993. /**
  74994. * The unsigned integer type.
  74995. */
  74996. static readonly UNSIGNED_INT: number;
  74997. /**
  74998. * The float type.
  74999. */
  75000. static readonly FLOAT: number;
  75001. /**
  75002. * Gets or sets the instance divisor when in instanced mode
  75003. */
  75004. instanceDivisor: number;
  75005. /**
  75006. * Gets the byte stride.
  75007. */
  75008. readonly byteStride: number;
  75009. /**
  75010. * Gets the byte offset.
  75011. */
  75012. readonly byteOffset: number;
  75013. /**
  75014. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  75015. */
  75016. readonly normalized: boolean;
  75017. /**
  75018. * Gets the data type of each component in the array.
  75019. */
  75020. readonly type: number;
  75021. /**
  75022. * Constructor
  75023. * @param engine the engine
  75024. * @param data the data to use for this vertex buffer
  75025. * @param kind the vertex buffer kind
  75026. * @param updatable whether the data is updatable
  75027. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75028. * @param stride the stride (optional)
  75029. * @param instanced whether the buffer is instanced (optional)
  75030. * @param offset the offset of the data (optional)
  75031. * @param size the number of components (optional)
  75032. * @param type the type of the component (optional)
  75033. * @param normalized whether the data contains normalized data (optional)
  75034. * @param useBytes set to true if stride and offset are in bytes (optional)
  75035. * @param divisor defines the instance divisor to use (1 by default)
  75036. */
  75037. 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);
  75038. /** @hidden */
  75039. _rebuild(): void;
  75040. /**
  75041. * Returns the kind of the VertexBuffer (string)
  75042. * @returns a string
  75043. */
  75044. getKind(): string;
  75045. /**
  75046. * Gets a boolean indicating if the VertexBuffer is updatable?
  75047. * @returns true if the buffer is updatable
  75048. */
  75049. isUpdatable(): boolean;
  75050. /**
  75051. * Gets current buffer's data
  75052. * @returns a DataArray or null
  75053. */
  75054. getData(): Nullable<DataArray>;
  75055. /**
  75056. * Gets underlying native buffer
  75057. * @returns underlying native buffer
  75058. */
  75059. getBuffer(): Nullable<DataBuffer>;
  75060. /**
  75061. * Gets the stride in float32 units (i.e. byte stride / 4).
  75062. * May not be an integer if the byte stride is not divisible by 4.
  75063. * DEPRECATED. Use byteStride instead.
  75064. * @returns the stride in float32 units
  75065. */
  75066. getStrideSize(): number;
  75067. /**
  75068. * Returns the offset as a multiple of the type byte length.
  75069. * DEPRECATED. Use byteOffset instead.
  75070. * @returns the offset in bytes
  75071. */
  75072. getOffset(): number;
  75073. /**
  75074. * Returns the number of components per vertex attribute (integer)
  75075. * @returns the size in float
  75076. */
  75077. getSize(): number;
  75078. /**
  75079. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  75080. * @returns true if this buffer is instanced
  75081. */
  75082. getIsInstanced(): boolean;
  75083. /**
  75084. * Returns the instancing divisor, zero for non-instanced (integer).
  75085. * @returns a number
  75086. */
  75087. getInstanceDivisor(): number;
  75088. /**
  75089. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75090. * @param data defines the data to store
  75091. */
  75092. create(data?: DataArray): void;
  75093. /**
  75094. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  75095. * This function will create a new buffer if the current one is not updatable
  75096. * @param data defines the data to store
  75097. */
  75098. update(data: DataArray): void;
  75099. /**
  75100. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  75101. * Returns the directly updated WebGLBuffer.
  75102. * @param data the new data
  75103. * @param offset the new offset
  75104. * @param useBytes set to true if the offset is in bytes
  75105. */
  75106. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  75107. /**
  75108. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  75109. */
  75110. dispose(): void;
  75111. /**
  75112. * Enumerates each value of this vertex buffer as numbers.
  75113. * @param count the number of values to enumerate
  75114. * @param callback the callback function called for each value
  75115. */
  75116. forEach(count: number, callback: (value: number, index: number) => void): void;
  75117. /**
  75118. * Positions
  75119. */
  75120. static readonly PositionKind: string;
  75121. /**
  75122. * Normals
  75123. */
  75124. static readonly NormalKind: string;
  75125. /**
  75126. * Tangents
  75127. */
  75128. static readonly TangentKind: string;
  75129. /**
  75130. * Texture coordinates
  75131. */
  75132. static readonly UVKind: string;
  75133. /**
  75134. * Texture coordinates 2
  75135. */
  75136. static readonly UV2Kind: string;
  75137. /**
  75138. * Texture coordinates 3
  75139. */
  75140. static readonly UV3Kind: string;
  75141. /**
  75142. * Texture coordinates 4
  75143. */
  75144. static readonly UV4Kind: string;
  75145. /**
  75146. * Texture coordinates 5
  75147. */
  75148. static readonly UV5Kind: string;
  75149. /**
  75150. * Texture coordinates 6
  75151. */
  75152. static readonly UV6Kind: string;
  75153. /**
  75154. * Colors
  75155. */
  75156. static readonly ColorKind: string;
  75157. /**
  75158. * Matrix indices (for bones)
  75159. */
  75160. static readonly MatricesIndicesKind: string;
  75161. /**
  75162. * Matrix weights (for bones)
  75163. */
  75164. static readonly MatricesWeightsKind: string;
  75165. /**
  75166. * Additional matrix indices (for bones)
  75167. */
  75168. static readonly MatricesIndicesExtraKind: string;
  75169. /**
  75170. * Additional matrix weights (for bones)
  75171. */
  75172. static readonly MatricesWeightsExtraKind: string;
  75173. /**
  75174. * Deduces the stride given a kind.
  75175. * @param kind The kind string to deduce
  75176. * @returns The deduced stride
  75177. */
  75178. static DeduceStride(kind: string): number;
  75179. /**
  75180. * Gets the byte length of the given type.
  75181. * @param type the type
  75182. * @returns the number of bytes
  75183. */
  75184. static GetTypeByteLength(type: number): number;
  75185. /**
  75186. * Enumerates each value of the given parameters as numbers.
  75187. * @param data the data to enumerate
  75188. * @param byteOffset the byte offset of the data
  75189. * @param byteStride the byte stride of the data
  75190. * @param componentCount the number of components per element
  75191. * @param componentType the type of the component
  75192. * @param count the number of values to enumerate
  75193. * @param normalized whether the data is normalized
  75194. * @param callback the callback function called for each value
  75195. */
  75196. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  75197. private static _GetFloatValue;
  75198. }
  75199. }
  75200. declare module BABYLON {
  75201. /**
  75202. * @hidden
  75203. */
  75204. export class IntersectionInfo {
  75205. bu: Nullable<number>;
  75206. bv: Nullable<number>;
  75207. distance: number;
  75208. faceId: number;
  75209. subMeshId: number;
  75210. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  75211. }
  75212. }
  75213. declare module BABYLON {
  75214. /**
  75215. * Represens a plane by the equation ax + by + cz + d = 0
  75216. */
  75217. export class Plane {
  75218. private static _TmpMatrix;
  75219. /**
  75220. * Normal of the plane (a,b,c)
  75221. */
  75222. normal: Vector3;
  75223. /**
  75224. * d component of the plane
  75225. */
  75226. d: number;
  75227. /**
  75228. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75229. * @param a a component of the plane
  75230. * @param b b component of the plane
  75231. * @param c c component of the plane
  75232. * @param d d component of the plane
  75233. */
  75234. constructor(a: number, b: number, c: number, d: number);
  75235. /**
  75236. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75237. */
  75238. asArray(): number[];
  75239. /**
  75240. * @returns a new plane copied from the current Plane.
  75241. */
  75242. clone(): Plane;
  75243. /**
  75244. * @returns the string "Plane".
  75245. */
  75246. getClassName(): string;
  75247. /**
  75248. * @returns the Plane hash code.
  75249. */
  75250. getHashCode(): number;
  75251. /**
  75252. * Normalize the current Plane in place.
  75253. * @returns the updated Plane.
  75254. */
  75255. normalize(): Plane;
  75256. /**
  75257. * Applies a transformation the plane and returns the result
  75258. * @param transformation the transformation matrix to be applied to the plane
  75259. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75260. */
  75261. transform(transformation: DeepImmutable<Matrix>): Plane;
  75262. /**
  75263. * Calcualtte the dot product between the point and the plane normal
  75264. * @param point point to calculate the dot product with
  75265. * @returns the dot product (float) of the point coordinates and the plane normal.
  75266. */
  75267. dotCoordinate(point: DeepImmutable<Vector3>): number;
  75268. /**
  75269. * Updates the current Plane from the plane defined by the three given points.
  75270. * @param point1 one of the points used to contruct the plane
  75271. * @param point2 one of the points used to contruct the plane
  75272. * @param point3 one of the points used to contruct the plane
  75273. * @returns the updated Plane.
  75274. */
  75275. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75276. /**
  75277. * Checks if the plane is facing a given direction
  75278. * @param direction the direction to check if the plane is facing
  75279. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75280. * @returns True is the vector "direction" is the same side than the plane normal.
  75281. */
  75282. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  75283. /**
  75284. * Calculates the distance to a point
  75285. * @param point point to calculate distance to
  75286. * @returns the signed distance (float) from the given point to the Plane.
  75287. */
  75288. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  75289. /**
  75290. * Creates a plane from an array
  75291. * @param array the array to create a plane from
  75292. * @returns a new Plane from the given array.
  75293. */
  75294. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  75295. /**
  75296. * Creates a plane from three points
  75297. * @param point1 point used to create the plane
  75298. * @param point2 point used to create the plane
  75299. * @param point3 point used to create the plane
  75300. * @returns a new Plane defined by the three given points.
  75301. */
  75302. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75303. /**
  75304. * Creates a plane from an origin point and a normal
  75305. * @param origin origin of the plane to be constructed
  75306. * @param normal normal of the plane to be constructed
  75307. * @returns a new Plane the normal vector to this plane at the given origin point.
  75308. * Note : the vector "normal" is updated because normalized.
  75309. */
  75310. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  75311. /**
  75312. * Calculates the distance from a plane and a point
  75313. * @param origin origin of the plane to be constructed
  75314. * @param normal normal of the plane to be constructed
  75315. * @param point point to calculate distance to
  75316. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75317. */
  75318. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  75319. }
  75320. }
  75321. declare module BABYLON {
  75322. /**
  75323. * Class used to store bounding sphere information
  75324. */
  75325. export class BoundingSphere {
  75326. /**
  75327. * Gets the center of the bounding sphere in local space
  75328. */
  75329. readonly center: Vector3;
  75330. /**
  75331. * Radius of the bounding sphere in local space
  75332. */
  75333. radius: number;
  75334. /**
  75335. * Gets the center of the bounding sphere in world space
  75336. */
  75337. readonly centerWorld: Vector3;
  75338. /**
  75339. * Radius of the bounding sphere in world space
  75340. */
  75341. radiusWorld: number;
  75342. /**
  75343. * Gets the minimum vector in local space
  75344. */
  75345. readonly minimum: Vector3;
  75346. /**
  75347. * Gets the maximum vector in local space
  75348. */
  75349. readonly maximum: Vector3;
  75350. private _worldMatrix;
  75351. private static readonly TmpVector3;
  75352. /**
  75353. * Creates a new bounding sphere
  75354. * @param min defines the minimum vector (in local space)
  75355. * @param max defines the maximum vector (in local space)
  75356. * @param worldMatrix defines the new world matrix
  75357. */
  75358. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75359. /**
  75360. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  75361. * @param min defines the new minimum vector (in local space)
  75362. * @param max defines the new maximum vector (in local space)
  75363. * @param worldMatrix defines the new world matrix
  75364. */
  75365. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75366. /**
  75367. * Scale the current bounding sphere by applying a scale factor
  75368. * @param factor defines the scale factor to apply
  75369. * @returns the current bounding box
  75370. */
  75371. scale(factor: number): BoundingSphere;
  75372. /**
  75373. * Gets the world matrix of the bounding box
  75374. * @returns a matrix
  75375. */
  75376. getWorldMatrix(): DeepImmutable<Matrix>;
  75377. /** @hidden */
  75378. _update(worldMatrix: DeepImmutable<Matrix>): void;
  75379. /**
  75380. * Tests if the bounding sphere is intersecting the frustum planes
  75381. * @param frustumPlanes defines the frustum planes to test
  75382. * @returns true if there is an intersection
  75383. */
  75384. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75385. /**
  75386. * Tests if the bounding sphere center is in between the frustum planes.
  75387. * Used for optimistic fast inclusion.
  75388. * @param frustumPlanes defines the frustum planes to test
  75389. * @returns true if the sphere center is in between the frustum planes
  75390. */
  75391. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75392. /**
  75393. * Tests if a point is inside the bounding sphere
  75394. * @param point defines the point to test
  75395. * @returns true if the point is inside the bounding sphere
  75396. */
  75397. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75398. /**
  75399. * Checks if two sphere intersct
  75400. * @param sphere0 sphere 0
  75401. * @param sphere1 sphere 1
  75402. * @returns true if the speres intersect
  75403. */
  75404. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  75405. }
  75406. }
  75407. declare module BABYLON {
  75408. /**
  75409. * Class used to store bounding box information
  75410. */
  75411. export class BoundingBox implements ICullable {
  75412. /**
  75413. * Gets the 8 vectors representing the bounding box in local space
  75414. */
  75415. readonly vectors: Vector3[];
  75416. /**
  75417. * Gets the center of the bounding box in local space
  75418. */
  75419. readonly center: Vector3;
  75420. /**
  75421. * Gets the center of the bounding box in world space
  75422. */
  75423. readonly centerWorld: Vector3;
  75424. /**
  75425. * Gets the extend size in local space
  75426. */
  75427. readonly extendSize: Vector3;
  75428. /**
  75429. * Gets the extend size in world space
  75430. */
  75431. readonly extendSizeWorld: Vector3;
  75432. /**
  75433. * Gets the OBB (object bounding box) directions
  75434. */
  75435. readonly directions: Vector3[];
  75436. /**
  75437. * Gets the 8 vectors representing the bounding box in world space
  75438. */
  75439. readonly vectorsWorld: Vector3[];
  75440. /**
  75441. * Gets the minimum vector in world space
  75442. */
  75443. readonly minimumWorld: Vector3;
  75444. /**
  75445. * Gets the maximum vector in world space
  75446. */
  75447. readonly maximumWorld: Vector3;
  75448. /**
  75449. * Gets the minimum vector in local space
  75450. */
  75451. readonly minimum: Vector3;
  75452. /**
  75453. * Gets the maximum vector in local space
  75454. */
  75455. readonly maximum: Vector3;
  75456. private _worldMatrix;
  75457. private static readonly TmpVector3;
  75458. /**
  75459. * @hidden
  75460. */
  75461. _tag: number;
  75462. /**
  75463. * Creates a new bounding box
  75464. * @param min defines the minimum vector (in local space)
  75465. * @param max defines the maximum vector (in local space)
  75466. * @param worldMatrix defines the new world matrix
  75467. */
  75468. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75469. /**
  75470. * Recreates the entire bounding box from scratch as if we call the constructor in place
  75471. * @param min defines the new minimum vector (in local space)
  75472. * @param max defines the new maximum vector (in local space)
  75473. * @param worldMatrix defines the new world matrix
  75474. */
  75475. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75476. /**
  75477. * Scale the current bounding box by applying a scale factor
  75478. * @param factor defines the scale factor to apply
  75479. * @returns the current bounding box
  75480. */
  75481. scale(factor: number): BoundingBox;
  75482. /**
  75483. * Gets the world matrix of the bounding box
  75484. * @returns a matrix
  75485. */
  75486. getWorldMatrix(): DeepImmutable<Matrix>;
  75487. /** @hidden */
  75488. _update(world: DeepImmutable<Matrix>): void;
  75489. /**
  75490. * Tests if the bounding box is intersecting the frustum planes
  75491. * @param frustumPlanes defines the frustum planes to test
  75492. * @returns true if there is an intersection
  75493. */
  75494. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75495. /**
  75496. * Tests if the bounding box is entirely inside the frustum planes
  75497. * @param frustumPlanes defines the frustum planes to test
  75498. * @returns true if there is an inclusion
  75499. */
  75500. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75501. /**
  75502. * Tests if a point is inside the bounding box
  75503. * @param point defines the point to test
  75504. * @returns true if the point is inside the bounding box
  75505. */
  75506. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75507. /**
  75508. * Tests if the bounding box intersects with a bounding sphere
  75509. * @param sphere defines the sphere to test
  75510. * @returns true if there is an intersection
  75511. */
  75512. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  75513. /**
  75514. * Tests if the bounding box intersects with a box defined by a min and max vectors
  75515. * @param min defines the min vector to use
  75516. * @param max defines the max vector to use
  75517. * @returns true if there is an intersection
  75518. */
  75519. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  75520. /**
  75521. * Tests if two bounding boxes are intersections
  75522. * @param box0 defines the first box to test
  75523. * @param box1 defines the second box to test
  75524. * @returns true if there is an intersection
  75525. */
  75526. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  75527. /**
  75528. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75529. * @param minPoint defines the minimum vector of the bounding box
  75530. * @param maxPoint defines the maximum vector of the bounding box
  75531. * @param sphereCenter defines the sphere center
  75532. * @param sphereRadius defines the sphere radius
  75533. * @returns true if there is an intersection
  75534. */
  75535. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75536. /**
  75537. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75538. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75539. * @param frustumPlanes defines the frustum planes to test
  75540. * @return true if there is an inclusion
  75541. */
  75542. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75543. /**
  75544. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75545. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75546. * @param frustumPlanes defines the frustum planes to test
  75547. * @return true if there is an intersection
  75548. */
  75549. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75550. }
  75551. }
  75552. declare module BABYLON {
  75553. /** @hidden */
  75554. export class Collider {
  75555. /** Define if a collision was found */
  75556. collisionFound: boolean;
  75557. /**
  75558. * Define last intersection point in local space
  75559. */
  75560. intersectionPoint: Vector3;
  75561. /**
  75562. * Define last collided mesh
  75563. */
  75564. collidedMesh: Nullable<AbstractMesh>;
  75565. private _collisionPoint;
  75566. private _planeIntersectionPoint;
  75567. private _tempVector;
  75568. private _tempVector2;
  75569. private _tempVector3;
  75570. private _tempVector4;
  75571. private _edge;
  75572. private _baseToVertex;
  75573. private _destinationPoint;
  75574. private _slidePlaneNormal;
  75575. private _displacementVector;
  75576. /** @hidden */
  75577. _radius: Vector3;
  75578. /** @hidden */
  75579. _retry: number;
  75580. private _velocity;
  75581. private _basePoint;
  75582. private _epsilon;
  75583. /** @hidden */
  75584. _velocityWorldLength: number;
  75585. /** @hidden */
  75586. _basePointWorld: Vector3;
  75587. private _velocityWorld;
  75588. private _normalizedVelocity;
  75589. /** @hidden */
  75590. _initialVelocity: Vector3;
  75591. /** @hidden */
  75592. _initialPosition: Vector3;
  75593. private _nearestDistance;
  75594. private _collisionMask;
  75595. collisionMask: number;
  75596. /**
  75597. * Gets the plane normal used to compute the sliding response (in local space)
  75598. */
  75599. readonly slidePlaneNormal: Vector3;
  75600. /** @hidden */
  75601. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75602. /** @hidden */
  75603. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75604. /** @hidden */
  75605. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75606. /** @hidden */
  75607. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75608. /** @hidden */
  75609. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75610. /** @hidden */
  75611. _getResponse(pos: Vector3, vel: Vector3): void;
  75612. }
  75613. }
  75614. declare module BABYLON {
  75615. /**
  75616. * Interface for cullable objects
  75617. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75618. */
  75619. export interface ICullable {
  75620. /**
  75621. * Checks if the object or part of the object is in the frustum
  75622. * @param frustumPlanes Camera near/planes
  75623. * @returns true if the object is in frustum otherwise false
  75624. */
  75625. isInFrustum(frustumPlanes: Plane[]): boolean;
  75626. /**
  75627. * Checks if a cullable object (mesh...) is in the camera frustum
  75628. * Unlike isInFrustum this cheks the full bounding box
  75629. * @param frustumPlanes Camera near/planes
  75630. * @returns true if the object is in frustum otherwise false
  75631. */
  75632. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75633. }
  75634. /**
  75635. * Info for a bounding data of a mesh
  75636. */
  75637. export class BoundingInfo implements ICullable {
  75638. /**
  75639. * Bounding box for the mesh
  75640. */
  75641. readonly boundingBox: BoundingBox;
  75642. /**
  75643. * Bounding sphere for the mesh
  75644. */
  75645. readonly boundingSphere: BoundingSphere;
  75646. private _isLocked;
  75647. private static readonly TmpVector3;
  75648. /**
  75649. * Constructs bounding info
  75650. * @param minimum min vector of the bounding box/sphere
  75651. * @param maximum max vector of the bounding box/sphere
  75652. * @param worldMatrix defines the new world matrix
  75653. */
  75654. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75655. /**
  75656. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75657. * @param min defines the new minimum vector (in local space)
  75658. * @param max defines the new maximum vector (in local space)
  75659. * @param worldMatrix defines the new world matrix
  75660. */
  75661. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75662. /**
  75663. * min vector of the bounding box/sphere
  75664. */
  75665. readonly minimum: Vector3;
  75666. /**
  75667. * max vector of the bounding box/sphere
  75668. */
  75669. readonly maximum: Vector3;
  75670. /**
  75671. * If the info is locked and won't be updated to avoid perf overhead
  75672. */
  75673. isLocked: boolean;
  75674. /**
  75675. * Updates the bounding sphere and box
  75676. * @param world world matrix to be used to update
  75677. */
  75678. update(world: DeepImmutable<Matrix>): void;
  75679. /**
  75680. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75681. * @param center New center of the bounding info
  75682. * @param extend New extend of the bounding info
  75683. * @returns the current bounding info
  75684. */
  75685. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75686. /**
  75687. * Scale the current bounding info by applying a scale factor
  75688. * @param factor defines the scale factor to apply
  75689. * @returns the current bounding info
  75690. */
  75691. scale(factor: number): BoundingInfo;
  75692. /**
  75693. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75694. * @param frustumPlanes defines the frustum to test
  75695. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75696. * @returns true if the bounding info is in the frustum planes
  75697. */
  75698. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  75699. /**
  75700. * Gets the world distance between the min and max points of the bounding box
  75701. */
  75702. readonly diagonalLength: number;
  75703. /**
  75704. * Checks if a cullable object (mesh...) is in the camera frustum
  75705. * Unlike isInFrustum this cheks the full bounding box
  75706. * @param frustumPlanes Camera near/planes
  75707. * @returns true if the object is in frustum otherwise false
  75708. */
  75709. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75710. /** @hidden */
  75711. _checkCollision(collider: Collider): boolean;
  75712. /**
  75713. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  75714. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75715. * @param point the point to check intersection with
  75716. * @returns if the point intersects
  75717. */
  75718. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75719. /**
  75720. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75721. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75722. * @param boundingInfo the bounding info to check intersection with
  75723. * @param precise if the intersection should be done using OBB
  75724. * @returns if the bounding info intersects
  75725. */
  75726. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75727. }
  75728. }
  75729. declare module BABYLON {
  75730. /**
  75731. * Extracts minimum and maximum values from a list of indexed positions
  75732. * @param positions defines the positions to use
  75733. * @param indices defines the indices to the positions
  75734. * @param indexStart defines the start index
  75735. * @param indexCount defines the end index
  75736. * @param bias defines bias value to add to the result
  75737. * @return minimum and maximum values
  75738. */
  75739. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75740. minimum: Vector3;
  75741. maximum: Vector3;
  75742. };
  75743. /**
  75744. * Extracts minimum and maximum values from a list of positions
  75745. * @param positions defines the positions to use
  75746. * @param start defines the start index in the positions array
  75747. * @param count defines the number of positions to handle
  75748. * @param bias defines bias value to add to the result
  75749. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75750. * @return minimum and maximum values
  75751. */
  75752. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75753. minimum: Vector3;
  75754. maximum: Vector3;
  75755. };
  75756. }
  75757. declare module BABYLON {
  75758. /** @hidden */
  75759. export class WebGLDataBuffer extends DataBuffer {
  75760. private _buffer;
  75761. constructor(resource: WebGLBuffer);
  75762. readonly underlyingResource: any;
  75763. }
  75764. }
  75765. declare module BABYLON {
  75766. /** @hidden */
  75767. export class WebGLPipelineContext implements IPipelineContext {
  75768. engine: ThinEngine;
  75769. program: Nullable<WebGLProgram>;
  75770. context?: WebGLRenderingContext;
  75771. vertexShader?: WebGLShader;
  75772. fragmentShader?: WebGLShader;
  75773. isParallelCompiled: boolean;
  75774. onCompiled?: () => void;
  75775. transformFeedback?: WebGLTransformFeedback | null;
  75776. readonly isAsync: boolean;
  75777. readonly isReady: boolean;
  75778. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75779. }
  75780. }
  75781. declare module BABYLON {
  75782. interface ThinEngine {
  75783. /**
  75784. * Create an uniform buffer
  75785. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75786. * @param elements defines the content of the uniform buffer
  75787. * @returns the webGL uniform buffer
  75788. */
  75789. createUniformBuffer(elements: FloatArray): DataBuffer;
  75790. /**
  75791. * Create a dynamic uniform buffer
  75792. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75793. * @param elements defines the content of the uniform buffer
  75794. * @returns the webGL uniform buffer
  75795. */
  75796. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75797. /**
  75798. * Update an existing uniform buffer
  75799. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75800. * @param uniformBuffer defines the target uniform buffer
  75801. * @param elements defines the content to update
  75802. * @param offset defines the offset in the uniform buffer where update should start
  75803. * @param count defines the size of the data to update
  75804. */
  75805. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75806. /**
  75807. * Bind an uniform buffer to the current webGL context
  75808. * @param buffer defines the buffer to bind
  75809. */
  75810. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75811. /**
  75812. * Bind a buffer to the current webGL context at a given location
  75813. * @param buffer defines the buffer to bind
  75814. * @param location defines the index where to bind the buffer
  75815. */
  75816. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75817. /**
  75818. * Bind a specific block at a given index in a specific shader program
  75819. * @param pipelineContext defines the pipeline context to use
  75820. * @param blockName defines the block name
  75821. * @param index defines the index where to bind the block
  75822. */
  75823. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75824. }
  75825. }
  75826. declare module BABYLON {
  75827. /**
  75828. * Uniform buffer objects.
  75829. *
  75830. * Handles blocks of uniform on the GPU.
  75831. *
  75832. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75833. *
  75834. * For more information, please refer to :
  75835. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75836. */
  75837. export class UniformBuffer {
  75838. private _engine;
  75839. private _buffer;
  75840. private _data;
  75841. private _bufferData;
  75842. private _dynamic?;
  75843. private _uniformLocations;
  75844. private _uniformSizes;
  75845. private _uniformLocationPointer;
  75846. private _needSync;
  75847. private _noUBO;
  75848. private _currentEffect;
  75849. /** @hidden */
  75850. _alreadyBound: boolean;
  75851. private static _MAX_UNIFORM_SIZE;
  75852. private static _tempBuffer;
  75853. /**
  75854. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  75855. * This is dynamic to allow compat with webgl 1 and 2.
  75856. * You will need to pass the name of the uniform as well as the value.
  75857. */
  75858. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75859. /**
  75860. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  75861. * This is dynamic to allow compat with webgl 1 and 2.
  75862. * You will need to pass the name of the uniform as well as the value.
  75863. */
  75864. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75865. /**
  75866. * Lambda to Update a single float in a uniform buffer.
  75867. * This is dynamic to allow compat with webgl 1 and 2.
  75868. * You will need to pass the name of the uniform as well as the value.
  75869. */
  75870. updateFloat: (name: string, x: number) => void;
  75871. /**
  75872. * Lambda to Update a vec2 of float in a uniform buffer.
  75873. * This is dynamic to allow compat with webgl 1 and 2.
  75874. * You will need to pass the name of the uniform as well as the value.
  75875. */
  75876. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75877. /**
  75878. * Lambda to Update a vec3 of float in a uniform buffer.
  75879. * This is dynamic to allow compat with webgl 1 and 2.
  75880. * You will need to pass the name of the uniform as well as the value.
  75881. */
  75882. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75883. /**
  75884. * Lambda to Update a vec4 of float in a uniform buffer.
  75885. * This is dynamic to allow compat with webgl 1 and 2.
  75886. * You will need to pass the name of the uniform as well as the value.
  75887. */
  75888. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75889. /**
  75890. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75891. * This is dynamic to allow compat with webgl 1 and 2.
  75892. * You will need to pass the name of the uniform as well as the value.
  75893. */
  75894. updateMatrix: (name: string, mat: Matrix) => void;
  75895. /**
  75896. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75897. * This is dynamic to allow compat with webgl 1 and 2.
  75898. * You will need to pass the name of the uniform as well as the value.
  75899. */
  75900. updateVector3: (name: string, vector: Vector3) => void;
  75901. /**
  75902. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75903. * This is dynamic to allow compat with webgl 1 and 2.
  75904. * You will need to pass the name of the uniform as well as the value.
  75905. */
  75906. updateVector4: (name: string, vector: Vector4) => void;
  75907. /**
  75908. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75909. * This is dynamic to allow compat with webgl 1 and 2.
  75910. * You will need to pass the name of the uniform as well as the value.
  75911. */
  75912. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75913. /**
  75914. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75915. * This is dynamic to allow compat with webgl 1 and 2.
  75916. * You will need to pass the name of the uniform as well as the value.
  75917. */
  75918. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75919. /**
  75920. * Instantiates a new Uniform buffer objects.
  75921. *
  75922. * Handles blocks of uniform on the GPU.
  75923. *
  75924. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75925. *
  75926. * For more information, please refer to :
  75927. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75928. * @param engine Define the engine the buffer is associated with
  75929. * @param data Define the data contained in the buffer
  75930. * @param dynamic Define if the buffer is updatable
  75931. */
  75932. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75933. /**
  75934. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75935. * or just falling back on setUniformXXX calls.
  75936. */
  75937. readonly useUbo: boolean;
  75938. /**
  75939. * Indicates if the WebGL underlying uniform buffer is in sync
  75940. * with the javascript cache data.
  75941. */
  75942. readonly isSync: boolean;
  75943. /**
  75944. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75945. * Also, a dynamic UniformBuffer will disable cache verification and always
  75946. * update the underlying WebGL uniform buffer to the GPU.
  75947. * @returns if Dynamic, otherwise false
  75948. */
  75949. isDynamic(): boolean;
  75950. /**
  75951. * The data cache on JS side.
  75952. * @returns the underlying data as a float array
  75953. */
  75954. getData(): Float32Array;
  75955. /**
  75956. * The underlying WebGL Uniform buffer.
  75957. * @returns the webgl buffer
  75958. */
  75959. getBuffer(): Nullable<DataBuffer>;
  75960. /**
  75961. * std140 layout specifies how to align data within an UBO structure.
  75962. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75963. * for specs.
  75964. */
  75965. private _fillAlignment;
  75966. /**
  75967. * Adds an uniform in the buffer.
  75968. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75969. * for the layout to be correct !
  75970. * @param name Name of the uniform, as used in the uniform block in the shader.
  75971. * @param size Data size, or data directly.
  75972. */
  75973. addUniform(name: string, size: number | number[]): void;
  75974. /**
  75975. * Adds a Matrix 4x4 to the uniform buffer.
  75976. * @param name Name of the uniform, as used in the uniform block in the shader.
  75977. * @param mat A 4x4 matrix.
  75978. */
  75979. addMatrix(name: string, mat: Matrix): void;
  75980. /**
  75981. * Adds a vec2 to the uniform buffer.
  75982. * @param name Name of the uniform, as used in the uniform block in the shader.
  75983. * @param x Define the x component value of the vec2
  75984. * @param y Define the y component value of the vec2
  75985. */
  75986. addFloat2(name: string, x: number, y: number): void;
  75987. /**
  75988. * Adds a vec3 to the uniform buffer.
  75989. * @param name Name of the uniform, as used in the uniform block in the shader.
  75990. * @param x Define the x component value of the vec3
  75991. * @param y Define the y component value of the vec3
  75992. * @param z Define the z component value of the vec3
  75993. */
  75994. addFloat3(name: string, x: number, y: number, z: number): void;
  75995. /**
  75996. * Adds a vec3 to the uniform buffer.
  75997. * @param name Name of the uniform, as used in the uniform block in the shader.
  75998. * @param color Define the vec3 from a Color
  75999. */
  76000. addColor3(name: string, color: Color3): void;
  76001. /**
  76002. * Adds a vec4 to the uniform buffer.
  76003. * @param name Name of the uniform, as used in the uniform block in the shader.
  76004. * @param color Define the rgb components from a Color
  76005. * @param alpha Define the a component of the vec4
  76006. */
  76007. addColor4(name: string, color: Color3, alpha: number): void;
  76008. /**
  76009. * Adds a vec3 to the uniform buffer.
  76010. * @param name Name of the uniform, as used in the uniform block in the shader.
  76011. * @param vector Define the vec3 components from a Vector
  76012. */
  76013. addVector3(name: string, vector: Vector3): void;
  76014. /**
  76015. * Adds a Matrix 3x3 to the uniform buffer.
  76016. * @param name Name of the uniform, as used in the uniform block in the shader.
  76017. */
  76018. addMatrix3x3(name: string): void;
  76019. /**
  76020. * Adds a Matrix 2x2 to the uniform buffer.
  76021. * @param name Name of the uniform, as used in the uniform block in the shader.
  76022. */
  76023. addMatrix2x2(name: string): void;
  76024. /**
  76025. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  76026. */
  76027. create(): void;
  76028. /** @hidden */
  76029. _rebuild(): void;
  76030. /**
  76031. * Updates the WebGL Uniform Buffer on the GPU.
  76032. * If the `dynamic` flag is set to true, no cache comparison is done.
  76033. * Otherwise, the buffer will be updated only if the cache differs.
  76034. */
  76035. update(): void;
  76036. /**
  76037. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  76038. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76039. * @param data Define the flattened data
  76040. * @param size Define the size of the data.
  76041. */
  76042. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  76043. private _valueCache;
  76044. private _cacheMatrix;
  76045. private _updateMatrix3x3ForUniform;
  76046. private _updateMatrix3x3ForEffect;
  76047. private _updateMatrix2x2ForEffect;
  76048. private _updateMatrix2x2ForUniform;
  76049. private _updateFloatForEffect;
  76050. private _updateFloatForUniform;
  76051. private _updateFloat2ForEffect;
  76052. private _updateFloat2ForUniform;
  76053. private _updateFloat3ForEffect;
  76054. private _updateFloat3ForUniform;
  76055. private _updateFloat4ForEffect;
  76056. private _updateFloat4ForUniform;
  76057. private _updateMatrixForEffect;
  76058. private _updateMatrixForUniform;
  76059. private _updateVector3ForEffect;
  76060. private _updateVector3ForUniform;
  76061. private _updateVector4ForEffect;
  76062. private _updateVector4ForUniform;
  76063. private _updateColor3ForEffect;
  76064. private _updateColor3ForUniform;
  76065. private _updateColor4ForEffect;
  76066. private _updateColor4ForUniform;
  76067. /**
  76068. * Sets a sampler uniform on the effect.
  76069. * @param name Define the name of the sampler.
  76070. * @param texture Define the texture to set in the sampler
  76071. */
  76072. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  76073. /**
  76074. * Directly updates the value of the uniform in the cache AND on the GPU.
  76075. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76076. * @param data Define the flattened data
  76077. */
  76078. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  76079. /**
  76080. * Binds this uniform buffer to an effect.
  76081. * @param effect Define the effect to bind the buffer to
  76082. * @param name Name of the uniform block in the shader.
  76083. */
  76084. bindToEffect(effect: Effect, name: string): void;
  76085. /**
  76086. * Disposes the uniform buffer.
  76087. */
  76088. dispose(): void;
  76089. }
  76090. }
  76091. declare module BABYLON {
  76092. /**
  76093. * Enum that determines the text-wrapping mode to use.
  76094. */
  76095. export enum InspectableType {
  76096. /**
  76097. * Checkbox for booleans
  76098. */
  76099. Checkbox = 0,
  76100. /**
  76101. * Sliders for numbers
  76102. */
  76103. Slider = 1,
  76104. /**
  76105. * Vector3
  76106. */
  76107. Vector3 = 2,
  76108. /**
  76109. * Quaternions
  76110. */
  76111. Quaternion = 3,
  76112. /**
  76113. * Color3
  76114. */
  76115. Color3 = 4,
  76116. /**
  76117. * String
  76118. */
  76119. String = 5
  76120. }
  76121. /**
  76122. * Interface used to define custom inspectable properties.
  76123. * This interface is used by the inspector to display custom property grids
  76124. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76125. */
  76126. export interface IInspectable {
  76127. /**
  76128. * Gets the label to display
  76129. */
  76130. label: string;
  76131. /**
  76132. * Gets the name of the property to edit
  76133. */
  76134. propertyName: string;
  76135. /**
  76136. * Gets the type of the editor to use
  76137. */
  76138. type: InspectableType;
  76139. /**
  76140. * Gets the minimum value of the property when using in "slider" mode
  76141. */
  76142. min?: number;
  76143. /**
  76144. * Gets the maximum value of the property when using in "slider" mode
  76145. */
  76146. max?: number;
  76147. /**
  76148. * Gets the setp to use when using in "slider" mode
  76149. */
  76150. step?: number;
  76151. }
  76152. }
  76153. declare module BABYLON {
  76154. /**
  76155. * Class used to provide helper for timing
  76156. */
  76157. export class TimingTools {
  76158. /**
  76159. * Polyfill for setImmediate
  76160. * @param action defines the action to execute after the current execution block
  76161. */
  76162. static SetImmediate(action: () => void): void;
  76163. }
  76164. }
  76165. declare module BABYLON {
  76166. /**
  76167. * Class used to enable instatition of objects by class name
  76168. */
  76169. export class InstantiationTools {
  76170. /**
  76171. * Use this object to register external classes like custom textures or material
  76172. * to allow the laoders to instantiate them
  76173. */
  76174. static RegisteredExternalClasses: {
  76175. [key: string]: Object;
  76176. };
  76177. /**
  76178. * Tries to instantiate a new object from a given class name
  76179. * @param className defines the class name to instantiate
  76180. * @returns the new object or null if the system was not able to do the instantiation
  76181. */
  76182. static Instantiate(className: string): any;
  76183. }
  76184. }
  76185. declare module BABYLON {
  76186. /**
  76187. * Define options used to create a depth texture
  76188. */
  76189. export class DepthTextureCreationOptions {
  76190. /** Specifies whether or not a stencil should be allocated in the texture */
  76191. generateStencil?: boolean;
  76192. /** Specifies whether or not bilinear filtering is enable on the texture */
  76193. bilinearFiltering?: boolean;
  76194. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  76195. comparisonFunction?: number;
  76196. /** Specifies if the created texture is a cube texture */
  76197. isCube?: boolean;
  76198. }
  76199. }
  76200. declare module BABYLON {
  76201. interface ThinEngine {
  76202. /**
  76203. * Creates a depth stencil cube texture.
  76204. * This is only available in WebGL 2.
  76205. * @param size The size of face edge in the cube texture.
  76206. * @param options The options defining the cube texture.
  76207. * @returns The cube texture
  76208. */
  76209. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  76210. /**
  76211. * Creates a cube texture
  76212. * @param rootUrl defines the url where the files to load is located
  76213. * @param scene defines the current scene
  76214. * @param files defines the list of files to load (1 per face)
  76215. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76216. * @param onLoad defines an optional callback raised when the texture is loaded
  76217. * @param onError defines an optional callback raised if there is an issue to load the texture
  76218. * @param format defines the format of the data
  76219. * @param forcedExtension defines the extension to use to pick the right loader
  76220. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76221. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76222. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76223. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  76224. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  76225. * @returns the cube texture as an InternalTexture
  76226. */
  76227. 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;
  76228. /**
  76229. * Creates a cube texture
  76230. * @param rootUrl defines the url where the files to load is located
  76231. * @param scene defines the current scene
  76232. * @param files defines the list of files to load (1 per face)
  76233. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76234. * @param onLoad defines an optional callback raised when the texture is loaded
  76235. * @param onError defines an optional callback raised if there is an issue to load the texture
  76236. * @param format defines the format of the data
  76237. * @param forcedExtension defines the extension to use to pick the right loader
  76238. * @returns the cube texture as an InternalTexture
  76239. */
  76240. 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;
  76241. /**
  76242. * Creates a cube texture
  76243. * @param rootUrl defines the url where the files to load is located
  76244. * @param scene defines the current scene
  76245. * @param files defines the list of files to load (1 per face)
  76246. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76247. * @param onLoad defines an optional callback raised when the texture is loaded
  76248. * @param onError defines an optional callback raised if there is an issue to load the texture
  76249. * @param format defines the format of the data
  76250. * @param forcedExtension defines the extension to use to pick the right loader
  76251. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76252. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76253. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76254. * @returns the cube texture as an InternalTexture
  76255. */
  76256. 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;
  76257. /** @hidden */
  76258. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  76259. /** @hidden */
  76260. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  76261. /** @hidden */
  76262. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76263. /** @hidden */
  76264. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76265. /**
  76266. * @hidden
  76267. */
  76268. _setCubeMapTextureParams(loadMipmap: boolean): void;
  76269. }
  76270. }
  76271. declare module BABYLON {
  76272. /**
  76273. * Class for creating a cube texture
  76274. */
  76275. export class CubeTexture extends BaseTexture {
  76276. private _delayedOnLoad;
  76277. /**
  76278. * The url of the texture
  76279. */
  76280. url: string;
  76281. /**
  76282. * Gets or sets the center of the bounding box associated with the cube texture.
  76283. * It must define where the camera used to render the texture was set
  76284. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76285. */
  76286. boundingBoxPosition: Vector3;
  76287. private _boundingBoxSize;
  76288. /**
  76289. * Gets or sets the size of the bounding box associated with the cube texture
  76290. * When defined, the cubemap will switch to local mode
  76291. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76292. * @example https://www.babylonjs-playground.com/#RNASML
  76293. */
  76294. /**
  76295. * Returns the bounding box size
  76296. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76297. */
  76298. boundingBoxSize: Vector3;
  76299. protected _rotationY: number;
  76300. /**
  76301. * Sets texture matrix rotation angle around Y axis in radians.
  76302. */
  76303. /**
  76304. * Gets texture matrix rotation angle around Y axis radians.
  76305. */
  76306. rotationY: number;
  76307. /**
  76308. * Are mip maps generated for this texture or not.
  76309. */
  76310. readonly noMipmap: boolean;
  76311. private _noMipmap;
  76312. private _files;
  76313. protected _forcedExtension: Nullable<string>;
  76314. private _extensions;
  76315. private _textureMatrix;
  76316. private _format;
  76317. private _createPolynomials;
  76318. /** @hidden */
  76319. _prefiltered: boolean;
  76320. /**
  76321. * Creates a cube texture from an array of image urls
  76322. * @param files defines an array of image urls
  76323. * @param scene defines the hosting scene
  76324. * @param noMipmap specifies if mip maps are not used
  76325. * @returns a cube texture
  76326. */
  76327. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  76328. /**
  76329. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  76330. * @param url defines the url of the prefiltered texture
  76331. * @param scene defines the scene the texture is attached to
  76332. * @param forcedExtension defines the extension of the file if different from the url
  76333. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76334. * @return the prefiltered texture
  76335. */
  76336. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  76337. /**
  76338. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  76339. * as prefiltered data.
  76340. * @param rootUrl defines the url of the texture or the root name of the six images
  76341. * @param scene defines the scene the texture is attached to
  76342. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  76343. * @param noMipmap defines if mipmaps should be created or not
  76344. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  76345. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  76346. * @param onError defines a callback triggered in case of error during load
  76347. * @param format defines the internal format to use for the texture once loaded
  76348. * @param prefiltered defines whether or not the texture is created from prefiltered data
  76349. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  76350. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76351. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76352. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76353. * @return the cube texture
  76354. */
  76355. 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);
  76356. /**
  76357. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  76358. */
  76359. readonly isPrefiltered: boolean;
  76360. /**
  76361. * Get the current class name of the texture useful for serialization or dynamic coding.
  76362. * @returns "CubeTexture"
  76363. */
  76364. getClassName(): string;
  76365. /**
  76366. * Update the url (and optional buffer) of this texture if url was null during construction.
  76367. * @param url the url of the texture
  76368. * @param forcedExtension defines the extension to use
  76369. * @param onLoad callback called when the texture is loaded (defaults to null)
  76370. */
  76371. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  76372. /**
  76373. * Delays loading of the cube texture
  76374. * @param forcedExtension defines the extension to use
  76375. */
  76376. delayLoad(forcedExtension?: string): void;
  76377. /**
  76378. * Returns the reflection texture matrix
  76379. * @returns the reflection texture matrix
  76380. */
  76381. getReflectionTextureMatrix(): Matrix;
  76382. /**
  76383. * Sets the reflection texture matrix
  76384. * @param value Reflection texture matrix
  76385. */
  76386. setReflectionTextureMatrix(value: Matrix): void;
  76387. /**
  76388. * Parses text to create a cube texture
  76389. * @param parsedTexture define the serialized text to read from
  76390. * @param scene defines the hosting scene
  76391. * @param rootUrl defines the root url of the cube texture
  76392. * @returns a cube texture
  76393. */
  76394. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  76395. /**
  76396. * Makes a clone, or deep copy, of the cube texture
  76397. * @returns a new cube texture
  76398. */
  76399. clone(): CubeTexture;
  76400. }
  76401. }
  76402. declare module BABYLON {
  76403. /**
  76404. * Manages the defines for the Material
  76405. */
  76406. export class MaterialDefines {
  76407. /** @hidden */
  76408. protected _keys: string[];
  76409. private _isDirty;
  76410. /** @hidden */
  76411. _renderId: number;
  76412. /** @hidden */
  76413. _areLightsDirty: boolean;
  76414. /** @hidden */
  76415. _areLightsDisposed: boolean;
  76416. /** @hidden */
  76417. _areAttributesDirty: boolean;
  76418. /** @hidden */
  76419. _areTexturesDirty: boolean;
  76420. /** @hidden */
  76421. _areFresnelDirty: boolean;
  76422. /** @hidden */
  76423. _areMiscDirty: boolean;
  76424. /** @hidden */
  76425. _areImageProcessingDirty: boolean;
  76426. /** @hidden */
  76427. _normals: boolean;
  76428. /** @hidden */
  76429. _uvs: boolean;
  76430. /** @hidden */
  76431. _needNormals: boolean;
  76432. /** @hidden */
  76433. _needUVs: boolean;
  76434. [id: string]: any;
  76435. /**
  76436. * Specifies if the material needs to be re-calculated
  76437. */
  76438. readonly isDirty: boolean;
  76439. /**
  76440. * Marks the material to indicate that it has been re-calculated
  76441. */
  76442. markAsProcessed(): void;
  76443. /**
  76444. * Marks the material to indicate that it needs to be re-calculated
  76445. */
  76446. markAsUnprocessed(): void;
  76447. /**
  76448. * Marks the material to indicate all of its defines need to be re-calculated
  76449. */
  76450. markAllAsDirty(): void;
  76451. /**
  76452. * Marks the material to indicate that image processing needs to be re-calculated
  76453. */
  76454. markAsImageProcessingDirty(): void;
  76455. /**
  76456. * Marks the material to indicate the lights need to be re-calculated
  76457. * @param disposed Defines whether the light is dirty due to dispose or not
  76458. */
  76459. markAsLightDirty(disposed?: boolean): void;
  76460. /**
  76461. * Marks the attribute state as changed
  76462. */
  76463. markAsAttributesDirty(): void;
  76464. /**
  76465. * Marks the texture state as changed
  76466. */
  76467. markAsTexturesDirty(): void;
  76468. /**
  76469. * Marks the fresnel state as changed
  76470. */
  76471. markAsFresnelDirty(): void;
  76472. /**
  76473. * Marks the misc state as changed
  76474. */
  76475. markAsMiscDirty(): void;
  76476. /**
  76477. * Rebuilds the material defines
  76478. */
  76479. rebuild(): void;
  76480. /**
  76481. * Specifies if two material defines are equal
  76482. * @param other - A material define instance to compare to
  76483. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  76484. */
  76485. isEqual(other: MaterialDefines): boolean;
  76486. /**
  76487. * Clones this instance's defines to another instance
  76488. * @param other - material defines to clone values to
  76489. */
  76490. cloneTo(other: MaterialDefines): void;
  76491. /**
  76492. * Resets the material define values
  76493. */
  76494. reset(): void;
  76495. /**
  76496. * Converts the material define values to a string
  76497. * @returns - String of material define information
  76498. */
  76499. toString(): string;
  76500. }
  76501. }
  76502. declare module BABYLON {
  76503. /**
  76504. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  76505. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  76506. * 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;
  76507. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  76508. */
  76509. export class ColorCurves {
  76510. private _dirty;
  76511. private _tempColor;
  76512. private _globalCurve;
  76513. private _highlightsCurve;
  76514. private _midtonesCurve;
  76515. private _shadowsCurve;
  76516. private _positiveCurve;
  76517. private _negativeCurve;
  76518. private _globalHue;
  76519. private _globalDensity;
  76520. private _globalSaturation;
  76521. private _globalExposure;
  76522. /**
  76523. * Gets the global Hue value.
  76524. * 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).
  76525. */
  76526. /**
  76527. * Sets the global Hue value.
  76528. * 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).
  76529. */
  76530. globalHue: number;
  76531. /**
  76532. * Gets the global Density value.
  76533. * 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.
  76534. * Values less than zero provide a filter of opposite hue.
  76535. */
  76536. /**
  76537. * Sets the global Density value.
  76538. * 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.
  76539. * Values less than zero provide a filter of opposite hue.
  76540. */
  76541. globalDensity: number;
  76542. /**
  76543. * Gets the global Saturation value.
  76544. * 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.
  76545. */
  76546. /**
  76547. * Sets the global Saturation value.
  76548. * 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.
  76549. */
  76550. globalSaturation: number;
  76551. /**
  76552. * Gets the global Exposure value.
  76553. * 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.
  76554. */
  76555. /**
  76556. * Sets the global Exposure value.
  76557. * 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.
  76558. */
  76559. globalExposure: number;
  76560. private _highlightsHue;
  76561. private _highlightsDensity;
  76562. private _highlightsSaturation;
  76563. private _highlightsExposure;
  76564. /**
  76565. * Gets the highlights Hue value.
  76566. * 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).
  76567. */
  76568. /**
  76569. * Sets the highlights Hue value.
  76570. * 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).
  76571. */
  76572. highlightsHue: number;
  76573. /**
  76574. * Gets the highlights Density value.
  76575. * 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.
  76576. * Values less than zero provide a filter of opposite hue.
  76577. */
  76578. /**
  76579. * Sets the highlights Density value.
  76580. * 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.
  76581. * Values less than zero provide a filter of opposite hue.
  76582. */
  76583. highlightsDensity: number;
  76584. /**
  76585. * Gets the highlights Saturation value.
  76586. * 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.
  76587. */
  76588. /**
  76589. * Sets the highlights Saturation value.
  76590. * 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.
  76591. */
  76592. highlightsSaturation: number;
  76593. /**
  76594. * Gets the highlights Exposure value.
  76595. * 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.
  76596. */
  76597. /**
  76598. * Sets the highlights Exposure value.
  76599. * 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.
  76600. */
  76601. highlightsExposure: number;
  76602. private _midtonesHue;
  76603. private _midtonesDensity;
  76604. private _midtonesSaturation;
  76605. private _midtonesExposure;
  76606. /**
  76607. * Gets the midtones Hue value.
  76608. * 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).
  76609. */
  76610. /**
  76611. * Sets the midtones Hue value.
  76612. * 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).
  76613. */
  76614. midtonesHue: number;
  76615. /**
  76616. * Gets the midtones Density value.
  76617. * 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.
  76618. * Values less than zero provide a filter of opposite hue.
  76619. */
  76620. /**
  76621. * Sets the midtones Density value.
  76622. * 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.
  76623. * Values less than zero provide a filter of opposite hue.
  76624. */
  76625. midtonesDensity: number;
  76626. /**
  76627. * Gets the midtones Saturation value.
  76628. * 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.
  76629. */
  76630. /**
  76631. * Sets the midtones Saturation value.
  76632. * 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.
  76633. */
  76634. midtonesSaturation: number;
  76635. /**
  76636. * Gets the midtones Exposure value.
  76637. * 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.
  76638. */
  76639. /**
  76640. * Sets the midtones Exposure value.
  76641. * 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.
  76642. */
  76643. midtonesExposure: number;
  76644. private _shadowsHue;
  76645. private _shadowsDensity;
  76646. private _shadowsSaturation;
  76647. private _shadowsExposure;
  76648. /**
  76649. * Gets the shadows Hue value.
  76650. * 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).
  76651. */
  76652. /**
  76653. * Sets the shadows Hue value.
  76654. * 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).
  76655. */
  76656. shadowsHue: number;
  76657. /**
  76658. * Gets the shadows Density value.
  76659. * 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.
  76660. * Values less than zero provide a filter of opposite hue.
  76661. */
  76662. /**
  76663. * Sets the shadows Density value.
  76664. * 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.
  76665. * Values less than zero provide a filter of opposite hue.
  76666. */
  76667. shadowsDensity: number;
  76668. /**
  76669. * Gets the shadows Saturation value.
  76670. * 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.
  76671. */
  76672. /**
  76673. * Sets the shadows Saturation value.
  76674. * 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.
  76675. */
  76676. shadowsSaturation: number;
  76677. /**
  76678. * Gets the shadows Exposure value.
  76679. * 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.
  76680. */
  76681. /**
  76682. * Sets the shadows Exposure value.
  76683. * 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.
  76684. */
  76685. shadowsExposure: number;
  76686. /**
  76687. * Returns the class name
  76688. * @returns The class name
  76689. */
  76690. getClassName(): string;
  76691. /**
  76692. * Binds the color curves to the shader.
  76693. * @param colorCurves The color curve to bind
  76694. * @param effect The effect to bind to
  76695. * @param positiveUniform The positive uniform shader parameter
  76696. * @param neutralUniform The neutral uniform shader parameter
  76697. * @param negativeUniform The negative uniform shader parameter
  76698. */
  76699. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  76700. /**
  76701. * Prepare the list of uniforms associated with the ColorCurves effects.
  76702. * @param uniformsList The list of uniforms used in the effect
  76703. */
  76704. static PrepareUniforms(uniformsList: string[]): void;
  76705. /**
  76706. * Returns color grading data based on a hue, density, saturation and exposure value.
  76707. * @param filterHue The hue of the color filter.
  76708. * @param filterDensity The density of the color filter.
  76709. * @param saturation The saturation.
  76710. * @param exposure The exposure.
  76711. * @param result The result data container.
  76712. */
  76713. private getColorGradingDataToRef;
  76714. /**
  76715. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  76716. * @param value The input slider value in range [-100,100].
  76717. * @returns Adjusted value.
  76718. */
  76719. private static applyColorGradingSliderNonlinear;
  76720. /**
  76721. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76722. * @param hue The hue (H) input.
  76723. * @param saturation The saturation (S) input.
  76724. * @param brightness The brightness (B) input.
  76725. * @result An RGBA color represented as Vector4.
  76726. */
  76727. private static fromHSBToRef;
  76728. /**
  76729. * Returns a value clamped between min and max
  76730. * @param value The value to clamp
  76731. * @param min The minimum of value
  76732. * @param max The maximum of value
  76733. * @returns The clamped value.
  76734. */
  76735. private static clamp;
  76736. /**
  76737. * Clones the current color curve instance.
  76738. * @return The cloned curves
  76739. */
  76740. clone(): ColorCurves;
  76741. /**
  76742. * Serializes the current color curve instance to a json representation.
  76743. * @return a JSON representation
  76744. */
  76745. serialize(): any;
  76746. /**
  76747. * Parses the color curve from a json representation.
  76748. * @param source the JSON source to parse
  76749. * @return The parsed curves
  76750. */
  76751. static Parse(source: any): ColorCurves;
  76752. }
  76753. }
  76754. declare module BABYLON {
  76755. /**
  76756. * Interface to follow in your material defines to integrate easily the
  76757. * Image proccessing functions.
  76758. * @hidden
  76759. */
  76760. export interface IImageProcessingConfigurationDefines {
  76761. IMAGEPROCESSING: boolean;
  76762. VIGNETTE: boolean;
  76763. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76764. VIGNETTEBLENDMODEOPAQUE: boolean;
  76765. TONEMAPPING: boolean;
  76766. TONEMAPPING_ACES: boolean;
  76767. CONTRAST: boolean;
  76768. EXPOSURE: boolean;
  76769. COLORCURVES: boolean;
  76770. COLORGRADING: boolean;
  76771. COLORGRADING3D: boolean;
  76772. SAMPLER3DGREENDEPTH: boolean;
  76773. SAMPLER3DBGRMAP: boolean;
  76774. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76775. }
  76776. /**
  76777. * @hidden
  76778. */
  76779. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76780. IMAGEPROCESSING: boolean;
  76781. VIGNETTE: boolean;
  76782. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76783. VIGNETTEBLENDMODEOPAQUE: boolean;
  76784. TONEMAPPING: boolean;
  76785. TONEMAPPING_ACES: boolean;
  76786. CONTRAST: boolean;
  76787. COLORCURVES: boolean;
  76788. COLORGRADING: boolean;
  76789. COLORGRADING3D: boolean;
  76790. SAMPLER3DGREENDEPTH: boolean;
  76791. SAMPLER3DBGRMAP: boolean;
  76792. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76793. EXPOSURE: boolean;
  76794. constructor();
  76795. }
  76796. /**
  76797. * This groups together the common properties used for image processing either in direct forward pass
  76798. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76799. * or not.
  76800. */
  76801. export class ImageProcessingConfiguration {
  76802. /**
  76803. * Default tone mapping applied in BabylonJS.
  76804. */
  76805. static readonly TONEMAPPING_STANDARD: number;
  76806. /**
  76807. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76808. * to other engines rendering to increase portability.
  76809. */
  76810. static readonly TONEMAPPING_ACES: number;
  76811. /**
  76812. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76813. */
  76814. colorCurves: Nullable<ColorCurves>;
  76815. private _colorCurvesEnabled;
  76816. /**
  76817. * Gets wether the color curves effect is enabled.
  76818. */
  76819. /**
  76820. * Sets wether the color curves effect is enabled.
  76821. */
  76822. colorCurvesEnabled: boolean;
  76823. private _colorGradingTexture;
  76824. /**
  76825. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76826. */
  76827. /**
  76828. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76829. */
  76830. colorGradingTexture: Nullable<BaseTexture>;
  76831. private _colorGradingEnabled;
  76832. /**
  76833. * Gets wether the color grading effect is enabled.
  76834. */
  76835. /**
  76836. * Sets wether the color grading effect is enabled.
  76837. */
  76838. colorGradingEnabled: boolean;
  76839. private _colorGradingWithGreenDepth;
  76840. /**
  76841. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76842. */
  76843. /**
  76844. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76845. */
  76846. colorGradingWithGreenDepth: boolean;
  76847. private _colorGradingBGR;
  76848. /**
  76849. * Gets wether the color grading texture contains BGR values.
  76850. */
  76851. /**
  76852. * Sets wether the color grading texture contains BGR values.
  76853. */
  76854. colorGradingBGR: boolean;
  76855. /** @hidden */
  76856. _exposure: number;
  76857. /**
  76858. * Gets the Exposure used in the effect.
  76859. */
  76860. /**
  76861. * Sets the Exposure used in the effect.
  76862. */
  76863. exposure: number;
  76864. private _toneMappingEnabled;
  76865. /**
  76866. * Gets wether the tone mapping effect is enabled.
  76867. */
  76868. /**
  76869. * Sets wether the tone mapping effect is enabled.
  76870. */
  76871. toneMappingEnabled: boolean;
  76872. private _toneMappingType;
  76873. /**
  76874. * Gets the type of tone mapping effect.
  76875. */
  76876. /**
  76877. * Sets the type of tone mapping effect used in BabylonJS.
  76878. */
  76879. toneMappingType: number;
  76880. protected _contrast: number;
  76881. /**
  76882. * Gets the contrast used in the effect.
  76883. */
  76884. /**
  76885. * Sets the contrast used in the effect.
  76886. */
  76887. contrast: number;
  76888. /**
  76889. * Vignette stretch size.
  76890. */
  76891. vignetteStretch: number;
  76892. /**
  76893. * Vignette centre X Offset.
  76894. */
  76895. vignetteCentreX: number;
  76896. /**
  76897. * Vignette centre Y Offset.
  76898. */
  76899. vignetteCentreY: number;
  76900. /**
  76901. * Vignette weight or intensity of the vignette effect.
  76902. */
  76903. vignetteWeight: number;
  76904. /**
  76905. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76906. * if vignetteEnabled is set to true.
  76907. */
  76908. vignetteColor: Color4;
  76909. /**
  76910. * Camera field of view used by the Vignette effect.
  76911. */
  76912. vignetteCameraFov: number;
  76913. private _vignetteBlendMode;
  76914. /**
  76915. * Gets the vignette blend mode allowing different kind of effect.
  76916. */
  76917. /**
  76918. * Sets the vignette blend mode allowing different kind of effect.
  76919. */
  76920. vignetteBlendMode: number;
  76921. private _vignetteEnabled;
  76922. /**
  76923. * Gets wether the vignette effect is enabled.
  76924. */
  76925. /**
  76926. * Sets wether the vignette effect is enabled.
  76927. */
  76928. vignetteEnabled: boolean;
  76929. private _applyByPostProcess;
  76930. /**
  76931. * Gets wether the image processing is applied through a post process or not.
  76932. */
  76933. /**
  76934. * Sets wether the image processing is applied through a post process or not.
  76935. */
  76936. applyByPostProcess: boolean;
  76937. private _isEnabled;
  76938. /**
  76939. * Gets wether the image processing is enabled or not.
  76940. */
  76941. /**
  76942. * Sets wether the image processing is enabled or not.
  76943. */
  76944. isEnabled: boolean;
  76945. /**
  76946. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76947. */
  76948. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76949. /**
  76950. * Method called each time the image processing information changes requires to recompile the effect.
  76951. */
  76952. protected _updateParameters(): void;
  76953. /**
  76954. * Gets the current class name.
  76955. * @return "ImageProcessingConfiguration"
  76956. */
  76957. getClassName(): string;
  76958. /**
  76959. * Prepare the list of uniforms associated with the Image Processing effects.
  76960. * @param uniforms The list of uniforms used in the effect
  76961. * @param defines the list of defines currently in use
  76962. */
  76963. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76964. /**
  76965. * Prepare the list of samplers associated with the Image Processing effects.
  76966. * @param samplersList The list of uniforms used in the effect
  76967. * @param defines the list of defines currently in use
  76968. */
  76969. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76970. /**
  76971. * Prepare the list of defines associated to the shader.
  76972. * @param defines the list of defines to complete
  76973. * @param forPostProcess Define if we are currently in post process mode or not
  76974. */
  76975. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76976. /**
  76977. * Returns true if all the image processing information are ready.
  76978. * @returns True if ready, otherwise, false
  76979. */
  76980. isReady(): boolean;
  76981. /**
  76982. * Binds the image processing to the shader.
  76983. * @param effect The effect to bind to
  76984. * @param overrideAspectRatio Override the aspect ratio of the effect
  76985. */
  76986. bind(effect: Effect, overrideAspectRatio?: number): void;
  76987. /**
  76988. * Clones the current image processing instance.
  76989. * @return The cloned image processing
  76990. */
  76991. clone(): ImageProcessingConfiguration;
  76992. /**
  76993. * Serializes the current image processing instance to a json representation.
  76994. * @return a JSON representation
  76995. */
  76996. serialize(): any;
  76997. /**
  76998. * Parses the image processing from a json representation.
  76999. * @param source the JSON source to parse
  77000. * @return The parsed image processing
  77001. */
  77002. static Parse(source: any): ImageProcessingConfiguration;
  77003. private static _VIGNETTEMODE_MULTIPLY;
  77004. private static _VIGNETTEMODE_OPAQUE;
  77005. /**
  77006. * Used to apply the vignette as a mix with the pixel color.
  77007. */
  77008. static readonly VIGNETTEMODE_MULTIPLY: number;
  77009. /**
  77010. * Used to apply the vignette as a replacement of the pixel color.
  77011. */
  77012. static readonly VIGNETTEMODE_OPAQUE: number;
  77013. }
  77014. }
  77015. declare module BABYLON {
  77016. /** @hidden */
  77017. export var postprocessVertexShader: {
  77018. name: string;
  77019. shader: string;
  77020. };
  77021. }
  77022. declare module BABYLON {
  77023. interface ThinEngine {
  77024. /**
  77025. * Creates a new render target texture
  77026. * @param size defines the size of the texture
  77027. * @param options defines the options used to create the texture
  77028. * @returns a new render target texture stored in an InternalTexture
  77029. */
  77030. createRenderTargetTexture(size: number | {
  77031. width: number;
  77032. height: number;
  77033. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  77034. /**
  77035. * Creates a depth stencil texture.
  77036. * This is only available in WebGL 2 or with the depth texture extension available.
  77037. * @param size The size of face edge in the texture.
  77038. * @param options The options defining the texture.
  77039. * @returns The texture
  77040. */
  77041. createDepthStencilTexture(size: number | {
  77042. width: number;
  77043. height: number;
  77044. }, options: DepthTextureCreationOptions): InternalTexture;
  77045. /** @hidden */
  77046. _createDepthStencilTexture(size: number | {
  77047. width: number;
  77048. height: number;
  77049. }, options: DepthTextureCreationOptions): InternalTexture;
  77050. }
  77051. }
  77052. declare module BABYLON {
  77053. /** Defines supported spaces */
  77054. export enum Space {
  77055. /** Local (object) space */
  77056. LOCAL = 0,
  77057. /** World space */
  77058. WORLD = 1,
  77059. /** Bone space */
  77060. BONE = 2
  77061. }
  77062. /** Defines the 3 main axes */
  77063. export class Axis {
  77064. /** X axis */
  77065. static X: Vector3;
  77066. /** Y axis */
  77067. static Y: Vector3;
  77068. /** Z axis */
  77069. static Z: Vector3;
  77070. }
  77071. }
  77072. declare module BABYLON {
  77073. /**
  77074. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  77075. * This is the base of the follow, arc rotate cameras and Free camera
  77076. * @see http://doc.babylonjs.com/features/cameras
  77077. */
  77078. export class TargetCamera extends Camera {
  77079. private static _RigCamTransformMatrix;
  77080. private static _TargetTransformMatrix;
  77081. private static _TargetFocalPoint;
  77082. /**
  77083. * Define the current direction the camera is moving to
  77084. */
  77085. cameraDirection: Vector3;
  77086. /**
  77087. * Define the current rotation the camera is rotating to
  77088. */
  77089. cameraRotation: Vector2;
  77090. /**
  77091. * When set, the up vector of the camera will be updated by the rotation of the camera
  77092. */
  77093. updateUpVectorFromRotation: boolean;
  77094. private _tmpQuaternion;
  77095. /**
  77096. * Define the current rotation of the camera
  77097. */
  77098. rotation: Vector3;
  77099. /**
  77100. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  77101. */
  77102. rotationQuaternion: Quaternion;
  77103. /**
  77104. * Define the current speed of the camera
  77105. */
  77106. speed: number;
  77107. /**
  77108. * Add constraint to the camera to prevent it to move freely in all directions and
  77109. * around all axis.
  77110. */
  77111. noRotationConstraint: boolean;
  77112. /**
  77113. * Define the current target of the camera as an object or a position.
  77114. */
  77115. lockedTarget: any;
  77116. /** @hidden */
  77117. _currentTarget: Vector3;
  77118. /** @hidden */
  77119. _initialFocalDistance: number;
  77120. /** @hidden */
  77121. _viewMatrix: Matrix;
  77122. /** @hidden */
  77123. _camMatrix: Matrix;
  77124. /** @hidden */
  77125. _cameraTransformMatrix: Matrix;
  77126. /** @hidden */
  77127. _cameraRotationMatrix: Matrix;
  77128. /** @hidden */
  77129. _referencePoint: Vector3;
  77130. /** @hidden */
  77131. _transformedReferencePoint: Vector3;
  77132. protected _globalCurrentTarget: Vector3;
  77133. protected _globalCurrentUpVector: Vector3;
  77134. /** @hidden */
  77135. _reset: () => void;
  77136. private _defaultUp;
  77137. /**
  77138. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  77139. * This is the base of the follow, arc rotate cameras and Free camera
  77140. * @see http://doc.babylonjs.com/features/cameras
  77141. * @param name Defines the name of the camera in the scene
  77142. * @param position Defines the start position of the camera in the scene
  77143. * @param scene Defines the scene the camera belongs to
  77144. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77145. */
  77146. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77147. /**
  77148. * Gets the position in front of the camera at a given distance.
  77149. * @param distance The distance from the camera we want the position to be
  77150. * @returns the position
  77151. */
  77152. getFrontPosition(distance: number): Vector3;
  77153. /** @hidden */
  77154. _getLockedTargetPosition(): Nullable<Vector3>;
  77155. private _storedPosition;
  77156. private _storedRotation;
  77157. private _storedRotationQuaternion;
  77158. /**
  77159. * Store current camera state of the camera (fov, position, rotation, etc..)
  77160. * @returns the camera
  77161. */
  77162. storeState(): Camera;
  77163. /**
  77164. * Restored camera state. You must call storeState() first
  77165. * @returns whether it was successful or not
  77166. * @hidden
  77167. */
  77168. _restoreStateValues(): boolean;
  77169. /** @hidden */
  77170. _initCache(): void;
  77171. /** @hidden */
  77172. _updateCache(ignoreParentClass?: boolean): void;
  77173. /** @hidden */
  77174. _isSynchronizedViewMatrix(): boolean;
  77175. /** @hidden */
  77176. _computeLocalCameraSpeed(): number;
  77177. /**
  77178. * Defines the target the camera should look at.
  77179. * @param target Defines the new target as a Vector or a mesh
  77180. */
  77181. setTarget(target: Vector3): void;
  77182. /**
  77183. * Return the current target position of the camera. This value is expressed in local space.
  77184. * @returns the target position
  77185. */
  77186. getTarget(): Vector3;
  77187. /** @hidden */
  77188. _decideIfNeedsToMove(): boolean;
  77189. /** @hidden */
  77190. _updatePosition(): void;
  77191. /** @hidden */
  77192. _checkInputs(): void;
  77193. protected _updateCameraRotationMatrix(): void;
  77194. /**
  77195. * 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)
  77196. * @returns the current camera
  77197. */
  77198. private _rotateUpVectorWithCameraRotationMatrix;
  77199. private _cachedRotationZ;
  77200. private _cachedQuaternionRotationZ;
  77201. /** @hidden */
  77202. _getViewMatrix(): Matrix;
  77203. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  77204. /**
  77205. * @hidden
  77206. */
  77207. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  77208. /**
  77209. * @hidden
  77210. */
  77211. _updateRigCameras(): void;
  77212. private _getRigCamPositionAndTarget;
  77213. /**
  77214. * Gets the current object class name.
  77215. * @return the class name
  77216. */
  77217. getClassName(): string;
  77218. }
  77219. }
  77220. declare module BABYLON {
  77221. /**
  77222. * Gather the list of keyboard event types as constants.
  77223. */
  77224. export class KeyboardEventTypes {
  77225. /**
  77226. * The keydown event is fired when a key becomes active (pressed).
  77227. */
  77228. static readonly KEYDOWN: number;
  77229. /**
  77230. * The keyup event is fired when a key has been released.
  77231. */
  77232. static readonly KEYUP: number;
  77233. }
  77234. /**
  77235. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77236. */
  77237. export class KeyboardInfo {
  77238. /**
  77239. * Defines the type of event (KeyboardEventTypes)
  77240. */
  77241. type: number;
  77242. /**
  77243. * Defines the related dom event
  77244. */
  77245. event: KeyboardEvent;
  77246. /**
  77247. * Instantiates a new keyboard info.
  77248. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77249. * @param type Defines the type of event (KeyboardEventTypes)
  77250. * @param event Defines the related dom event
  77251. */
  77252. constructor(
  77253. /**
  77254. * Defines the type of event (KeyboardEventTypes)
  77255. */
  77256. type: number,
  77257. /**
  77258. * Defines the related dom event
  77259. */
  77260. event: KeyboardEvent);
  77261. }
  77262. /**
  77263. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77264. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  77265. */
  77266. export class KeyboardInfoPre extends KeyboardInfo {
  77267. /**
  77268. * Defines the type of event (KeyboardEventTypes)
  77269. */
  77270. type: number;
  77271. /**
  77272. * Defines the related dom event
  77273. */
  77274. event: KeyboardEvent;
  77275. /**
  77276. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  77277. */
  77278. skipOnPointerObservable: boolean;
  77279. /**
  77280. * Instantiates a new keyboard pre info.
  77281. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77282. * @param type Defines the type of event (KeyboardEventTypes)
  77283. * @param event Defines the related dom event
  77284. */
  77285. constructor(
  77286. /**
  77287. * Defines the type of event (KeyboardEventTypes)
  77288. */
  77289. type: number,
  77290. /**
  77291. * Defines the related dom event
  77292. */
  77293. event: KeyboardEvent);
  77294. }
  77295. }
  77296. declare module BABYLON {
  77297. /**
  77298. * Manage the keyboard inputs to control the movement of a free camera.
  77299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77300. */
  77301. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  77302. /**
  77303. * Defines the camera the input is attached to.
  77304. */
  77305. camera: FreeCamera;
  77306. /**
  77307. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77308. */
  77309. keysUp: number[];
  77310. /**
  77311. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77312. */
  77313. keysDown: number[];
  77314. /**
  77315. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77316. */
  77317. keysLeft: number[];
  77318. /**
  77319. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77320. */
  77321. keysRight: number[];
  77322. private _keys;
  77323. private _onCanvasBlurObserver;
  77324. private _onKeyboardObserver;
  77325. private _engine;
  77326. private _scene;
  77327. /**
  77328. * Attach the input controls to a specific dom element to get the input from.
  77329. * @param element Defines the element the controls should be listened from
  77330. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77331. */
  77332. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77333. /**
  77334. * Detach the current controls from the specified dom element.
  77335. * @param element Defines the element to stop listening the inputs from
  77336. */
  77337. detachControl(element: Nullable<HTMLElement>): void;
  77338. /**
  77339. * Update the current camera state depending on the inputs that have been used this frame.
  77340. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77341. */
  77342. checkInputs(): void;
  77343. /**
  77344. * Gets the class name of the current intput.
  77345. * @returns the class name
  77346. */
  77347. getClassName(): string;
  77348. /** @hidden */
  77349. _onLostFocus(): void;
  77350. /**
  77351. * Get the friendly name associated with the input class.
  77352. * @returns the input friendly name
  77353. */
  77354. getSimpleName(): string;
  77355. }
  77356. }
  77357. declare module BABYLON {
  77358. /**
  77359. * Interface describing all the common properties and methods a shadow light needs to implement.
  77360. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  77361. * as well as binding the different shadow properties to the effects.
  77362. */
  77363. export interface IShadowLight extends Light {
  77364. /**
  77365. * The light id in the scene (used in scene.findLighById for instance)
  77366. */
  77367. id: string;
  77368. /**
  77369. * The position the shdow will be casted from.
  77370. */
  77371. position: Vector3;
  77372. /**
  77373. * In 2d mode (needCube being false), the direction used to cast the shadow.
  77374. */
  77375. direction: Vector3;
  77376. /**
  77377. * The transformed position. Position of the light in world space taking parenting in account.
  77378. */
  77379. transformedPosition: Vector3;
  77380. /**
  77381. * The transformed direction. Direction of the light in world space taking parenting in account.
  77382. */
  77383. transformedDirection: Vector3;
  77384. /**
  77385. * The friendly name of the light in the scene.
  77386. */
  77387. name: string;
  77388. /**
  77389. * Defines the shadow projection clipping minimum z value.
  77390. */
  77391. shadowMinZ: number;
  77392. /**
  77393. * Defines the shadow projection clipping maximum z value.
  77394. */
  77395. shadowMaxZ: number;
  77396. /**
  77397. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77398. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77399. */
  77400. computeTransformedInformation(): boolean;
  77401. /**
  77402. * Gets the scene the light belongs to.
  77403. * @returns The scene
  77404. */
  77405. getScene(): Scene;
  77406. /**
  77407. * Callback defining a custom Projection Matrix Builder.
  77408. * This can be used to override the default projection matrix computation.
  77409. */
  77410. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77411. /**
  77412. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77413. * @param matrix The materix to updated with the projection information
  77414. * @param viewMatrix The transform matrix of the light
  77415. * @param renderList The list of mesh to render in the map
  77416. * @returns The current light
  77417. */
  77418. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77419. /**
  77420. * Gets the current depth scale used in ESM.
  77421. * @returns The scale
  77422. */
  77423. getDepthScale(): number;
  77424. /**
  77425. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77426. * @returns true if a cube texture needs to be use
  77427. */
  77428. needCube(): boolean;
  77429. /**
  77430. * Detects if the projection matrix requires to be recomputed this frame.
  77431. * @returns true if it requires to be recomputed otherwise, false.
  77432. */
  77433. needProjectionMatrixCompute(): boolean;
  77434. /**
  77435. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77436. */
  77437. forceProjectionMatrixCompute(): void;
  77438. /**
  77439. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77440. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77441. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77442. */
  77443. getShadowDirection(faceIndex?: number): Vector3;
  77444. /**
  77445. * Gets the minZ used for shadow according to both the scene and the light.
  77446. * @param activeCamera The camera we are returning the min for
  77447. * @returns the depth min z
  77448. */
  77449. getDepthMinZ(activeCamera: Camera): number;
  77450. /**
  77451. * Gets the maxZ used for shadow according to both the scene and the light.
  77452. * @param activeCamera The camera we are returning the max for
  77453. * @returns the depth max z
  77454. */
  77455. getDepthMaxZ(activeCamera: Camera): number;
  77456. }
  77457. /**
  77458. * Base implementation IShadowLight
  77459. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  77460. */
  77461. export abstract class ShadowLight extends Light implements IShadowLight {
  77462. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  77463. protected _position: Vector3;
  77464. protected _setPosition(value: Vector3): void;
  77465. /**
  77466. * Sets the position the shadow will be casted from. Also use as the light position for both
  77467. * point and spot lights.
  77468. */
  77469. /**
  77470. * Sets the position the shadow will be casted from. Also use as the light position for both
  77471. * point and spot lights.
  77472. */
  77473. position: Vector3;
  77474. protected _direction: Vector3;
  77475. protected _setDirection(value: Vector3): void;
  77476. /**
  77477. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  77478. * Also use as the light direction on spot and directional lights.
  77479. */
  77480. /**
  77481. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  77482. * Also use as the light direction on spot and directional lights.
  77483. */
  77484. direction: Vector3;
  77485. private _shadowMinZ;
  77486. /**
  77487. * Gets the shadow projection clipping minimum z value.
  77488. */
  77489. /**
  77490. * Sets the shadow projection clipping minimum z value.
  77491. */
  77492. shadowMinZ: number;
  77493. private _shadowMaxZ;
  77494. /**
  77495. * Sets the shadow projection clipping maximum z value.
  77496. */
  77497. /**
  77498. * Gets the shadow projection clipping maximum z value.
  77499. */
  77500. shadowMaxZ: number;
  77501. /**
  77502. * Callback defining a custom Projection Matrix Builder.
  77503. * This can be used to override the default projection matrix computation.
  77504. */
  77505. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77506. /**
  77507. * The transformed position. Position of the light in world space taking parenting in account.
  77508. */
  77509. transformedPosition: Vector3;
  77510. /**
  77511. * The transformed direction. Direction of the light in world space taking parenting in account.
  77512. */
  77513. transformedDirection: Vector3;
  77514. private _needProjectionMatrixCompute;
  77515. /**
  77516. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77517. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77518. */
  77519. computeTransformedInformation(): boolean;
  77520. /**
  77521. * Return the depth scale used for the shadow map.
  77522. * @returns the depth scale.
  77523. */
  77524. getDepthScale(): number;
  77525. /**
  77526. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77527. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77528. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77529. */
  77530. getShadowDirection(faceIndex?: number): Vector3;
  77531. /**
  77532. * Returns the ShadowLight absolute position in the World.
  77533. * @returns the position vector in world space
  77534. */
  77535. getAbsolutePosition(): Vector3;
  77536. /**
  77537. * Sets the ShadowLight direction toward the passed target.
  77538. * @param target The point to target in local space
  77539. * @returns the updated ShadowLight direction
  77540. */
  77541. setDirectionToTarget(target: Vector3): Vector3;
  77542. /**
  77543. * Returns the light rotation in euler definition.
  77544. * @returns the x y z rotation in local space.
  77545. */
  77546. getRotation(): Vector3;
  77547. /**
  77548. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77549. * @returns true if a cube texture needs to be use
  77550. */
  77551. needCube(): boolean;
  77552. /**
  77553. * Detects if the projection matrix requires to be recomputed this frame.
  77554. * @returns true if it requires to be recomputed otherwise, false.
  77555. */
  77556. needProjectionMatrixCompute(): boolean;
  77557. /**
  77558. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77559. */
  77560. forceProjectionMatrixCompute(): void;
  77561. /** @hidden */
  77562. _initCache(): void;
  77563. /** @hidden */
  77564. _isSynchronized(): boolean;
  77565. /**
  77566. * Computes the world matrix of the node
  77567. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77568. * @returns the world matrix
  77569. */
  77570. computeWorldMatrix(force?: boolean): Matrix;
  77571. /**
  77572. * Gets the minZ used for shadow according to both the scene and the light.
  77573. * @param activeCamera The camera we are returning the min for
  77574. * @returns the depth min z
  77575. */
  77576. getDepthMinZ(activeCamera: Camera): number;
  77577. /**
  77578. * Gets the maxZ used for shadow according to both the scene and the light.
  77579. * @param activeCamera The camera we are returning the max for
  77580. * @returns the depth max z
  77581. */
  77582. getDepthMaxZ(activeCamera: Camera): number;
  77583. /**
  77584. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77585. * @param matrix The materix to updated with the projection information
  77586. * @param viewMatrix The transform matrix of the light
  77587. * @param renderList The list of mesh to render in the map
  77588. * @returns The current light
  77589. */
  77590. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77591. }
  77592. }
  77593. declare module BABYLON {
  77594. /**
  77595. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77596. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77597. */
  77598. export class EffectFallbacks implements IEffectFallbacks {
  77599. private _defines;
  77600. private _currentRank;
  77601. private _maxRank;
  77602. private _mesh;
  77603. /**
  77604. * Removes the fallback from the bound mesh.
  77605. */
  77606. unBindMesh(): void;
  77607. /**
  77608. * Adds a fallback on the specified property.
  77609. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77610. * @param define The name of the define in the shader
  77611. */
  77612. addFallback(rank: number, define: string): void;
  77613. /**
  77614. * Sets the mesh to use CPU skinning when needing to fallback.
  77615. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77616. * @param mesh The mesh to use the fallbacks.
  77617. */
  77618. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77619. /**
  77620. * Checks to see if more fallbacks are still availible.
  77621. */
  77622. readonly hasMoreFallbacks: boolean;
  77623. /**
  77624. * Removes the defines that should be removed when falling back.
  77625. * @param currentDefines defines the current define statements for the shader.
  77626. * @param effect defines the current effect we try to compile
  77627. * @returns The resulting defines with defines of the current rank removed.
  77628. */
  77629. reduce(currentDefines: string, effect: Effect): string;
  77630. }
  77631. }
  77632. declare module BABYLON {
  77633. /**
  77634. * "Static Class" containing the most commonly used helper while dealing with material for
  77635. * rendering purpose.
  77636. *
  77637. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77638. *
  77639. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77640. */
  77641. export class MaterialHelper {
  77642. /**
  77643. * Bind the current view position to an effect.
  77644. * @param effect The effect to be bound
  77645. * @param scene The scene the eyes position is used from
  77646. */
  77647. static BindEyePosition(effect: Effect, scene: Scene): void;
  77648. /**
  77649. * Helps preparing the defines values about the UVs in used in the effect.
  77650. * UVs are shared as much as we can accross channels in the shaders.
  77651. * @param texture The texture we are preparing the UVs for
  77652. * @param defines The defines to update
  77653. * @param key The channel key "diffuse", "specular"... used in the shader
  77654. */
  77655. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77656. /**
  77657. * Binds a texture matrix value to its corrsponding uniform
  77658. * @param texture The texture to bind the matrix for
  77659. * @param uniformBuffer The uniform buffer receivin the data
  77660. * @param key The channel key "diffuse", "specular"... used in the shader
  77661. */
  77662. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77663. /**
  77664. * Gets the current status of the fog (should it be enabled?)
  77665. * @param mesh defines the mesh to evaluate for fog support
  77666. * @param scene defines the hosting scene
  77667. * @returns true if fog must be enabled
  77668. */
  77669. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77670. /**
  77671. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77672. * @param mesh defines the current mesh
  77673. * @param scene defines the current scene
  77674. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77675. * @param pointsCloud defines if point cloud rendering has to be turned on
  77676. * @param fogEnabled defines if fog has to be turned on
  77677. * @param alphaTest defines if alpha testing has to be turned on
  77678. * @param defines defines the current list of defines
  77679. */
  77680. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77681. /**
  77682. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77683. * @param scene defines the current scene
  77684. * @param engine defines the current engine
  77685. * @param defines specifies the list of active defines
  77686. * @param useInstances defines if instances have to be turned on
  77687. * @param useClipPlane defines if clip plane have to be turned on
  77688. */
  77689. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77690. /**
  77691. * Prepares the defines for bones
  77692. * @param mesh The mesh containing the geometry data we will draw
  77693. * @param defines The defines to update
  77694. */
  77695. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77696. /**
  77697. * Prepares the defines for morph targets
  77698. * @param mesh The mesh containing the geometry data we will draw
  77699. * @param defines The defines to update
  77700. */
  77701. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  77702. /**
  77703. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  77704. * @param mesh The mesh containing the geometry data we will draw
  77705. * @param defines The defines to update
  77706. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  77707. * @param useBones Precise whether bones should be used or not (override mesh info)
  77708. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  77709. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  77710. * @returns false if defines are considered not dirty and have not been checked
  77711. */
  77712. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  77713. /**
  77714. * Prepares the defines related to multiview
  77715. * @param scene The scene we are intending to draw
  77716. * @param defines The defines to update
  77717. */
  77718. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77719. /**
  77720. * Prepares the defines related to the light information passed in parameter
  77721. * @param scene The scene we are intending to draw
  77722. * @param mesh The mesh the effect is compiling for
  77723. * @param light The light the effect is compiling for
  77724. * @param lightIndex The index of the light
  77725. * @param defines The defines to update
  77726. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77727. * @param state Defines the current state regarding what is needed (normals, etc...)
  77728. */
  77729. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77730. needNormals: boolean;
  77731. needRebuild: boolean;
  77732. shadowEnabled: boolean;
  77733. specularEnabled: boolean;
  77734. lightmapMode: boolean;
  77735. }): void;
  77736. /**
  77737. * Prepares the defines related to the light information passed in parameter
  77738. * @param scene The scene we are intending to draw
  77739. * @param mesh The mesh the effect is compiling for
  77740. * @param defines The defines to update
  77741. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77742. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77743. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77744. * @returns true if normals will be required for the rest of the effect
  77745. */
  77746. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77747. /**
  77748. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77749. * @param lightIndex defines the light index
  77750. * @param uniformsList The uniform list
  77751. * @param samplersList The sampler list
  77752. * @param projectedLightTexture defines if projected texture must be used
  77753. * @param uniformBuffersList defines an optional list of uniform buffers
  77754. */
  77755. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77756. /**
  77757. * Prepares the uniforms and samplers list to be used in the effect
  77758. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77759. * @param samplersList The sampler list
  77760. * @param defines The defines helping in the list generation
  77761. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77762. */
  77763. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77764. /**
  77765. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77766. * @param defines The defines to update while falling back
  77767. * @param fallbacks The authorized effect fallbacks
  77768. * @param maxSimultaneousLights The maximum number of lights allowed
  77769. * @param rank the current rank of the Effect
  77770. * @returns The newly affected rank
  77771. */
  77772. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77773. private static _TmpMorphInfluencers;
  77774. /**
  77775. * Prepares the list of attributes required for morph targets according to the effect defines.
  77776. * @param attribs The current list of supported attribs
  77777. * @param mesh The mesh to prepare the morph targets attributes for
  77778. * @param influencers The number of influencers
  77779. */
  77780. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77781. /**
  77782. * Prepares the list of attributes required for morph targets according to the effect defines.
  77783. * @param attribs The current list of supported attribs
  77784. * @param mesh The mesh to prepare the morph targets attributes for
  77785. * @param defines The current Defines of the effect
  77786. */
  77787. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77788. /**
  77789. * Prepares the list of attributes required for bones according to the effect defines.
  77790. * @param attribs The current list of supported attribs
  77791. * @param mesh The mesh to prepare the bones attributes for
  77792. * @param defines The current Defines of the effect
  77793. * @param fallbacks The current efffect fallback strategy
  77794. */
  77795. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77796. /**
  77797. * Check and prepare the list of attributes required for instances according to the effect defines.
  77798. * @param attribs The current list of supported attribs
  77799. * @param defines The current MaterialDefines of the effect
  77800. */
  77801. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77802. /**
  77803. * Add the list of attributes required for instances to the attribs array.
  77804. * @param attribs The current list of supported attribs
  77805. */
  77806. static PushAttributesForInstances(attribs: string[]): void;
  77807. /**
  77808. * Binds the light information to the effect.
  77809. * @param light The light containing the generator
  77810. * @param effect The effect we are binding the data to
  77811. * @param lightIndex The light index in the effect used to render
  77812. */
  77813. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77814. /**
  77815. * Binds the lights information from the scene to the effect for the given mesh.
  77816. * @param light Light to bind
  77817. * @param lightIndex Light index
  77818. * @param scene The scene where the light belongs to
  77819. * @param effect The effect we are binding the data to
  77820. * @param useSpecular Defines if specular is supported
  77821. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77823. */
  77824. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77825. /**
  77826. * Binds the lights information from the scene to the effect for the given mesh.
  77827. * @param scene The scene the lights belongs to
  77828. * @param mesh The mesh we are binding the information to render
  77829. * @param effect The effect we are binding the data to
  77830. * @param defines The generated defines for the effect
  77831. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77832. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77833. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77834. */
  77835. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77836. private static _tempFogColor;
  77837. /**
  77838. * Binds the fog information from the scene to the effect for the given mesh.
  77839. * @param scene The scene the lights belongs to
  77840. * @param mesh The mesh we are binding the information to render
  77841. * @param effect The effect we are binding the data to
  77842. * @param linearSpace Defines if the fog effect is applied in linear space
  77843. */
  77844. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77845. /**
  77846. * Binds the bones information from the mesh to the effect.
  77847. * @param mesh The mesh we are binding the information to render
  77848. * @param effect The effect we are binding the data to
  77849. */
  77850. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77851. /**
  77852. * Binds the morph targets information from the mesh to the effect.
  77853. * @param abstractMesh The mesh we are binding the information to render
  77854. * @param effect The effect we are binding the data to
  77855. */
  77856. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77857. /**
  77858. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77859. * @param defines The generated defines used in the effect
  77860. * @param effect The effect we are binding the data to
  77861. * @param scene The scene we are willing to render with logarithmic scale for
  77862. */
  77863. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77864. /**
  77865. * Binds the clip plane information from the scene to the effect.
  77866. * @param scene The scene the clip plane information are extracted from
  77867. * @param effect The effect we are binding the data to
  77868. */
  77869. static BindClipPlane(effect: Effect, scene: Scene): void;
  77870. }
  77871. }
  77872. declare module BABYLON {
  77873. /** @hidden */
  77874. export var packingFunctions: {
  77875. name: string;
  77876. shader: string;
  77877. };
  77878. }
  77879. declare module BABYLON {
  77880. /** @hidden */
  77881. export var shadowMapPixelShader: {
  77882. name: string;
  77883. shader: string;
  77884. };
  77885. }
  77886. declare module BABYLON {
  77887. /** @hidden */
  77888. export var bonesDeclaration: {
  77889. name: string;
  77890. shader: string;
  77891. };
  77892. }
  77893. declare module BABYLON {
  77894. /** @hidden */
  77895. export var morphTargetsVertexGlobalDeclaration: {
  77896. name: string;
  77897. shader: string;
  77898. };
  77899. }
  77900. declare module BABYLON {
  77901. /** @hidden */
  77902. export var morphTargetsVertexDeclaration: {
  77903. name: string;
  77904. shader: string;
  77905. };
  77906. }
  77907. declare module BABYLON {
  77908. /** @hidden */
  77909. export var instancesDeclaration: {
  77910. name: string;
  77911. shader: string;
  77912. };
  77913. }
  77914. declare module BABYLON {
  77915. /** @hidden */
  77916. export var helperFunctions: {
  77917. name: string;
  77918. shader: string;
  77919. };
  77920. }
  77921. declare module BABYLON {
  77922. /** @hidden */
  77923. export var morphTargetsVertex: {
  77924. name: string;
  77925. shader: string;
  77926. };
  77927. }
  77928. declare module BABYLON {
  77929. /** @hidden */
  77930. export var instancesVertex: {
  77931. name: string;
  77932. shader: string;
  77933. };
  77934. }
  77935. declare module BABYLON {
  77936. /** @hidden */
  77937. export var bonesVertex: {
  77938. name: string;
  77939. shader: string;
  77940. };
  77941. }
  77942. declare module BABYLON {
  77943. /** @hidden */
  77944. export var shadowMapVertexShader: {
  77945. name: string;
  77946. shader: string;
  77947. };
  77948. }
  77949. declare module BABYLON {
  77950. /** @hidden */
  77951. export var depthBoxBlurPixelShader: {
  77952. name: string;
  77953. shader: string;
  77954. };
  77955. }
  77956. declare module BABYLON {
  77957. /**
  77958. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77959. */
  77960. export interface ICustomShaderOptions {
  77961. /**
  77962. * Gets or sets the custom shader name to use
  77963. */
  77964. shaderName: string;
  77965. /**
  77966. * The list of attribute names used in the shader
  77967. */
  77968. attributes?: string[];
  77969. /**
  77970. * The list of unifrom names used in the shader
  77971. */
  77972. uniforms?: string[];
  77973. /**
  77974. * The list of sampler names used in the shader
  77975. */
  77976. samplers?: string[];
  77977. /**
  77978. * The list of defines used in the shader
  77979. */
  77980. defines?: string[];
  77981. }
  77982. /**
  77983. * Interface to implement to create a shadow generator compatible with BJS.
  77984. */
  77985. export interface IShadowGenerator {
  77986. /**
  77987. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77988. * @returns The render target texture if present otherwise, null
  77989. */
  77990. getShadowMap(): Nullable<RenderTargetTexture>;
  77991. /**
  77992. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77993. * @returns The render target texture if the shadow map is present otherwise, null
  77994. */
  77995. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77996. /**
  77997. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77998. * @param subMesh The submesh we want to render in the shadow map
  77999. * @param useInstances Defines wether will draw in the map using instances
  78000. * @returns true if ready otherwise, false
  78001. */
  78002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78003. /**
  78004. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78005. * @param defines Defines of the material we want to update
  78006. * @param lightIndex Index of the light in the enabled light list of the material
  78007. */
  78008. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  78009. /**
  78010. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78011. * defined in the generator but impacting the effect).
  78012. * It implies the unifroms available on the materials are the standard BJS ones.
  78013. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78014. * @param effect The effect we are binfing the information for
  78015. */
  78016. bindShadowLight(lightIndex: string, effect: Effect): void;
  78017. /**
  78018. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78019. * (eq to shadow prjection matrix * light transform matrix)
  78020. * @returns The transform matrix used to create the shadow map
  78021. */
  78022. getTransformMatrix(): Matrix;
  78023. /**
  78024. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78025. * Cube and 2D textures for instance.
  78026. */
  78027. recreateShadowMap(): void;
  78028. /**
  78029. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78030. * @param onCompiled Callback triggered at the and of the effects compilation
  78031. * @param options Sets of optional options forcing the compilation with different modes
  78032. */
  78033. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78034. useInstances: boolean;
  78035. }>): void;
  78036. /**
  78037. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78038. * @param options Sets of optional options forcing the compilation with different modes
  78039. * @returns A promise that resolves when the compilation completes
  78040. */
  78041. forceCompilationAsync(options?: Partial<{
  78042. useInstances: boolean;
  78043. }>): Promise<void>;
  78044. /**
  78045. * Serializes the shadow generator setup to a json object.
  78046. * @returns The serialized JSON object
  78047. */
  78048. serialize(): any;
  78049. /**
  78050. * Disposes the Shadow map and related Textures and effects.
  78051. */
  78052. dispose(): void;
  78053. }
  78054. /**
  78055. * Default implementation IShadowGenerator.
  78056. * This is the main object responsible of generating shadows in the framework.
  78057. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  78058. */
  78059. export class ShadowGenerator implements IShadowGenerator {
  78060. /**
  78061. * Shadow generator mode None: no filtering applied.
  78062. */
  78063. static readonly FILTER_NONE: number;
  78064. /**
  78065. * Shadow generator mode ESM: Exponential Shadow Mapping.
  78066. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78067. */
  78068. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  78069. /**
  78070. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  78071. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  78072. */
  78073. static readonly FILTER_POISSONSAMPLING: number;
  78074. /**
  78075. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  78076. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78077. */
  78078. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  78079. /**
  78080. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  78081. * edge artifacts on steep falloff.
  78082. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78083. */
  78084. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  78085. /**
  78086. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  78087. * edge artifacts on steep falloff.
  78088. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78089. */
  78090. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  78091. /**
  78092. * Shadow generator mode PCF: Percentage Closer Filtering
  78093. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78094. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  78095. */
  78096. static readonly FILTER_PCF: number;
  78097. /**
  78098. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  78099. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78100. * Contact Hardening
  78101. */
  78102. static readonly FILTER_PCSS: number;
  78103. /**
  78104. * Reserved for PCF and PCSS
  78105. * Highest Quality.
  78106. *
  78107. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  78108. *
  78109. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  78110. */
  78111. static readonly QUALITY_HIGH: number;
  78112. /**
  78113. * Reserved for PCF and PCSS
  78114. * Good tradeoff for quality/perf cross devices
  78115. *
  78116. * Execute PCF on a 3*3 kernel.
  78117. *
  78118. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  78119. */
  78120. static readonly QUALITY_MEDIUM: number;
  78121. /**
  78122. * Reserved for PCF and PCSS
  78123. * The lowest quality but the fastest.
  78124. *
  78125. * Execute PCF on a 1*1 kernel.
  78126. *
  78127. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  78128. */
  78129. static readonly QUALITY_LOW: number;
  78130. /** Gets or sets the custom shader name to use */
  78131. customShaderOptions: ICustomShaderOptions;
  78132. /**
  78133. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  78134. */
  78135. onBeforeShadowMapRenderObservable: Observable<Effect>;
  78136. /**
  78137. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  78138. */
  78139. onAfterShadowMapRenderObservable: Observable<Effect>;
  78140. /**
  78141. * Observable triggered before a mesh is rendered in the shadow map.
  78142. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  78143. */
  78144. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  78145. /**
  78146. * Observable triggered after a mesh is rendered in the shadow map.
  78147. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  78148. */
  78149. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  78150. private _bias;
  78151. /**
  78152. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  78153. */
  78154. /**
  78155. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  78156. */
  78157. bias: number;
  78158. private _normalBias;
  78159. /**
  78160. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78161. */
  78162. /**
  78163. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78164. */
  78165. normalBias: number;
  78166. private _blurBoxOffset;
  78167. /**
  78168. * Gets the blur box offset: offset applied during the blur pass.
  78169. * Only useful if useKernelBlur = false
  78170. */
  78171. /**
  78172. * Sets the blur box offset: offset applied during the blur pass.
  78173. * Only useful if useKernelBlur = false
  78174. */
  78175. blurBoxOffset: number;
  78176. private _blurScale;
  78177. /**
  78178. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  78179. * 2 means half of the size.
  78180. */
  78181. /**
  78182. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  78183. * 2 means half of the size.
  78184. */
  78185. blurScale: number;
  78186. private _blurKernel;
  78187. /**
  78188. * Gets the blur kernel: kernel size of the blur pass.
  78189. * Only useful if useKernelBlur = true
  78190. */
  78191. /**
  78192. * Sets the blur kernel: kernel size of the blur pass.
  78193. * Only useful if useKernelBlur = true
  78194. */
  78195. blurKernel: number;
  78196. private _useKernelBlur;
  78197. /**
  78198. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  78199. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78200. */
  78201. /**
  78202. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  78203. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78204. */
  78205. useKernelBlur: boolean;
  78206. private _depthScale;
  78207. /**
  78208. * Gets the depth scale used in ESM mode.
  78209. */
  78210. /**
  78211. * Sets the depth scale used in ESM mode.
  78212. * This can override the scale stored on the light.
  78213. */
  78214. depthScale: number;
  78215. private _filter;
  78216. /**
  78217. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  78218. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78219. */
  78220. /**
  78221. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  78222. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78223. */
  78224. filter: number;
  78225. /**
  78226. * Gets if the current filter is set to Poisson Sampling.
  78227. */
  78228. /**
  78229. * Sets the current filter to Poisson Sampling.
  78230. */
  78231. usePoissonSampling: boolean;
  78232. /**
  78233. * Gets if the current filter is set to ESM.
  78234. */
  78235. /**
  78236. * Sets the current filter is to ESM.
  78237. */
  78238. useExponentialShadowMap: boolean;
  78239. /**
  78240. * Gets if the current filter is set to filtered ESM.
  78241. */
  78242. /**
  78243. * Gets if the current filter is set to filtered ESM.
  78244. */
  78245. useBlurExponentialShadowMap: boolean;
  78246. /**
  78247. * Gets if the current filter is set to "close ESM" (using the inverse of the
  78248. * exponential to prevent steep falloff artifacts).
  78249. */
  78250. /**
  78251. * Sets the current filter to "close ESM" (using the inverse of the
  78252. * exponential to prevent steep falloff artifacts).
  78253. */
  78254. useCloseExponentialShadowMap: boolean;
  78255. /**
  78256. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  78257. * exponential to prevent steep falloff artifacts).
  78258. */
  78259. /**
  78260. * Sets the current filter to filtered "close ESM" (using the inverse of the
  78261. * exponential to prevent steep falloff artifacts).
  78262. */
  78263. useBlurCloseExponentialShadowMap: boolean;
  78264. /**
  78265. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  78266. */
  78267. /**
  78268. * Sets the current filter to "PCF" (percentage closer filtering).
  78269. */
  78270. usePercentageCloserFiltering: boolean;
  78271. private _filteringQuality;
  78272. /**
  78273. * Gets the PCF or PCSS Quality.
  78274. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78275. */
  78276. /**
  78277. * Sets the PCF or PCSS Quality.
  78278. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78279. */
  78280. filteringQuality: number;
  78281. /**
  78282. * Gets if the current filter is set to "PCSS" (contact hardening).
  78283. */
  78284. /**
  78285. * Sets the current filter to "PCSS" (contact hardening).
  78286. */
  78287. useContactHardeningShadow: boolean;
  78288. private _contactHardeningLightSizeUVRatio;
  78289. /**
  78290. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78291. * Using a ratio helps keeping shape stability independently of the map size.
  78292. *
  78293. * It does not account for the light projection as it was having too much
  78294. * instability during the light setup or during light position changes.
  78295. *
  78296. * Only valid if useContactHardeningShadow is true.
  78297. */
  78298. /**
  78299. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78300. * Using a ratio helps keeping shape stability independently of the map size.
  78301. *
  78302. * It does not account for the light projection as it was having too much
  78303. * instability during the light setup or during light position changes.
  78304. *
  78305. * Only valid if useContactHardeningShadow is true.
  78306. */
  78307. contactHardeningLightSizeUVRatio: number;
  78308. private _darkness;
  78309. /** Gets or sets the actual darkness of a shadow */
  78310. darkness: number;
  78311. /**
  78312. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  78313. * 0 means strongest and 1 would means no shadow.
  78314. * @returns the darkness.
  78315. */
  78316. getDarkness(): number;
  78317. /**
  78318. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  78319. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  78320. * @returns the shadow generator allowing fluent coding.
  78321. */
  78322. setDarkness(darkness: number): ShadowGenerator;
  78323. private _transparencyShadow;
  78324. /** Gets or sets the ability to have transparent shadow */
  78325. transparencyShadow: boolean;
  78326. /**
  78327. * Sets the ability to have transparent shadow (boolean).
  78328. * @param transparent True if transparent else False
  78329. * @returns the shadow generator allowing fluent coding
  78330. */
  78331. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  78332. private _shadowMap;
  78333. private _shadowMap2;
  78334. /**
  78335. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78336. * @returns The render target texture if present otherwise, null
  78337. */
  78338. getShadowMap(): Nullable<RenderTargetTexture>;
  78339. /**
  78340. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78341. * @returns The render target texture if the shadow map is present otherwise, null
  78342. */
  78343. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78344. /**
  78345. * Gets the class name of that object
  78346. * @returns "ShadowGenerator"
  78347. */
  78348. getClassName(): string;
  78349. /**
  78350. * Helper function to add a mesh and its descendants to the list of shadow casters.
  78351. * @param mesh Mesh to add
  78352. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  78353. * @returns the Shadow Generator itself
  78354. */
  78355. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78356. /**
  78357. * Helper function to remove a mesh and its descendants from the list of shadow casters
  78358. * @param mesh Mesh to remove
  78359. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  78360. * @returns the Shadow Generator itself
  78361. */
  78362. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78363. /**
  78364. * Controls the extent to which the shadows fade out at the edge of the frustum
  78365. * Used only by directionals and spots
  78366. */
  78367. frustumEdgeFalloff: number;
  78368. private _light;
  78369. /**
  78370. * Returns the associated light object.
  78371. * @returns the light generating the shadow
  78372. */
  78373. getLight(): IShadowLight;
  78374. /**
  78375. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  78376. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  78377. * It might on the other hand introduce peter panning.
  78378. */
  78379. forceBackFacesOnly: boolean;
  78380. private _scene;
  78381. private _lightDirection;
  78382. private _effect;
  78383. private _viewMatrix;
  78384. private _projectionMatrix;
  78385. private _transformMatrix;
  78386. private _cachedPosition;
  78387. private _cachedDirection;
  78388. private _cachedDefines;
  78389. private _currentRenderID;
  78390. private _boxBlurPostprocess;
  78391. private _kernelBlurXPostprocess;
  78392. private _kernelBlurYPostprocess;
  78393. private _blurPostProcesses;
  78394. private _mapSize;
  78395. private _currentFaceIndex;
  78396. private _currentFaceIndexCache;
  78397. private _textureType;
  78398. private _defaultTextureMatrix;
  78399. private _storedUniqueId;
  78400. /** @hidden */
  78401. static _SceneComponentInitialization: (scene: Scene) => void;
  78402. /**
  78403. * Creates a ShadowGenerator object.
  78404. * A ShadowGenerator is the required tool to use the shadows.
  78405. * Each light casting shadows needs to use its own ShadowGenerator.
  78406. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  78407. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  78408. * @param light The light object generating the shadows.
  78409. * @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.
  78410. */
  78411. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  78412. private _initializeGenerator;
  78413. private _initializeShadowMap;
  78414. private _initializeBlurRTTAndPostProcesses;
  78415. private _renderForShadowMap;
  78416. private _renderSubMeshForShadowMap;
  78417. private _applyFilterValues;
  78418. /**
  78419. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78420. * @param onCompiled Callback triggered at the and of the effects compilation
  78421. * @param options Sets of optional options forcing the compilation with different modes
  78422. */
  78423. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78424. useInstances: boolean;
  78425. }>): void;
  78426. /**
  78427. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78428. * @param options Sets of optional options forcing the compilation with different modes
  78429. * @returns A promise that resolves when the compilation completes
  78430. */
  78431. forceCompilationAsync(options?: Partial<{
  78432. useInstances: boolean;
  78433. }>): Promise<void>;
  78434. /**
  78435. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78436. * @param subMesh The submesh we want to render in the shadow map
  78437. * @param useInstances Defines wether will draw in the map using instances
  78438. * @returns true if ready otherwise, false
  78439. */
  78440. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78441. /**
  78442. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78443. * @param defines Defines of the material we want to update
  78444. * @param lightIndex Index of the light in the enabled light list of the material
  78445. */
  78446. prepareDefines(defines: any, lightIndex: number): void;
  78447. /**
  78448. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78449. * defined in the generator but impacting the effect).
  78450. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78451. * @param effect The effect we are binfing the information for
  78452. */
  78453. bindShadowLight(lightIndex: string, effect: Effect): void;
  78454. /**
  78455. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78456. * (eq to shadow prjection matrix * light transform matrix)
  78457. * @returns The transform matrix used to create the shadow map
  78458. */
  78459. getTransformMatrix(): Matrix;
  78460. /**
  78461. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78462. * Cube and 2D textures for instance.
  78463. */
  78464. recreateShadowMap(): void;
  78465. private _disposeBlurPostProcesses;
  78466. private _disposeRTTandPostProcesses;
  78467. /**
  78468. * Disposes the ShadowGenerator.
  78469. * Returns nothing.
  78470. */
  78471. dispose(): void;
  78472. /**
  78473. * Serializes the shadow generator setup to a json object.
  78474. * @returns The serialized JSON object
  78475. */
  78476. serialize(): any;
  78477. /**
  78478. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  78479. * @param parsedShadowGenerator The JSON object to parse
  78480. * @param scene The scene to create the shadow map for
  78481. * @returns The parsed shadow generator
  78482. */
  78483. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  78484. }
  78485. }
  78486. declare module BABYLON {
  78487. /**
  78488. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  78489. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  78490. * 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.
  78491. */
  78492. export abstract class Light extends Node {
  78493. /**
  78494. * Falloff Default: light is falling off following the material specification:
  78495. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  78496. */
  78497. static readonly FALLOFF_DEFAULT: number;
  78498. /**
  78499. * Falloff Physical: light is falling off following the inverse squared distance law.
  78500. */
  78501. static readonly FALLOFF_PHYSICAL: number;
  78502. /**
  78503. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  78504. * to enhance interoperability with other engines.
  78505. */
  78506. static readonly FALLOFF_GLTF: number;
  78507. /**
  78508. * Falloff Standard: light is falling off like in the standard material
  78509. * to enhance interoperability with other materials.
  78510. */
  78511. static readonly FALLOFF_STANDARD: number;
  78512. /**
  78513. * If every light affecting the material is in this lightmapMode,
  78514. * material.lightmapTexture adds or multiplies
  78515. * (depends on material.useLightmapAsShadowmap)
  78516. * after every other light calculations.
  78517. */
  78518. static readonly LIGHTMAP_DEFAULT: number;
  78519. /**
  78520. * material.lightmapTexture as only diffuse lighting from this light
  78521. * adds only specular lighting from this light
  78522. * adds dynamic shadows
  78523. */
  78524. static readonly LIGHTMAP_SPECULAR: number;
  78525. /**
  78526. * material.lightmapTexture as only lighting
  78527. * no light calculation from this light
  78528. * only adds dynamic shadows from this light
  78529. */
  78530. static readonly LIGHTMAP_SHADOWSONLY: number;
  78531. /**
  78532. * Each light type uses the default quantity according to its type:
  78533. * point/spot lights use luminous intensity
  78534. * directional lights use illuminance
  78535. */
  78536. static readonly INTENSITYMODE_AUTOMATIC: number;
  78537. /**
  78538. * lumen (lm)
  78539. */
  78540. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78541. /**
  78542. * candela (lm/sr)
  78543. */
  78544. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78545. /**
  78546. * lux (lm/m^2)
  78547. */
  78548. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78549. /**
  78550. * nit (cd/m^2)
  78551. */
  78552. static readonly INTENSITYMODE_LUMINANCE: number;
  78553. /**
  78554. * Light type const id of the point light.
  78555. */
  78556. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78557. /**
  78558. * Light type const id of the directional light.
  78559. */
  78560. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78561. /**
  78562. * Light type const id of the spot light.
  78563. */
  78564. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78565. /**
  78566. * Light type const id of the hemispheric light.
  78567. */
  78568. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78569. /**
  78570. * Diffuse gives the basic color to an object.
  78571. */
  78572. diffuse: Color3;
  78573. /**
  78574. * Specular produces a highlight color on an object.
  78575. * Note: This is note affecting PBR materials.
  78576. */
  78577. specular: Color3;
  78578. /**
  78579. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78580. * falling off base on range or angle.
  78581. * This can be set to any values in Light.FALLOFF_x.
  78582. *
  78583. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78584. * other types of materials.
  78585. */
  78586. falloffType: number;
  78587. /**
  78588. * Strength of the light.
  78589. * Note: By default it is define in the framework own unit.
  78590. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78591. */
  78592. intensity: number;
  78593. private _range;
  78594. protected _inverseSquaredRange: number;
  78595. /**
  78596. * Defines how far from the source the light is impacting in scene units.
  78597. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78598. */
  78599. /**
  78600. * Defines how far from the source the light is impacting in scene units.
  78601. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78602. */
  78603. range: number;
  78604. /**
  78605. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78606. * of light.
  78607. */
  78608. private _photometricScale;
  78609. private _intensityMode;
  78610. /**
  78611. * Gets the photometric scale used to interpret the intensity.
  78612. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78613. */
  78614. /**
  78615. * Sets the photometric scale used to interpret the intensity.
  78616. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78617. */
  78618. intensityMode: number;
  78619. private _radius;
  78620. /**
  78621. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78622. */
  78623. /**
  78624. * sets the light radius used by PBR Materials to simulate soft area lights.
  78625. */
  78626. radius: number;
  78627. private _renderPriority;
  78628. /**
  78629. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78630. * exceeding the number allowed of the materials.
  78631. */
  78632. renderPriority: number;
  78633. private _shadowEnabled;
  78634. /**
  78635. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78636. * the current shadow generator.
  78637. */
  78638. /**
  78639. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78640. * the current shadow generator.
  78641. */
  78642. shadowEnabled: boolean;
  78643. private _includedOnlyMeshes;
  78644. /**
  78645. * Gets the only meshes impacted by this light.
  78646. */
  78647. /**
  78648. * Sets the only meshes impacted by this light.
  78649. */
  78650. includedOnlyMeshes: AbstractMesh[];
  78651. private _excludedMeshes;
  78652. /**
  78653. * Gets the meshes not impacted by this light.
  78654. */
  78655. /**
  78656. * Sets the meshes not impacted by this light.
  78657. */
  78658. excludedMeshes: AbstractMesh[];
  78659. private _excludeWithLayerMask;
  78660. /**
  78661. * Gets the layer id use to find what meshes are not impacted by the light.
  78662. * Inactive if 0
  78663. */
  78664. /**
  78665. * Sets the layer id use to find what meshes are not impacted by the light.
  78666. * Inactive if 0
  78667. */
  78668. excludeWithLayerMask: number;
  78669. private _includeOnlyWithLayerMask;
  78670. /**
  78671. * Gets the layer id use to find what meshes are impacted by the light.
  78672. * Inactive if 0
  78673. */
  78674. /**
  78675. * Sets the layer id use to find what meshes are impacted by the light.
  78676. * Inactive if 0
  78677. */
  78678. includeOnlyWithLayerMask: number;
  78679. private _lightmapMode;
  78680. /**
  78681. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78682. */
  78683. /**
  78684. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78685. */
  78686. lightmapMode: number;
  78687. /**
  78688. * Shadow generator associted to the light.
  78689. * @hidden Internal use only.
  78690. */
  78691. _shadowGenerator: Nullable<IShadowGenerator>;
  78692. /**
  78693. * @hidden Internal use only.
  78694. */
  78695. _excludedMeshesIds: string[];
  78696. /**
  78697. * @hidden Internal use only.
  78698. */
  78699. _includedOnlyMeshesIds: string[];
  78700. /**
  78701. * The current light unifom buffer.
  78702. * @hidden Internal use only.
  78703. */
  78704. _uniformBuffer: UniformBuffer;
  78705. /** @hidden */
  78706. _renderId: number;
  78707. /**
  78708. * Creates a Light object in the scene.
  78709. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78710. * @param name The firendly name of the light
  78711. * @param scene The scene the light belongs too
  78712. */
  78713. constructor(name: string, scene: Scene);
  78714. protected abstract _buildUniformLayout(): void;
  78715. /**
  78716. * Sets the passed Effect "effect" with the Light information.
  78717. * @param effect The effect to update
  78718. * @param lightIndex The index of the light in the effect to update
  78719. * @returns The light
  78720. */
  78721. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78722. /**
  78723. * Sets the passed Effect "effect" with the Light information.
  78724. * @param effect The effect to update
  78725. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78726. * @returns The light
  78727. */
  78728. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78729. /**
  78730. * Returns the string "Light".
  78731. * @returns the class name
  78732. */
  78733. getClassName(): string;
  78734. /** @hidden */
  78735. readonly _isLight: boolean;
  78736. /**
  78737. * Converts the light information to a readable string for debug purpose.
  78738. * @param fullDetails Supports for multiple levels of logging within scene loading
  78739. * @returns the human readable light info
  78740. */
  78741. toString(fullDetails?: boolean): string;
  78742. /** @hidden */
  78743. protected _syncParentEnabledState(): void;
  78744. /**
  78745. * Set the enabled state of this node.
  78746. * @param value - the new enabled state
  78747. */
  78748. setEnabled(value: boolean): void;
  78749. /**
  78750. * Returns the Light associated shadow generator if any.
  78751. * @return the associated shadow generator.
  78752. */
  78753. getShadowGenerator(): Nullable<IShadowGenerator>;
  78754. /**
  78755. * Returns a Vector3, the absolute light position in the World.
  78756. * @returns the world space position of the light
  78757. */
  78758. getAbsolutePosition(): Vector3;
  78759. /**
  78760. * Specifies if the light will affect the passed mesh.
  78761. * @param mesh The mesh to test against the light
  78762. * @return true the mesh is affected otherwise, false.
  78763. */
  78764. canAffectMesh(mesh: AbstractMesh): boolean;
  78765. /**
  78766. * Sort function to order lights for rendering.
  78767. * @param a First Light object to compare to second.
  78768. * @param b Second Light object to compare first.
  78769. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78770. */
  78771. static CompareLightsPriority(a: Light, b: Light): number;
  78772. /**
  78773. * Releases resources associated with this node.
  78774. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78775. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78776. */
  78777. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78778. /**
  78779. * Returns the light type ID (integer).
  78780. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78781. */
  78782. getTypeID(): number;
  78783. /**
  78784. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78785. * @returns the scaled intensity in intensity mode unit
  78786. */
  78787. getScaledIntensity(): number;
  78788. /**
  78789. * Returns a new Light object, named "name", from the current one.
  78790. * @param name The name of the cloned light
  78791. * @returns the new created light
  78792. */
  78793. clone(name: string): Nullable<Light>;
  78794. /**
  78795. * Serializes the current light into a Serialization object.
  78796. * @returns the serialized object.
  78797. */
  78798. serialize(): any;
  78799. /**
  78800. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78801. * This new light is named "name" and added to the passed scene.
  78802. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78803. * @param name The friendly name of the light
  78804. * @param scene The scene the new light will belong to
  78805. * @returns the constructor function
  78806. */
  78807. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78808. /**
  78809. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78810. * @param parsedLight The JSON representation of the light
  78811. * @param scene The scene to create the parsed light in
  78812. * @returns the created light after parsing
  78813. */
  78814. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78815. private _hookArrayForExcluded;
  78816. private _hookArrayForIncludedOnly;
  78817. private _resyncMeshes;
  78818. /**
  78819. * Forces the meshes to update their light related information in their rendering used effects
  78820. * @hidden Internal Use Only
  78821. */
  78822. _markMeshesAsLightDirty(): void;
  78823. /**
  78824. * Recomputes the cached photometric scale if needed.
  78825. */
  78826. private _computePhotometricScale;
  78827. /**
  78828. * Returns the Photometric Scale according to the light type and intensity mode.
  78829. */
  78830. private _getPhotometricScale;
  78831. /**
  78832. * Reorder the light in the scene according to their defined priority.
  78833. * @hidden Internal Use Only
  78834. */
  78835. _reorderLightsInScene(): void;
  78836. /**
  78837. * Prepares the list of defines specific to the light type.
  78838. * @param defines the list of defines
  78839. * @param lightIndex defines the index of the light for the effect
  78840. */
  78841. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78842. }
  78843. }
  78844. declare module BABYLON {
  78845. /**
  78846. * Interface used to define Action
  78847. */
  78848. export interface IAction {
  78849. /**
  78850. * Trigger for the action
  78851. */
  78852. trigger: number;
  78853. /** Options of the trigger */
  78854. triggerOptions: any;
  78855. /**
  78856. * Gets the trigger parameters
  78857. * @returns the trigger parameters
  78858. */
  78859. getTriggerParameter(): any;
  78860. /**
  78861. * Internal only - executes current action event
  78862. * @hidden
  78863. */
  78864. _executeCurrent(evt?: ActionEvent): void;
  78865. /**
  78866. * Serialize placeholder for child classes
  78867. * @param parent of child
  78868. * @returns the serialized object
  78869. */
  78870. serialize(parent: any): any;
  78871. /**
  78872. * Internal only
  78873. * @hidden
  78874. */
  78875. _prepare(): void;
  78876. /**
  78877. * Internal only - manager for action
  78878. * @hidden
  78879. */
  78880. _actionManager: AbstractActionManager;
  78881. /**
  78882. * Adds action to chain of actions, may be a DoNothingAction
  78883. * @param action defines the next action to execute
  78884. * @returns The action passed in
  78885. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78886. */
  78887. then(action: IAction): IAction;
  78888. }
  78889. /**
  78890. * The action to be carried out following a trigger
  78891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78892. */
  78893. export class Action implements IAction {
  78894. /** the trigger, with or without parameters, for the action */
  78895. triggerOptions: any;
  78896. /**
  78897. * Trigger for the action
  78898. */
  78899. trigger: number;
  78900. /**
  78901. * Internal only - manager for action
  78902. * @hidden
  78903. */
  78904. _actionManager: ActionManager;
  78905. private _nextActiveAction;
  78906. private _child;
  78907. private _condition?;
  78908. private _triggerParameter;
  78909. /**
  78910. * An event triggered prior to action being executed.
  78911. */
  78912. onBeforeExecuteObservable: Observable<Action>;
  78913. /**
  78914. * Creates a new Action
  78915. * @param triggerOptions the trigger, with or without parameters, for the action
  78916. * @param condition an optional determinant of action
  78917. */
  78918. constructor(
  78919. /** the trigger, with or without parameters, for the action */
  78920. triggerOptions: any, condition?: Condition);
  78921. /**
  78922. * Internal only
  78923. * @hidden
  78924. */
  78925. _prepare(): void;
  78926. /**
  78927. * Gets the trigger parameters
  78928. * @returns the trigger parameters
  78929. */
  78930. getTriggerParameter(): any;
  78931. /**
  78932. * Internal only - executes current action event
  78933. * @hidden
  78934. */
  78935. _executeCurrent(evt?: ActionEvent): void;
  78936. /**
  78937. * Execute placeholder for child classes
  78938. * @param evt optional action event
  78939. */
  78940. execute(evt?: ActionEvent): void;
  78941. /**
  78942. * Skips to next active action
  78943. */
  78944. skipToNextActiveAction(): void;
  78945. /**
  78946. * Adds action to chain of actions, may be a DoNothingAction
  78947. * @param action defines the next action to execute
  78948. * @returns The action passed in
  78949. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78950. */
  78951. then(action: Action): Action;
  78952. /**
  78953. * Internal only
  78954. * @hidden
  78955. */
  78956. _getProperty(propertyPath: string): string;
  78957. /**
  78958. * Internal only
  78959. * @hidden
  78960. */
  78961. _getEffectiveTarget(target: any, propertyPath: string): any;
  78962. /**
  78963. * Serialize placeholder for child classes
  78964. * @param parent of child
  78965. * @returns the serialized object
  78966. */
  78967. serialize(parent: any): any;
  78968. /**
  78969. * Internal only called by serialize
  78970. * @hidden
  78971. */
  78972. protected _serialize(serializedAction: any, parent?: any): any;
  78973. /**
  78974. * Internal only
  78975. * @hidden
  78976. */
  78977. static _SerializeValueAsString: (value: any) => string;
  78978. /**
  78979. * Internal only
  78980. * @hidden
  78981. */
  78982. static _GetTargetProperty: (target: Node | Scene) => {
  78983. name: string;
  78984. targetType: string;
  78985. value: string;
  78986. };
  78987. }
  78988. }
  78989. declare module BABYLON {
  78990. /**
  78991. * A Condition applied to an Action
  78992. */
  78993. export class Condition {
  78994. /**
  78995. * Internal only - manager for action
  78996. * @hidden
  78997. */
  78998. _actionManager: ActionManager;
  78999. /**
  79000. * Internal only
  79001. * @hidden
  79002. */
  79003. _evaluationId: number;
  79004. /**
  79005. * Internal only
  79006. * @hidden
  79007. */
  79008. _currentResult: boolean;
  79009. /**
  79010. * Creates a new Condition
  79011. * @param actionManager the manager of the action the condition is applied to
  79012. */
  79013. constructor(actionManager: ActionManager);
  79014. /**
  79015. * Check if the current condition is valid
  79016. * @returns a boolean
  79017. */
  79018. isValid(): boolean;
  79019. /**
  79020. * Internal only
  79021. * @hidden
  79022. */
  79023. _getProperty(propertyPath: string): string;
  79024. /**
  79025. * Internal only
  79026. * @hidden
  79027. */
  79028. _getEffectiveTarget(target: any, propertyPath: string): any;
  79029. /**
  79030. * Serialize placeholder for child classes
  79031. * @returns the serialized object
  79032. */
  79033. serialize(): any;
  79034. /**
  79035. * Internal only
  79036. * @hidden
  79037. */
  79038. protected _serialize(serializedCondition: any): any;
  79039. }
  79040. /**
  79041. * Defines specific conditional operators as extensions of Condition
  79042. */
  79043. export class ValueCondition extends Condition {
  79044. /** path to specify the property of the target the conditional operator uses */
  79045. propertyPath: string;
  79046. /** the value compared by the conditional operator against the current value of the property */
  79047. value: any;
  79048. /** the conditional operator, default ValueCondition.IsEqual */
  79049. operator: number;
  79050. /**
  79051. * Internal only
  79052. * @hidden
  79053. */
  79054. private static _IsEqual;
  79055. /**
  79056. * Internal only
  79057. * @hidden
  79058. */
  79059. private static _IsDifferent;
  79060. /**
  79061. * Internal only
  79062. * @hidden
  79063. */
  79064. private static _IsGreater;
  79065. /**
  79066. * Internal only
  79067. * @hidden
  79068. */
  79069. private static _IsLesser;
  79070. /**
  79071. * returns the number for IsEqual
  79072. */
  79073. static readonly IsEqual: number;
  79074. /**
  79075. * Returns the number for IsDifferent
  79076. */
  79077. static readonly IsDifferent: number;
  79078. /**
  79079. * Returns the number for IsGreater
  79080. */
  79081. static readonly IsGreater: number;
  79082. /**
  79083. * Returns the number for IsLesser
  79084. */
  79085. static readonly IsLesser: number;
  79086. /**
  79087. * Internal only The action manager for the condition
  79088. * @hidden
  79089. */
  79090. _actionManager: ActionManager;
  79091. /**
  79092. * Internal only
  79093. * @hidden
  79094. */
  79095. private _target;
  79096. /**
  79097. * Internal only
  79098. * @hidden
  79099. */
  79100. private _effectiveTarget;
  79101. /**
  79102. * Internal only
  79103. * @hidden
  79104. */
  79105. private _property;
  79106. /**
  79107. * Creates a new ValueCondition
  79108. * @param actionManager manager for the action the condition applies to
  79109. * @param target for the action
  79110. * @param propertyPath path to specify the property of the target the conditional operator uses
  79111. * @param value the value compared by the conditional operator against the current value of the property
  79112. * @param operator the conditional operator, default ValueCondition.IsEqual
  79113. */
  79114. constructor(actionManager: ActionManager, target: any,
  79115. /** path to specify the property of the target the conditional operator uses */
  79116. propertyPath: string,
  79117. /** the value compared by the conditional operator against the current value of the property */
  79118. value: any,
  79119. /** the conditional operator, default ValueCondition.IsEqual */
  79120. operator?: number);
  79121. /**
  79122. * Compares the given value with the property value for the specified conditional operator
  79123. * @returns the result of the comparison
  79124. */
  79125. isValid(): boolean;
  79126. /**
  79127. * Serialize the ValueCondition into a JSON compatible object
  79128. * @returns serialization object
  79129. */
  79130. serialize(): any;
  79131. /**
  79132. * Gets the name of the conditional operator for the ValueCondition
  79133. * @param operator the conditional operator
  79134. * @returns the name
  79135. */
  79136. static GetOperatorName(operator: number): string;
  79137. }
  79138. /**
  79139. * Defines a predicate condition as an extension of Condition
  79140. */
  79141. export class PredicateCondition extends Condition {
  79142. /** defines the predicate function used to validate the condition */
  79143. predicate: () => boolean;
  79144. /**
  79145. * Internal only - manager for action
  79146. * @hidden
  79147. */
  79148. _actionManager: ActionManager;
  79149. /**
  79150. * Creates a new PredicateCondition
  79151. * @param actionManager manager for the action the condition applies to
  79152. * @param predicate defines the predicate function used to validate the condition
  79153. */
  79154. constructor(actionManager: ActionManager,
  79155. /** defines the predicate function used to validate the condition */
  79156. predicate: () => boolean);
  79157. /**
  79158. * @returns the validity of the predicate condition
  79159. */
  79160. isValid(): boolean;
  79161. }
  79162. /**
  79163. * Defines a state condition as an extension of Condition
  79164. */
  79165. export class StateCondition extends Condition {
  79166. /** Value to compare with target state */
  79167. value: string;
  79168. /**
  79169. * Internal only - manager for action
  79170. * @hidden
  79171. */
  79172. _actionManager: ActionManager;
  79173. /**
  79174. * Internal only
  79175. * @hidden
  79176. */
  79177. private _target;
  79178. /**
  79179. * Creates a new StateCondition
  79180. * @param actionManager manager for the action the condition applies to
  79181. * @param target of the condition
  79182. * @param value to compare with target state
  79183. */
  79184. constructor(actionManager: ActionManager, target: any,
  79185. /** Value to compare with target state */
  79186. value: string);
  79187. /**
  79188. * Gets a boolean indicating if the current condition is met
  79189. * @returns the validity of the state
  79190. */
  79191. isValid(): boolean;
  79192. /**
  79193. * Serialize the StateCondition into a JSON compatible object
  79194. * @returns serialization object
  79195. */
  79196. serialize(): any;
  79197. }
  79198. }
  79199. declare module BABYLON {
  79200. /**
  79201. * This defines an action responsible to toggle a boolean once triggered.
  79202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79203. */
  79204. export class SwitchBooleanAction extends Action {
  79205. /**
  79206. * The path to the boolean property in the target object
  79207. */
  79208. propertyPath: string;
  79209. private _target;
  79210. private _effectiveTarget;
  79211. private _property;
  79212. /**
  79213. * Instantiate the action
  79214. * @param triggerOptions defines the trigger options
  79215. * @param target defines the object containing the boolean
  79216. * @param propertyPath defines the path to the boolean property in the target object
  79217. * @param condition defines the trigger related conditions
  79218. */
  79219. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  79220. /** @hidden */
  79221. _prepare(): void;
  79222. /**
  79223. * Execute the action toggle the boolean value.
  79224. */
  79225. execute(): void;
  79226. /**
  79227. * Serializes the actions and its related information.
  79228. * @param parent defines the object to serialize in
  79229. * @returns the serialized object
  79230. */
  79231. serialize(parent: any): any;
  79232. }
  79233. /**
  79234. * This defines an action responsible to set a the state field of the target
  79235. * to a desired value once triggered.
  79236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79237. */
  79238. export class SetStateAction extends Action {
  79239. /**
  79240. * The value to store in the state field.
  79241. */
  79242. value: string;
  79243. private _target;
  79244. /**
  79245. * Instantiate the action
  79246. * @param triggerOptions defines the trigger options
  79247. * @param target defines the object containing the state property
  79248. * @param value defines the value to store in the state field
  79249. * @param condition defines the trigger related conditions
  79250. */
  79251. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  79252. /**
  79253. * Execute the action and store the value on the target state property.
  79254. */
  79255. execute(): void;
  79256. /**
  79257. * Serializes the actions and its related information.
  79258. * @param parent defines the object to serialize in
  79259. * @returns the serialized object
  79260. */
  79261. serialize(parent: any): any;
  79262. }
  79263. /**
  79264. * This defines an action responsible to set a property of the target
  79265. * to a desired value once triggered.
  79266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79267. */
  79268. export class SetValueAction extends Action {
  79269. /**
  79270. * The path of the property to set in the target.
  79271. */
  79272. propertyPath: string;
  79273. /**
  79274. * The value to set in the property
  79275. */
  79276. value: any;
  79277. private _target;
  79278. private _effectiveTarget;
  79279. private _property;
  79280. /**
  79281. * Instantiate the action
  79282. * @param triggerOptions defines the trigger options
  79283. * @param target defines the object containing the property
  79284. * @param propertyPath defines the path of the property to set in the target
  79285. * @param value defines the value to set in the property
  79286. * @param condition defines the trigger related conditions
  79287. */
  79288. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79289. /** @hidden */
  79290. _prepare(): void;
  79291. /**
  79292. * Execute the action and set the targetted property to the desired value.
  79293. */
  79294. execute(): void;
  79295. /**
  79296. * Serializes the actions and its related information.
  79297. * @param parent defines the object to serialize in
  79298. * @returns the serialized object
  79299. */
  79300. serialize(parent: any): any;
  79301. }
  79302. /**
  79303. * This defines an action responsible to increment the target value
  79304. * to a desired value once triggered.
  79305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79306. */
  79307. export class IncrementValueAction extends Action {
  79308. /**
  79309. * The path of the property to increment in the target.
  79310. */
  79311. propertyPath: string;
  79312. /**
  79313. * The value we should increment the property by.
  79314. */
  79315. value: any;
  79316. private _target;
  79317. private _effectiveTarget;
  79318. private _property;
  79319. /**
  79320. * Instantiate the action
  79321. * @param triggerOptions defines the trigger options
  79322. * @param target defines the object containing the property
  79323. * @param propertyPath defines the path of the property to increment in the target
  79324. * @param value defines the value value we should increment the property by
  79325. * @param condition defines the trigger related conditions
  79326. */
  79327. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79328. /** @hidden */
  79329. _prepare(): void;
  79330. /**
  79331. * Execute the action and increment the target of the value amount.
  79332. */
  79333. execute(): void;
  79334. /**
  79335. * Serializes the actions and its related information.
  79336. * @param parent defines the object to serialize in
  79337. * @returns the serialized object
  79338. */
  79339. serialize(parent: any): any;
  79340. }
  79341. /**
  79342. * This defines an action responsible to start an animation once triggered.
  79343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79344. */
  79345. export class PlayAnimationAction extends Action {
  79346. /**
  79347. * Where the animation should start (animation frame)
  79348. */
  79349. from: number;
  79350. /**
  79351. * Where the animation should stop (animation frame)
  79352. */
  79353. to: number;
  79354. /**
  79355. * Define if the animation should loop or stop after the first play.
  79356. */
  79357. loop?: boolean;
  79358. private _target;
  79359. /**
  79360. * Instantiate the action
  79361. * @param triggerOptions defines the trigger options
  79362. * @param target defines the target animation or animation name
  79363. * @param from defines from where the animation should start (animation frame)
  79364. * @param end defines where the animation should stop (animation frame)
  79365. * @param loop defines if the animation should loop or stop after the first play
  79366. * @param condition defines the trigger related conditions
  79367. */
  79368. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  79369. /** @hidden */
  79370. _prepare(): void;
  79371. /**
  79372. * Execute the action and play the animation.
  79373. */
  79374. execute(): void;
  79375. /**
  79376. * Serializes the actions and its related information.
  79377. * @param parent defines the object to serialize in
  79378. * @returns the serialized object
  79379. */
  79380. serialize(parent: any): any;
  79381. }
  79382. /**
  79383. * This defines an action responsible to stop an animation once triggered.
  79384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79385. */
  79386. export class StopAnimationAction extends Action {
  79387. private _target;
  79388. /**
  79389. * Instantiate the action
  79390. * @param triggerOptions defines the trigger options
  79391. * @param target defines the target animation or animation name
  79392. * @param condition defines the trigger related conditions
  79393. */
  79394. constructor(triggerOptions: any, target: any, condition?: Condition);
  79395. /** @hidden */
  79396. _prepare(): void;
  79397. /**
  79398. * Execute the action and stop the animation.
  79399. */
  79400. execute(): void;
  79401. /**
  79402. * Serializes the actions and its related information.
  79403. * @param parent defines the object to serialize in
  79404. * @returns the serialized object
  79405. */
  79406. serialize(parent: any): any;
  79407. }
  79408. /**
  79409. * This defines an action responsible that does nothing once triggered.
  79410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79411. */
  79412. export class DoNothingAction extends Action {
  79413. /**
  79414. * Instantiate the action
  79415. * @param triggerOptions defines the trigger options
  79416. * @param condition defines the trigger related conditions
  79417. */
  79418. constructor(triggerOptions?: any, condition?: Condition);
  79419. /**
  79420. * Execute the action and do nothing.
  79421. */
  79422. execute(): void;
  79423. /**
  79424. * Serializes the actions and its related information.
  79425. * @param parent defines the object to serialize in
  79426. * @returns the serialized object
  79427. */
  79428. serialize(parent: any): any;
  79429. }
  79430. /**
  79431. * This defines an action responsible to trigger several actions once triggered.
  79432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79433. */
  79434. export class CombineAction extends Action {
  79435. /**
  79436. * The list of aggregated animations to run.
  79437. */
  79438. children: Action[];
  79439. /**
  79440. * Instantiate the action
  79441. * @param triggerOptions defines the trigger options
  79442. * @param children defines the list of aggregated animations to run
  79443. * @param condition defines the trigger related conditions
  79444. */
  79445. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  79446. /** @hidden */
  79447. _prepare(): void;
  79448. /**
  79449. * Execute the action and executes all the aggregated actions.
  79450. */
  79451. execute(evt: ActionEvent): void;
  79452. /**
  79453. * Serializes the actions and its related information.
  79454. * @param parent defines the object to serialize in
  79455. * @returns the serialized object
  79456. */
  79457. serialize(parent: any): any;
  79458. }
  79459. /**
  79460. * This defines an action responsible to run code (external event) once triggered.
  79461. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79462. */
  79463. export class ExecuteCodeAction extends Action {
  79464. /**
  79465. * The callback function to run.
  79466. */
  79467. func: (evt: ActionEvent) => void;
  79468. /**
  79469. * Instantiate the action
  79470. * @param triggerOptions defines the trigger options
  79471. * @param func defines the callback function to run
  79472. * @param condition defines the trigger related conditions
  79473. */
  79474. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  79475. /**
  79476. * Execute the action and run the attached code.
  79477. */
  79478. execute(evt: ActionEvent): void;
  79479. }
  79480. /**
  79481. * This defines an action responsible to set the parent property of the target once triggered.
  79482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79483. */
  79484. export class SetParentAction extends Action {
  79485. private _parent;
  79486. private _target;
  79487. /**
  79488. * Instantiate the action
  79489. * @param triggerOptions defines the trigger options
  79490. * @param target defines the target containing the parent property
  79491. * @param parent defines from where the animation should start (animation frame)
  79492. * @param condition defines the trigger related conditions
  79493. */
  79494. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  79495. /** @hidden */
  79496. _prepare(): void;
  79497. /**
  79498. * Execute the action and set the parent property.
  79499. */
  79500. execute(): void;
  79501. /**
  79502. * Serializes the actions and its related information.
  79503. * @param parent defines the object to serialize in
  79504. * @returns the serialized object
  79505. */
  79506. serialize(parent: any): any;
  79507. }
  79508. }
  79509. declare module BABYLON {
  79510. /**
  79511. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  79512. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  79513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79514. */
  79515. export class ActionManager extends AbstractActionManager {
  79516. /**
  79517. * Nothing
  79518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79519. */
  79520. static readonly NothingTrigger: number;
  79521. /**
  79522. * On pick
  79523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79524. */
  79525. static readonly OnPickTrigger: number;
  79526. /**
  79527. * On left pick
  79528. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79529. */
  79530. static readonly OnLeftPickTrigger: number;
  79531. /**
  79532. * On right pick
  79533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79534. */
  79535. static readonly OnRightPickTrigger: number;
  79536. /**
  79537. * On center pick
  79538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79539. */
  79540. static readonly OnCenterPickTrigger: number;
  79541. /**
  79542. * On pick down
  79543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79544. */
  79545. static readonly OnPickDownTrigger: number;
  79546. /**
  79547. * On double pick
  79548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79549. */
  79550. static readonly OnDoublePickTrigger: number;
  79551. /**
  79552. * On pick up
  79553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79554. */
  79555. static readonly OnPickUpTrigger: number;
  79556. /**
  79557. * On pick out.
  79558. * This trigger will only be raised if you also declared a OnPickDown
  79559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79560. */
  79561. static readonly OnPickOutTrigger: number;
  79562. /**
  79563. * On long press
  79564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79565. */
  79566. static readonly OnLongPressTrigger: number;
  79567. /**
  79568. * On pointer over
  79569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79570. */
  79571. static readonly OnPointerOverTrigger: number;
  79572. /**
  79573. * On pointer out
  79574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79575. */
  79576. static readonly OnPointerOutTrigger: number;
  79577. /**
  79578. * On every frame
  79579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79580. */
  79581. static readonly OnEveryFrameTrigger: number;
  79582. /**
  79583. * On intersection enter
  79584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79585. */
  79586. static readonly OnIntersectionEnterTrigger: number;
  79587. /**
  79588. * On intersection exit
  79589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79590. */
  79591. static readonly OnIntersectionExitTrigger: number;
  79592. /**
  79593. * On key down
  79594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79595. */
  79596. static readonly OnKeyDownTrigger: number;
  79597. /**
  79598. * On key up
  79599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79600. */
  79601. static readonly OnKeyUpTrigger: number;
  79602. private _scene;
  79603. /**
  79604. * Creates a new action manager
  79605. * @param scene defines the hosting scene
  79606. */
  79607. constructor(scene: Scene);
  79608. /**
  79609. * Releases all associated resources
  79610. */
  79611. dispose(): void;
  79612. /**
  79613. * Gets hosting scene
  79614. * @returns the hosting scene
  79615. */
  79616. getScene(): Scene;
  79617. /**
  79618. * Does this action manager handles actions of any of the given triggers
  79619. * @param triggers defines the triggers to be tested
  79620. * @return a boolean indicating whether one (or more) of the triggers is handled
  79621. */
  79622. hasSpecificTriggers(triggers: number[]): boolean;
  79623. /**
  79624. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79625. * speed.
  79626. * @param triggerA defines the trigger to be tested
  79627. * @param triggerB defines the trigger to be tested
  79628. * @return a boolean indicating whether one (or more) of the triggers is handled
  79629. */
  79630. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79631. /**
  79632. * Does this action manager handles actions of a given trigger
  79633. * @param trigger defines the trigger to be tested
  79634. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79635. * @return whether the trigger is handled
  79636. */
  79637. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79638. /**
  79639. * Does this action manager has pointer triggers
  79640. */
  79641. readonly hasPointerTriggers: boolean;
  79642. /**
  79643. * Does this action manager has pick triggers
  79644. */
  79645. readonly hasPickTriggers: boolean;
  79646. /**
  79647. * Registers an action to this action manager
  79648. * @param action defines the action to be registered
  79649. * @return the action amended (prepared) after registration
  79650. */
  79651. registerAction(action: IAction): Nullable<IAction>;
  79652. /**
  79653. * Unregisters an action to this action manager
  79654. * @param action defines the action to be unregistered
  79655. * @return a boolean indicating whether the action has been unregistered
  79656. */
  79657. unregisterAction(action: IAction): Boolean;
  79658. /**
  79659. * Process a specific trigger
  79660. * @param trigger defines the trigger to process
  79661. * @param evt defines the event details to be processed
  79662. */
  79663. processTrigger(trigger: number, evt?: IActionEvent): void;
  79664. /** @hidden */
  79665. _getEffectiveTarget(target: any, propertyPath: string): any;
  79666. /** @hidden */
  79667. _getProperty(propertyPath: string): string;
  79668. /**
  79669. * Serialize this manager to a JSON object
  79670. * @param name defines the property name to store this manager
  79671. * @returns a JSON representation of this manager
  79672. */
  79673. serialize(name: string): any;
  79674. /**
  79675. * Creates a new ActionManager from a JSON data
  79676. * @param parsedActions defines the JSON data to read from
  79677. * @param object defines the hosting mesh
  79678. * @param scene defines the hosting scene
  79679. */
  79680. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  79681. /**
  79682. * Get a trigger name by index
  79683. * @param trigger defines the trigger index
  79684. * @returns a trigger name
  79685. */
  79686. static GetTriggerName(trigger: number): string;
  79687. }
  79688. }
  79689. declare module BABYLON {
  79690. /**
  79691. * Class representing a ray with position and direction
  79692. */
  79693. export class Ray {
  79694. /** origin point */
  79695. origin: Vector3;
  79696. /** direction */
  79697. direction: Vector3;
  79698. /** length of the ray */
  79699. length: number;
  79700. private static readonly TmpVector3;
  79701. private _tmpRay;
  79702. /**
  79703. * Creates a new ray
  79704. * @param origin origin point
  79705. * @param direction direction
  79706. * @param length length of the ray
  79707. */
  79708. constructor(
  79709. /** origin point */
  79710. origin: Vector3,
  79711. /** direction */
  79712. direction: Vector3,
  79713. /** length of the ray */
  79714. length?: number);
  79715. /**
  79716. * Checks if the ray intersects a box
  79717. * @param minimum bound of the box
  79718. * @param maximum bound of the box
  79719. * @param intersectionTreshold extra extend to be added to the box in all direction
  79720. * @returns if the box was hit
  79721. */
  79722. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  79723. /**
  79724. * Checks if the ray intersects a box
  79725. * @param box the bounding box to check
  79726. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79727. * @returns if the box was hit
  79728. */
  79729. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79730. /**
  79731. * If the ray hits a sphere
  79732. * @param sphere the bounding sphere to check
  79733. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  79734. * @returns true if it hits the sphere
  79735. */
  79736. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  79737. /**
  79738. * If the ray hits a triange
  79739. * @param vertex0 triangle vertex
  79740. * @param vertex1 triangle vertex
  79741. * @param vertex2 triangle vertex
  79742. * @returns intersection information if hit
  79743. */
  79744. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  79745. /**
  79746. * Checks if ray intersects a plane
  79747. * @param plane the plane to check
  79748. * @returns the distance away it was hit
  79749. */
  79750. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79751. /**
  79752. * Calculate the intercept of a ray on a given axis
  79753. * @param axis to check 'x' | 'y' | 'z'
  79754. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79755. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79756. */
  79757. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79758. /**
  79759. * Checks if ray intersects a mesh
  79760. * @param mesh the mesh to check
  79761. * @param fastCheck if only the bounding box should checked
  79762. * @returns picking info of the intersecton
  79763. */
  79764. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79765. /**
  79766. * Checks if ray intersects a mesh
  79767. * @param meshes the meshes to check
  79768. * @param fastCheck if only the bounding box should checked
  79769. * @param results array to store result in
  79770. * @returns Array of picking infos
  79771. */
  79772. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79773. private _comparePickingInfo;
  79774. private static smallnum;
  79775. private static rayl;
  79776. /**
  79777. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79778. * @param sega the first point of the segment to test the intersection against
  79779. * @param segb the second point of the segment to test the intersection against
  79780. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79781. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79782. */
  79783. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79784. /**
  79785. * Update the ray from viewport position
  79786. * @param x position
  79787. * @param y y position
  79788. * @param viewportWidth viewport width
  79789. * @param viewportHeight viewport height
  79790. * @param world world matrix
  79791. * @param view view matrix
  79792. * @param projection projection matrix
  79793. * @returns this ray updated
  79794. */
  79795. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79796. /**
  79797. * Creates a ray with origin and direction of 0,0,0
  79798. * @returns the new ray
  79799. */
  79800. static Zero(): Ray;
  79801. /**
  79802. * Creates a new ray from screen space and viewport
  79803. * @param x position
  79804. * @param y y position
  79805. * @param viewportWidth viewport width
  79806. * @param viewportHeight viewport height
  79807. * @param world world matrix
  79808. * @param view view matrix
  79809. * @param projection projection matrix
  79810. * @returns new ray
  79811. */
  79812. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79813. /**
  79814. * 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
  79815. * transformed to the given world matrix.
  79816. * @param origin The origin point
  79817. * @param end The end point
  79818. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79819. * @returns the new ray
  79820. */
  79821. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79822. /**
  79823. * Transforms a ray by a matrix
  79824. * @param ray ray to transform
  79825. * @param matrix matrix to apply
  79826. * @returns the resulting new ray
  79827. */
  79828. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79829. /**
  79830. * Transforms a ray by a matrix
  79831. * @param ray ray to transform
  79832. * @param matrix matrix to apply
  79833. * @param result ray to store result in
  79834. */
  79835. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79836. /**
  79837. * Unproject a ray from screen space to object space
  79838. * @param sourceX defines the screen space x coordinate to use
  79839. * @param sourceY defines the screen space y coordinate to use
  79840. * @param viewportWidth defines the current width of the viewport
  79841. * @param viewportHeight defines the current height of the viewport
  79842. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79843. * @param view defines the view matrix to use
  79844. * @param projection defines the projection matrix to use
  79845. */
  79846. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79847. }
  79848. /**
  79849. * Type used to define predicate used to select faces when a mesh intersection is detected
  79850. */
  79851. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79852. interface Scene {
  79853. /** @hidden */
  79854. _tempPickingRay: Nullable<Ray>;
  79855. /** @hidden */
  79856. _cachedRayForTransform: Ray;
  79857. /** @hidden */
  79858. _pickWithRayInverseMatrix: Matrix;
  79859. /** @hidden */
  79860. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79861. /** @hidden */
  79862. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79863. }
  79864. }
  79865. declare module BABYLON {
  79866. /**
  79867. * Groups all the scene component constants in one place to ease maintenance.
  79868. * @hidden
  79869. */
  79870. export class SceneComponentConstants {
  79871. static readonly NAME_EFFECTLAYER: string;
  79872. static readonly NAME_LAYER: string;
  79873. static readonly NAME_LENSFLARESYSTEM: string;
  79874. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79875. static readonly NAME_PARTICLESYSTEM: string;
  79876. static readonly NAME_GAMEPAD: string;
  79877. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79878. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79879. static readonly NAME_DEPTHRENDERER: string;
  79880. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79881. static readonly NAME_SPRITE: string;
  79882. static readonly NAME_OUTLINERENDERER: string;
  79883. static readonly NAME_PROCEDURALTEXTURE: string;
  79884. static readonly NAME_SHADOWGENERATOR: string;
  79885. static readonly NAME_OCTREE: string;
  79886. static readonly NAME_PHYSICSENGINE: string;
  79887. static readonly NAME_AUDIO: string;
  79888. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79889. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79890. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79891. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79892. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79893. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79894. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79895. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79896. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79897. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79898. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79899. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79900. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79901. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79902. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79903. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79904. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79905. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79906. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79907. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79908. static readonly STEP_AFTERRENDER_AUDIO: number;
  79909. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79910. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79911. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79912. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79913. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79914. static readonly STEP_POINTERMOVE_SPRITE: number;
  79915. static readonly STEP_POINTERDOWN_SPRITE: number;
  79916. static readonly STEP_POINTERUP_SPRITE: number;
  79917. }
  79918. /**
  79919. * This represents a scene component.
  79920. *
  79921. * This is used to decouple the dependency the scene is having on the different workloads like
  79922. * layers, post processes...
  79923. */
  79924. export interface ISceneComponent {
  79925. /**
  79926. * The name of the component. Each component must have a unique name.
  79927. */
  79928. name: string;
  79929. /**
  79930. * The scene the component belongs to.
  79931. */
  79932. scene: Scene;
  79933. /**
  79934. * Register the component to one instance of a scene.
  79935. */
  79936. register(): void;
  79937. /**
  79938. * Rebuilds the elements related to this component in case of
  79939. * context lost for instance.
  79940. */
  79941. rebuild(): void;
  79942. /**
  79943. * Disposes the component and the associated ressources.
  79944. */
  79945. dispose(): void;
  79946. }
  79947. /**
  79948. * This represents a SERIALIZABLE scene component.
  79949. *
  79950. * This extends Scene Component to add Serialization methods on top.
  79951. */
  79952. export interface ISceneSerializableComponent extends ISceneComponent {
  79953. /**
  79954. * Adds all the elements from the container to the scene
  79955. * @param container the container holding the elements
  79956. */
  79957. addFromContainer(container: AbstractScene): void;
  79958. /**
  79959. * Removes all the elements in the container from the scene
  79960. * @param container contains the elements to remove
  79961. * @param dispose if the removed element should be disposed (default: false)
  79962. */
  79963. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79964. /**
  79965. * Serializes the component data to the specified json object
  79966. * @param serializationObject The object to serialize to
  79967. */
  79968. serialize(serializationObject: any): void;
  79969. }
  79970. /**
  79971. * Strong typing of a Mesh related stage step action
  79972. */
  79973. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79974. /**
  79975. * Strong typing of a Evaluate Sub Mesh related stage step action
  79976. */
  79977. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79978. /**
  79979. * Strong typing of a Active Mesh related stage step action
  79980. */
  79981. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79982. /**
  79983. * Strong typing of a Camera related stage step action
  79984. */
  79985. export type CameraStageAction = (camera: Camera) => void;
  79986. /**
  79987. * Strong typing of a Camera Frame buffer related stage step action
  79988. */
  79989. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79990. /**
  79991. * Strong typing of a Render Target related stage step action
  79992. */
  79993. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79994. /**
  79995. * Strong typing of a RenderingGroup related stage step action
  79996. */
  79997. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79998. /**
  79999. * Strong typing of a Mesh Render related stage step action
  80000. */
  80001. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  80002. /**
  80003. * Strong typing of a simple stage step action
  80004. */
  80005. export type SimpleStageAction = () => void;
  80006. /**
  80007. * Strong typing of a render target action.
  80008. */
  80009. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  80010. /**
  80011. * Strong typing of a pointer move action.
  80012. */
  80013. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  80014. /**
  80015. * Strong typing of a pointer up/down action.
  80016. */
  80017. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  80018. /**
  80019. * Representation of a stage in the scene (Basically a list of ordered steps)
  80020. * @hidden
  80021. */
  80022. export class Stage<T extends Function> extends Array<{
  80023. index: number;
  80024. component: ISceneComponent;
  80025. action: T;
  80026. }> {
  80027. /**
  80028. * Hide ctor from the rest of the world.
  80029. * @param items The items to add.
  80030. */
  80031. private constructor();
  80032. /**
  80033. * Creates a new Stage.
  80034. * @returns A new instance of a Stage
  80035. */
  80036. static Create<T extends Function>(): Stage<T>;
  80037. /**
  80038. * Registers a step in an ordered way in the targeted stage.
  80039. * @param index Defines the position to register the step in
  80040. * @param component Defines the component attached to the step
  80041. * @param action Defines the action to launch during the step
  80042. */
  80043. registerStep(index: number, component: ISceneComponent, action: T): void;
  80044. /**
  80045. * Clears all the steps from the stage.
  80046. */
  80047. clear(): void;
  80048. }
  80049. }
  80050. declare module BABYLON {
  80051. interface Scene {
  80052. /** @hidden */
  80053. _pointerOverSprite: Nullable<Sprite>;
  80054. /** @hidden */
  80055. _pickedDownSprite: Nullable<Sprite>;
  80056. /** @hidden */
  80057. _tempSpritePickingRay: Nullable<Ray>;
  80058. /**
  80059. * All of the sprite managers added to this scene
  80060. * @see http://doc.babylonjs.com/babylon101/sprites
  80061. */
  80062. spriteManagers: Array<ISpriteManager>;
  80063. /**
  80064. * An event triggered when sprites rendering is about to start
  80065. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80066. */
  80067. onBeforeSpritesRenderingObservable: Observable<Scene>;
  80068. /**
  80069. * An event triggered when sprites rendering is done
  80070. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80071. */
  80072. onAfterSpritesRenderingObservable: Observable<Scene>;
  80073. /** @hidden */
  80074. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80075. /** Launch a ray to try to pick a sprite in the scene
  80076. * @param x position on screen
  80077. * @param y position on screen
  80078. * @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
  80079. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80080. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80081. * @returns a PickingInfo
  80082. */
  80083. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80084. /** Use the given ray to pick a sprite in the scene
  80085. * @param ray The ray (in world space) to use to pick meshes
  80086. * @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
  80087. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80088. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80089. * @returns a PickingInfo
  80090. */
  80091. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80092. /** @hidden */
  80093. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80094. /** Launch a ray to try to pick sprites in the scene
  80095. * @param x position on screen
  80096. * @param y position on screen
  80097. * @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
  80098. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80099. * @returns a PickingInfo array
  80100. */
  80101. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80102. /** Use the given ray to pick sprites in the scene
  80103. * @param ray The ray (in world space) to use to pick meshes
  80104. * @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
  80105. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80106. * @returns a PickingInfo array
  80107. */
  80108. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80109. /**
  80110. * Force the sprite under the pointer
  80111. * @param sprite defines the sprite to use
  80112. */
  80113. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  80114. /**
  80115. * Gets the sprite under the pointer
  80116. * @returns a Sprite or null if no sprite is under the pointer
  80117. */
  80118. getPointerOverSprite(): Nullable<Sprite>;
  80119. }
  80120. /**
  80121. * Defines the sprite scene component responsible to manage sprites
  80122. * in a given scene.
  80123. */
  80124. export class SpriteSceneComponent implements ISceneComponent {
  80125. /**
  80126. * The component name helpfull to identify the component in the list of scene components.
  80127. */
  80128. readonly name: string;
  80129. /**
  80130. * The scene the component belongs to.
  80131. */
  80132. scene: Scene;
  80133. /** @hidden */
  80134. private _spritePredicate;
  80135. /**
  80136. * Creates a new instance of the component for the given scene
  80137. * @param scene Defines the scene to register the component in
  80138. */
  80139. constructor(scene: Scene);
  80140. /**
  80141. * Registers the component in a given scene
  80142. */
  80143. register(): void;
  80144. /**
  80145. * Rebuilds the elements related to this component in case of
  80146. * context lost for instance.
  80147. */
  80148. rebuild(): void;
  80149. /**
  80150. * Disposes the component and the associated ressources.
  80151. */
  80152. dispose(): void;
  80153. private _pickSpriteButKeepRay;
  80154. private _pointerMove;
  80155. private _pointerDown;
  80156. private _pointerUp;
  80157. }
  80158. }
  80159. declare module BABYLON {
  80160. /** @hidden */
  80161. export var fogFragmentDeclaration: {
  80162. name: string;
  80163. shader: string;
  80164. };
  80165. }
  80166. declare module BABYLON {
  80167. /** @hidden */
  80168. export var fogFragment: {
  80169. name: string;
  80170. shader: string;
  80171. };
  80172. }
  80173. declare module BABYLON {
  80174. /** @hidden */
  80175. export var spritesPixelShader: {
  80176. name: string;
  80177. shader: string;
  80178. };
  80179. }
  80180. declare module BABYLON {
  80181. /** @hidden */
  80182. export var fogVertexDeclaration: {
  80183. name: string;
  80184. shader: string;
  80185. };
  80186. }
  80187. declare module BABYLON {
  80188. /** @hidden */
  80189. export var spritesVertexShader: {
  80190. name: string;
  80191. shader: string;
  80192. };
  80193. }
  80194. declare module BABYLON {
  80195. /**
  80196. * Defines the minimum interface to fullfil in order to be a sprite manager.
  80197. */
  80198. export interface ISpriteManager extends IDisposable {
  80199. /**
  80200. * Restricts the camera to viewing objects with the same layerMask.
  80201. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  80202. */
  80203. layerMask: number;
  80204. /**
  80205. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80206. */
  80207. isPickable: boolean;
  80208. /**
  80209. * Specifies the rendering group id for this mesh (0 by default)
  80210. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80211. */
  80212. renderingGroupId: number;
  80213. /**
  80214. * Defines the list of sprites managed by the manager.
  80215. */
  80216. sprites: Array<Sprite>;
  80217. /**
  80218. * Tests the intersection of a sprite with a specific ray.
  80219. * @param ray The ray we are sending to test the collision
  80220. * @param camera The camera space we are sending rays in
  80221. * @param predicate A predicate allowing excluding sprites from the list of object to test
  80222. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  80223. * @returns picking info or null.
  80224. */
  80225. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80226. /**
  80227. * Intersects the sprites with a ray
  80228. * @param ray defines the ray to intersect with
  80229. * @param camera defines the current active camera
  80230. * @param predicate defines a predicate used to select candidate sprites
  80231. * @returns null if no hit or a PickingInfo array
  80232. */
  80233. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80234. /**
  80235. * Renders the list of sprites on screen.
  80236. */
  80237. render(): void;
  80238. }
  80239. /**
  80240. * Class used to manage multiple sprites on the same spritesheet
  80241. * @see http://doc.babylonjs.com/babylon101/sprites
  80242. */
  80243. export class SpriteManager implements ISpriteManager {
  80244. /** defines the manager's name */
  80245. name: string;
  80246. /** Gets the list of sprites */
  80247. sprites: Sprite[];
  80248. /** Gets or sets the rendering group id (0 by default) */
  80249. renderingGroupId: number;
  80250. /** Gets or sets camera layer mask */
  80251. layerMask: number;
  80252. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  80253. fogEnabled: boolean;
  80254. /** Gets or sets a boolean indicating if the sprites are pickable */
  80255. isPickable: boolean;
  80256. /** Defines the default width of a cell in the spritesheet */
  80257. cellWidth: number;
  80258. /** Defines the default height of a cell in the spritesheet */
  80259. cellHeight: number;
  80260. /** Associative array from JSON sprite data file */
  80261. private _cellData;
  80262. /** Array of sprite names from JSON sprite data file */
  80263. private _spriteMap;
  80264. /** True when packed cell data from JSON file is ready*/
  80265. private _packedAndReady;
  80266. /**
  80267. * An event triggered when the manager is disposed.
  80268. */
  80269. onDisposeObservable: Observable<SpriteManager>;
  80270. private _onDisposeObserver;
  80271. /**
  80272. * Callback called when the manager is disposed
  80273. */
  80274. onDispose: () => void;
  80275. private _capacity;
  80276. private _fromPacked;
  80277. private _spriteTexture;
  80278. private _epsilon;
  80279. private _scene;
  80280. private _vertexData;
  80281. private _buffer;
  80282. private _vertexBuffers;
  80283. private _indexBuffer;
  80284. private _effectBase;
  80285. private _effectFog;
  80286. /**
  80287. * Gets or sets the spritesheet texture
  80288. */
  80289. texture: Texture;
  80290. /**
  80291. * Creates a new sprite manager
  80292. * @param name defines the manager's name
  80293. * @param imgUrl defines the sprite sheet url
  80294. * @param capacity defines the maximum allowed number of sprites
  80295. * @param cellSize defines the size of a sprite cell
  80296. * @param scene defines the hosting scene
  80297. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  80298. * @param samplingMode defines the smapling mode to use with spritesheet
  80299. * @param fromPacked set to false; do not alter
  80300. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  80301. */
  80302. constructor(
  80303. /** defines the manager's name */
  80304. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  80305. private _makePacked;
  80306. private _appendSpriteVertex;
  80307. /**
  80308. * Intersects the sprites with a ray
  80309. * @param ray defines the ray to intersect with
  80310. * @param camera defines the current active camera
  80311. * @param predicate defines a predicate used to select candidate sprites
  80312. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  80313. * @returns null if no hit or a PickingInfo
  80314. */
  80315. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80316. /**
  80317. * Intersects the sprites with a ray
  80318. * @param ray defines the ray to intersect with
  80319. * @param camera defines the current active camera
  80320. * @param predicate defines a predicate used to select candidate sprites
  80321. * @returns null if no hit or a PickingInfo array
  80322. */
  80323. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80324. /**
  80325. * Render all child sprites
  80326. */
  80327. render(): void;
  80328. /**
  80329. * Release associated resources
  80330. */
  80331. dispose(): void;
  80332. }
  80333. }
  80334. declare module BABYLON {
  80335. /**
  80336. * Class used to represent a sprite
  80337. * @see http://doc.babylonjs.com/babylon101/sprites
  80338. */
  80339. export class Sprite {
  80340. /** defines the name */
  80341. name: string;
  80342. /** Gets or sets the current world position */
  80343. position: Vector3;
  80344. /** Gets or sets the main color */
  80345. color: Color4;
  80346. /** Gets or sets the width */
  80347. width: number;
  80348. /** Gets or sets the height */
  80349. height: number;
  80350. /** Gets or sets rotation angle */
  80351. angle: number;
  80352. /** Gets or sets the cell index in the sprite sheet */
  80353. cellIndex: number;
  80354. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  80355. cellRef: string;
  80356. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  80357. invertU: number;
  80358. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  80359. invertV: number;
  80360. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  80361. disposeWhenFinishedAnimating: boolean;
  80362. /** Gets the list of attached animations */
  80363. animations: Animation[];
  80364. /** Gets or sets a boolean indicating if the sprite can be picked */
  80365. isPickable: boolean;
  80366. /**
  80367. * Gets or sets the associated action manager
  80368. */
  80369. actionManager: Nullable<ActionManager>;
  80370. private _animationStarted;
  80371. private _loopAnimation;
  80372. private _fromIndex;
  80373. private _toIndex;
  80374. private _delay;
  80375. private _direction;
  80376. private _manager;
  80377. private _time;
  80378. private _onAnimationEnd;
  80379. /**
  80380. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  80381. */
  80382. isVisible: boolean;
  80383. /**
  80384. * Gets or sets the sprite size
  80385. */
  80386. size: number;
  80387. /**
  80388. * Creates a new Sprite
  80389. * @param name defines the name
  80390. * @param manager defines the manager
  80391. */
  80392. constructor(
  80393. /** defines the name */
  80394. name: string, manager: ISpriteManager);
  80395. /**
  80396. * Starts an animation
  80397. * @param from defines the initial key
  80398. * @param to defines the end key
  80399. * @param loop defines if the animation must loop
  80400. * @param delay defines the start delay (in ms)
  80401. * @param onAnimationEnd defines a callback to call when animation ends
  80402. */
  80403. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  80404. /** Stops current animation (if any) */
  80405. stopAnimation(): void;
  80406. /** @hidden */
  80407. _animate(deltaTime: number): void;
  80408. /** Release associated resources */
  80409. dispose(): void;
  80410. }
  80411. }
  80412. declare module BABYLON {
  80413. /**
  80414. * Information about the result of picking within a scene
  80415. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  80416. */
  80417. export class PickingInfo {
  80418. /** @hidden */
  80419. _pickingUnavailable: boolean;
  80420. /**
  80421. * If the pick collided with an object
  80422. */
  80423. hit: boolean;
  80424. /**
  80425. * Distance away where the pick collided
  80426. */
  80427. distance: number;
  80428. /**
  80429. * The location of pick collision
  80430. */
  80431. pickedPoint: Nullable<Vector3>;
  80432. /**
  80433. * The mesh corresponding the the pick collision
  80434. */
  80435. pickedMesh: Nullable<AbstractMesh>;
  80436. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  80437. bu: number;
  80438. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  80439. bv: number;
  80440. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  80441. faceId: number;
  80442. /** Id of the the submesh that was picked */
  80443. subMeshId: number;
  80444. /** If a sprite was picked, this will be the sprite the pick collided with */
  80445. pickedSprite: Nullable<Sprite>;
  80446. /**
  80447. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  80448. */
  80449. originMesh: Nullable<AbstractMesh>;
  80450. /**
  80451. * The ray that was used to perform the picking.
  80452. */
  80453. ray: Nullable<Ray>;
  80454. /**
  80455. * Gets the normal correspodning to the face the pick collided with
  80456. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  80457. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  80458. * @returns The normal correspodning to the face the pick collided with
  80459. */
  80460. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  80461. /**
  80462. * Gets the texture coordinates of where the pick occured
  80463. * @returns the vector containing the coordnates of the texture
  80464. */
  80465. getTextureCoordinates(): Nullable<Vector2>;
  80466. }
  80467. }
  80468. declare module BABYLON {
  80469. /**
  80470. * Gather the list of pointer event types as constants.
  80471. */
  80472. export class PointerEventTypes {
  80473. /**
  80474. * 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.
  80475. */
  80476. static readonly POINTERDOWN: number;
  80477. /**
  80478. * The pointerup event is fired when a pointer is no longer active.
  80479. */
  80480. static readonly POINTERUP: number;
  80481. /**
  80482. * The pointermove event is fired when a pointer changes coordinates.
  80483. */
  80484. static readonly POINTERMOVE: number;
  80485. /**
  80486. * The pointerwheel event is fired when a mouse wheel has been rotated.
  80487. */
  80488. static readonly POINTERWHEEL: number;
  80489. /**
  80490. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  80491. */
  80492. static readonly POINTERPICK: number;
  80493. /**
  80494. * The pointertap event is fired when a the object has been touched and released without drag.
  80495. */
  80496. static readonly POINTERTAP: number;
  80497. /**
  80498. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  80499. */
  80500. static readonly POINTERDOUBLETAP: number;
  80501. }
  80502. /**
  80503. * Base class of pointer info types.
  80504. */
  80505. export class PointerInfoBase {
  80506. /**
  80507. * Defines the type of event (PointerEventTypes)
  80508. */
  80509. type: number;
  80510. /**
  80511. * Defines the related dom event
  80512. */
  80513. event: PointerEvent | MouseWheelEvent;
  80514. /**
  80515. * Instantiates the base class of pointers info.
  80516. * @param type Defines the type of event (PointerEventTypes)
  80517. * @param event Defines the related dom event
  80518. */
  80519. constructor(
  80520. /**
  80521. * Defines the type of event (PointerEventTypes)
  80522. */
  80523. type: number,
  80524. /**
  80525. * Defines the related dom event
  80526. */
  80527. event: PointerEvent | MouseWheelEvent);
  80528. }
  80529. /**
  80530. * This class is used to store pointer related info for the onPrePointerObservable event.
  80531. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80532. */
  80533. export class PointerInfoPre extends PointerInfoBase {
  80534. /**
  80535. * Ray from a pointer if availible (eg. 6dof controller)
  80536. */
  80537. ray: Nullable<Ray>;
  80538. /**
  80539. * Defines the local position of the pointer on the canvas.
  80540. */
  80541. localPosition: Vector2;
  80542. /**
  80543. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80544. */
  80545. skipOnPointerObservable: boolean;
  80546. /**
  80547. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80548. * @param type Defines the type of event (PointerEventTypes)
  80549. * @param event Defines the related dom event
  80550. * @param localX Defines the local x coordinates of the pointer when the event occured
  80551. * @param localY Defines the local y coordinates of the pointer when the event occured
  80552. */
  80553. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80554. }
  80555. /**
  80556. * This type contains all the data related to a pointer event in Babylon.js.
  80557. * 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.
  80558. */
  80559. export class PointerInfo extends PointerInfoBase {
  80560. /**
  80561. * Defines the picking info associated to the info (if any)\
  80562. */
  80563. pickInfo: Nullable<PickingInfo>;
  80564. /**
  80565. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80566. * @param type Defines the type of event (PointerEventTypes)
  80567. * @param event Defines the related dom event
  80568. * @param pickInfo Defines the picking info associated to the info (if any)\
  80569. */
  80570. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80571. /**
  80572. * Defines the picking info associated to the info (if any)\
  80573. */
  80574. pickInfo: Nullable<PickingInfo>);
  80575. }
  80576. /**
  80577. * Data relating to a touch event on the screen.
  80578. */
  80579. export interface PointerTouch {
  80580. /**
  80581. * X coordinate of touch.
  80582. */
  80583. x: number;
  80584. /**
  80585. * Y coordinate of touch.
  80586. */
  80587. y: number;
  80588. /**
  80589. * Id of touch. Unique for each finger.
  80590. */
  80591. pointerId: number;
  80592. /**
  80593. * Event type passed from DOM.
  80594. */
  80595. type: any;
  80596. }
  80597. }
  80598. declare module BABYLON {
  80599. /**
  80600. * Manage the mouse inputs to control the movement of a free camera.
  80601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80602. */
  80603. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80604. /**
  80605. * Define if touch is enabled in the mouse input
  80606. */
  80607. touchEnabled: boolean;
  80608. /**
  80609. * Defines the camera the input is attached to.
  80610. */
  80611. camera: FreeCamera;
  80612. /**
  80613. * Defines the buttons associated with the input to handle camera move.
  80614. */
  80615. buttons: number[];
  80616. /**
  80617. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80618. */
  80619. angularSensibility: number;
  80620. private _pointerInput;
  80621. private _onMouseMove;
  80622. private _observer;
  80623. private previousPosition;
  80624. /**
  80625. * Observable for when a pointer move event occurs containing the move offset
  80626. */
  80627. onPointerMovedObservable: Observable<{
  80628. offsetX: number;
  80629. offsetY: number;
  80630. }>;
  80631. /**
  80632. * @hidden
  80633. * If the camera should be rotated automatically based on pointer movement
  80634. */
  80635. _allowCameraRotation: boolean;
  80636. /**
  80637. * Manage the mouse inputs to control the movement of a free camera.
  80638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80639. * @param touchEnabled Defines if touch is enabled or not
  80640. */
  80641. constructor(
  80642. /**
  80643. * Define if touch is enabled in the mouse input
  80644. */
  80645. touchEnabled?: boolean);
  80646. /**
  80647. * Attach the input controls to a specific dom element to get the input from.
  80648. * @param element Defines the element the controls should be listened from
  80649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80650. */
  80651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80652. /**
  80653. * Called on JS contextmenu event.
  80654. * Override this method to provide functionality.
  80655. */
  80656. protected onContextMenu(evt: PointerEvent): void;
  80657. /**
  80658. * Detach the current controls from the specified dom element.
  80659. * @param element Defines the element to stop listening the inputs from
  80660. */
  80661. detachControl(element: Nullable<HTMLElement>): void;
  80662. /**
  80663. * Gets the class name of the current intput.
  80664. * @returns the class name
  80665. */
  80666. getClassName(): string;
  80667. /**
  80668. * Get the friendly name associated with the input class.
  80669. * @returns the input friendly name
  80670. */
  80671. getSimpleName(): string;
  80672. }
  80673. }
  80674. declare module BABYLON {
  80675. /**
  80676. * Manage the touch inputs to control the movement of a free camera.
  80677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80678. */
  80679. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80680. /**
  80681. * Defines the camera the input is attached to.
  80682. */
  80683. camera: FreeCamera;
  80684. /**
  80685. * Defines the touch sensibility for rotation.
  80686. * The higher the faster.
  80687. */
  80688. touchAngularSensibility: number;
  80689. /**
  80690. * Defines the touch sensibility for move.
  80691. * The higher the faster.
  80692. */
  80693. touchMoveSensibility: number;
  80694. private _offsetX;
  80695. private _offsetY;
  80696. private _pointerPressed;
  80697. private _pointerInput;
  80698. private _observer;
  80699. private _onLostFocus;
  80700. /**
  80701. * Attach the input controls to a specific dom element to get the input from.
  80702. * @param element Defines the element the controls should be listened from
  80703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80704. */
  80705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80706. /**
  80707. * Detach the current controls from the specified dom element.
  80708. * @param element Defines the element to stop listening the inputs from
  80709. */
  80710. detachControl(element: Nullable<HTMLElement>): void;
  80711. /**
  80712. * Update the current camera state depending on the inputs that have been used this frame.
  80713. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80714. */
  80715. checkInputs(): void;
  80716. /**
  80717. * Gets the class name of the current intput.
  80718. * @returns the class name
  80719. */
  80720. getClassName(): string;
  80721. /**
  80722. * Get the friendly name associated with the input class.
  80723. * @returns the input friendly name
  80724. */
  80725. getSimpleName(): string;
  80726. }
  80727. }
  80728. declare module BABYLON {
  80729. /**
  80730. * Default Inputs manager for the FreeCamera.
  80731. * It groups all the default supported inputs for ease of use.
  80732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80733. */
  80734. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  80735. /**
  80736. * @hidden
  80737. */
  80738. _mouseInput: Nullable<FreeCameraMouseInput>;
  80739. /**
  80740. * Instantiates a new FreeCameraInputsManager.
  80741. * @param camera Defines the camera the inputs belong to
  80742. */
  80743. constructor(camera: FreeCamera);
  80744. /**
  80745. * Add keyboard input support to the input manager.
  80746. * @returns the current input manager
  80747. */
  80748. addKeyboard(): FreeCameraInputsManager;
  80749. /**
  80750. * Add mouse input support to the input manager.
  80751. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80752. * @returns the current input manager
  80753. */
  80754. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80755. /**
  80756. * Removes the mouse input support from the manager
  80757. * @returns the current input manager
  80758. */
  80759. removeMouse(): FreeCameraInputsManager;
  80760. /**
  80761. * Add touch input support to the input manager.
  80762. * @returns the current input manager
  80763. */
  80764. addTouch(): FreeCameraInputsManager;
  80765. /**
  80766. * Remove all attached input methods from a camera
  80767. */
  80768. clear(): void;
  80769. }
  80770. }
  80771. declare module BABYLON {
  80772. /**
  80773. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80774. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80775. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80776. */
  80777. export class FreeCamera extends TargetCamera {
  80778. /**
  80779. * Define the collision ellipsoid of the camera.
  80780. * This is helpful to simulate a camera body like the player body around the camera
  80781. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80782. */
  80783. ellipsoid: Vector3;
  80784. /**
  80785. * Define an offset for the position of the ellipsoid around the camera.
  80786. * This can be helpful to determine the center of the body near the gravity center of the body
  80787. * instead of its head.
  80788. */
  80789. ellipsoidOffset: Vector3;
  80790. /**
  80791. * Enable or disable collisions of the camera with the rest of the scene objects.
  80792. */
  80793. checkCollisions: boolean;
  80794. /**
  80795. * Enable or disable gravity on the camera.
  80796. */
  80797. applyGravity: boolean;
  80798. /**
  80799. * Define the input manager associated to the camera.
  80800. */
  80801. inputs: FreeCameraInputsManager;
  80802. /**
  80803. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80804. * Higher values reduce sensitivity.
  80805. */
  80806. /**
  80807. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80808. * Higher values reduce sensitivity.
  80809. */
  80810. angularSensibility: number;
  80811. /**
  80812. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80813. */
  80814. keysUp: number[];
  80815. /**
  80816. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80817. */
  80818. keysDown: number[];
  80819. /**
  80820. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80821. */
  80822. keysLeft: number[];
  80823. /**
  80824. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80825. */
  80826. keysRight: number[];
  80827. /**
  80828. * Event raised when the camera collide with a mesh in the scene.
  80829. */
  80830. onCollide: (collidedMesh: AbstractMesh) => void;
  80831. private _collider;
  80832. private _needMoveForGravity;
  80833. private _oldPosition;
  80834. private _diffPosition;
  80835. private _newPosition;
  80836. /** @hidden */
  80837. _localDirection: Vector3;
  80838. /** @hidden */
  80839. _transformedDirection: Vector3;
  80840. /**
  80841. * Instantiates a Free Camera.
  80842. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80843. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80844. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80845. * @param name Define the name of the camera in the scene
  80846. * @param position Define the start position of the camera in the scene
  80847. * @param scene Define the scene the camera belongs to
  80848. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80849. */
  80850. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80851. /**
  80852. * Attached controls to the current camera.
  80853. * @param element Defines the element the controls should be listened from
  80854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80855. */
  80856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80857. /**
  80858. * Detach the current controls from the camera.
  80859. * The camera will stop reacting to inputs.
  80860. * @param element Defines the element to stop listening the inputs from
  80861. */
  80862. detachControl(element: HTMLElement): void;
  80863. private _collisionMask;
  80864. /**
  80865. * Define a collision mask to limit the list of object the camera can collide with
  80866. */
  80867. collisionMask: number;
  80868. /** @hidden */
  80869. _collideWithWorld(displacement: Vector3): void;
  80870. private _onCollisionPositionChange;
  80871. /** @hidden */
  80872. _checkInputs(): void;
  80873. /** @hidden */
  80874. _decideIfNeedsToMove(): boolean;
  80875. /** @hidden */
  80876. _updatePosition(): void;
  80877. /**
  80878. * Destroy the camera and release the current resources hold by it.
  80879. */
  80880. dispose(): void;
  80881. /**
  80882. * Gets the current object class name.
  80883. * @return the class name
  80884. */
  80885. getClassName(): string;
  80886. }
  80887. }
  80888. declare module BABYLON {
  80889. /**
  80890. * Represents a gamepad control stick position
  80891. */
  80892. export class StickValues {
  80893. /**
  80894. * The x component of the control stick
  80895. */
  80896. x: number;
  80897. /**
  80898. * The y component of the control stick
  80899. */
  80900. y: number;
  80901. /**
  80902. * Initializes the gamepad x and y control stick values
  80903. * @param x The x component of the gamepad control stick value
  80904. * @param y The y component of the gamepad control stick value
  80905. */
  80906. constructor(
  80907. /**
  80908. * The x component of the control stick
  80909. */
  80910. x: number,
  80911. /**
  80912. * The y component of the control stick
  80913. */
  80914. y: number);
  80915. }
  80916. /**
  80917. * An interface which manages callbacks for gamepad button changes
  80918. */
  80919. export interface GamepadButtonChanges {
  80920. /**
  80921. * Called when a gamepad has been changed
  80922. */
  80923. changed: boolean;
  80924. /**
  80925. * Called when a gamepad press event has been triggered
  80926. */
  80927. pressChanged: boolean;
  80928. /**
  80929. * Called when a touch event has been triggered
  80930. */
  80931. touchChanged: boolean;
  80932. /**
  80933. * Called when a value has changed
  80934. */
  80935. valueChanged: boolean;
  80936. }
  80937. /**
  80938. * Represents a gamepad
  80939. */
  80940. export class Gamepad {
  80941. /**
  80942. * The id of the gamepad
  80943. */
  80944. id: string;
  80945. /**
  80946. * The index of the gamepad
  80947. */
  80948. index: number;
  80949. /**
  80950. * The browser gamepad
  80951. */
  80952. browserGamepad: any;
  80953. /**
  80954. * Specifies what type of gamepad this represents
  80955. */
  80956. type: number;
  80957. private _leftStick;
  80958. private _rightStick;
  80959. /** @hidden */
  80960. _isConnected: boolean;
  80961. private _leftStickAxisX;
  80962. private _leftStickAxisY;
  80963. private _rightStickAxisX;
  80964. private _rightStickAxisY;
  80965. /**
  80966. * Triggered when the left control stick has been changed
  80967. */
  80968. private _onleftstickchanged;
  80969. /**
  80970. * Triggered when the right control stick has been changed
  80971. */
  80972. private _onrightstickchanged;
  80973. /**
  80974. * Represents a gamepad controller
  80975. */
  80976. static GAMEPAD: number;
  80977. /**
  80978. * Represents a generic controller
  80979. */
  80980. static GENERIC: number;
  80981. /**
  80982. * Represents an XBox controller
  80983. */
  80984. static XBOX: number;
  80985. /**
  80986. * Represents a pose-enabled controller
  80987. */
  80988. static POSE_ENABLED: number;
  80989. /**
  80990. * Represents an Dual Shock controller
  80991. */
  80992. static DUALSHOCK: number;
  80993. /**
  80994. * Specifies whether the left control stick should be Y-inverted
  80995. */
  80996. protected _invertLeftStickY: boolean;
  80997. /**
  80998. * Specifies if the gamepad has been connected
  80999. */
  81000. readonly isConnected: boolean;
  81001. /**
  81002. * Initializes the gamepad
  81003. * @param id The id of the gamepad
  81004. * @param index The index of the gamepad
  81005. * @param browserGamepad The browser gamepad
  81006. * @param leftStickX The x component of the left joystick
  81007. * @param leftStickY The y component of the left joystick
  81008. * @param rightStickX The x component of the right joystick
  81009. * @param rightStickY The y component of the right joystick
  81010. */
  81011. constructor(
  81012. /**
  81013. * The id of the gamepad
  81014. */
  81015. id: string,
  81016. /**
  81017. * The index of the gamepad
  81018. */
  81019. index: number,
  81020. /**
  81021. * The browser gamepad
  81022. */
  81023. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  81024. /**
  81025. * Callback triggered when the left joystick has changed
  81026. * @param callback
  81027. */
  81028. onleftstickchanged(callback: (values: StickValues) => void): void;
  81029. /**
  81030. * Callback triggered when the right joystick has changed
  81031. * @param callback
  81032. */
  81033. onrightstickchanged(callback: (values: StickValues) => void): void;
  81034. /**
  81035. * Gets the left joystick
  81036. */
  81037. /**
  81038. * Sets the left joystick values
  81039. */
  81040. leftStick: StickValues;
  81041. /**
  81042. * Gets the right joystick
  81043. */
  81044. /**
  81045. * Sets the right joystick value
  81046. */
  81047. rightStick: StickValues;
  81048. /**
  81049. * Updates the gamepad joystick positions
  81050. */
  81051. update(): void;
  81052. /**
  81053. * Disposes the gamepad
  81054. */
  81055. dispose(): void;
  81056. }
  81057. /**
  81058. * Represents a generic gamepad
  81059. */
  81060. export class GenericPad extends Gamepad {
  81061. private _buttons;
  81062. private _onbuttondown;
  81063. private _onbuttonup;
  81064. /**
  81065. * Observable triggered when a button has been pressed
  81066. */
  81067. onButtonDownObservable: Observable<number>;
  81068. /**
  81069. * Observable triggered when a button has been released
  81070. */
  81071. onButtonUpObservable: Observable<number>;
  81072. /**
  81073. * Callback triggered when a button has been pressed
  81074. * @param callback Called when a button has been pressed
  81075. */
  81076. onbuttondown(callback: (buttonPressed: number) => void): void;
  81077. /**
  81078. * Callback triggered when a button has been released
  81079. * @param callback Called when a button has been released
  81080. */
  81081. onbuttonup(callback: (buttonReleased: number) => void): void;
  81082. /**
  81083. * Initializes the generic gamepad
  81084. * @param id The id of the generic gamepad
  81085. * @param index The index of the generic gamepad
  81086. * @param browserGamepad The browser gamepad
  81087. */
  81088. constructor(id: string, index: number, browserGamepad: any);
  81089. private _setButtonValue;
  81090. /**
  81091. * Updates the generic gamepad
  81092. */
  81093. update(): void;
  81094. /**
  81095. * Disposes the generic gamepad
  81096. */
  81097. dispose(): void;
  81098. }
  81099. }
  81100. declare module BABYLON {
  81101. interface Engine {
  81102. /**
  81103. * Creates a raw texture
  81104. * @param data defines the data to store in the texture
  81105. * @param width defines the width of the texture
  81106. * @param height defines the height of the texture
  81107. * @param format defines the format of the data
  81108. * @param generateMipMaps defines if the engine should generate the mip levels
  81109. * @param invertY defines if data must be stored with Y axis inverted
  81110. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  81111. * @param compression defines the compression used (null by default)
  81112. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81113. * @returns the raw texture inside an InternalTexture
  81114. */
  81115. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  81116. /**
  81117. * Update a raw texture
  81118. * @param texture defines the texture to update
  81119. * @param data defines the data to store in the texture
  81120. * @param format defines the format of the data
  81121. * @param invertY defines if data must be stored with Y axis inverted
  81122. */
  81123. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81124. /**
  81125. * Update a raw texture
  81126. * @param texture defines the texture to update
  81127. * @param data defines the data to store in the texture
  81128. * @param format defines the format of the data
  81129. * @param invertY defines if data must be stored with Y axis inverted
  81130. * @param compression defines the compression used (null by default)
  81131. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81132. */
  81133. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  81134. /**
  81135. * Creates a new raw cube texture
  81136. * @param data defines the array of data to use to create each face
  81137. * @param size defines the size of the textures
  81138. * @param format defines the format of the data
  81139. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81140. * @param generateMipMaps defines if the engine should generate the mip levels
  81141. * @param invertY defines if data must be stored with Y axis inverted
  81142. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81143. * @param compression defines the compression used (null by default)
  81144. * @returns the cube texture as an InternalTexture
  81145. */
  81146. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  81147. /**
  81148. * Update a raw cube texture
  81149. * @param texture defines the texture to udpdate
  81150. * @param data defines the data to store
  81151. * @param format defines the data format
  81152. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81153. * @param invertY defines if data must be stored with Y axis inverted
  81154. */
  81155. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  81156. /**
  81157. * Update a raw cube texture
  81158. * @param texture defines the texture to udpdate
  81159. * @param data defines the data to store
  81160. * @param format defines the data format
  81161. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81162. * @param invertY defines if data must be stored with Y axis inverted
  81163. * @param compression defines the compression used (null by default)
  81164. */
  81165. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  81166. /**
  81167. * Update a raw cube texture
  81168. * @param texture defines the texture to udpdate
  81169. * @param data defines the data to store
  81170. * @param format defines the data format
  81171. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81172. * @param invertY defines if data must be stored with Y axis inverted
  81173. * @param compression defines the compression used (null by default)
  81174. * @param level defines which level of the texture to update
  81175. */
  81176. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  81177. /**
  81178. * Creates a new raw cube texture from a specified url
  81179. * @param url defines the url where the data is located
  81180. * @param scene defines the current scene
  81181. * @param size defines the size of the textures
  81182. * @param format defines the format of the data
  81183. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81184. * @param noMipmap defines if the engine should avoid generating the mip levels
  81185. * @param callback defines a callback used to extract texture data from loaded data
  81186. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81187. * @param onLoad defines a callback called when texture is loaded
  81188. * @param onError defines a callback called if there is an error
  81189. * @returns the cube texture as an InternalTexture
  81190. */
  81191. 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;
  81192. /**
  81193. * Creates a new raw cube texture from a specified url
  81194. * @param url defines the url where the data is located
  81195. * @param scene defines the current scene
  81196. * @param size defines the size of the textures
  81197. * @param format defines the format of the data
  81198. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81199. * @param noMipmap defines if the engine should avoid generating the mip levels
  81200. * @param callback defines a callback used to extract texture data from loaded data
  81201. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81202. * @param onLoad defines a callback called when texture is loaded
  81203. * @param onError defines a callback called if there is an error
  81204. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81205. * @param invertY defines if data must be stored with Y axis inverted
  81206. * @returns the cube texture as an InternalTexture
  81207. */
  81208. 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;
  81209. /**
  81210. * Creates a new raw 3D texture
  81211. * @param data defines the data used to create the texture
  81212. * @param width defines the width of the texture
  81213. * @param height defines the height of the texture
  81214. * @param depth defines the depth of the texture
  81215. * @param format defines the format of the texture
  81216. * @param generateMipMaps defines if the engine must generate mip levels
  81217. * @param invertY defines if data must be stored with Y axis inverted
  81218. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81219. * @param compression defines the compressed used (can be null)
  81220. * @param textureType defines the compressed used (can be null)
  81221. * @returns a new raw 3D texture (stored in an InternalTexture)
  81222. */
  81223. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81224. /**
  81225. * Update a raw 3D texture
  81226. * @param texture defines the texture to update
  81227. * @param data defines the data to store
  81228. * @param format defines the data format
  81229. * @param invertY defines if data must be stored with Y axis inverted
  81230. */
  81231. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81232. /**
  81233. * Update a raw 3D texture
  81234. * @param texture defines the texture to update
  81235. * @param data defines the data to store
  81236. * @param format defines the data format
  81237. * @param invertY defines if data must be stored with Y axis inverted
  81238. * @param compression defines the used compression (can be null)
  81239. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81240. */
  81241. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81242. /**
  81243. * Creates a new raw 2D array texture
  81244. * @param data defines the data used to create the texture
  81245. * @param width defines the width of the texture
  81246. * @param height defines the height of the texture
  81247. * @param depth defines the number of layers of the texture
  81248. * @param format defines the format of the texture
  81249. * @param generateMipMaps defines if the engine must generate mip levels
  81250. * @param invertY defines if data must be stored with Y axis inverted
  81251. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81252. * @param compression defines the compressed used (can be null)
  81253. * @param textureType defines the compressed used (can be null)
  81254. * @returns a new raw 2D array texture (stored in an InternalTexture)
  81255. */
  81256. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81257. /**
  81258. * Update a raw 2D array texture
  81259. * @param texture defines the texture to update
  81260. * @param data defines the data to store
  81261. * @param format defines the data format
  81262. * @param invertY defines if data must be stored with Y axis inverted
  81263. */
  81264. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81265. /**
  81266. * Update a raw 2D array texture
  81267. * @param texture defines the texture to update
  81268. * @param data defines the data to store
  81269. * @param format defines the data format
  81270. * @param invertY defines if data must be stored with Y axis inverted
  81271. * @param compression defines the used compression (can be null)
  81272. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81273. */
  81274. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81275. }
  81276. }
  81277. declare module BABYLON {
  81278. /**
  81279. * Raw texture can help creating a texture directly from an array of data.
  81280. * This can be super useful if you either get the data from an uncompressed source or
  81281. * if you wish to create your texture pixel by pixel.
  81282. */
  81283. export class RawTexture extends Texture {
  81284. /**
  81285. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81286. */
  81287. format: number;
  81288. private _engine;
  81289. /**
  81290. * Instantiates a new RawTexture.
  81291. * Raw texture can help creating a texture directly from an array of data.
  81292. * This can be super useful if you either get the data from an uncompressed source or
  81293. * if you wish to create your texture pixel by pixel.
  81294. * @param data define the array of data to use to create the texture
  81295. * @param width define the width of the texture
  81296. * @param height define the height of the texture
  81297. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81298. * @param scene define the scene the texture belongs to
  81299. * @param generateMipMaps define whether mip maps should be generated or not
  81300. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81301. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81302. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81303. */
  81304. constructor(data: ArrayBufferView, width: number, height: number,
  81305. /**
  81306. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81307. */
  81308. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  81309. /**
  81310. * Updates the texture underlying data.
  81311. * @param data Define the new data of the texture
  81312. */
  81313. update(data: ArrayBufferView): void;
  81314. /**
  81315. * Creates a luminance texture from some data.
  81316. * @param data Define the texture data
  81317. * @param width Define the width of the texture
  81318. * @param height Define the height of the texture
  81319. * @param scene Define the scene the texture belongs to
  81320. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81321. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81322. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81323. * @returns the luminance texture
  81324. */
  81325. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81326. /**
  81327. * Creates a luminance alpha texture from some data.
  81328. * @param data Define the texture data
  81329. * @param width Define the width of the texture
  81330. * @param height Define the height of the texture
  81331. * @param scene Define the scene the texture belongs to
  81332. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81333. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81334. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81335. * @returns the luminance alpha texture
  81336. */
  81337. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81338. /**
  81339. * Creates an alpha texture from some data.
  81340. * @param data Define the texture data
  81341. * @param width Define the width of the texture
  81342. * @param height Define the height of the texture
  81343. * @param scene Define the scene the texture belongs to
  81344. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81345. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81346. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81347. * @returns the alpha texture
  81348. */
  81349. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81350. /**
  81351. * Creates a RGB texture from some data.
  81352. * @param data Define the texture data
  81353. * @param width Define the width of the texture
  81354. * @param height Define the height of the texture
  81355. * @param scene Define the scene the texture belongs to
  81356. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81357. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81358. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81359. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81360. * @returns the RGB alpha texture
  81361. */
  81362. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81363. /**
  81364. * Creates a RGBA texture from some data.
  81365. * @param data Define the texture data
  81366. * @param width Define the width of the texture
  81367. * @param height Define the height of the texture
  81368. * @param scene Define the scene the texture belongs to
  81369. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81370. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81371. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81372. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81373. * @returns the RGBA texture
  81374. */
  81375. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81376. /**
  81377. * Creates a R texture from some data.
  81378. * @param data Define the texture data
  81379. * @param width Define the width of the texture
  81380. * @param height Define the height of the texture
  81381. * @param scene Define the scene the texture belongs to
  81382. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81383. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81384. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81385. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81386. * @returns the R texture
  81387. */
  81388. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81389. }
  81390. }
  81391. declare module BABYLON {
  81392. /**
  81393. * Interface for the size containing width and height
  81394. */
  81395. export interface ISize {
  81396. /**
  81397. * Width
  81398. */
  81399. width: number;
  81400. /**
  81401. * Heighht
  81402. */
  81403. height: number;
  81404. }
  81405. /**
  81406. * Size containing widht and height
  81407. */
  81408. export class Size implements ISize {
  81409. /**
  81410. * Width
  81411. */
  81412. width: number;
  81413. /**
  81414. * Height
  81415. */
  81416. height: number;
  81417. /**
  81418. * Creates a Size object from the given width and height (floats).
  81419. * @param width width of the new size
  81420. * @param height height of the new size
  81421. */
  81422. constructor(width: number, height: number);
  81423. /**
  81424. * Returns a string with the Size width and height
  81425. * @returns a string with the Size width and height
  81426. */
  81427. toString(): string;
  81428. /**
  81429. * "Size"
  81430. * @returns the string "Size"
  81431. */
  81432. getClassName(): string;
  81433. /**
  81434. * Returns the Size hash code.
  81435. * @returns a hash code for a unique width and height
  81436. */
  81437. getHashCode(): number;
  81438. /**
  81439. * Updates the current size from the given one.
  81440. * @param src the given size
  81441. */
  81442. copyFrom(src: Size): void;
  81443. /**
  81444. * Updates in place the current Size from the given floats.
  81445. * @param width width of the new size
  81446. * @param height height of the new size
  81447. * @returns the updated Size.
  81448. */
  81449. copyFromFloats(width: number, height: number): Size;
  81450. /**
  81451. * Updates in place the current Size from the given floats.
  81452. * @param width width to set
  81453. * @param height height to set
  81454. * @returns the updated Size.
  81455. */
  81456. set(width: number, height: number): Size;
  81457. /**
  81458. * Multiplies the width and height by numbers
  81459. * @param w factor to multiple the width by
  81460. * @param h factor to multiple the height by
  81461. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  81462. */
  81463. multiplyByFloats(w: number, h: number): Size;
  81464. /**
  81465. * Clones the size
  81466. * @returns a new Size copied from the given one.
  81467. */
  81468. clone(): Size;
  81469. /**
  81470. * True if the current Size and the given one width and height are strictly equal.
  81471. * @param other the other size to compare against
  81472. * @returns True if the current Size and the given one width and height are strictly equal.
  81473. */
  81474. equals(other: Size): boolean;
  81475. /**
  81476. * The surface of the Size : width * height (float).
  81477. */
  81478. readonly surface: number;
  81479. /**
  81480. * Create a new size of zero
  81481. * @returns a new Size set to (0.0, 0.0)
  81482. */
  81483. static Zero(): Size;
  81484. /**
  81485. * Sums the width and height of two sizes
  81486. * @param otherSize size to add to this size
  81487. * @returns a new Size set as the addition result of the current Size and the given one.
  81488. */
  81489. add(otherSize: Size): Size;
  81490. /**
  81491. * Subtracts the width and height of two
  81492. * @param otherSize size to subtract to this size
  81493. * @returns a new Size set as the subtraction result of the given one from the current Size.
  81494. */
  81495. subtract(otherSize: Size): Size;
  81496. /**
  81497. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  81498. * @param start starting size to lerp between
  81499. * @param end end size to lerp between
  81500. * @param amount amount to lerp between the start and end values
  81501. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  81502. */
  81503. static Lerp(start: Size, end: Size, amount: number): Size;
  81504. }
  81505. }
  81506. declare module BABYLON {
  81507. /**
  81508. * Defines a runtime animation
  81509. */
  81510. export class RuntimeAnimation {
  81511. private _events;
  81512. /**
  81513. * The current frame of the runtime animation
  81514. */
  81515. private _currentFrame;
  81516. /**
  81517. * The animation used by the runtime animation
  81518. */
  81519. private _animation;
  81520. /**
  81521. * The target of the runtime animation
  81522. */
  81523. private _target;
  81524. /**
  81525. * The initiating animatable
  81526. */
  81527. private _host;
  81528. /**
  81529. * The original value of the runtime animation
  81530. */
  81531. private _originalValue;
  81532. /**
  81533. * The original blend value of the runtime animation
  81534. */
  81535. private _originalBlendValue;
  81536. /**
  81537. * The offsets cache of the runtime animation
  81538. */
  81539. private _offsetsCache;
  81540. /**
  81541. * The high limits cache of the runtime animation
  81542. */
  81543. private _highLimitsCache;
  81544. /**
  81545. * Specifies if the runtime animation has been stopped
  81546. */
  81547. private _stopped;
  81548. /**
  81549. * The blending factor of the runtime animation
  81550. */
  81551. private _blendingFactor;
  81552. /**
  81553. * The BabylonJS scene
  81554. */
  81555. private _scene;
  81556. /**
  81557. * The current value of the runtime animation
  81558. */
  81559. private _currentValue;
  81560. /** @hidden */
  81561. _animationState: _IAnimationState;
  81562. /**
  81563. * The active target of the runtime animation
  81564. */
  81565. private _activeTargets;
  81566. private _currentActiveTarget;
  81567. private _directTarget;
  81568. /**
  81569. * The target path of the runtime animation
  81570. */
  81571. private _targetPath;
  81572. /**
  81573. * The weight of the runtime animation
  81574. */
  81575. private _weight;
  81576. /**
  81577. * The ratio offset of the runtime animation
  81578. */
  81579. private _ratioOffset;
  81580. /**
  81581. * The previous delay of the runtime animation
  81582. */
  81583. private _previousDelay;
  81584. /**
  81585. * The previous ratio of the runtime animation
  81586. */
  81587. private _previousRatio;
  81588. private _enableBlending;
  81589. private _keys;
  81590. private _minFrame;
  81591. private _maxFrame;
  81592. private _minValue;
  81593. private _maxValue;
  81594. private _targetIsArray;
  81595. /**
  81596. * Gets the current frame of the runtime animation
  81597. */
  81598. readonly currentFrame: number;
  81599. /**
  81600. * Gets the weight of the runtime animation
  81601. */
  81602. readonly weight: number;
  81603. /**
  81604. * Gets the current value of the runtime animation
  81605. */
  81606. readonly currentValue: any;
  81607. /**
  81608. * Gets the target path of the runtime animation
  81609. */
  81610. readonly targetPath: string;
  81611. /**
  81612. * Gets the actual target of the runtime animation
  81613. */
  81614. readonly target: any;
  81615. /** @hidden */
  81616. _onLoop: () => void;
  81617. /**
  81618. * Create a new RuntimeAnimation object
  81619. * @param target defines the target of the animation
  81620. * @param animation defines the source animation object
  81621. * @param scene defines the hosting scene
  81622. * @param host defines the initiating Animatable
  81623. */
  81624. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81625. private _preparePath;
  81626. /**
  81627. * Gets the animation from the runtime animation
  81628. */
  81629. readonly animation: Animation;
  81630. /**
  81631. * Resets the runtime animation to the beginning
  81632. * @param restoreOriginal defines whether to restore the target property to the original value
  81633. */
  81634. reset(restoreOriginal?: boolean): void;
  81635. /**
  81636. * Specifies if the runtime animation is stopped
  81637. * @returns Boolean specifying if the runtime animation is stopped
  81638. */
  81639. isStopped(): boolean;
  81640. /**
  81641. * Disposes of the runtime animation
  81642. */
  81643. dispose(): void;
  81644. /**
  81645. * Apply the interpolated value to the target
  81646. * @param currentValue defines the value computed by the animation
  81647. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81648. */
  81649. setValue(currentValue: any, weight: number): void;
  81650. private _getOriginalValues;
  81651. private _setValue;
  81652. /**
  81653. * Gets the loop pmode of the runtime animation
  81654. * @returns Loop Mode
  81655. */
  81656. private _getCorrectLoopMode;
  81657. /**
  81658. * Move the current animation to a given frame
  81659. * @param frame defines the frame to move to
  81660. */
  81661. goToFrame(frame: number): void;
  81662. /**
  81663. * @hidden Internal use only
  81664. */
  81665. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81666. /**
  81667. * Execute the current animation
  81668. * @param delay defines the delay to add to the current frame
  81669. * @param from defines the lower bound of the animation range
  81670. * @param to defines the upper bound of the animation range
  81671. * @param loop defines if the current animation must loop
  81672. * @param speedRatio defines the current speed ratio
  81673. * @param weight defines the weight of the animation (default is -1 so no weight)
  81674. * @param onLoop optional callback called when animation loops
  81675. * @returns a boolean indicating if the animation is running
  81676. */
  81677. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81678. }
  81679. }
  81680. declare module BABYLON {
  81681. /**
  81682. * Class used to store an actual running animation
  81683. */
  81684. export class Animatable {
  81685. /** defines the target object */
  81686. target: any;
  81687. /** defines the starting frame number (default is 0) */
  81688. fromFrame: number;
  81689. /** defines the ending frame number (default is 100) */
  81690. toFrame: number;
  81691. /** defines if the animation must loop (default is false) */
  81692. loopAnimation: boolean;
  81693. /** defines a callback to call when animation ends if it is not looping */
  81694. onAnimationEnd?: (() => void) | null | undefined;
  81695. /** defines a callback to call when animation loops */
  81696. onAnimationLoop?: (() => void) | null | undefined;
  81697. private _localDelayOffset;
  81698. private _pausedDelay;
  81699. private _runtimeAnimations;
  81700. private _paused;
  81701. private _scene;
  81702. private _speedRatio;
  81703. private _weight;
  81704. private _syncRoot;
  81705. /**
  81706. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81707. * This will only apply for non looping animation (default is true)
  81708. */
  81709. disposeOnEnd: boolean;
  81710. /**
  81711. * Gets a boolean indicating if the animation has started
  81712. */
  81713. animationStarted: boolean;
  81714. /**
  81715. * Observer raised when the animation ends
  81716. */
  81717. onAnimationEndObservable: Observable<Animatable>;
  81718. /**
  81719. * Observer raised when the animation loops
  81720. */
  81721. onAnimationLoopObservable: Observable<Animatable>;
  81722. /**
  81723. * Gets the root Animatable used to synchronize and normalize animations
  81724. */
  81725. readonly syncRoot: Nullable<Animatable>;
  81726. /**
  81727. * Gets the current frame of the first RuntimeAnimation
  81728. * Used to synchronize Animatables
  81729. */
  81730. readonly masterFrame: number;
  81731. /**
  81732. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81733. */
  81734. weight: number;
  81735. /**
  81736. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81737. */
  81738. speedRatio: number;
  81739. /**
  81740. * Creates a new Animatable
  81741. * @param scene defines the hosting scene
  81742. * @param target defines the target object
  81743. * @param fromFrame defines the starting frame number (default is 0)
  81744. * @param toFrame defines the ending frame number (default is 100)
  81745. * @param loopAnimation defines if the animation must loop (default is false)
  81746. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81747. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81748. * @param animations defines a group of animation to add to the new Animatable
  81749. * @param onAnimationLoop defines a callback to call when animation loops
  81750. */
  81751. constructor(scene: Scene,
  81752. /** defines the target object */
  81753. target: any,
  81754. /** defines the starting frame number (default is 0) */
  81755. fromFrame?: number,
  81756. /** defines the ending frame number (default is 100) */
  81757. toFrame?: number,
  81758. /** defines if the animation must loop (default is false) */
  81759. loopAnimation?: boolean, speedRatio?: number,
  81760. /** defines a callback to call when animation ends if it is not looping */
  81761. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81762. /** defines a callback to call when animation loops */
  81763. onAnimationLoop?: (() => void) | null | undefined);
  81764. /**
  81765. * Synchronize and normalize current Animatable with a source Animatable
  81766. * This is useful when using animation weights and when animations are not of the same length
  81767. * @param root defines the root Animatable to synchronize with
  81768. * @returns the current Animatable
  81769. */
  81770. syncWith(root: Animatable): Animatable;
  81771. /**
  81772. * Gets the list of runtime animations
  81773. * @returns an array of RuntimeAnimation
  81774. */
  81775. getAnimations(): RuntimeAnimation[];
  81776. /**
  81777. * Adds more animations to the current animatable
  81778. * @param target defines the target of the animations
  81779. * @param animations defines the new animations to add
  81780. */
  81781. appendAnimations(target: any, animations: Animation[]): void;
  81782. /**
  81783. * Gets the source animation for a specific property
  81784. * @param property defines the propertyu to look for
  81785. * @returns null or the source animation for the given property
  81786. */
  81787. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81788. /**
  81789. * Gets the runtime animation for a specific property
  81790. * @param property defines the propertyu to look for
  81791. * @returns null or the runtime animation for the given property
  81792. */
  81793. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81794. /**
  81795. * Resets the animatable to its original state
  81796. */
  81797. reset(): void;
  81798. /**
  81799. * Allows the animatable to blend with current running animations
  81800. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81801. * @param blendingSpeed defines the blending speed to use
  81802. */
  81803. enableBlending(blendingSpeed: number): void;
  81804. /**
  81805. * Disable animation blending
  81806. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81807. */
  81808. disableBlending(): void;
  81809. /**
  81810. * Jump directly to a given frame
  81811. * @param frame defines the frame to jump to
  81812. */
  81813. goToFrame(frame: number): void;
  81814. /**
  81815. * Pause the animation
  81816. */
  81817. pause(): void;
  81818. /**
  81819. * Restart the animation
  81820. */
  81821. restart(): void;
  81822. private _raiseOnAnimationEnd;
  81823. /**
  81824. * Stop and delete the current animation
  81825. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81826. * @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)
  81827. */
  81828. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81829. /**
  81830. * Wait asynchronously for the animation to end
  81831. * @returns a promise which will be fullfilled when the animation ends
  81832. */
  81833. waitAsync(): Promise<Animatable>;
  81834. /** @hidden */
  81835. _animate(delay: number): boolean;
  81836. }
  81837. interface Scene {
  81838. /** @hidden */
  81839. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81840. /** @hidden */
  81841. _processLateAnimationBindingsForMatrices(holder: {
  81842. totalWeight: number;
  81843. animations: RuntimeAnimation[];
  81844. originalValue: Matrix;
  81845. }): any;
  81846. /** @hidden */
  81847. _processLateAnimationBindingsForQuaternions(holder: {
  81848. totalWeight: number;
  81849. animations: RuntimeAnimation[];
  81850. originalValue: Quaternion;
  81851. }, refQuaternion: Quaternion): Quaternion;
  81852. /** @hidden */
  81853. _processLateAnimationBindings(): void;
  81854. /**
  81855. * Will start the animation sequence of a given target
  81856. * @param target defines the target
  81857. * @param from defines from which frame should animation start
  81858. * @param to defines until which frame should animation run.
  81859. * @param weight defines the weight to apply to the animation (1.0 by default)
  81860. * @param loop defines if the animation loops
  81861. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81862. * @param onAnimationEnd defines the function to be executed when the animation ends
  81863. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81864. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81865. * @param onAnimationLoop defines the callback to call when an animation loops
  81866. * @returns the animatable object created for this animation
  81867. */
  81868. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81869. /**
  81870. * Will start the animation sequence of a given target
  81871. * @param target defines the target
  81872. * @param from defines from which frame should animation start
  81873. * @param to defines until which frame should animation run.
  81874. * @param loop defines if the animation loops
  81875. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81876. * @param onAnimationEnd defines the function to be executed when the animation ends
  81877. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81878. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81879. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81880. * @param onAnimationLoop defines the callback to call when an animation loops
  81881. * @returns the animatable object created for this animation
  81882. */
  81883. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81884. /**
  81885. * Will start the animation sequence of a given target and its hierarchy
  81886. * @param target defines the target
  81887. * @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.
  81888. * @param from defines from which frame should animation start
  81889. * @param to defines until which frame should animation run.
  81890. * @param loop defines if the animation loops
  81891. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81892. * @param onAnimationEnd defines the function to be executed when the animation ends
  81893. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81894. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81895. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81896. * @param onAnimationLoop defines the callback to call when an animation loops
  81897. * @returns the list of created animatables
  81898. */
  81899. 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[];
  81900. /**
  81901. * Begin a new animation on a given node
  81902. * @param target defines the target where the animation will take place
  81903. * @param animations defines the list of animations to start
  81904. * @param from defines the initial value
  81905. * @param to defines the final value
  81906. * @param loop defines if you want animation to loop (off by default)
  81907. * @param speedRatio defines the speed ratio to apply to all animations
  81908. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81909. * @param onAnimationLoop defines the callback to call when an animation loops
  81910. * @returns the list of created animatables
  81911. */
  81912. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81913. /**
  81914. * Begin a new animation on a given node and its hierarchy
  81915. * @param target defines the root node where the animation will take place
  81916. * @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.
  81917. * @param animations defines the list of animations to start
  81918. * @param from defines the initial value
  81919. * @param to defines the final value
  81920. * @param loop defines if you want animation to loop (off by default)
  81921. * @param speedRatio defines the speed ratio to apply to all animations
  81922. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81923. * @param onAnimationLoop defines the callback to call when an animation loops
  81924. * @returns the list of animatables created for all nodes
  81925. */
  81926. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81927. /**
  81928. * Gets the animatable associated with a specific target
  81929. * @param target defines the target of the animatable
  81930. * @returns the required animatable if found
  81931. */
  81932. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81933. /**
  81934. * Gets all animatables associated with a given target
  81935. * @param target defines the target to look animatables for
  81936. * @returns an array of Animatables
  81937. */
  81938. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81939. /**
  81940. * Stops and removes all animations that have been applied to the scene
  81941. */
  81942. stopAllAnimations(): void;
  81943. /**
  81944. * Gets the current delta time used by animation engine
  81945. */
  81946. deltaTime: number;
  81947. }
  81948. interface Bone {
  81949. /**
  81950. * Copy an animation range from another bone
  81951. * @param source defines the source bone
  81952. * @param rangeName defines the range name to copy
  81953. * @param frameOffset defines the frame offset
  81954. * @param rescaleAsRequired defines if rescaling must be applied if required
  81955. * @param skelDimensionsRatio defines the scaling ratio
  81956. * @returns true if operation was successful
  81957. */
  81958. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81959. }
  81960. }
  81961. declare module BABYLON {
  81962. /**
  81963. * Class used to override all child animations of a given target
  81964. */
  81965. export class AnimationPropertiesOverride {
  81966. /**
  81967. * Gets or sets a value indicating if animation blending must be used
  81968. */
  81969. enableBlending: boolean;
  81970. /**
  81971. * Gets or sets the blending speed to use when enableBlending is true
  81972. */
  81973. blendingSpeed: number;
  81974. /**
  81975. * Gets or sets the default loop mode to use
  81976. */
  81977. loopMode: number;
  81978. }
  81979. }
  81980. declare module BABYLON {
  81981. /**
  81982. * Class used to handle skinning animations
  81983. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81984. */
  81985. export class Skeleton implements IAnimatable {
  81986. /** defines the skeleton name */
  81987. name: string;
  81988. /** defines the skeleton Id */
  81989. id: string;
  81990. /**
  81991. * Defines the list of child bones
  81992. */
  81993. bones: Bone[];
  81994. /**
  81995. * Defines an estimate of the dimension of the skeleton at rest
  81996. */
  81997. dimensionsAtRest: Vector3;
  81998. /**
  81999. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  82000. */
  82001. needInitialSkinMatrix: boolean;
  82002. /**
  82003. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  82004. */
  82005. overrideMesh: Nullable<AbstractMesh>;
  82006. /**
  82007. * Gets the list of animations attached to this skeleton
  82008. */
  82009. animations: Array<Animation>;
  82010. private _scene;
  82011. private _isDirty;
  82012. private _transformMatrices;
  82013. private _transformMatrixTexture;
  82014. private _meshesWithPoseMatrix;
  82015. private _animatables;
  82016. private _identity;
  82017. private _synchronizedWithMesh;
  82018. private _ranges;
  82019. private _lastAbsoluteTransformsUpdateId;
  82020. private _canUseTextureForBones;
  82021. private _uniqueId;
  82022. /** @hidden */
  82023. _numBonesWithLinkedTransformNode: number;
  82024. /** @hidden */
  82025. _hasWaitingData: Nullable<boolean>;
  82026. /**
  82027. * Specifies if the skeleton should be serialized
  82028. */
  82029. doNotSerialize: boolean;
  82030. private _useTextureToStoreBoneMatrices;
  82031. /**
  82032. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  82033. * Please note that this option is not available if the hardware does not support it
  82034. */
  82035. useTextureToStoreBoneMatrices: boolean;
  82036. private _animationPropertiesOverride;
  82037. /**
  82038. * Gets or sets the animation properties override
  82039. */
  82040. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82041. /**
  82042. * List of inspectable custom properties (used by the Inspector)
  82043. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82044. */
  82045. inspectableCustomProperties: IInspectable[];
  82046. /**
  82047. * An observable triggered before computing the skeleton's matrices
  82048. */
  82049. onBeforeComputeObservable: Observable<Skeleton>;
  82050. /**
  82051. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  82052. */
  82053. readonly isUsingTextureForMatrices: boolean;
  82054. /**
  82055. * Gets the unique ID of this skeleton
  82056. */
  82057. readonly uniqueId: number;
  82058. /**
  82059. * Creates a new skeleton
  82060. * @param name defines the skeleton name
  82061. * @param id defines the skeleton Id
  82062. * @param scene defines the hosting scene
  82063. */
  82064. constructor(
  82065. /** defines the skeleton name */
  82066. name: string,
  82067. /** defines the skeleton Id */
  82068. id: string, scene: Scene);
  82069. /**
  82070. * Gets the current object class name.
  82071. * @return the class name
  82072. */
  82073. getClassName(): string;
  82074. /**
  82075. * Returns an array containing the root bones
  82076. * @returns an array containing the root bones
  82077. */
  82078. getChildren(): Array<Bone>;
  82079. /**
  82080. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  82081. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82082. * @returns a Float32Array containing matrices data
  82083. */
  82084. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  82085. /**
  82086. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  82087. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82088. * @returns a raw texture containing the data
  82089. */
  82090. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  82091. /**
  82092. * Gets the current hosting scene
  82093. * @returns a scene object
  82094. */
  82095. getScene(): Scene;
  82096. /**
  82097. * Gets a string representing the current skeleton data
  82098. * @param fullDetails defines a boolean indicating if we want a verbose version
  82099. * @returns a string representing the current skeleton data
  82100. */
  82101. toString(fullDetails?: boolean): string;
  82102. /**
  82103. * Get bone's index searching by name
  82104. * @param name defines bone's name to search for
  82105. * @return the indice of the bone. Returns -1 if not found
  82106. */
  82107. getBoneIndexByName(name: string): number;
  82108. /**
  82109. * Creater a new animation range
  82110. * @param name defines the name of the range
  82111. * @param from defines the start key
  82112. * @param to defines the end key
  82113. */
  82114. createAnimationRange(name: string, from: number, to: number): void;
  82115. /**
  82116. * Delete a specific animation range
  82117. * @param name defines the name of the range
  82118. * @param deleteFrames defines if frames must be removed as well
  82119. */
  82120. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82121. /**
  82122. * Gets a specific animation range
  82123. * @param name defines the name of the range to look for
  82124. * @returns the requested animation range or null if not found
  82125. */
  82126. getAnimationRange(name: string): Nullable<AnimationRange>;
  82127. /**
  82128. * Gets the list of all animation ranges defined on this skeleton
  82129. * @returns an array
  82130. */
  82131. getAnimationRanges(): Nullable<AnimationRange>[];
  82132. /**
  82133. * Copy animation range from a source skeleton.
  82134. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  82135. * @param source defines the source skeleton
  82136. * @param name defines the name of the range to copy
  82137. * @param rescaleAsRequired defines if rescaling must be applied if required
  82138. * @returns true if operation was successful
  82139. */
  82140. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  82141. /**
  82142. * Forces the skeleton to go to rest pose
  82143. */
  82144. returnToRest(): void;
  82145. private _getHighestAnimationFrame;
  82146. /**
  82147. * Begin a specific animation range
  82148. * @param name defines the name of the range to start
  82149. * @param loop defines if looping must be turned on (false by default)
  82150. * @param speedRatio defines the speed ratio to apply (1 by default)
  82151. * @param onAnimationEnd defines a callback which will be called when animation will end
  82152. * @returns a new animatable
  82153. */
  82154. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82155. /** @hidden */
  82156. _markAsDirty(): void;
  82157. /** @hidden */
  82158. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82159. /** @hidden */
  82160. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82161. private _computeTransformMatrices;
  82162. /**
  82163. * Build all resources required to render a skeleton
  82164. */
  82165. prepare(): void;
  82166. /**
  82167. * Gets the list of animatables currently running for this skeleton
  82168. * @returns an array of animatables
  82169. */
  82170. getAnimatables(): IAnimatable[];
  82171. /**
  82172. * Clone the current skeleton
  82173. * @param name defines the name of the new skeleton
  82174. * @param id defines the id of the new skeleton
  82175. * @returns the new skeleton
  82176. */
  82177. clone(name: string, id?: string): Skeleton;
  82178. /**
  82179. * Enable animation blending for this skeleton
  82180. * @param blendingSpeed defines the blending speed to apply
  82181. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82182. */
  82183. enableBlending(blendingSpeed?: number): void;
  82184. /**
  82185. * Releases all resources associated with the current skeleton
  82186. */
  82187. dispose(): void;
  82188. /**
  82189. * Serialize the skeleton in a JSON object
  82190. * @returns a JSON object
  82191. */
  82192. serialize(): any;
  82193. /**
  82194. * Creates a new skeleton from serialized data
  82195. * @param parsedSkeleton defines the serialized data
  82196. * @param scene defines the hosting scene
  82197. * @returns a new skeleton
  82198. */
  82199. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  82200. /**
  82201. * Compute all node absolute transforms
  82202. * @param forceUpdate defines if computation must be done even if cache is up to date
  82203. */
  82204. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  82205. /**
  82206. * Gets the root pose matrix
  82207. * @returns a matrix
  82208. */
  82209. getPoseMatrix(): Nullable<Matrix>;
  82210. /**
  82211. * Sorts bones per internal index
  82212. */
  82213. sortBones(): void;
  82214. private _sortBones;
  82215. }
  82216. }
  82217. declare module BABYLON {
  82218. /**
  82219. * Class used to store bone information
  82220. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82221. */
  82222. export class Bone extends Node {
  82223. /**
  82224. * defines the bone name
  82225. */
  82226. name: string;
  82227. private static _tmpVecs;
  82228. private static _tmpQuat;
  82229. private static _tmpMats;
  82230. /**
  82231. * Gets the list of child bones
  82232. */
  82233. children: Bone[];
  82234. /** Gets the animations associated with this bone */
  82235. animations: Animation[];
  82236. /**
  82237. * Gets or sets bone length
  82238. */
  82239. length: number;
  82240. /**
  82241. * @hidden Internal only
  82242. * Set this value to map this bone to a different index in the transform matrices
  82243. * Set this value to -1 to exclude the bone from the transform matrices
  82244. */
  82245. _index: Nullable<number>;
  82246. private _skeleton;
  82247. private _localMatrix;
  82248. private _restPose;
  82249. private _baseMatrix;
  82250. private _absoluteTransform;
  82251. private _invertedAbsoluteTransform;
  82252. private _parent;
  82253. private _scalingDeterminant;
  82254. private _worldTransform;
  82255. private _localScaling;
  82256. private _localRotation;
  82257. private _localPosition;
  82258. private _needToDecompose;
  82259. private _needToCompose;
  82260. /** @hidden */
  82261. _linkedTransformNode: Nullable<TransformNode>;
  82262. /** @hidden */
  82263. _waitingTransformNodeId: Nullable<string>;
  82264. /** @hidden */
  82265. /** @hidden */
  82266. _matrix: Matrix;
  82267. /**
  82268. * Create a new bone
  82269. * @param name defines the bone name
  82270. * @param skeleton defines the parent skeleton
  82271. * @param parentBone defines the parent (can be null if the bone is the root)
  82272. * @param localMatrix defines the local matrix
  82273. * @param restPose defines the rest pose matrix
  82274. * @param baseMatrix defines the base matrix
  82275. * @param index defines index of the bone in the hiearchy
  82276. */
  82277. constructor(
  82278. /**
  82279. * defines the bone name
  82280. */
  82281. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  82282. /**
  82283. * Gets the current object class name.
  82284. * @return the class name
  82285. */
  82286. getClassName(): string;
  82287. /**
  82288. * Gets the parent skeleton
  82289. * @returns a skeleton
  82290. */
  82291. getSkeleton(): Skeleton;
  82292. /**
  82293. * Gets parent bone
  82294. * @returns a bone or null if the bone is the root of the bone hierarchy
  82295. */
  82296. getParent(): Nullable<Bone>;
  82297. /**
  82298. * Returns an array containing the root bones
  82299. * @returns an array containing the root bones
  82300. */
  82301. getChildren(): Array<Bone>;
  82302. /**
  82303. * Gets the node index in matrix array generated for rendering
  82304. * @returns the node index
  82305. */
  82306. getIndex(): number;
  82307. /**
  82308. * Sets the parent bone
  82309. * @param parent defines the parent (can be null if the bone is the root)
  82310. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82311. */
  82312. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  82313. /**
  82314. * Gets the local matrix
  82315. * @returns a matrix
  82316. */
  82317. getLocalMatrix(): Matrix;
  82318. /**
  82319. * Gets the base matrix (initial matrix which remains unchanged)
  82320. * @returns a matrix
  82321. */
  82322. getBaseMatrix(): Matrix;
  82323. /**
  82324. * Gets the rest pose matrix
  82325. * @returns a matrix
  82326. */
  82327. getRestPose(): Matrix;
  82328. /**
  82329. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  82330. */
  82331. getWorldMatrix(): Matrix;
  82332. /**
  82333. * Sets the local matrix to rest pose matrix
  82334. */
  82335. returnToRest(): void;
  82336. /**
  82337. * Gets the inverse of the absolute transform matrix.
  82338. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  82339. * @returns a matrix
  82340. */
  82341. getInvertedAbsoluteTransform(): Matrix;
  82342. /**
  82343. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  82344. * @returns a matrix
  82345. */
  82346. getAbsoluteTransform(): Matrix;
  82347. /**
  82348. * Links with the given transform node.
  82349. * The local matrix of this bone is copied from the transform node every frame.
  82350. * @param transformNode defines the transform node to link to
  82351. */
  82352. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  82353. /**
  82354. * Gets the node used to drive the bone's transformation
  82355. * @returns a transform node or null
  82356. */
  82357. getTransformNode(): Nullable<TransformNode>;
  82358. /** Gets or sets current position (in local space) */
  82359. position: Vector3;
  82360. /** Gets or sets current rotation (in local space) */
  82361. rotation: Vector3;
  82362. /** Gets or sets current rotation quaternion (in local space) */
  82363. rotationQuaternion: Quaternion;
  82364. /** Gets or sets current scaling (in local space) */
  82365. scaling: Vector3;
  82366. /**
  82367. * Gets the animation properties override
  82368. */
  82369. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82370. private _decompose;
  82371. private _compose;
  82372. /**
  82373. * Update the base and local matrices
  82374. * @param matrix defines the new base or local matrix
  82375. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82376. * @param updateLocalMatrix defines if the local matrix should be updated
  82377. */
  82378. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  82379. /** @hidden */
  82380. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  82381. /**
  82382. * Flag the bone as dirty (Forcing it to update everything)
  82383. */
  82384. markAsDirty(): void;
  82385. /** @hidden */
  82386. _markAsDirtyAndCompose(): void;
  82387. private _markAsDirtyAndDecompose;
  82388. /**
  82389. * Translate the bone in local or world space
  82390. * @param vec The amount to translate the bone
  82391. * @param space The space that the translation is in
  82392. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82393. */
  82394. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82395. /**
  82396. * Set the postion of the bone in local or world space
  82397. * @param position The position to set the bone
  82398. * @param space The space that the position is in
  82399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82400. */
  82401. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82402. /**
  82403. * Set the absolute position of the bone (world space)
  82404. * @param position The position to set the bone
  82405. * @param mesh The mesh that this bone is attached to
  82406. */
  82407. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  82408. /**
  82409. * Scale the bone on the x, y and z axes (in local space)
  82410. * @param x The amount to scale the bone on the x axis
  82411. * @param y The amount to scale the bone on the y axis
  82412. * @param z The amount to scale the bone on the z axis
  82413. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  82414. */
  82415. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  82416. /**
  82417. * Set the bone scaling in local space
  82418. * @param scale defines the scaling vector
  82419. */
  82420. setScale(scale: Vector3): void;
  82421. /**
  82422. * Gets the current scaling in local space
  82423. * @returns the current scaling vector
  82424. */
  82425. getScale(): Vector3;
  82426. /**
  82427. * Gets the current scaling in local space and stores it in a target vector
  82428. * @param result defines the target vector
  82429. */
  82430. getScaleToRef(result: Vector3): void;
  82431. /**
  82432. * Set the yaw, pitch, and roll of the bone in local or world space
  82433. * @param yaw The rotation of the bone on the y axis
  82434. * @param pitch The rotation of the bone on the x axis
  82435. * @param roll The rotation of the bone on the z axis
  82436. * @param space The space that the axes of rotation are in
  82437. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82438. */
  82439. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  82440. /**
  82441. * Add a rotation to the bone on an axis in local or world space
  82442. * @param axis The axis to rotate the bone on
  82443. * @param amount The amount to rotate the bone
  82444. * @param space The space that the axis is in
  82445. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82446. */
  82447. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  82448. /**
  82449. * Set the rotation of the bone to a particular axis angle in local or world space
  82450. * @param axis The axis to rotate the bone on
  82451. * @param angle The angle that the bone should be rotated to
  82452. * @param space The space that the axis is in
  82453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82454. */
  82455. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  82456. /**
  82457. * Set the euler rotation of the bone in local of world space
  82458. * @param rotation The euler rotation that the bone should be set to
  82459. * @param space The space that the rotation is in
  82460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82461. */
  82462. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82463. /**
  82464. * Set the quaternion rotation of the bone in local of world space
  82465. * @param quat The quaternion rotation that the bone should be set to
  82466. * @param space The space that the rotation is in
  82467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82468. */
  82469. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  82470. /**
  82471. * Set the rotation matrix of the bone in local of world space
  82472. * @param rotMat The rotation matrix that the bone should be set to
  82473. * @param space The space that the rotation is in
  82474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82475. */
  82476. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  82477. private _rotateWithMatrix;
  82478. private _getNegativeRotationToRef;
  82479. /**
  82480. * Get the position of the bone in local or world space
  82481. * @param space The space that the returned position is in
  82482. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82483. * @returns The position of the bone
  82484. */
  82485. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82486. /**
  82487. * Copy the position of the bone to a vector3 in local or world space
  82488. * @param space The space that the returned position is in
  82489. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82490. * @param result The vector3 to copy the position to
  82491. */
  82492. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  82493. /**
  82494. * Get the absolute position of the bone (world space)
  82495. * @param mesh The mesh that this bone is attached to
  82496. * @returns The absolute position of the bone
  82497. */
  82498. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  82499. /**
  82500. * Copy the absolute position of the bone (world space) to the result param
  82501. * @param mesh The mesh that this bone is attached to
  82502. * @param result The vector3 to copy the absolute position to
  82503. */
  82504. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  82505. /**
  82506. * Compute the absolute transforms of this bone and its children
  82507. */
  82508. computeAbsoluteTransforms(): void;
  82509. /**
  82510. * Get the world direction from an axis that is in the local space of the bone
  82511. * @param localAxis The local direction that is used to compute the world direction
  82512. * @param mesh The mesh that this bone is attached to
  82513. * @returns The world direction
  82514. */
  82515. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82516. /**
  82517. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  82518. * @param localAxis The local direction that is used to compute the world direction
  82519. * @param mesh The mesh that this bone is attached to
  82520. * @param result The vector3 that the world direction will be copied to
  82521. */
  82522. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82523. /**
  82524. * Get the euler rotation of the bone in local or world space
  82525. * @param space The space that the rotation should be in
  82526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82527. * @returns The euler rotation
  82528. */
  82529. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82530. /**
  82531. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82532. * @param space The space that the rotation should be in
  82533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82534. * @param result The vector3 that the rotation should be copied to
  82535. */
  82536. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82537. /**
  82538. * Get the quaternion rotation of the bone in either local or world space
  82539. * @param space The space that the rotation should be in
  82540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82541. * @returns The quaternion rotation
  82542. */
  82543. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82544. /**
  82545. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82546. * @param space The space that the rotation should be in
  82547. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82548. * @param result The quaternion that the rotation should be copied to
  82549. */
  82550. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82551. /**
  82552. * Get the rotation matrix of the bone in local or world space
  82553. * @param space The space that the rotation should be in
  82554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82555. * @returns The rotation matrix
  82556. */
  82557. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82558. /**
  82559. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82560. * @param space The space that the rotation should be in
  82561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82562. * @param result The quaternion that the rotation should be copied to
  82563. */
  82564. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82565. /**
  82566. * Get the world position of a point that is in the local space of the bone
  82567. * @param position The local position
  82568. * @param mesh The mesh that this bone is attached to
  82569. * @returns The world position
  82570. */
  82571. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82572. /**
  82573. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82574. * @param position The local position
  82575. * @param mesh The mesh that this bone is attached to
  82576. * @param result The vector3 that the world position should be copied to
  82577. */
  82578. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82579. /**
  82580. * Get the local position of a point that is in world space
  82581. * @param position The world position
  82582. * @param mesh The mesh that this bone is attached to
  82583. * @returns The local position
  82584. */
  82585. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82586. /**
  82587. * Get the local position of a point that is in world space and copy it to the result param
  82588. * @param position The world position
  82589. * @param mesh The mesh that this bone is attached to
  82590. * @param result The vector3 that the local position should be copied to
  82591. */
  82592. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82593. }
  82594. }
  82595. declare module BABYLON {
  82596. /**
  82597. * 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.
  82598. * @see https://doc.babylonjs.com/how_to/transformnode
  82599. */
  82600. export class TransformNode extends Node {
  82601. /**
  82602. * Object will not rotate to face the camera
  82603. */
  82604. static BILLBOARDMODE_NONE: number;
  82605. /**
  82606. * Object will rotate to face the camera but only on the x axis
  82607. */
  82608. static BILLBOARDMODE_X: number;
  82609. /**
  82610. * Object will rotate to face the camera but only on the y axis
  82611. */
  82612. static BILLBOARDMODE_Y: number;
  82613. /**
  82614. * Object will rotate to face the camera but only on the z axis
  82615. */
  82616. static BILLBOARDMODE_Z: number;
  82617. /**
  82618. * Object will rotate to face the camera
  82619. */
  82620. static BILLBOARDMODE_ALL: number;
  82621. /**
  82622. * Object will rotate to face the camera's position instead of orientation
  82623. */
  82624. static BILLBOARDMODE_USE_POSITION: number;
  82625. private _forward;
  82626. private _forwardInverted;
  82627. private _up;
  82628. private _right;
  82629. private _rightInverted;
  82630. private _position;
  82631. private _rotation;
  82632. private _rotationQuaternion;
  82633. protected _scaling: Vector3;
  82634. protected _isDirty: boolean;
  82635. private _transformToBoneReferal;
  82636. private _isAbsoluteSynced;
  82637. private _billboardMode;
  82638. /**
  82639. * Gets or sets the billboard mode. Default is 0.
  82640. *
  82641. * | Value | Type | Description |
  82642. * | --- | --- | --- |
  82643. * | 0 | BILLBOARDMODE_NONE | |
  82644. * | 1 | BILLBOARDMODE_X | |
  82645. * | 2 | BILLBOARDMODE_Y | |
  82646. * | 4 | BILLBOARDMODE_Z | |
  82647. * | 7 | BILLBOARDMODE_ALL | |
  82648. *
  82649. */
  82650. billboardMode: number;
  82651. private _preserveParentRotationForBillboard;
  82652. /**
  82653. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82654. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82655. */
  82656. preserveParentRotationForBillboard: boolean;
  82657. /**
  82658. * 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
  82659. */
  82660. scalingDeterminant: number;
  82661. private _infiniteDistance;
  82662. /**
  82663. * Gets or sets the distance of the object to max, often used by skybox
  82664. */
  82665. infiniteDistance: boolean;
  82666. /**
  82667. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82668. * By default the system will update normals to compensate
  82669. */
  82670. ignoreNonUniformScaling: boolean;
  82671. /**
  82672. * 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
  82673. */
  82674. reIntegrateRotationIntoRotationQuaternion: boolean;
  82675. /** @hidden */
  82676. _poseMatrix: Nullable<Matrix>;
  82677. /** @hidden */
  82678. _localMatrix: Matrix;
  82679. private _usePivotMatrix;
  82680. private _absolutePosition;
  82681. private _absoluteScaling;
  82682. private _absoluteRotationQuaternion;
  82683. private _pivotMatrix;
  82684. private _pivotMatrixInverse;
  82685. protected _postMultiplyPivotMatrix: boolean;
  82686. protected _isWorldMatrixFrozen: boolean;
  82687. /** @hidden */
  82688. _indexInSceneTransformNodesArray: number;
  82689. /**
  82690. * An event triggered after the world matrix is updated
  82691. */
  82692. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  82693. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  82694. /**
  82695. * Gets a string identifying the name of the class
  82696. * @returns "TransformNode" string
  82697. */
  82698. getClassName(): string;
  82699. /**
  82700. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  82701. */
  82702. position: Vector3;
  82703. /**
  82704. * 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)).
  82705. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  82706. */
  82707. rotation: Vector3;
  82708. /**
  82709. * 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)).
  82710. */
  82711. scaling: Vector3;
  82712. /**
  82713. * 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).
  82714. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  82715. */
  82716. rotationQuaternion: Nullable<Quaternion>;
  82717. /**
  82718. * The forward direction of that transform in world space.
  82719. */
  82720. readonly forward: Vector3;
  82721. /**
  82722. * The up direction of that transform in world space.
  82723. */
  82724. readonly up: Vector3;
  82725. /**
  82726. * The right direction of that transform in world space.
  82727. */
  82728. readonly right: Vector3;
  82729. /**
  82730. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82731. * @param matrix the matrix to copy the pose from
  82732. * @returns this TransformNode.
  82733. */
  82734. updatePoseMatrix(matrix: Matrix): TransformNode;
  82735. /**
  82736. * Returns the mesh Pose matrix.
  82737. * @returns the pose matrix
  82738. */
  82739. getPoseMatrix(): Matrix;
  82740. /** @hidden */
  82741. _isSynchronized(): boolean;
  82742. /** @hidden */
  82743. _initCache(): void;
  82744. /**
  82745. * Flag the transform node as dirty (Forcing it to update everything)
  82746. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  82747. * @returns this transform node
  82748. */
  82749. markAsDirty(property: string): TransformNode;
  82750. /**
  82751. * Returns the current mesh absolute position.
  82752. * Returns a Vector3.
  82753. */
  82754. readonly absolutePosition: Vector3;
  82755. /**
  82756. * Returns the current mesh absolute scaling.
  82757. * Returns a Vector3.
  82758. */
  82759. readonly absoluteScaling: Vector3;
  82760. /**
  82761. * Returns the current mesh absolute rotation.
  82762. * Returns a Quaternion.
  82763. */
  82764. readonly absoluteRotationQuaternion: Quaternion;
  82765. /**
  82766. * Sets a new matrix to apply before all other transformation
  82767. * @param matrix defines the transform matrix
  82768. * @returns the current TransformNode
  82769. */
  82770. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82771. /**
  82772. * Sets a new pivot matrix to the current node
  82773. * @param matrix defines the new pivot matrix to use
  82774. * @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
  82775. * @returns the current TransformNode
  82776. */
  82777. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82778. /**
  82779. * Returns the mesh pivot matrix.
  82780. * Default : Identity.
  82781. * @returns the matrix
  82782. */
  82783. getPivotMatrix(): Matrix;
  82784. /**
  82785. * Instantiate (when possible) or clone that node with its hierarchy
  82786. * @param newParent defines the new parent to use for the instance (or clone)
  82787. * @param options defines options to configure how copy is done
  82788. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82789. * @returns an instance (or a clone) of the current node with its hiearchy
  82790. */
  82791. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82792. doNotInstantiate: boolean;
  82793. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82794. /**
  82795. * Prevents the World matrix to be computed any longer
  82796. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82797. * @returns the TransformNode.
  82798. */
  82799. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82800. /**
  82801. * Allows back the World matrix computation.
  82802. * @returns the TransformNode.
  82803. */
  82804. unfreezeWorldMatrix(): this;
  82805. /**
  82806. * True if the World matrix has been frozen.
  82807. */
  82808. readonly isWorldMatrixFrozen: boolean;
  82809. /**
  82810. * Retuns the mesh absolute position in the World.
  82811. * @returns a Vector3.
  82812. */
  82813. getAbsolutePosition(): Vector3;
  82814. /**
  82815. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82816. * @param absolutePosition the absolute position to set
  82817. * @returns the TransformNode.
  82818. */
  82819. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82820. /**
  82821. * Sets the mesh position in its local space.
  82822. * @param vector3 the position to set in localspace
  82823. * @returns the TransformNode.
  82824. */
  82825. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82826. /**
  82827. * Returns the mesh position in the local space from the current World matrix values.
  82828. * @returns a new Vector3.
  82829. */
  82830. getPositionExpressedInLocalSpace(): Vector3;
  82831. /**
  82832. * Translates the mesh along the passed Vector3 in its local space.
  82833. * @param vector3 the distance to translate in localspace
  82834. * @returns the TransformNode.
  82835. */
  82836. locallyTranslate(vector3: Vector3): TransformNode;
  82837. private static _lookAtVectorCache;
  82838. /**
  82839. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82840. * @param targetPoint the position (must be in same space as current mesh) to look at
  82841. * @param yawCor optional yaw (y-axis) correction in radians
  82842. * @param pitchCor optional pitch (x-axis) correction in radians
  82843. * @param rollCor optional roll (z-axis) correction in radians
  82844. * @param space the choosen space of the target
  82845. * @returns the TransformNode.
  82846. */
  82847. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82848. /**
  82849. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82850. * This Vector3 is expressed in the World space.
  82851. * @param localAxis axis to rotate
  82852. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82853. */
  82854. getDirection(localAxis: Vector3): Vector3;
  82855. /**
  82856. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82857. * localAxis is expressed in the mesh local space.
  82858. * result is computed in the Wordl space from the mesh World matrix.
  82859. * @param localAxis axis to rotate
  82860. * @param result the resulting transformnode
  82861. * @returns this TransformNode.
  82862. */
  82863. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82864. /**
  82865. * Sets this transform node rotation to the given local axis.
  82866. * @param localAxis the axis in local space
  82867. * @param yawCor optional yaw (y-axis) correction in radians
  82868. * @param pitchCor optional pitch (x-axis) correction in radians
  82869. * @param rollCor optional roll (z-axis) correction in radians
  82870. * @returns this TransformNode
  82871. */
  82872. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82873. /**
  82874. * Sets a new pivot point to the current node
  82875. * @param point defines the new pivot point to use
  82876. * @param space defines if the point is in world or local space (local by default)
  82877. * @returns the current TransformNode
  82878. */
  82879. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82880. /**
  82881. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82882. * @returns the pivot point
  82883. */
  82884. getPivotPoint(): Vector3;
  82885. /**
  82886. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82887. * @param result the vector3 to store the result
  82888. * @returns this TransformNode.
  82889. */
  82890. getPivotPointToRef(result: Vector3): TransformNode;
  82891. /**
  82892. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82893. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82894. */
  82895. getAbsolutePivotPoint(): Vector3;
  82896. /**
  82897. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82898. * @param result vector3 to store the result
  82899. * @returns this TransformNode.
  82900. */
  82901. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82902. /**
  82903. * Defines the passed node as the parent of the current node.
  82904. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82905. * @see https://doc.babylonjs.com/how_to/parenting
  82906. * @param node the node ot set as the parent
  82907. * @returns this TransformNode.
  82908. */
  82909. setParent(node: Nullable<Node>): TransformNode;
  82910. private _nonUniformScaling;
  82911. /**
  82912. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82913. */
  82914. readonly nonUniformScaling: boolean;
  82915. /** @hidden */
  82916. _updateNonUniformScalingState(value: boolean): boolean;
  82917. /**
  82918. * Attach the current TransformNode to another TransformNode associated with a bone
  82919. * @param bone Bone affecting the TransformNode
  82920. * @param affectedTransformNode TransformNode associated with the bone
  82921. * @returns this object
  82922. */
  82923. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82924. /**
  82925. * Detach the transform node if its associated with a bone
  82926. * @returns this object
  82927. */
  82928. detachFromBone(): TransformNode;
  82929. private static _rotationAxisCache;
  82930. /**
  82931. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82932. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82933. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82934. * The passed axis is also normalized.
  82935. * @param axis the axis to rotate around
  82936. * @param amount the amount to rotate in radians
  82937. * @param space Space to rotate in (Default: local)
  82938. * @returns the TransformNode.
  82939. */
  82940. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82941. /**
  82942. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82943. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82944. * The passed axis is also normalized. .
  82945. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82946. * @param point the point to rotate around
  82947. * @param axis the axis to rotate around
  82948. * @param amount the amount to rotate in radians
  82949. * @returns the TransformNode
  82950. */
  82951. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82952. /**
  82953. * Translates the mesh along the axis vector for the passed distance in the given space.
  82954. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82955. * @param axis the axis to translate in
  82956. * @param distance the distance to translate
  82957. * @param space Space to rotate in (Default: local)
  82958. * @returns the TransformNode.
  82959. */
  82960. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82961. /**
  82962. * Adds a rotation step to the mesh current rotation.
  82963. * x, y, z are Euler angles expressed in radians.
  82964. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82965. * This means this rotation is made in the mesh local space only.
  82966. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82967. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82968. * ```javascript
  82969. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82970. * ```
  82971. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82972. * 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.
  82973. * @param x Rotation to add
  82974. * @param y Rotation to add
  82975. * @param z Rotation to add
  82976. * @returns the TransformNode.
  82977. */
  82978. addRotation(x: number, y: number, z: number): TransformNode;
  82979. /**
  82980. * @hidden
  82981. */
  82982. protected _getEffectiveParent(): Nullable<Node>;
  82983. /**
  82984. * Computes the world matrix of the node
  82985. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82986. * @returns the world matrix
  82987. */
  82988. computeWorldMatrix(force?: boolean): Matrix;
  82989. protected _afterComputeWorldMatrix(): void;
  82990. /**
  82991. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82992. * @param func callback function to add
  82993. *
  82994. * @returns the TransformNode.
  82995. */
  82996. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82997. /**
  82998. * Removes a registered callback function.
  82999. * @param func callback function to remove
  83000. * @returns the TransformNode.
  83001. */
  83002. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83003. /**
  83004. * Gets the position of the current mesh in camera space
  83005. * @param camera defines the camera to use
  83006. * @returns a position
  83007. */
  83008. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  83009. /**
  83010. * Returns the distance from the mesh to the active camera
  83011. * @param camera defines the camera to use
  83012. * @returns the distance
  83013. */
  83014. getDistanceToCamera(camera?: Nullable<Camera>): number;
  83015. /**
  83016. * Clone the current transform node
  83017. * @param name Name of the new clone
  83018. * @param newParent New parent for the clone
  83019. * @param doNotCloneChildren Do not clone children hierarchy
  83020. * @returns the new transform node
  83021. */
  83022. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  83023. /**
  83024. * Serializes the objects information.
  83025. * @param currentSerializationObject defines the object to serialize in
  83026. * @returns the serialized object
  83027. */
  83028. serialize(currentSerializationObject?: any): any;
  83029. /**
  83030. * Returns a new TransformNode object parsed from the source provided.
  83031. * @param parsedTransformNode is the source.
  83032. * @param scene the scne the object belongs to
  83033. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  83034. * @returns a new TransformNode object parsed from the source provided.
  83035. */
  83036. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  83037. /**
  83038. * Get all child-transformNodes of this node
  83039. * @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
  83040. * @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
  83041. * @returns an array of TransformNode
  83042. */
  83043. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  83044. /**
  83045. * Releases resources associated with this transform node.
  83046. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83047. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83048. */
  83049. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83050. /**
  83051. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83052. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83053. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83054. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  83055. * @returns the current mesh
  83056. */
  83057. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  83058. private _syncAbsoluteScalingAndRotation;
  83059. }
  83060. }
  83061. declare module BABYLON {
  83062. /**
  83063. * Defines the types of pose enabled controllers that are supported
  83064. */
  83065. export enum PoseEnabledControllerType {
  83066. /**
  83067. * HTC Vive
  83068. */
  83069. VIVE = 0,
  83070. /**
  83071. * Oculus Rift
  83072. */
  83073. OCULUS = 1,
  83074. /**
  83075. * Windows mixed reality
  83076. */
  83077. WINDOWS = 2,
  83078. /**
  83079. * Samsung gear VR
  83080. */
  83081. GEAR_VR = 3,
  83082. /**
  83083. * Google Daydream
  83084. */
  83085. DAYDREAM = 4,
  83086. /**
  83087. * Generic
  83088. */
  83089. GENERIC = 5
  83090. }
  83091. /**
  83092. * Defines the MutableGamepadButton interface for the state of a gamepad button
  83093. */
  83094. export interface MutableGamepadButton {
  83095. /**
  83096. * Value of the button/trigger
  83097. */
  83098. value: number;
  83099. /**
  83100. * If the button/trigger is currently touched
  83101. */
  83102. touched: boolean;
  83103. /**
  83104. * If the button/trigger is currently pressed
  83105. */
  83106. pressed: boolean;
  83107. }
  83108. /**
  83109. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  83110. * @hidden
  83111. */
  83112. export interface ExtendedGamepadButton extends GamepadButton {
  83113. /**
  83114. * If the button/trigger is currently pressed
  83115. */
  83116. readonly pressed: boolean;
  83117. /**
  83118. * If the button/trigger is currently touched
  83119. */
  83120. readonly touched: boolean;
  83121. /**
  83122. * Value of the button/trigger
  83123. */
  83124. readonly value: number;
  83125. }
  83126. /** @hidden */
  83127. export interface _GamePadFactory {
  83128. /**
  83129. * Returns wether or not the current gamepad can be created for this type of controller.
  83130. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83131. * @returns true if it can be created, otherwise false
  83132. */
  83133. canCreate(gamepadInfo: any): boolean;
  83134. /**
  83135. * Creates a new instance of the Gamepad.
  83136. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83137. * @returns the new gamepad instance
  83138. */
  83139. create(gamepadInfo: any): Gamepad;
  83140. }
  83141. /**
  83142. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83143. */
  83144. export class PoseEnabledControllerHelper {
  83145. /** @hidden */
  83146. static _ControllerFactories: _GamePadFactory[];
  83147. /** @hidden */
  83148. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  83149. /**
  83150. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83151. * @param vrGamepad the gamepad to initialized
  83152. * @returns a vr controller of the type the gamepad identified as
  83153. */
  83154. static InitiateController(vrGamepad: any): Gamepad;
  83155. }
  83156. /**
  83157. * Defines the PoseEnabledController object that contains state of a vr capable controller
  83158. */
  83159. export class PoseEnabledController extends Gamepad implements PoseControlled {
  83160. /**
  83161. * If the controller is used in a webXR session
  83162. */
  83163. isXR: boolean;
  83164. private _deviceRoomPosition;
  83165. private _deviceRoomRotationQuaternion;
  83166. /**
  83167. * The device position in babylon space
  83168. */
  83169. devicePosition: Vector3;
  83170. /**
  83171. * The device rotation in babylon space
  83172. */
  83173. deviceRotationQuaternion: Quaternion;
  83174. /**
  83175. * The scale factor of the device in babylon space
  83176. */
  83177. deviceScaleFactor: number;
  83178. /**
  83179. * (Likely devicePosition should be used instead) The device position in its room space
  83180. */
  83181. position: Vector3;
  83182. /**
  83183. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  83184. */
  83185. rotationQuaternion: Quaternion;
  83186. /**
  83187. * The type of controller (Eg. Windows mixed reality)
  83188. */
  83189. controllerType: PoseEnabledControllerType;
  83190. protected _calculatedPosition: Vector3;
  83191. private _calculatedRotation;
  83192. /**
  83193. * The raw pose from the device
  83194. */
  83195. rawPose: DevicePose;
  83196. private _trackPosition;
  83197. private _maxRotationDistFromHeadset;
  83198. private _draggedRoomRotation;
  83199. /**
  83200. * @hidden
  83201. */
  83202. _disableTrackPosition(fixedPosition: Vector3): void;
  83203. /**
  83204. * Internal, the mesh attached to the controller
  83205. * @hidden
  83206. */
  83207. _mesh: Nullable<AbstractMesh>;
  83208. private _poseControlledCamera;
  83209. private _leftHandSystemQuaternion;
  83210. /**
  83211. * Internal, matrix used to convert room space to babylon space
  83212. * @hidden
  83213. */
  83214. _deviceToWorld: Matrix;
  83215. /**
  83216. * Node to be used when casting a ray from the controller
  83217. * @hidden
  83218. */
  83219. _pointingPoseNode: Nullable<TransformNode>;
  83220. /**
  83221. * Name of the child mesh that can be used to cast a ray from the controller
  83222. */
  83223. static readonly POINTING_POSE: string;
  83224. /**
  83225. * Creates a new PoseEnabledController from a gamepad
  83226. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  83227. */
  83228. constructor(browserGamepad: any);
  83229. private _workingMatrix;
  83230. /**
  83231. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  83232. */
  83233. update(): void;
  83234. /**
  83235. * Updates only the pose device and mesh without doing any button event checking
  83236. */
  83237. protected _updatePoseAndMesh(): void;
  83238. /**
  83239. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  83240. * @param poseData raw pose fromthe device
  83241. */
  83242. updateFromDevice(poseData: DevicePose): void;
  83243. /**
  83244. * @hidden
  83245. */
  83246. _meshAttachedObservable: Observable<AbstractMesh>;
  83247. /**
  83248. * Attaches a mesh to the controller
  83249. * @param mesh the mesh to be attached
  83250. */
  83251. attachToMesh(mesh: AbstractMesh): void;
  83252. /**
  83253. * Attaches the controllers mesh to a camera
  83254. * @param camera the camera the mesh should be attached to
  83255. */
  83256. attachToPoseControlledCamera(camera: TargetCamera): void;
  83257. /**
  83258. * Disposes of the controller
  83259. */
  83260. dispose(): void;
  83261. /**
  83262. * The mesh that is attached to the controller
  83263. */
  83264. readonly mesh: Nullable<AbstractMesh>;
  83265. /**
  83266. * Gets the ray of the controller in the direction the controller is pointing
  83267. * @param length the length the resulting ray should be
  83268. * @returns a ray in the direction the controller is pointing
  83269. */
  83270. getForwardRay(length?: number): Ray;
  83271. }
  83272. }
  83273. declare module BABYLON {
  83274. /**
  83275. * Defines the WebVRController object that represents controllers tracked in 3D space
  83276. */
  83277. export abstract class WebVRController extends PoseEnabledController {
  83278. /**
  83279. * Internal, the default controller model for the controller
  83280. */
  83281. protected _defaultModel: Nullable<AbstractMesh>;
  83282. /**
  83283. * Fired when the trigger state has changed
  83284. */
  83285. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  83286. /**
  83287. * Fired when the main button state has changed
  83288. */
  83289. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83290. /**
  83291. * Fired when the secondary button state has changed
  83292. */
  83293. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83294. /**
  83295. * Fired when the pad state has changed
  83296. */
  83297. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  83298. /**
  83299. * Fired when controllers stick values have changed
  83300. */
  83301. onPadValuesChangedObservable: Observable<StickValues>;
  83302. /**
  83303. * Array of button availible on the controller
  83304. */
  83305. protected _buttons: Array<MutableGamepadButton>;
  83306. private _onButtonStateChange;
  83307. /**
  83308. * Fired when a controller button's state has changed
  83309. * @param callback the callback containing the button that was modified
  83310. */
  83311. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  83312. /**
  83313. * X and Y axis corresponding to the controllers joystick
  83314. */
  83315. pad: StickValues;
  83316. /**
  83317. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  83318. */
  83319. hand: string;
  83320. /**
  83321. * The default controller model for the controller
  83322. */
  83323. readonly defaultModel: Nullable<AbstractMesh>;
  83324. /**
  83325. * Creates a new WebVRController from a gamepad
  83326. * @param vrGamepad the gamepad that the WebVRController should be created from
  83327. */
  83328. constructor(vrGamepad: any);
  83329. /**
  83330. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  83331. */
  83332. update(): void;
  83333. /**
  83334. * Function to be called when a button is modified
  83335. */
  83336. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  83337. /**
  83338. * Loads a mesh and attaches it to the controller
  83339. * @param scene the scene the mesh should be added to
  83340. * @param meshLoaded callback for when the mesh has been loaded
  83341. */
  83342. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  83343. private _setButtonValue;
  83344. private _changes;
  83345. private _checkChanges;
  83346. /**
  83347. * Disposes of th webVRCOntroller
  83348. */
  83349. dispose(): void;
  83350. }
  83351. }
  83352. declare module BABYLON {
  83353. /**
  83354. * The HemisphericLight simulates the ambient environment light,
  83355. * so the passed direction is the light reflection direction, not the incoming direction.
  83356. */
  83357. export class HemisphericLight extends Light {
  83358. /**
  83359. * The groundColor is the light in the opposite direction to the one specified during creation.
  83360. * 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.
  83361. */
  83362. groundColor: Color3;
  83363. /**
  83364. * The light reflection direction, not the incoming direction.
  83365. */
  83366. direction: Vector3;
  83367. /**
  83368. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  83369. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  83370. * The HemisphericLight can't cast shadows.
  83371. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83372. * @param name The friendly name of the light
  83373. * @param direction The direction of the light reflection
  83374. * @param scene The scene the light belongs to
  83375. */
  83376. constructor(name: string, direction: Vector3, scene: Scene);
  83377. protected _buildUniformLayout(): void;
  83378. /**
  83379. * Returns the string "HemisphericLight".
  83380. * @return The class name
  83381. */
  83382. getClassName(): string;
  83383. /**
  83384. * Sets the HemisphericLight direction towards the passed target (Vector3).
  83385. * Returns the updated direction.
  83386. * @param target The target the direction should point to
  83387. * @return The computed direction
  83388. */
  83389. setDirectionToTarget(target: Vector3): Vector3;
  83390. /**
  83391. * Returns the shadow generator associated to the light.
  83392. * @returns Always null for hemispheric lights because it does not support shadows.
  83393. */
  83394. getShadowGenerator(): Nullable<IShadowGenerator>;
  83395. /**
  83396. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  83397. * @param effect The effect to update
  83398. * @param lightIndex The index of the light in the effect to update
  83399. * @returns The hemispheric light
  83400. */
  83401. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  83402. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  83403. /**
  83404. * Computes the world matrix of the node
  83405. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83406. * @param useWasUpdatedFlag defines a reserved property
  83407. * @returns the world matrix
  83408. */
  83409. computeWorldMatrix(): Matrix;
  83410. /**
  83411. * Returns the integer 3.
  83412. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83413. */
  83414. getTypeID(): number;
  83415. /**
  83416. * Prepares the list of defines specific to the light type.
  83417. * @param defines the list of defines
  83418. * @param lightIndex defines the index of the light for the effect
  83419. */
  83420. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83421. }
  83422. }
  83423. declare module BABYLON {
  83424. /** @hidden */
  83425. export var vrMultiviewToSingleviewPixelShader: {
  83426. name: string;
  83427. shader: string;
  83428. };
  83429. }
  83430. declare module BABYLON {
  83431. /**
  83432. * Renders to multiple views with a single draw call
  83433. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  83434. */
  83435. export class MultiviewRenderTarget extends RenderTargetTexture {
  83436. /**
  83437. * Creates a multiview render target
  83438. * @param scene scene used with the render target
  83439. * @param size the size of the render target (used for each view)
  83440. */
  83441. constructor(scene: Scene, size?: number | {
  83442. width: number;
  83443. height: number;
  83444. } | {
  83445. ratio: number;
  83446. });
  83447. /**
  83448. * @hidden
  83449. * @param faceIndex the face index, if its a cube texture
  83450. */
  83451. _bindFrameBuffer(faceIndex?: number): void;
  83452. /**
  83453. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83454. * @returns the view count
  83455. */
  83456. getViewCount(): number;
  83457. }
  83458. }
  83459. declare module BABYLON {
  83460. /**
  83461. * Represents a camera frustum
  83462. */
  83463. export class Frustum {
  83464. /**
  83465. * Gets the planes representing the frustum
  83466. * @param transform matrix to be applied to the returned planes
  83467. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  83468. */
  83469. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  83470. /**
  83471. * Gets the near frustum plane transformed by the transform matrix
  83472. * @param transform transformation matrix to be applied to the resulting frustum plane
  83473. * @param frustumPlane the resuling frustum plane
  83474. */
  83475. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83476. /**
  83477. * Gets the far frustum plane transformed by the transform matrix
  83478. * @param transform transformation matrix to be applied to the resulting frustum plane
  83479. * @param frustumPlane the resuling frustum plane
  83480. */
  83481. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83482. /**
  83483. * Gets the left frustum plane transformed by the transform matrix
  83484. * @param transform transformation matrix to be applied to the resulting frustum plane
  83485. * @param frustumPlane the resuling frustum plane
  83486. */
  83487. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83488. /**
  83489. * Gets the right frustum plane transformed by the transform matrix
  83490. * @param transform transformation matrix to be applied to the resulting frustum plane
  83491. * @param frustumPlane the resuling frustum plane
  83492. */
  83493. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83494. /**
  83495. * Gets the top frustum plane transformed by the transform matrix
  83496. * @param transform transformation matrix to be applied to the resulting frustum plane
  83497. * @param frustumPlane the resuling frustum plane
  83498. */
  83499. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83500. /**
  83501. * Gets the bottom frustum plane transformed by the transform matrix
  83502. * @param transform transformation matrix to be applied to the resulting frustum plane
  83503. * @param frustumPlane the resuling frustum plane
  83504. */
  83505. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83506. /**
  83507. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  83508. * @param transform transformation matrix to be applied to the resulting frustum planes
  83509. * @param frustumPlanes the resuling frustum planes
  83510. */
  83511. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  83512. }
  83513. }
  83514. declare module BABYLON {
  83515. interface Engine {
  83516. /**
  83517. * Creates a new multiview render target
  83518. * @param width defines the width of the texture
  83519. * @param height defines the height of the texture
  83520. * @returns the created multiview texture
  83521. */
  83522. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  83523. /**
  83524. * Binds a multiview framebuffer to be drawn to
  83525. * @param multiviewTexture texture to bind
  83526. */
  83527. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83528. }
  83529. interface Camera {
  83530. /**
  83531. * @hidden
  83532. * 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)
  83533. */
  83534. _useMultiviewToSingleView: boolean;
  83535. /**
  83536. * @hidden
  83537. * 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)
  83538. */
  83539. _multiviewTexture: Nullable<RenderTargetTexture>;
  83540. /**
  83541. * @hidden
  83542. * ensures the multiview texture of the camera exists and has the specified width/height
  83543. * @param width height to set on the multiview texture
  83544. * @param height width to set on the multiview texture
  83545. */
  83546. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83547. }
  83548. interface Scene {
  83549. /** @hidden */
  83550. _transformMatrixR: Matrix;
  83551. /** @hidden */
  83552. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83553. /** @hidden */
  83554. _createMultiviewUbo(): void;
  83555. /** @hidden */
  83556. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83557. /** @hidden */
  83558. _renderMultiviewToSingleView(camera: Camera): void;
  83559. }
  83560. }
  83561. declare module BABYLON {
  83562. /**
  83563. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83564. * This will not be used for webXR as it supports displaying texture arrays directly
  83565. */
  83566. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83567. /**
  83568. * Initializes a VRMultiviewToSingleview
  83569. * @param name name of the post process
  83570. * @param camera camera to be applied to
  83571. * @param scaleFactor scaling factor to the size of the output texture
  83572. */
  83573. constructor(name: string, camera: Camera, scaleFactor: number);
  83574. }
  83575. }
  83576. declare module BABYLON {
  83577. /**
  83578. * Interface used to define additional presentation attributes
  83579. */
  83580. export interface IVRPresentationAttributes {
  83581. /**
  83582. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83583. */
  83584. highRefreshRate: boolean;
  83585. /**
  83586. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83587. */
  83588. foveationLevel: number;
  83589. }
  83590. interface Engine {
  83591. /** @hidden */
  83592. _vrDisplay: any;
  83593. /** @hidden */
  83594. _vrSupported: boolean;
  83595. /** @hidden */
  83596. _oldSize: Size;
  83597. /** @hidden */
  83598. _oldHardwareScaleFactor: number;
  83599. /** @hidden */
  83600. _vrExclusivePointerMode: boolean;
  83601. /** @hidden */
  83602. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83603. /** @hidden */
  83604. _onVRDisplayPointerRestricted: () => void;
  83605. /** @hidden */
  83606. _onVRDisplayPointerUnrestricted: () => void;
  83607. /** @hidden */
  83608. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83609. /** @hidden */
  83610. _onVrDisplayDisconnect: Nullable<() => void>;
  83611. /** @hidden */
  83612. _onVrDisplayPresentChange: Nullable<() => void>;
  83613. /**
  83614. * Observable signaled when VR display mode changes
  83615. */
  83616. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83617. /**
  83618. * Observable signaled when VR request present is complete
  83619. */
  83620. onVRRequestPresentComplete: Observable<boolean>;
  83621. /**
  83622. * Observable signaled when VR request present starts
  83623. */
  83624. onVRRequestPresentStart: Observable<Engine>;
  83625. /**
  83626. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83627. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83628. */
  83629. isInVRExclusivePointerMode: boolean;
  83630. /**
  83631. * Gets a boolean indicating if a webVR device was detected
  83632. * @returns true if a webVR device was detected
  83633. */
  83634. isVRDevicePresent(): boolean;
  83635. /**
  83636. * Gets the current webVR device
  83637. * @returns the current webVR device (or null)
  83638. */
  83639. getVRDevice(): any;
  83640. /**
  83641. * Initializes a webVR display and starts listening to display change events
  83642. * The onVRDisplayChangedObservable will be notified upon these changes
  83643. * @returns A promise containing a VRDisplay and if vr is supported
  83644. */
  83645. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83646. /** @hidden */
  83647. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83648. /**
  83649. * Gets or sets the presentation attributes used to configure VR rendering
  83650. */
  83651. vrPresentationAttributes?: IVRPresentationAttributes;
  83652. /**
  83653. * Call this function to switch to webVR mode
  83654. * Will do nothing if webVR is not supported or if there is no webVR device
  83655. * @param options the webvr options provided to the camera. mainly used for multiview
  83656. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83657. */
  83658. enableVR(options: WebVROptions): void;
  83659. /** @hidden */
  83660. _onVRFullScreenTriggered(): void;
  83661. }
  83662. }
  83663. declare module BABYLON {
  83664. /**
  83665. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83666. * IMPORTANT!! The data is right-hand data.
  83667. * @export
  83668. * @interface DevicePose
  83669. */
  83670. export interface DevicePose {
  83671. /**
  83672. * The position of the device, values in array are [x,y,z].
  83673. */
  83674. readonly position: Nullable<Float32Array>;
  83675. /**
  83676. * The linearVelocity of the device, values in array are [x,y,z].
  83677. */
  83678. readonly linearVelocity: Nullable<Float32Array>;
  83679. /**
  83680. * The linearAcceleration of the device, values in array are [x,y,z].
  83681. */
  83682. readonly linearAcceleration: Nullable<Float32Array>;
  83683. /**
  83684. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  83685. */
  83686. readonly orientation: Nullable<Float32Array>;
  83687. /**
  83688. * The angularVelocity of the device, values in array are [x,y,z].
  83689. */
  83690. readonly angularVelocity: Nullable<Float32Array>;
  83691. /**
  83692. * The angularAcceleration of the device, values in array are [x,y,z].
  83693. */
  83694. readonly angularAcceleration: Nullable<Float32Array>;
  83695. }
  83696. /**
  83697. * Interface representing a pose controlled object in Babylon.
  83698. * A pose controlled object has both regular pose values as well as pose values
  83699. * from an external device such as a VR head mounted display
  83700. */
  83701. export interface PoseControlled {
  83702. /**
  83703. * The position of the object in babylon space.
  83704. */
  83705. position: Vector3;
  83706. /**
  83707. * The rotation quaternion of the object in babylon space.
  83708. */
  83709. rotationQuaternion: Quaternion;
  83710. /**
  83711. * The position of the device in babylon space.
  83712. */
  83713. devicePosition?: Vector3;
  83714. /**
  83715. * The rotation quaternion of the device in babylon space.
  83716. */
  83717. deviceRotationQuaternion: Quaternion;
  83718. /**
  83719. * The raw pose coming from the device.
  83720. */
  83721. rawPose: Nullable<DevicePose>;
  83722. /**
  83723. * The scale of the device to be used when translating from device space to babylon space.
  83724. */
  83725. deviceScaleFactor: number;
  83726. /**
  83727. * Updates the poseControlled values based on the input device pose.
  83728. * @param poseData the pose data to update the object with
  83729. */
  83730. updateFromDevice(poseData: DevicePose): void;
  83731. }
  83732. /**
  83733. * Set of options to customize the webVRCamera
  83734. */
  83735. export interface WebVROptions {
  83736. /**
  83737. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  83738. */
  83739. trackPosition?: boolean;
  83740. /**
  83741. * Sets the scale of the vrDevice in babylon space. (default: 1)
  83742. */
  83743. positionScale?: number;
  83744. /**
  83745. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  83746. */
  83747. displayName?: string;
  83748. /**
  83749. * Should the native controller meshes be initialized. (default: true)
  83750. */
  83751. controllerMeshes?: boolean;
  83752. /**
  83753. * Creating a default HemiLight only on controllers. (default: true)
  83754. */
  83755. defaultLightingOnControllers?: boolean;
  83756. /**
  83757. * If you don't want to use the default VR button of the helper. (default: false)
  83758. */
  83759. useCustomVRButton?: boolean;
  83760. /**
  83761. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83762. */
  83763. customVRButton?: HTMLButtonElement;
  83764. /**
  83765. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83766. */
  83767. rayLength?: number;
  83768. /**
  83769. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83770. */
  83771. defaultHeight?: number;
  83772. /**
  83773. * If multiview should be used if availible (default: false)
  83774. */
  83775. useMultiview?: boolean;
  83776. }
  83777. /**
  83778. * This represents a WebVR camera.
  83779. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83780. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83781. */
  83782. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83783. private webVROptions;
  83784. /**
  83785. * @hidden
  83786. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83787. */
  83788. _vrDevice: any;
  83789. /**
  83790. * The rawPose of the vrDevice.
  83791. */
  83792. rawPose: Nullable<DevicePose>;
  83793. private _onVREnabled;
  83794. private _specsVersion;
  83795. private _attached;
  83796. private _frameData;
  83797. protected _descendants: Array<Node>;
  83798. private _deviceRoomPosition;
  83799. /** @hidden */
  83800. _deviceRoomRotationQuaternion: Quaternion;
  83801. private _standingMatrix;
  83802. /**
  83803. * Represents device position in babylon space.
  83804. */
  83805. devicePosition: Vector3;
  83806. /**
  83807. * Represents device rotation in babylon space.
  83808. */
  83809. deviceRotationQuaternion: Quaternion;
  83810. /**
  83811. * The scale of the device to be used when translating from device space to babylon space.
  83812. */
  83813. deviceScaleFactor: number;
  83814. private _deviceToWorld;
  83815. private _worldToDevice;
  83816. /**
  83817. * References to the webVR controllers for the vrDevice.
  83818. */
  83819. controllers: Array<WebVRController>;
  83820. /**
  83821. * Emits an event when a controller is attached.
  83822. */
  83823. onControllersAttachedObservable: Observable<WebVRController[]>;
  83824. /**
  83825. * Emits an event when a controller's mesh has been loaded;
  83826. */
  83827. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83828. /**
  83829. * Emits an event when the HMD's pose has been updated.
  83830. */
  83831. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83832. private _poseSet;
  83833. /**
  83834. * If the rig cameras be used as parent instead of this camera.
  83835. */
  83836. rigParenting: boolean;
  83837. private _lightOnControllers;
  83838. private _defaultHeight?;
  83839. /**
  83840. * Instantiates a WebVRFreeCamera.
  83841. * @param name The name of the WebVRFreeCamera
  83842. * @param position The starting anchor position for the camera
  83843. * @param scene The scene the camera belongs to
  83844. * @param webVROptions a set of customizable options for the webVRCamera
  83845. */
  83846. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83847. /**
  83848. * Gets the device distance from the ground in meters.
  83849. * @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.
  83850. */
  83851. deviceDistanceToRoomGround(): number;
  83852. /**
  83853. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83854. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83855. */
  83856. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83857. /**
  83858. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83859. * @returns A promise with a boolean set to if the standing matrix is supported.
  83860. */
  83861. useStandingMatrixAsync(): Promise<boolean>;
  83862. /**
  83863. * Disposes the camera
  83864. */
  83865. dispose(): void;
  83866. /**
  83867. * Gets a vrController by name.
  83868. * @param name The name of the controller to retreive
  83869. * @returns the controller matching the name specified or null if not found
  83870. */
  83871. getControllerByName(name: string): Nullable<WebVRController>;
  83872. private _leftController;
  83873. /**
  83874. * The controller corresponding to the users left hand.
  83875. */
  83876. readonly leftController: Nullable<WebVRController>;
  83877. private _rightController;
  83878. /**
  83879. * The controller corresponding to the users right hand.
  83880. */
  83881. readonly rightController: Nullable<WebVRController>;
  83882. /**
  83883. * Casts a ray forward from the vrCamera's gaze.
  83884. * @param length Length of the ray (default: 100)
  83885. * @returns the ray corresponding to the gaze
  83886. */
  83887. getForwardRay(length?: number): Ray;
  83888. /**
  83889. * @hidden
  83890. * Updates the camera based on device's frame data
  83891. */
  83892. _checkInputs(): void;
  83893. /**
  83894. * Updates the poseControlled values based on the input device pose.
  83895. * @param poseData Pose coming from the device
  83896. */
  83897. updateFromDevice(poseData: DevicePose): void;
  83898. private _htmlElementAttached;
  83899. private _detachIfAttached;
  83900. /**
  83901. * WebVR's attach control will start broadcasting frames to the device.
  83902. * Note that in certain browsers (chrome for example) this function must be called
  83903. * within a user-interaction callback. Example:
  83904. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83905. *
  83906. * @param element html element to attach the vrDevice to
  83907. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83908. */
  83909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83910. /**
  83911. * Detaches the camera from the html element and disables VR
  83912. *
  83913. * @param element html element to detach from
  83914. */
  83915. detachControl(element: HTMLElement): void;
  83916. /**
  83917. * @returns the name of this class
  83918. */
  83919. getClassName(): string;
  83920. /**
  83921. * Calls resetPose on the vrDisplay
  83922. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83923. */
  83924. resetToCurrentRotation(): void;
  83925. /**
  83926. * @hidden
  83927. * Updates the rig cameras (left and right eye)
  83928. */
  83929. _updateRigCameras(): void;
  83930. private _workingVector;
  83931. private _oneVector;
  83932. private _workingMatrix;
  83933. private updateCacheCalled;
  83934. private _correctPositionIfNotTrackPosition;
  83935. /**
  83936. * @hidden
  83937. * Updates the cached values of the camera
  83938. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83939. */
  83940. _updateCache(ignoreParentClass?: boolean): void;
  83941. /**
  83942. * @hidden
  83943. * Get current device position in babylon world
  83944. */
  83945. _computeDevicePosition(): void;
  83946. /**
  83947. * Updates the current device position and rotation in the babylon world
  83948. */
  83949. update(): void;
  83950. /**
  83951. * @hidden
  83952. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83953. * @returns an identity matrix
  83954. */
  83955. _getViewMatrix(): Matrix;
  83956. private _tmpMatrix;
  83957. /**
  83958. * This function is called by the two RIG cameras.
  83959. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83960. * @hidden
  83961. */
  83962. _getWebVRViewMatrix(): Matrix;
  83963. /** @hidden */
  83964. _getWebVRProjectionMatrix(): Matrix;
  83965. private _onGamepadConnectedObserver;
  83966. private _onGamepadDisconnectedObserver;
  83967. private _updateCacheWhenTrackingDisabledObserver;
  83968. /**
  83969. * Initializes the controllers and their meshes
  83970. */
  83971. initControllers(): void;
  83972. }
  83973. }
  83974. declare module BABYLON {
  83975. /**
  83976. * Size options for a post process
  83977. */
  83978. export type PostProcessOptions = {
  83979. width: number;
  83980. height: number;
  83981. };
  83982. /**
  83983. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83984. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83985. */
  83986. export class PostProcess {
  83987. /** Name of the PostProcess. */
  83988. name: string;
  83989. /**
  83990. * Gets or sets the unique id of the post process
  83991. */
  83992. uniqueId: number;
  83993. /**
  83994. * Width of the texture to apply the post process on
  83995. */
  83996. width: number;
  83997. /**
  83998. * Height of the texture to apply the post process on
  83999. */
  84000. height: number;
  84001. /**
  84002. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  84003. * @hidden
  84004. */
  84005. _outputTexture: Nullable<InternalTexture>;
  84006. /**
  84007. * Sampling mode used by the shader
  84008. * See https://doc.babylonjs.com/classes/3.1/texture
  84009. */
  84010. renderTargetSamplingMode: number;
  84011. /**
  84012. * Clear color to use when screen clearing
  84013. */
  84014. clearColor: Color4;
  84015. /**
  84016. * If the buffer needs to be cleared before applying the post process. (default: true)
  84017. * Should be set to false if shader will overwrite all previous pixels.
  84018. */
  84019. autoClear: boolean;
  84020. /**
  84021. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  84022. */
  84023. alphaMode: number;
  84024. /**
  84025. * Sets the setAlphaBlendConstants of the babylon engine
  84026. */
  84027. alphaConstants: Color4;
  84028. /**
  84029. * Animations to be used for the post processing
  84030. */
  84031. animations: Animation[];
  84032. /**
  84033. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  84034. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  84035. */
  84036. enablePixelPerfectMode: boolean;
  84037. /**
  84038. * Force the postprocess to be applied without taking in account viewport
  84039. */
  84040. forceFullscreenViewport: boolean;
  84041. /**
  84042. * List of inspectable custom properties (used by the Inspector)
  84043. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84044. */
  84045. inspectableCustomProperties: IInspectable[];
  84046. /**
  84047. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  84048. *
  84049. * | Value | Type | Description |
  84050. * | ----- | ----------------------------------- | ----------- |
  84051. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  84052. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  84053. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  84054. *
  84055. */
  84056. scaleMode: number;
  84057. /**
  84058. * Force textures to be a power of two (default: false)
  84059. */
  84060. alwaysForcePOT: boolean;
  84061. private _samples;
  84062. /**
  84063. * Number of sample textures (default: 1)
  84064. */
  84065. samples: number;
  84066. /**
  84067. * Modify the scale of the post process to be the same as the viewport (default: false)
  84068. */
  84069. adaptScaleToCurrentViewport: boolean;
  84070. private _camera;
  84071. private _scene;
  84072. private _engine;
  84073. private _options;
  84074. private _reusable;
  84075. private _textureType;
  84076. /**
  84077. * Smart array of input and output textures for the post process.
  84078. * @hidden
  84079. */
  84080. _textures: SmartArray<InternalTexture>;
  84081. /**
  84082. * The index in _textures that corresponds to the output texture.
  84083. * @hidden
  84084. */
  84085. _currentRenderTextureInd: number;
  84086. private _effect;
  84087. private _samplers;
  84088. private _fragmentUrl;
  84089. private _vertexUrl;
  84090. private _parameters;
  84091. private _scaleRatio;
  84092. protected _indexParameters: any;
  84093. private _shareOutputWithPostProcess;
  84094. private _texelSize;
  84095. private _forcedOutputTexture;
  84096. /**
  84097. * Returns the fragment url or shader name used in the post process.
  84098. * @returns the fragment url or name in the shader store.
  84099. */
  84100. getEffectName(): string;
  84101. /**
  84102. * An event triggered when the postprocess is activated.
  84103. */
  84104. onActivateObservable: Observable<Camera>;
  84105. private _onActivateObserver;
  84106. /**
  84107. * A function that is added to the onActivateObservable
  84108. */
  84109. onActivate: Nullable<(camera: Camera) => void>;
  84110. /**
  84111. * An event triggered when the postprocess changes its size.
  84112. */
  84113. onSizeChangedObservable: Observable<PostProcess>;
  84114. private _onSizeChangedObserver;
  84115. /**
  84116. * A function that is added to the onSizeChangedObservable
  84117. */
  84118. onSizeChanged: (postProcess: PostProcess) => void;
  84119. /**
  84120. * An event triggered when the postprocess applies its effect.
  84121. */
  84122. onApplyObservable: Observable<Effect>;
  84123. private _onApplyObserver;
  84124. /**
  84125. * A function that is added to the onApplyObservable
  84126. */
  84127. onApply: (effect: Effect) => void;
  84128. /**
  84129. * An event triggered before rendering the postprocess
  84130. */
  84131. onBeforeRenderObservable: Observable<Effect>;
  84132. private _onBeforeRenderObserver;
  84133. /**
  84134. * A function that is added to the onBeforeRenderObservable
  84135. */
  84136. onBeforeRender: (effect: Effect) => void;
  84137. /**
  84138. * An event triggered after rendering the postprocess
  84139. */
  84140. onAfterRenderObservable: Observable<Effect>;
  84141. private _onAfterRenderObserver;
  84142. /**
  84143. * A function that is added to the onAfterRenderObservable
  84144. */
  84145. onAfterRender: (efect: Effect) => void;
  84146. /**
  84147. * 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
  84148. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  84149. */
  84150. inputTexture: InternalTexture;
  84151. /**
  84152. * Gets the camera which post process is applied to.
  84153. * @returns The camera the post process is applied to.
  84154. */
  84155. getCamera(): Camera;
  84156. /**
  84157. * Gets the texel size of the postprocess.
  84158. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  84159. */
  84160. readonly texelSize: Vector2;
  84161. /**
  84162. * Creates a new instance PostProcess
  84163. * @param name The name of the PostProcess.
  84164. * @param fragmentUrl The url of the fragment shader to be used.
  84165. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  84166. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  84167. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84168. * @param camera The camera to apply the render pass to.
  84169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84170. * @param engine The engine which the post process will be applied. (default: current engine)
  84171. * @param reusable If the post process can be reused on the same frame. (default: false)
  84172. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  84173. * @param textureType Type of textures used when performing the post process. (default: 0)
  84174. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  84175. * @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
  84176. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  84177. */
  84178. constructor(
  84179. /** Name of the PostProcess. */
  84180. 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);
  84181. /**
  84182. * Gets a string idenfifying the name of the class
  84183. * @returns "PostProcess" string
  84184. */
  84185. getClassName(): string;
  84186. /**
  84187. * Gets the engine which this post process belongs to.
  84188. * @returns The engine the post process was enabled with.
  84189. */
  84190. getEngine(): Engine;
  84191. /**
  84192. * The effect that is created when initializing the post process.
  84193. * @returns The created effect corresponding the the postprocess.
  84194. */
  84195. getEffect(): Effect;
  84196. /**
  84197. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  84198. * @param postProcess The post process to share the output with.
  84199. * @returns This post process.
  84200. */
  84201. shareOutputWith(postProcess: PostProcess): PostProcess;
  84202. /**
  84203. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  84204. * This should be called if the post process that shares output with this post process is disabled/disposed.
  84205. */
  84206. useOwnOutput(): void;
  84207. /**
  84208. * Updates the effect with the current post process compile time values and recompiles the shader.
  84209. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84210. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84211. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84212. * @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
  84213. * @param onCompiled Called when the shader has been compiled.
  84214. * @param onError Called if there is an error when compiling a shader.
  84215. */
  84216. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84217. /**
  84218. * The post process is reusable if it can be used multiple times within one frame.
  84219. * @returns If the post process is reusable
  84220. */
  84221. isReusable(): boolean;
  84222. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  84223. markTextureDirty(): void;
  84224. /**
  84225. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  84226. * 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.
  84227. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  84228. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  84229. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  84230. * @returns The target texture that was bound to be written to.
  84231. */
  84232. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  84233. /**
  84234. * If the post process is supported.
  84235. */
  84236. readonly isSupported: boolean;
  84237. /**
  84238. * The aspect ratio of the output texture.
  84239. */
  84240. readonly aspectRatio: number;
  84241. /**
  84242. * Get a value indicating if the post-process is ready to be used
  84243. * @returns true if the post-process is ready (shader is compiled)
  84244. */
  84245. isReady(): boolean;
  84246. /**
  84247. * Binds all textures and uniforms to the shader, this will be run on every pass.
  84248. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  84249. */
  84250. apply(): Nullable<Effect>;
  84251. private _disposeTextures;
  84252. /**
  84253. * Disposes the post process.
  84254. * @param camera The camera to dispose the post process on.
  84255. */
  84256. dispose(camera?: Camera): void;
  84257. }
  84258. }
  84259. declare module BABYLON {
  84260. /** @hidden */
  84261. export var kernelBlurVaryingDeclaration: {
  84262. name: string;
  84263. shader: string;
  84264. };
  84265. }
  84266. declare module BABYLON {
  84267. /** @hidden */
  84268. export var kernelBlurFragment: {
  84269. name: string;
  84270. shader: string;
  84271. };
  84272. }
  84273. declare module BABYLON {
  84274. /** @hidden */
  84275. export var kernelBlurFragment2: {
  84276. name: string;
  84277. shader: string;
  84278. };
  84279. }
  84280. declare module BABYLON {
  84281. /** @hidden */
  84282. export var kernelBlurPixelShader: {
  84283. name: string;
  84284. shader: string;
  84285. };
  84286. }
  84287. declare module BABYLON {
  84288. /** @hidden */
  84289. export var kernelBlurVertex: {
  84290. name: string;
  84291. shader: string;
  84292. };
  84293. }
  84294. declare module BABYLON {
  84295. /** @hidden */
  84296. export var kernelBlurVertexShader: {
  84297. name: string;
  84298. shader: string;
  84299. };
  84300. }
  84301. declare module BABYLON {
  84302. /**
  84303. * The Blur Post Process which blurs an image based on a kernel and direction.
  84304. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  84305. */
  84306. export class BlurPostProcess extends PostProcess {
  84307. /** The direction in which to blur the image. */
  84308. direction: Vector2;
  84309. private blockCompilation;
  84310. protected _kernel: number;
  84311. protected _idealKernel: number;
  84312. protected _packedFloat: boolean;
  84313. private _staticDefines;
  84314. /**
  84315. * Sets the length in pixels of the blur sample region
  84316. */
  84317. /**
  84318. * Gets the length in pixels of the blur sample region
  84319. */
  84320. kernel: number;
  84321. /**
  84322. * Sets wether or not the blur needs to unpack/repack floats
  84323. */
  84324. /**
  84325. * Gets wether or not the blur is unpacking/repacking floats
  84326. */
  84327. packedFloat: boolean;
  84328. /**
  84329. * Creates a new instance BlurPostProcess
  84330. * @param name The name of the effect.
  84331. * @param direction The direction in which to blur the image.
  84332. * @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.
  84333. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84334. * @param camera The camera to apply the render pass to.
  84335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84336. * @param engine The engine which the post process will be applied. (default: current engine)
  84337. * @param reusable If the post process can be reused on the same frame. (default: false)
  84338. * @param textureType Type of textures used when performing the post process. (default: 0)
  84339. * @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)
  84340. */
  84341. constructor(name: string,
  84342. /** The direction in which to blur the image. */
  84343. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  84344. /**
  84345. * Updates the effect with the current post process compile time values and recompiles the shader.
  84346. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84347. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84348. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84349. * @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
  84350. * @param onCompiled Called when the shader has been compiled.
  84351. * @param onError Called if there is an error when compiling a shader.
  84352. */
  84353. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84354. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84355. /**
  84356. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  84357. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  84358. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  84359. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  84360. * The gaps between physical kernels are compensated for in the weighting of the samples
  84361. * @param idealKernel Ideal blur kernel.
  84362. * @return Nearest best kernel.
  84363. */
  84364. protected _nearestBestKernel(idealKernel: number): number;
  84365. /**
  84366. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  84367. * @param x The point on the Gaussian distribution to sample.
  84368. * @return the value of the Gaussian function at x.
  84369. */
  84370. protected _gaussianWeight(x: number): number;
  84371. /**
  84372. * Generates a string that can be used as a floating point number in GLSL.
  84373. * @param x Value to print.
  84374. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  84375. * @return GLSL float string.
  84376. */
  84377. protected _glslFloat(x: number, decimalFigures?: number): string;
  84378. }
  84379. }
  84380. declare module BABYLON {
  84381. /**
  84382. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84383. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84384. * You can then easily use it as a reflectionTexture on a flat surface.
  84385. * In case the surface is not a plane, please consider relying on reflection probes.
  84386. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84387. */
  84388. export class MirrorTexture extends RenderTargetTexture {
  84389. private scene;
  84390. /**
  84391. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  84392. * 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.
  84393. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84394. */
  84395. mirrorPlane: Plane;
  84396. /**
  84397. * Define the blur ratio used to blur the reflection if needed.
  84398. */
  84399. blurRatio: number;
  84400. /**
  84401. * Define the adaptive blur kernel used to blur the reflection if needed.
  84402. * This will autocompute the closest best match for the `blurKernel`
  84403. */
  84404. adaptiveBlurKernel: number;
  84405. /**
  84406. * Define the blur kernel used to blur the reflection if needed.
  84407. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84408. */
  84409. blurKernel: number;
  84410. /**
  84411. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  84412. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84413. */
  84414. blurKernelX: number;
  84415. /**
  84416. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  84417. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84418. */
  84419. blurKernelY: number;
  84420. private _autoComputeBlurKernel;
  84421. protected _onRatioRescale(): void;
  84422. private _updateGammaSpace;
  84423. private _imageProcessingConfigChangeObserver;
  84424. private _transformMatrix;
  84425. private _mirrorMatrix;
  84426. private _savedViewMatrix;
  84427. private _blurX;
  84428. private _blurY;
  84429. private _adaptiveBlurKernel;
  84430. private _blurKernelX;
  84431. private _blurKernelY;
  84432. private _blurRatio;
  84433. /**
  84434. * Instantiates a Mirror Texture.
  84435. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84436. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84437. * You can then easily use it as a reflectionTexture on a flat surface.
  84438. * In case the surface is not a plane, please consider relying on reflection probes.
  84439. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84440. * @param name
  84441. * @param size
  84442. * @param scene
  84443. * @param generateMipMaps
  84444. * @param type
  84445. * @param samplingMode
  84446. * @param generateDepthBuffer
  84447. */
  84448. constructor(name: string, size: number | {
  84449. width: number;
  84450. height: number;
  84451. } | {
  84452. ratio: number;
  84453. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  84454. private _preparePostProcesses;
  84455. /**
  84456. * Clone the mirror texture.
  84457. * @returns the cloned texture
  84458. */
  84459. clone(): MirrorTexture;
  84460. /**
  84461. * Serialize the texture to a JSON representation you could use in Parse later on
  84462. * @returns the serialized JSON representation
  84463. */
  84464. serialize(): any;
  84465. /**
  84466. * Dispose the texture and release its associated resources.
  84467. */
  84468. dispose(): void;
  84469. }
  84470. }
  84471. declare module BABYLON {
  84472. /**
  84473. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84474. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84475. */
  84476. export class Texture extends BaseTexture {
  84477. /**
  84478. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  84479. */
  84480. static SerializeBuffers: boolean;
  84481. /** @hidden */
  84482. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  84483. /** @hidden */
  84484. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  84485. /** @hidden */
  84486. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  84487. /** nearest is mag = nearest and min = nearest and mip = linear */
  84488. static readonly NEAREST_SAMPLINGMODE: number;
  84489. /** nearest is mag = nearest and min = nearest and mip = linear */
  84490. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  84491. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84492. static readonly BILINEAR_SAMPLINGMODE: number;
  84493. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84494. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  84495. /** Trilinear is mag = linear and min = linear and mip = linear */
  84496. static readonly TRILINEAR_SAMPLINGMODE: number;
  84497. /** Trilinear is mag = linear and min = linear and mip = linear */
  84498. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  84499. /** mag = nearest and min = nearest and mip = nearest */
  84500. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  84501. /** mag = nearest and min = linear and mip = nearest */
  84502. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  84503. /** mag = nearest and min = linear and mip = linear */
  84504. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  84505. /** mag = nearest and min = linear and mip = none */
  84506. static readonly NEAREST_LINEAR: number;
  84507. /** mag = nearest and min = nearest and mip = none */
  84508. static readonly NEAREST_NEAREST: number;
  84509. /** mag = linear and min = nearest and mip = nearest */
  84510. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  84511. /** mag = linear and min = nearest and mip = linear */
  84512. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  84513. /** mag = linear and min = linear and mip = none */
  84514. static readonly LINEAR_LINEAR: number;
  84515. /** mag = linear and min = nearest and mip = none */
  84516. static readonly LINEAR_NEAREST: number;
  84517. /** Explicit coordinates mode */
  84518. static readonly EXPLICIT_MODE: number;
  84519. /** Spherical coordinates mode */
  84520. static readonly SPHERICAL_MODE: number;
  84521. /** Planar coordinates mode */
  84522. static readonly PLANAR_MODE: number;
  84523. /** Cubic coordinates mode */
  84524. static readonly CUBIC_MODE: number;
  84525. /** Projection coordinates mode */
  84526. static readonly PROJECTION_MODE: number;
  84527. /** Inverse Cubic coordinates mode */
  84528. static readonly SKYBOX_MODE: number;
  84529. /** Inverse Cubic coordinates mode */
  84530. static readonly INVCUBIC_MODE: number;
  84531. /** Equirectangular coordinates mode */
  84532. static readonly EQUIRECTANGULAR_MODE: number;
  84533. /** Equirectangular Fixed coordinates mode */
  84534. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84535. /** Equirectangular Fixed Mirrored coordinates mode */
  84536. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84537. /** Texture is not repeating outside of 0..1 UVs */
  84538. static readonly CLAMP_ADDRESSMODE: number;
  84539. /** Texture is repeating outside of 0..1 UVs */
  84540. static readonly WRAP_ADDRESSMODE: number;
  84541. /** Texture is repeating and mirrored */
  84542. static readonly MIRROR_ADDRESSMODE: number;
  84543. /**
  84544. * 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
  84545. */
  84546. static UseSerializedUrlIfAny: boolean;
  84547. /**
  84548. * Define the url of the texture.
  84549. */
  84550. url: Nullable<string>;
  84551. /**
  84552. * Define an offset on the texture to offset the u coordinates of the UVs
  84553. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84554. */
  84555. uOffset: number;
  84556. /**
  84557. * Define an offset on the texture to offset the v coordinates of the UVs
  84558. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84559. */
  84560. vOffset: number;
  84561. /**
  84562. * Define an offset on the texture to scale the u coordinates of the UVs
  84563. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84564. */
  84565. uScale: number;
  84566. /**
  84567. * Define an offset on the texture to scale the v coordinates of the UVs
  84568. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84569. */
  84570. vScale: number;
  84571. /**
  84572. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84573. * @see http://doc.babylonjs.com/how_to/more_materials
  84574. */
  84575. uAng: number;
  84576. /**
  84577. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84578. * @see http://doc.babylonjs.com/how_to/more_materials
  84579. */
  84580. vAng: number;
  84581. /**
  84582. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84583. * @see http://doc.babylonjs.com/how_to/more_materials
  84584. */
  84585. wAng: number;
  84586. /**
  84587. * Defines the center of rotation (U)
  84588. */
  84589. uRotationCenter: number;
  84590. /**
  84591. * Defines the center of rotation (V)
  84592. */
  84593. vRotationCenter: number;
  84594. /**
  84595. * Defines the center of rotation (W)
  84596. */
  84597. wRotationCenter: number;
  84598. /**
  84599. * Are mip maps generated for this texture or not.
  84600. */
  84601. readonly noMipmap: boolean;
  84602. /**
  84603. * List of inspectable custom properties (used by the Inspector)
  84604. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84605. */
  84606. inspectableCustomProperties: Nullable<IInspectable[]>;
  84607. private _noMipmap;
  84608. /** @hidden */
  84609. _invertY: boolean;
  84610. private _rowGenerationMatrix;
  84611. private _cachedTextureMatrix;
  84612. private _projectionModeMatrix;
  84613. private _t0;
  84614. private _t1;
  84615. private _t2;
  84616. private _cachedUOffset;
  84617. private _cachedVOffset;
  84618. private _cachedUScale;
  84619. private _cachedVScale;
  84620. private _cachedUAng;
  84621. private _cachedVAng;
  84622. private _cachedWAng;
  84623. private _cachedProjectionMatrixId;
  84624. private _cachedCoordinatesMode;
  84625. /** @hidden */
  84626. protected _initialSamplingMode: number;
  84627. /** @hidden */
  84628. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84629. private _deleteBuffer;
  84630. protected _format: Nullable<number>;
  84631. private _delayedOnLoad;
  84632. private _delayedOnError;
  84633. private _mimeType?;
  84634. /**
  84635. * Observable triggered once the texture has been loaded.
  84636. */
  84637. onLoadObservable: Observable<Texture>;
  84638. protected _isBlocking: boolean;
  84639. /**
  84640. * Is the texture preventing material to render while loading.
  84641. * If false, a default texture will be used instead of the loading one during the preparation step.
  84642. */
  84643. isBlocking: boolean;
  84644. /**
  84645. * Get the current sampling mode associated with the texture.
  84646. */
  84647. readonly samplingMode: number;
  84648. /**
  84649. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84650. */
  84651. readonly invertY: boolean;
  84652. /**
  84653. * Instantiates a new texture.
  84654. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84655. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84656. * @param url defines the url of the picture to load as a texture
  84657. * @param scene defines the scene or engine the texture will belong to
  84658. * @param noMipmap defines if the texture will require mip maps or not
  84659. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84660. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84661. * @param onLoad defines a callback triggered when the texture has been loaded
  84662. * @param onError defines a callback triggered when an error occurred during the loading session
  84663. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84664. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84665. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84666. * @param mimeType defines an optional mime type information
  84667. */
  84668. 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);
  84669. /**
  84670. * Update the url (and optional buffer) of this texture if url was null during construction.
  84671. * @param url the url of the texture
  84672. * @param buffer the buffer of the texture (defaults to null)
  84673. * @param onLoad callback called when the texture is loaded (defaults to null)
  84674. */
  84675. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84676. /**
  84677. * Finish the loading sequence of a texture flagged as delayed load.
  84678. * @hidden
  84679. */
  84680. delayLoad(): void;
  84681. private _prepareRowForTextureGeneration;
  84682. /**
  84683. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  84684. * @returns the transform matrix of the texture.
  84685. */
  84686. getTextureMatrix(uBase?: number): Matrix;
  84687. /**
  84688. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  84689. * @returns The reflection texture transform
  84690. */
  84691. getReflectionTextureMatrix(): Matrix;
  84692. /**
  84693. * Clones the texture.
  84694. * @returns the cloned texture
  84695. */
  84696. clone(): Texture;
  84697. /**
  84698. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84699. * @returns The JSON representation of the texture
  84700. */
  84701. serialize(): any;
  84702. /**
  84703. * Get the current class name of the texture useful for serialization or dynamic coding.
  84704. * @returns "Texture"
  84705. */
  84706. getClassName(): string;
  84707. /**
  84708. * Dispose the texture and release its associated resources.
  84709. */
  84710. dispose(): void;
  84711. /**
  84712. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  84713. * @param parsedTexture Define the JSON representation of the texture
  84714. * @param scene Define the scene the parsed texture should be instantiated in
  84715. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  84716. * @returns The parsed texture if successful
  84717. */
  84718. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  84719. /**
  84720. * Creates a texture from its base 64 representation.
  84721. * @param data Define the base64 payload without the data: prefix
  84722. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84723. * @param scene Define the scene the texture should belong to
  84724. * @param noMipmap Forces the texture to not create mip map information if true
  84725. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84726. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84727. * @param onLoad define a callback triggered when the texture has been loaded
  84728. * @param onError define a callback triggered when an error occurred during the loading session
  84729. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84730. * @returns the created texture
  84731. */
  84732. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  84733. /**
  84734. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  84735. * @param data Define the base64 payload without the data: prefix
  84736. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84737. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  84738. * @param scene Define the scene the texture should belong to
  84739. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  84740. * @param noMipmap Forces the texture to not create mip map information if true
  84741. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84742. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84743. * @param onLoad define a callback triggered when the texture has been loaded
  84744. * @param onError define a callback triggered when an error occurred during the loading session
  84745. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84746. * @returns the created texture
  84747. */
  84748. 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;
  84749. }
  84750. }
  84751. declare module BABYLON {
  84752. /**
  84753. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84754. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84755. */
  84756. export class PostProcessManager {
  84757. private _scene;
  84758. private _indexBuffer;
  84759. private _vertexBuffers;
  84760. /**
  84761. * Creates a new instance PostProcess
  84762. * @param scene The scene that the post process is associated with.
  84763. */
  84764. constructor(scene: Scene);
  84765. private _prepareBuffers;
  84766. private _buildIndexBuffer;
  84767. /**
  84768. * Rebuilds the vertex buffers of the manager.
  84769. * @hidden
  84770. */
  84771. _rebuild(): void;
  84772. /**
  84773. * Prepares a frame to be run through a post process.
  84774. * @param sourceTexture The input texture to the post procesess. (default: null)
  84775. * @param postProcesses An array of post processes to be run. (default: null)
  84776. * @returns True if the post processes were able to be run.
  84777. * @hidden
  84778. */
  84779. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84780. /**
  84781. * Manually render a set of post processes to a texture.
  84782. * @param postProcesses An array of post processes to be run.
  84783. * @param targetTexture The target texture to render to.
  84784. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84785. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84786. * @param lodLevel defines which lod of the texture to render to
  84787. */
  84788. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84789. /**
  84790. * Finalize the result of the output of the postprocesses.
  84791. * @param doNotPresent If true the result will not be displayed to the screen.
  84792. * @param targetTexture The target texture to render to.
  84793. * @param faceIndex The index of the face to bind the target texture to.
  84794. * @param postProcesses The array of post processes to render.
  84795. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84796. * @hidden
  84797. */
  84798. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84799. /**
  84800. * Disposes of the post process manager.
  84801. */
  84802. dispose(): void;
  84803. }
  84804. }
  84805. declare module BABYLON {
  84806. /** Interface used by value gradients (color, factor, ...) */
  84807. export interface IValueGradient {
  84808. /**
  84809. * Gets or sets the gradient value (between 0 and 1)
  84810. */
  84811. gradient: number;
  84812. }
  84813. /** Class used to store color4 gradient */
  84814. export class ColorGradient implements IValueGradient {
  84815. /**
  84816. * Gets or sets the gradient value (between 0 and 1)
  84817. */
  84818. gradient: number;
  84819. /**
  84820. * Gets or sets first associated color
  84821. */
  84822. color1: Color4;
  84823. /**
  84824. * Gets or sets second associated color
  84825. */
  84826. color2?: Color4;
  84827. /**
  84828. * Will get a color picked randomly between color1 and color2.
  84829. * If color2 is undefined then color1 will be used
  84830. * @param result defines the target Color4 to store the result in
  84831. */
  84832. getColorToRef(result: Color4): void;
  84833. }
  84834. /** Class used to store color 3 gradient */
  84835. export class Color3Gradient implements IValueGradient {
  84836. /**
  84837. * Gets or sets the gradient value (between 0 and 1)
  84838. */
  84839. gradient: number;
  84840. /**
  84841. * Gets or sets the associated color
  84842. */
  84843. color: Color3;
  84844. }
  84845. /** Class used to store factor gradient */
  84846. export class FactorGradient implements IValueGradient {
  84847. /**
  84848. * Gets or sets the gradient value (between 0 and 1)
  84849. */
  84850. gradient: number;
  84851. /**
  84852. * Gets or sets first associated factor
  84853. */
  84854. factor1: number;
  84855. /**
  84856. * Gets or sets second associated factor
  84857. */
  84858. factor2?: number;
  84859. /**
  84860. * Will get a number picked randomly between factor1 and factor2.
  84861. * If factor2 is undefined then factor1 will be used
  84862. * @returns the picked number
  84863. */
  84864. getFactor(): number;
  84865. }
  84866. /**
  84867. * Helper used to simplify some generic gradient tasks
  84868. */
  84869. export class GradientHelper {
  84870. /**
  84871. * Gets the current gradient from an array of IValueGradient
  84872. * @param ratio defines the current ratio to get
  84873. * @param gradients defines the array of IValueGradient
  84874. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84875. */
  84876. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84877. }
  84878. }
  84879. declare module BABYLON {
  84880. interface ThinEngine {
  84881. /**
  84882. * Creates a dynamic texture
  84883. * @param width defines the width of the texture
  84884. * @param height defines the height of the texture
  84885. * @param generateMipMaps defines if the engine should generate the mip levels
  84886. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84887. * @returns the dynamic texture inside an InternalTexture
  84888. */
  84889. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84890. /**
  84891. * Update the content of a dynamic texture
  84892. * @param texture defines the texture to update
  84893. * @param canvas defines the canvas containing the source
  84894. * @param invertY defines if data must be stored with Y axis inverted
  84895. * @param premulAlpha defines if alpha is stored as premultiplied
  84896. * @param format defines the format of the data
  84897. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84898. */
  84899. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84900. }
  84901. }
  84902. declare module BABYLON {
  84903. /**
  84904. * Helper class used to generate a canvas to manipulate images
  84905. */
  84906. export class CanvasGenerator {
  84907. /**
  84908. * Create a new canvas (or offscreen canvas depending on the context)
  84909. * @param width defines the expected width
  84910. * @param height defines the expected height
  84911. * @return a new canvas or offscreen canvas
  84912. */
  84913. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84914. }
  84915. }
  84916. declare module BABYLON {
  84917. /**
  84918. * A class extending Texture allowing drawing on a texture
  84919. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84920. */
  84921. export class DynamicTexture extends Texture {
  84922. private _generateMipMaps;
  84923. private _canvas;
  84924. private _context;
  84925. private _engine;
  84926. /**
  84927. * Creates a DynamicTexture
  84928. * @param name defines the name of the texture
  84929. * @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
  84930. * @param scene defines the scene where you want the texture
  84931. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84932. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84933. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84934. */
  84935. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84936. /**
  84937. * Get the current class name of the texture useful for serialization or dynamic coding.
  84938. * @returns "DynamicTexture"
  84939. */
  84940. getClassName(): string;
  84941. /**
  84942. * Gets the current state of canRescale
  84943. */
  84944. readonly canRescale: boolean;
  84945. private _recreate;
  84946. /**
  84947. * Scales the texture
  84948. * @param ratio the scale factor to apply to both width and height
  84949. */
  84950. scale(ratio: number): void;
  84951. /**
  84952. * Resizes the texture
  84953. * @param width the new width
  84954. * @param height the new height
  84955. */
  84956. scaleTo(width: number, height: number): void;
  84957. /**
  84958. * Gets the context of the canvas used by the texture
  84959. * @returns the canvas context of the dynamic texture
  84960. */
  84961. getContext(): CanvasRenderingContext2D;
  84962. /**
  84963. * Clears the texture
  84964. */
  84965. clear(): void;
  84966. /**
  84967. * Updates the texture
  84968. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84969. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84970. */
  84971. update(invertY?: boolean, premulAlpha?: boolean): void;
  84972. /**
  84973. * Draws text onto the texture
  84974. * @param text defines the text to be drawn
  84975. * @param x defines the placement of the text from the left
  84976. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84977. * @param font defines the font to be used with font-style, font-size, font-name
  84978. * @param color defines the color used for the text
  84979. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84980. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84981. * @param update defines whether texture is immediately update (default is true)
  84982. */
  84983. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84984. /**
  84985. * Clones the texture
  84986. * @returns the clone of the texture.
  84987. */
  84988. clone(): DynamicTexture;
  84989. /**
  84990. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84991. * @returns a serialized dynamic texture object
  84992. */
  84993. serialize(): any;
  84994. /** @hidden */
  84995. _rebuild(): void;
  84996. }
  84997. }
  84998. declare module BABYLON {
  84999. interface AbstractScene {
  85000. /**
  85001. * The list of procedural textures added to the scene
  85002. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85003. */
  85004. proceduralTextures: Array<ProceduralTexture>;
  85005. }
  85006. /**
  85007. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85008. * in a given scene.
  85009. */
  85010. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85011. /**
  85012. * The component name helpfull to identify the component in the list of scene components.
  85013. */
  85014. readonly name: string;
  85015. /**
  85016. * The scene the component belongs to.
  85017. */
  85018. scene: Scene;
  85019. /**
  85020. * Creates a new instance of the component for the given scene
  85021. * @param scene Defines the scene to register the component in
  85022. */
  85023. constructor(scene: Scene);
  85024. /**
  85025. * Registers the component in a given scene
  85026. */
  85027. register(): void;
  85028. /**
  85029. * Rebuilds the elements related to this component in case of
  85030. * context lost for instance.
  85031. */
  85032. rebuild(): void;
  85033. /**
  85034. * Disposes the component and the associated ressources.
  85035. */
  85036. dispose(): void;
  85037. private _beforeClear;
  85038. }
  85039. }
  85040. declare module BABYLON {
  85041. interface ThinEngine {
  85042. /**
  85043. * Creates a new render target cube texture
  85044. * @param size defines the size of the texture
  85045. * @param options defines the options used to create the texture
  85046. * @returns a new render target cube texture stored in an InternalTexture
  85047. */
  85048. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85049. }
  85050. }
  85051. declare module BABYLON {
  85052. /** @hidden */
  85053. export var proceduralVertexShader: {
  85054. name: string;
  85055. shader: string;
  85056. };
  85057. }
  85058. declare module BABYLON {
  85059. /**
  85060. * 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.
  85061. * This is the base class of any Procedural texture and contains most of the shareable code.
  85062. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85063. */
  85064. export class ProceduralTexture extends Texture {
  85065. isCube: boolean;
  85066. /**
  85067. * Define if the texture is enabled or not (disabled texture will not render)
  85068. */
  85069. isEnabled: boolean;
  85070. /**
  85071. * Define if the texture must be cleared before rendering (default is true)
  85072. */
  85073. autoClear: boolean;
  85074. /**
  85075. * Callback called when the texture is generated
  85076. */
  85077. onGenerated: () => void;
  85078. /**
  85079. * Event raised when the texture is generated
  85080. */
  85081. onGeneratedObservable: Observable<ProceduralTexture>;
  85082. /** @hidden */
  85083. _generateMipMaps: boolean;
  85084. /** @hidden **/
  85085. _effect: Effect;
  85086. /** @hidden */
  85087. _textures: {
  85088. [key: string]: Texture;
  85089. };
  85090. private _size;
  85091. private _currentRefreshId;
  85092. private _refreshRate;
  85093. private _vertexBuffers;
  85094. private _indexBuffer;
  85095. private _uniforms;
  85096. private _samplers;
  85097. private _fragment;
  85098. private _floats;
  85099. private _ints;
  85100. private _floatsArrays;
  85101. private _colors3;
  85102. private _colors4;
  85103. private _vectors2;
  85104. private _vectors3;
  85105. private _matrices;
  85106. private _fallbackTexture;
  85107. private _fallbackTextureUsed;
  85108. private _engine;
  85109. private _cachedDefines;
  85110. private _contentUpdateId;
  85111. private _contentData;
  85112. /**
  85113. * Instantiates a new procedural texture.
  85114. * 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.
  85115. * This is the base class of any Procedural texture and contains most of the shareable code.
  85116. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85117. * @param name Define the name of the texture
  85118. * @param size Define the size of the texture to create
  85119. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85120. * @param scene Define the scene the texture belongs to
  85121. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85122. * @param generateMipMaps Define if the texture should creates mip maps or not
  85123. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85124. */
  85125. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85126. /**
  85127. * The effect that is created when initializing the post process.
  85128. * @returns The created effect corresponding the the postprocess.
  85129. */
  85130. getEffect(): Effect;
  85131. /**
  85132. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85133. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85134. */
  85135. getContent(): Nullable<ArrayBufferView>;
  85136. private _createIndexBuffer;
  85137. /** @hidden */
  85138. _rebuild(): void;
  85139. /**
  85140. * Resets the texture in order to recreate its associated resources.
  85141. * This can be called in case of context loss
  85142. */
  85143. reset(): void;
  85144. protected _getDefines(): string;
  85145. /**
  85146. * Is the texture ready to be used ? (rendered at least once)
  85147. * @returns true if ready, otherwise, false.
  85148. */
  85149. isReady(): boolean;
  85150. /**
  85151. * Resets the refresh counter of the texture and start bak from scratch.
  85152. * Could be useful to regenerate the texture if it is setup to render only once.
  85153. */
  85154. resetRefreshCounter(): void;
  85155. /**
  85156. * Set the fragment shader to use in order to render the texture.
  85157. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85158. */
  85159. setFragment(fragment: any): void;
  85160. /**
  85161. * Define the refresh rate of the texture or the rendering frequency.
  85162. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85163. */
  85164. refreshRate: number;
  85165. /** @hidden */
  85166. _shouldRender(): boolean;
  85167. /**
  85168. * Get the size the texture is rendering at.
  85169. * @returns the size (texture is always squared)
  85170. */
  85171. getRenderSize(): number;
  85172. /**
  85173. * Resize the texture to new value.
  85174. * @param size Define the new size the texture should have
  85175. * @param generateMipMaps Define whether the new texture should create mip maps
  85176. */
  85177. resize(size: number, generateMipMaps: boolean): void;
  85178. private _checkUniform;
  85179. /**
  85180. * Set a texture in the shader program used to render.
  85181. * @param name Define the name of the uniform samplers as defined in the shader
  85182. * @param texture Define the texture to bind to this sampler
  85183. * @return the texture itself allowing "fluent" like uniform updates
  85184. */
  85185. setTexture(name: string, texture: Texture): ProceduralTexture;
  85186. /**
  85187. * Set a float in the shader.
  85188. * @param name Define the name of the uniform as defined in the shader
  85189. * @param value Define the value to give to the uniform
  85190. * @return the texture itself allowing "fluent" like uniform updates
  85191. */
  85192. setFloat(name: string, value: number): ProceduralTexture;
  85193. /**
  85194. * Set a int in the shader.
  85195. * @param name Define the name of the uniform as defined in the shader
  85196. * @param value Define the value to give to the uniform
  85197. * @return the texture itself allowing "fluent" like uniform updates
  85198. */
  85199. setInt(name: string, value: number): ProceduralTexture;
  85200. /**
  85201. * Set an array of floats in the shader.
  85202. * @param name Define the name of the uniform as defined in the shader
  85203. * @param value Define the value to give to the uniform
  85204. * @return the texture itself allowing "fluent" like uniform updates
  85205. */
  85206. setFloats(name: string, value: number[]): ProceduralTexture;
  85207. /**
  85208. * Set a vec3 in the shader from a Color3.
  85209. * @param name Define the name of the uniform as defined in the shader
  85210. * @param value Define the value to give to the uniform
  85211. * @return the texture itself allowing "fluent" like uniform updates
  85212. */
  85213. setColor3(name: string, value: Color3): ProceduralTexture;
  85214. /**
  85215. * Set a vec4 in the shader from a Color4.
  85216. * @param name Define the name of the uniform as defined in the shader
  85217. * @param value Define the value to give to the uniform
  85218. * @return the texture itself allowing "fluent" like uniform updates
  85219. */
  85220. setColor4(name: string, value: Color4): ProceduralTexture;
  85221. /**
  85222. * Set a vec2 in the shader from a Vector2.
  85223. * @param name Define the name of the uniform as defined in the shader
  85224. * @param value Define the value to give to the uniform
  85225. * @return the texture itself allowing "fluent" like uniform updates
  85226. */
  85227. setVector2(name: string, value: Vector2): ProceduralTexture;
  85228. /**
  85229. * Set a vec3 in the shader from a Vector3.
  85230. * @param name Define the name of the uniform as defined in the shader
  85231. * @param value Define the value to give to the uniform
  85232. * @return the texture itself allowing "fluent" like uniform updates
  85233. */
  85234. setVector3(name: string, value: Vector3): ProceduralTexture;
  85235. /**
  85236. * Set a mat4 in the shader from a MAtrix.
  85237. * @param name Define the name of the uniform as defined in the shader
  85238. * @param value Define the value to give to the uniform
  85239. * @return the texture itself allowing "fluent" like uniform updates
  85240. */
  85241. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85242. /**
  85243. * Render the texture to its associated render target.
  85244. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85245. */
  85246. render(useCameraPostProcess?: boolean): void;
  85247. /**
  85248. * Clone the texture.
  85249. * @returns the cloned texture
  85250. */
  85251. clone(): ProceduralTexture;
  85252. /**
  85253. * Dispose the texture and release its asoociated resources.
  85254. */
  85255. dispose(): void;
  85256. }
  85257. }
  85258. declare module BABYLON {
  85259. /**
  85260. * This represents the base class for particle system in Babylon.
  85261. * 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.
  85262. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85263. * @example https://doc.babylonjs.com/babylon101/particles
  85264. */
  85265. export class BaseParticleSystem {
  85266. /**
  85267. * Source color is added to the destination color without alpha affecting the result
  85268. */
  85269. static BLENDMODE_ONEONE: number;
  85270. /**
  85271. * Blend current color and particle color using particle’s alpha
  85272. */
  85273. static BLENDMODE_STANDARD: number;
  85274. /**
  85275. * Add current color and particle color multiplied by particle’s alpha
  85276. */
  85277. static BLENDMODE_ADD: number;
  85278. /**
  85279. * Multiply current color with particle color
  85280. */
  85281. static BLENDMODE_MULTIPLY: number;
  85282. /**
  85283. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85284. */
  85285. static BLENDMODE_MULTIPLYADD: number;
  85286. /**
  85287. * List of animations used by the particle system.
  85288. */
  85289. animations: Animation[];
  85290. /**
  85291. * The id of the Particle system.
  85292. */
  85293. id: string;
  85294. /**
  85295. * The friendly name of the Particle system.
  85296. */
  85297. name: string;
  85298. /**
  85299. * The rendering group used by the Particle system to chose when to render.
  85300. */
  85301. renderingGroupId: number;
  85302. /**
  85303. * The emitter represents the Mesh or position we are attaching the particle system to.
  85304. */
  85305. emitter: Nullable<AbstractMesh | Vector3>;
  85306. /**
  85307. * The maximum number of particles to emit per frame
  85308. */
  85309. emitRate: number;
  85310. /**
  85311. * If you want to launch only a few particles at once, that can be done, as well.
  85312. */
  85313. manualEmitCount: number;
  85314. /**
  85315. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85316. */
  85317. updateSpeed: number;
  85318. /**
  85319. * The amount of time the particle system is running (depends of the overall update speed).
  85320. */
  85321. targetStopDuration: number;
  85322. /**
  85323. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85324. */
  85325. disposeOnStop: boolean;
  85326. /**
  85327. * Minimum power of emitting particles.
  85328. */
  85329. minEmitPower: number;
  85330. /**
  85331. * Maximum power of emitting particles.
  85332. */
  85333. maxEmitPower: number;
  85334. /**
  85335. * Minimum life time of emitting particles.
  85336. */
  85337. minLifeTime: number;
  85338. /**
  85339. * Maximum life time of emitting particles.
  85340. */
  85341. maxLifeTime: number;
  85342. /**
  85343. * Minimum Size of emitting particles.
  85344. */
  85345. minSize: number;
  85346. /**
  85347. * Maximum Size of emitting particles.
  85348. */
  85349. maxSize: number;
  85350. /**
  85351. * Minimum scale of emitting particles on X axis.
  85352. */
  85353. minScaleX: number;
  85354. /**
  85355. * Maximum scale of emitting particles on X axis.
  85356. */
  85357. maxScaleX: number;
  85358. /**
  85359. * Minimum scale of emitting particles on Y axis.
  85360. */
  85361. minScaleY: number;
  85362. /**
  85363. * Maximum scale of emitting particles on Y axis.
  85364. */
  85365. maxScaleY: number;
  85366. /**
  85367. * Gets or sets the minimal initial rotation in radians.
  85368. */
  85369. minInitialRotation: number;
  85370. /**
  85371. * Gets or sets the maximal initial rotation in radians.
  85372. */
  85373. maxInitialRotation: number;
  85374. /**
  85375. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85376. */
  85377. minAngularSpeed: number;
  85378. /**
  85379. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85380. */
  85381. maxAngularSpeed: number;
  85382. /**
  85383. * The texture used to render each particle. (this can be a spritesheet)
  85384. */
  85385. particleTexture: Nullable<Texture>;
  85386. /**
  85387. * The layer mask we are rendering the particles through.
  85388. */
  85389. layerMask: number;
  85390. /**
  85391. * This can help using your own shader to render the particle system.
  85392. * The according effect will be created
  85393. */
  85394. customShader: any;
  85395. /**
  85396. * By default particle system starts as soon as they are created. This prevents the
  85397. * automatic start to happen and let you decide when to start emitting particles.
  85398. */
  85399. preventAutoStart: boolean;
  85400. private _noiseTexture;
  85401. /**
  85402. * Gets or sets a texture used to add random noise to particle positions
  85403. */
  85404. noiseTexture: Nullable<ProceduralTexture>;
  85405. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85406. noiseStrength: Vector3;
  85407. /**
  85408. * Callback triggered when the particle animation is ending.
  85409. */
  85410. onAnimationEnd: Nullable<() => void>;
  85411. /**
  85412. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85413. */
  85414. blendMode: number;
  85415. /**
  85416. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85417. * to override the particles.
  85418. */
  85419. forceDepthWrite: boolean;
  85420. /** 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 */
  85421. preWarmCycles: number;
  85422. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85423. preWarmStepOffset: number;
  85424. /**
  85425. * 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)
  85426. */
  85427. spriteCellChangeSpeed: number;
  85428. /**
  85429. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85430. */
  85431. startSpriteCellID: number;
  85432. /**
  85433. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85434. */
  85435. endSpriteCellID: number;
  85436. /**
  85437. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85438. */
  85439. spriteCellWidth: number;
  85440. /**
  85441. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85442. */
  85443. spriteCellHeight: number;
  85444. /**
  85445. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85446. */
  85447. spriteRandomStartCell: boolean;
  85448. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85449. translationPivot: Vector2;
  85450. /** @hidden */
  85451. protected _isAnimationSheetEnabled: boolean;
  85452. /**
  85453. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85454. */
  85455. beginAnimationOnStart: boolean;
  85456. /**
  85457. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85458. */
  85459. beginAnimationFrom: number;
  85460. /**
  85461. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85462. */
  85463. beginAnimationTo: number;
  85464. /**
  85465. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85466. */
  85467. beginAnimationLoop: boolean;
  85468. /**
  85469. * Gets or sets a world offset applied to all particles
  85470. */
  85471. worldOffset: Vector3;
  85472. /**
  85473. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85474. */
  85475. isAnimationSheetEnabled: boolean;
  85476. /**
  85477. * Get hosting scene
  85478. * @returns the scene
  85479. */
  85480. getScene(): Scene;
  85481. /**
  85482. * You can use gravity if you want to give an orientation to your particles.
  85483. */
  85484. gravity: Vector3;
  85485. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85486. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85487. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85488. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85489. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85490. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85491. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85492. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85493. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85494. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85495. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85496. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85497. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85498. /**
  85499. * Defines the delay in milliseconds before starting the system (0 by default)
  85500. */
  85501. startDelay: number;
  85502. /**
  85503. * Gets the current list of drag gradients.
  85504. * You must use addDragGradient and removeDragGradient to udpate this list
  85505. * @returns the list of drag gradients
  85506. */
  85507. getDragGradients(): Nullable<Array<FactorGradient>>;
  85508. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85509. limitVelocityDamping: number;
  85510. /**
  85511. * Gets the current list of limit velocity gradients.
  85512. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85513. * @returns the list of limit velocity gradients
  85514. */
  85515. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85516. /**
  85517. * Gets the current list of color gradients.
  85518. * You must use addColorGradient and removeColorGradient to udpate this list
  85519. * @returns the list of color gradients
  85520. */
  85521. getColorGradients(): Nullable<Array<ColorGradient>>;
  85522. /**
  85523. * Gets the current list of size gradients.
  85524. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85525. * @returns the list of size gradients
  85526. */
  85527. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85528. /**
  85529. * Gets the current list of color remap gradients.
  85530. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85531. * @returns the list of color remap gradients
  85532. */
  85533. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85534. /**
  85535. * Gets the current list of alpha remap gradients.
  85536. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85537. * @returns the list of alpha remap gradients
  85538. */
  85539. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85540. /**
  85541. * Gets the current list of life time gradients.
  85542. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85543. * @returns the list of life time gradients
  85544. */
  85545. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85546. /**
  85547. * Gets the current list of angular speed gradients.
  85548. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85549. * @returns the list of angular speed gradients
  85550. */
  85551. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85552. /**
  85553. * Gets the current list of velocity gradients.
  85554. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85555. * @returns the list of velocity gradients
  85556. */
  85557. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85558. /**
  85559. * Gets the current list of start size gradients.
  85560. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85561. * @returns the list of start size gradients
  85562. */
  85563. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85564. /**
  85565. * Gets the current list of emit rate gradients.
  85566. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85567. * @returns the list of emit rate gradients
  85568. */
  85569. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85570. /**
  85571. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85572. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85573. */
  85574. direction1: Vector3;
  85575. /**
  85576. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85577. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85578. */
  85579. direction2: Vector3;
  85580. /**
  85581. * 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.
  85582. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85583. */
  85584. minEmitBox: Vector3;
  85585. /**
  85586. * 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.
  85587. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85588. */
  85589. maxEmitBox: Vector3;
  85590. /**
  85591. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85592. */
  85593. color1: Color4;
  85594. /**
  85595. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85596. */
  85597. color2: Color4;
  85598. /**
  85599. * Color the particle will have at the end of its lifetime
  85600. */
  85601. colorDead: Color4;
  85602. /**
  85603. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85604. */
  85605. textureMask: Color4;
  85606. /**
  85607. * The particle emitter type defines the emitter used by the particle system.
  85608. * It can be for example box, sphere, or cone...
  85609. */
  85610. particleEmitterType: IParticleEmitterType;
  85611. /** @hidden */
  85612. _isSubEmitter: boolean;
  85613. /**
  85614. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85615. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85616. */
  85617. billboardMode: number;
  85618. protected _isBillboardBased: boolean;
  85619. /**
  85620. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85621. */
  85622. isBillboardBased: boolean;
  85623. /**
  85624. * The scene the particle system belongs to.
  85625. */
  85626. protected _scene: Scene;
  85627. /**
  85628. * Local cache of defines for image processing.
  85629. */
  85630. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85631. /**
  85632. * Default configuration related to image processing available in the standard Material.
  85633. */
  85634. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85635. /**
  85636. * Gets the image processing configuration used either in this material.
  85637. */
  85638. /**
  85639. * Sets the Default image processing configuration used either in the this material.
  85640. *
  85641. * If sets to null, the scene one is in use.
  85642. */
  85643. imageProcessingConfiguration: ImageProcessingConfiguration;
  85644. /**
  85645. * Attaches a new image processing configuration to the Standard Material.
  85646. * @param configuration
  85647. */
  85648. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85649. /** @hidden */
  85650. protected _reset(): void;
  85651. /** @hidden */
  85652. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85653. /**
  85654. * Instantiates a particle system.
  85655. * 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.
  85656. * @param name The name of the particle system
  85657. */
  85658. constructor(name: string);
  85659. /**
  85660. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85661. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85662. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85663. * @returns the emitter
  85664. */
  85665. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85666. /**
  85667. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85668. * @param radius The radius of the hemisphere to emit from
  85669. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85670. * @returns the emitter
  85671. */
  85672. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85673. /**
  85674. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85675. * @param radius The radius of the sphere to emit from
  85676. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85677. * @returns the emitter
  85678. */
  85679. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85680. /**
  85681. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85682. * @param radius The radius of the sphere to emit from
  85683. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85684. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85685. * @returns the emitter
  85686. */
  85687. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85688. /**
  85689. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85690. * @param radius The radius of the emission cylinder
  85691. * @param height The height of the emission cylinder
  85692. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85693. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85694. * @returns the emitter
  85695. */
  85696. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85697. /**
  85698. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85699. * @param radius The radius of the cylinder to emit from
  85700. * @param height The height of the emission cylinder
  85701. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85702. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85703. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85704. * @returns the emitter
  85705. */
  85706. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85707. /**
  85708. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85709. * @param radius The radius of the cone to emit from
  85710. * @param angle The base angle of the cone
  85711. * @returns the emitter
  85712. */
  85713. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85714. /**
  85715. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85718. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85719. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85720. * @returns the emitter
  85721. */
  85722. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85723. }
  85724. }
  85725. declare module BABYLON {
  85726. /**
  85727. * Type of sub emitter
  85728. */
  85729. export enum SubEmitterType {
  85730. /**
  85731. * Attached to the particle over it's lifetime
  85732. */
  85733. ATTACHED = 0,
  85734. /**
  85735. * Created when the particle dies
  85736. */
  85737. END = 1
  85738. }
  85739. /**
  85740. * Sub emitter class used to emit particles from an existing particle
  85741. */
  85742. export class SubEmitter {
  85743. /**
  85744. * the particle system to be used by the sub emitter
  85745. */
  85746. particleSystem: ParticleSystem;
  85747. /**
  85748. * Type of the submitter (Default: END)
  85749. */
  85750. type: SubEmitterType;
  85751. /**
  85752. * 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)
  85753. * Note: This only is supported when using an emitter of type Mesh
  85754. */
  85755. inheritDirection: boolean;
  85756. /**
  85757. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85758. */
  85759. inheritedVelocityAmount: number;
  85760. /**
  85761. * Creates a sub emitter
  85762. * @param particleSystem the particle system to be used by the sub emitter
  85763. */
  85764. constructor(
  85765. /**
  85766. * the particle system to be used by the sub emitter
  85767. */
  85768. particleSystem: ParticleSystem);
  85769. /**
  85770. * Clones the sub emitter
  85771. * @returns the cloned sub emitter
  85772. */
  85773. clone(): SubEmitter;
  85774. /**
  85775. * Serialize current object to a JSON object
  85776. * @returns the serialized object
  85777. */
  85778. serialize(): any;
  85779. /** @hidden */
  85780. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85781. /**
  85782. * Creates a new SubEmitter from a serialized JSON version
  85783. * @param serializationObject defines the JSON object to read from
  85784. * @param scene defines the hosting scene
  85785. * @param rootUrl defines the rootUrl for data loading
  85786. * @returns a new SubEmitter
  85787. */
  85788. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85789. /** Release associated resources */
  85790. dispose(): void;
  85791. }
  85792. }
  85793. declare module BABYLON {
  85794. /** @hidden */
  85795. export var clipPlaneFragmentDeclaration: {
  85796. name: string;
  85797. shader: string;
  85798. };
  85799. }
  85800. declare module BABYLON {
  85801. /** @hidden */
  85802. export var imageProcessingDeclaration: {
  85803. name: string;
  85804. shader: string;
  85805. };
  85806. }
  85807. declare module BABYLON {
  85808. /** @hidden */
  85809. export var imageProcessingFunctions: {
  85810. name: string;
  85811. shader: string;
  85812. };
  85813. }
  85814. declare module BABYLON {
  85815. /** @hidden */
  85816. export var clipPlaneFragment: {
  85817. name: string;
  85818. shader: string;
  85819. };
  85820. }
  85821. declare module BABYLON {
  85822. /** @hidden */
  85823. export var particlesPixelShader: {
  85824. name: string;
  85825. shader: string;
  85826. };
  85827. }
  85828. declare module BABYLON {
  85829. /** @hidden */
  85830. export var clipPlaneVertexDeclaration: {
  85831. name: string;
  85832. shader: string;
  85833. };
  85834. }
  85835. declare module BABYLON {
  85836. /** @hidden */
  85837. export var clipPlaneVertex: {
  85838. name: string;
  85839. shader: string;
  85840. };
  85841. }
  85842. declare module BABYLON {
  85843. /** @hidden */
  85844. export var particlesVertexShader: {
  85845. name: string;
  85846. shader: string;
  85847. };
  85848. }
  85849. declare module BABYLON {
  85850. /**
  85851. * This represents a particle system in Babylon.
  85852. * 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.
  85853. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85854. * @example https://doc.babylonjs.com/babylon101/particles
  85855. */
  85856. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85857. /**
  85858. * Billboard mode will only apply to Y axis
  85859. */
  85860. static readonly BILLBOARDMODE_Y: number;
  85861. /**
  85862. * Billboard mode will apply to all axes
  85863. */
  85864. static readonly BILLBOARDMODE_ALL: number;
  85865. /**
  85866. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85867. */
  85868. static readonly BILLBOARDMODE_STRETCHED: number;
  85869. /**
  85870. * This function can be defined to provide custom update for active particles.
  85871. * This function will be called instead of regular update (age, position, color, etc.).
  85872. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85873. */
  85874. updateFunction: (particles: Particle[]) => void;
  85875. private _emitterWorldMatrix;
  85876. /**
  85877. * This function can be defined to specify initial direction for every new particle.
  85878. * It by default use the emitterType defined function
  85879. */
  85880. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85881. /**
  85882. * This function can be defined to specify initial position for every new particle.
  85883. * It by default use the emitterType defined function
  85884. */
  85885. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85886. /**
  85887. * @hidden
  85888. */
  85889. _inheritedVelocityOffset: Vector3;
  85890. /**
  85891. * An event triggered when the system is disposed
  85892. */
  85893. onDisposeObservable: Observable<ParticleSystem>;
  85894. private _onDisposeObserver;
  85895. /**
  85896. * Sets a callback that will be triggered when the system is disposed
  85897. */
  85898. onDispose: () => void;
  85899. private _particles;
  85900. private _epsilon;
  85901. private _capacity;
  85902. private _stockParticles;
  85903. private _newPartsExcess;
  85904. private _vertexData;
  85905. private _vertexBuffer;
  85906. private _vertexBuffers;
  85907. private _spriteBuffer;
  85908. private _indexBuffer;
  85909. private _effect;
  85910. private _customEffect;
  85911. private _cachedDefines;
  85912. private _scaledColorStep;
  85913. private _colorDiff;
  85914. private _scaledDirection;
  85915. private _scaledGravity;
  85916. private _currentRenderId;
  85917. private _alive;
  85918. private _useInstancing;
  85919. private _started;
  85920. private _stopped;
  85921. private _actualFrame;
  85922. private _scaledUpdateSpeed;
  85923. private _vertexBufferSize;
  85924. /** @hidden */
  85925. _currentEmitRateGradient: Nullable<FactorGradient>;
  85926. /** @hidden */
  85927. _currentEmitRate1: number;
  85928. /** @hidden */
  85929. _currentEmitRate2: number;
  85930. /** @hidden */
  85931. _currentStartSizeGradient: Nullable<FactorGradient>;
  85932. /** @hidden */
  85933. _currentStartSize1: number;
  85934. /** @hidden */
  85935. _currentStartSize2: number;
  85936. private readonly _rawTextureWidth;
  85937. private _rampGradientsTexture;
  85938. private _useRampGradients;
  85939. /** Gets or sets a boolean indicating that ramp gradients must be used
  85940. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85941. */
  85942. useRampGradients: boolean;
  85943. /**
  85944. * 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.
  85945. * 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: [])
  85946. */
  85947. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85948. private _subEmitters;
  85949. /**
  85950. * @hidden
  85951. * If the particle systems emitter should be disposed when the particle system is disposed
  85952. */
  85953. _disposeEmitterOnDispose: boolean;
  85954. /**
  85955. * The current active Sub-systems, this property is used by the root particle system only.
  85956. */
  85957. activeSubSystems: Array<ParticleSystem>;
  85958. private _rootParticleSystem;
  85959. /**
  85960. * Gets the current list of active particles
  85961. */
  85962. readonly particles: Particle[];
  85963. /**
  85964. * Returns the string "ParticleSystem"
  85965. * @returns a string containing the class name
  85966. */
  85967. getClassName(): string;
  85968. /**
  85969. * Instantiates a particle system.
  85970. * 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.
  85971. * @param name The name of the particle system
  85972. * @param capacity The max number of particles alive at the same time
  85973. * @param scene The scene the particle system belongs to
  85974. * @param customEffect a custom effect used to change the way particles are rendered by default
  85975. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85976. * @param epsilon Offset used to render the particles
  85977. */
  85978. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85979. private _addFactorGradient;
  85980. private _removeFactorGradient;
  85981. /**
  85982. * Adds a new life time gradient
  85983. * @param gradient defines the gradient to use (between 0 and 1)
  85984. * @param factor defines the life time factor to affect to the specified gradient
  85985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85986. * @returns the current particle system
  85987. */
  85988. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85989. /**
  85990. * Remove a specific life time gradient
  85991. * @param gradient defines the gradient to remove
  85992. * @returns the current particle system
  85993. */
  85994. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85995. /**
  85996. * Adds a new size gradient
  85997. * @param gradient defines the gradient to use (between 0 and 1)
  85998. * @param factor defines the size factor to affect to the specified gradient
  85999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86000. * @returns the current particle system
  86001. */
  86002. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86003. /**
  86004. * Remove a specific size gradient
  86005. * @param gradient defines the gradient to remove
  86006. * @returns the current particle system
  86007. */
  86008. removeSizeGradient(gradient: number): IParticleSystem;
  86009. /**
  86010. * Adds a new color remap gradient
  86011. * @param gradient defines the gradient to use (between 0 and 1)
  86012. * @param min defines the color remap minimal range
  86013. * @param max defines the color remap maximal range
  86014. * @returns the current particle system
  86015. */
  86016. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86017. /**
  86018. * Remove a specific color remap gradient
  86019. * @param gradient defines the gradient to remove
  86020. * @returns the current particle system
  86021. */
  86022. removeColorRemapGradient(gradient: number): IParticleSystem;
  86023. /**
  86024. * Adds a new alpha remap gradient
  86025. * @param gradient defines the gradient to use (between 0 and 1)
  86026. * @param min defines the alpha remap minimal range
  86027. * @param max defines the alpha remap maximal range
  86028. * @returns the current particle system
  86029. */
  86030. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86031. /**
  86032. * Remove a specific alpha remap gradient
  86033. * @param gradient defines the gradient to remove
  86034. * @returns the current particle system
  86035. */
  86036. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86037. /**
  86038. * Adds a new angular speed gradient
  86039. * @param gradient defines the gradient to use (between 0 and 1)
  86040. * @param factor defines the angular speed to affect to the specified gradient
  86041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86042. * @returns the current particle system
  86043. */
  86044. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86045. /**
  86046. * Remove a specific angular speed gradient
  86047. * @param gradient defines the gradient to remove
  86048. * @returns the current particle system
  86049. */
  86050. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86051. /**
  86052. * Adds a new velocity gradient
  86053. * @param gradient defines the gradient to use (between 0 and 1)
  86054. * @param factor defines the velocity to affect to the specified gradient
  86055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86056. * @returns the current particle system
  86057. */
  86058. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86059. /**
  86060. * Remove a specific velocity gradient
  86061. * @param gradient defines the gradient to remove
  86062. * @returns the current particle system
  86063. */
  86064. removeVelocityGradient(gradient: number): IParticleSystem;
  86065. /**
  86066. * Adds a new limit velocity gradient
  86067. * @param gradient defines the gradient to use (between 0 and 1)
  86068. * @param factor defines the limit velocity value to affect to the specified gradient
  86069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86070. * @returns the current particle system
  86071. */
  86072. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86073. /**
  86074. * Remove a specific limit velocity gradient
  86075. * @param gradient defines the gradient to remove
  86076. * @returns the current particle system
  86077. */
  86078. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86079. /**
  86080. * Adds a new drag gradient
  86081. * @param gradient defines the gradient to use (between 0 and 1)
  86082. * @param factor defines the drag value to affect to the specified gradient
  86083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86084. * @returns the current particle system
  86085. */
  86086. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86087. /**
  86088. * Remove a specific drag gradient
  86089. * @param gradient defines the gradient to remove
  86090. * @returns the current particle system
  86091. */
  86092. removeDragGradient(gradient: number): IParticleSystem;
  86093. /**
  86094. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86095. * @param gradient defines the gradient to use (between 0 and 1)
  86096. * @param factor defines the emit rate value to affect to the specified gradient
  86097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86098. * @returns the current particle system
  86099. */
  86100. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86101. /**
  86102. * Remove a specific emit rate gradient
  86103. * @param gradient defines the gradient to remove
  86104. * @returns the current particle system
  86105. */
  86106. removeEmitRateGradient(gradient: number): IParticleSystem;
  86107. /**
  86108. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86109. * @param gradient defines the gradient to use (between 0 and 1)
  86110. * @param factor defines the start size value to affect to the specified gradient
  86111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86112. * @returns the current particle system
  86113. */
  86114. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86115. /**
  86116. * Remove a specific start size gradient
  86117. * @param gradient defines the gradient to remove
  86118. * @returns the current particle system
  86119. */
  86120. removeStartSizeGradient(gradient: number): IParticleSystem;
  86121. private _createRampGradientTexture;
  86122. /**
  86123. * Gets the current list of ramp gradients.
  86124. * You must use addRampGradient and removeRampGradient to udpate this list
  86125. * @returns the list of ramp gradients
  86126. */
  86127. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86128. /**
  86129. * Adds a new ramp gradient used to remap particle colors
  86130. * @param gradient defines the gradient to use (between 0 and 1)
  86131. * @param color defines the color to affect to the specified gradient
  86132. * @returns the current particle system
  86133. */
  86134. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86135. /**
  86136. * Remove a specific ramp gradient
  86137. * @param gradient defines the gradient to remove
  86138. * @returns the current particle system
  86139. */
  86140. removeRampGradient(gradient: number): ParticleSystem;
  86141. /**
  86142. * Adds a new color gradient
  86143. * @param gradient defines the gradient to use (between 0 and 1)
  86144. * @param color1 defines the color to affect to the specified gradient
  86145. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86146. * @returns this particle system
  86147. */
  86148. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86149. /**
  86150. * Remove a specific color gradient
  86151. * @param gradient defines the gradient to remove
  86152. * @returns this particle system
  86153. */
  86154. removeColorGradient(gradient: number): IParticleSystem;
  86155. private _fetchR;
  86156. protected _reset(): void;
  86157. private _resetEffect;
  86158. private _createVertexBuffers;
  86159. private _createIndexBuffer;
  86160. /**
  86161. * Gets the maximum number of particles active at the same time.
  86162. * @returns The max number of active particles.
  86163. */
  86164. getCapacity(): number;
  86165. /**
  86166. * Gets whether there are still active particles in the system.
  86167. * @returns True if it is alive, otherwise false.
  86168. */
  86169. isAlive(): boolean;
  86170. /**
  86171. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86172. * @returns True if it has been started, otherwise false.
  86173. */
  86174. isStarted(): boolean;
  86175. private _prepareSubEmitterInternalArray;
  86176. /**
  86177. * Starts the particle system and begins to emit
  86178. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86179. */
  86180. start(delay?: number): void;
  86181. /**
  86182. * Stops the particle system.
  86183. * @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.
  86184. */
  86185. stop(stopSubEmitters?: boolean): void;
  86186. /**
  86187. * Remove all active particles
  86188. */
  86189. reset(): void;
  86190. /**
  86191. * @hidden (for internal use only)
  86192. */
  86193. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86194. /**
  86195. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86196. * Its lifetime will start back at 0.
  86197. */
  86198. recycleParticle: (particle: Particle) => void;
  86199. private _stopSubEmitters;
  86200. private _createParticle;
  86201. private _removeFromRoot;
  86202. private _emitFromParticle;
  86203. private _update;
  86204. /** @hidden */
  86205. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86206. /** @hidden */
  86207. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86208. /** @hidden */
  86209. private _getEffect;
  86210. /**
  86211. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86212. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86213. */
  86214. animate(preWarmOnly?: boolean): void;
  86215. private _appendParticleVertices;
  86216. /**
  86217. * Rebuilds the particle system.
  86218. */
  86219. rebuild(): void;
  86220. /**
  86221. * Is this system ready to be used/rendered
  86222. * @return true if the system is ready
  86223. */
  86224. isReady(): boolean;
  86225. private _render;
  86226. /**
  86227. * Renders the particle system in its current state.
  86228. * @returns the current number of particles
  86229. */
  86230. render(): number;
  86231. /**
  86232. * Disposes the particle system and free the associated resources
  86233. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86234. */
  86235. dispose(disposeTexture?: boolean): void;
  86236. /**
  86237. * Clones the particle system.
  86238. * @param name The name of the cloned object
  86239. * @param newEmitter The new emitter to use
  86240. * @returns the cloned particle system
  86241. */
  86242. clone(name: string, newEmitter: any): ParticleSystem;
  86243. /**
  86244. * Serializes the particle system to a JSON object.
  86245. * @returns the JSON object
  86246. */
  86247. serialize(): any;
  86248. /** @hidden */
  86249. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  86250. /** @hidden */
  86251. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86252. /**
  86253. * Parses a JSON object to create a particle system.
  86254. * @param parsedParticleSystem The JSON object to parse
  86255. * @param scene The scene to create the particle system in
  86256. * @param rootUrl The root url to use to load external dependencies like texture
  86257. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86258. * @returns the Parsed particle system
  86259. */
  86260. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86261. }
  86262. }
  86263. declare module BABYLON {
  86264. /**
  86265. * A particle represents one of the element emitted by a particle system.
  86266. * This is mainly define by its coordinates, direction, velocity and age.
  86267. */
  86268. export class Particle {
  86269. /**
  86270. * The particle system the particle belongs to.
  86271. */
  86272. particleSystem: ParticleSystem;
  86273. private static _Count;
  86274. /**
  86275. * Unique ID of the particle
  86276. */
  86277. id: number;
  86278. /**
  86279. * The world position of the particle in the scene.
  86280. */
  86281. position: Vector3;
  86282. /**
  86283. * The world direction of the particle in the scene.
  86284. */
  86285. direction: Vector3;
  86286. /**
  86287. * The color of the particle.
  86288. */
  86289. color: Color4;
  86290. /**
  86291. * The color change of the particle per step.
  86292. */
  86293. colorStep: Color4;
  86294. /**
  86295. * Defines how long will the life of the particle be.
  86296. */
  86297. lifeTime: number;
  86298. /**
  86299. * The current age of the particle.
  86300. */
  86301. age: number;
  86302. /**
  86303. * The current size of the particle.
  86304. */
  86305. size: number;
  86306. /**
  86307. * The current scale of the particle.
  86308. */
  86309. scale: Vector2;
  86310. /**
  86311. * The current angle of the particle.
  86312. */
  86313. angle: number;
  86314. /**
  86315. * Defines how fast is the angle changing.
  86316. */
  86317. angularSpeed: number;
  86318. /**
  86319. * Defines the cell index used by the particle to be rendered from a sprite.
  86320. */
  86321. cellIndex: number;
  86322. /**
  86323. * The information required to support color remapping
  86324. */
  86325. remapData: Vector4;
  86326. /** @hidden */
  86327. _randomCellOffset?: number;
  86328. /** @hidden */
  86329. _initialDirection: Nullable<Vector3>;
  86330. /** @hidden */
  86331. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86332. /** @hidden */
  86333. _initialStartSpriteCellID: number;
  86334. /** @hidden */
  86335. _initialEndSpriteCellID: number;
  86336. /** @hidden */
  86337. _currentColorGradient: Nullable<ColorGradient>;
  86338. /** @hidden */
  86339. _currentColor1: Color4;
  86340. /** @hidden */
  86341. _currentColor2: Color4;
  86342. /** @hidden */
  86343. _currentSizeGradient: Nullable<FactorGradient>;
  86344. /** @hidden */
  86345. _currentSize1: number;
  86346. /** @hidden */
  86347. _currentSize2: number;
  86348. /** @hidden */
  86349. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86350. /** @hidden */
  86351. _currentAngularSpeed1: number;
  86352. /** @hidden */
  86353. _currentAngularSpeed2: number;
  86354. /** @hidden */
  86355. _currentVelocityGradient: Nullable<FactorGradient>;
  86356. /** @hidden */
  86357. _currentVelocity1: number;
  86358. /** @hidden */
  86359. _currentVelocity2: number;
  86360. /** @hidden */
  86361. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86362. /** @hidden */
  86363. _currentLimitVelocity1: number;
  86364. /** @hidden */
  86365. _currentLimitVelocity2: number;
  86366. /** @hidden */
  86367. _currentDragGradient: Nullable<FactorGradient>;
  86368. /** @hidden */
  86369. _currentDrag1: number;
  86370. /** @hidden */
  86371. _currentDrag2: number;
  86372. /** @hidden */
  86373. _randomNoiseCoordinates1: Vector3;
  86374. /** @hidden */
  86375. _randomNoiseCoordinates2: Vector3;
  86376. /**
  86377. * Creates a new instance Particle
  86378. * @param particleSystem the particle system the particle belongs to
  86379. */
  86380. constructor(
  86381. /**
  86382. * The particle system the particle belongs to.
  86383. */
  86384. particleSystem: ParticleSystem);
  86385. private updateCellInfoFromSystem;
  86386. /**
  86387. * Defines how the sprite cell index is updated for the particle
  86388. */
  86389. updateCellIndex(): void;
  86390. /** @hidden */
  86391. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86392. /** @hidden */
  86393. _inheritParticleInfoToSubEmitters(): void;
  86394. /** @hidden */
  86395. _reset(): void;
  86396. /**
  86397. * Copy the properties of particle to another one.
  86398. * @param other the particle to copy the information to.
  86399. */
  86400. copyTo(other: Particle): void;
  86401. }
  86402. }
  86403. declare module BABYLON {
  86404. /**
  86405. * Particle emitter represents a volume emitting particles.
  86406. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86407. */
  86408. export interface IParticleEmitterType {
  86409. /**
  86410. * Called by the particle System when the direction is computed for the created particle.
  86411. * @param worldMatrix is the world matrix of the particle system
  86412. * @param directionToUpdate is the direction vector to update with the result
  86413. * @param particle is the particle we are computed the direction for
  86414. */
  86415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86416. /**
  86417. * Called by the particle System when the position is computed for the created particle.
  86418. * @param worldMatrix is the world matrix of the particle system
  86419. * @param positionToUpdate is the position vector to update with the result
  86420. * @param particle is the particle we are computed the position for
  86421. */
  86422. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86423. /**
  86424. * Clones the current emitter and returns a copy of it
  86425. * @returns the new emitter
  86426. */
  86427. clone(): IParticleEmitterType;
  86428. /**
  86429. * Called by the GPUParticleSystem to setup the update shader
  86430. * @param effect defines the update shader
  86431. */
  86432. applyToShader(effect: Effect): void;
  86433. /**
  86434. * Returns a string to use to update the GPU particles update shader
  86435. * @returns the effect defines string
  86436. */
  86437. getEffectDefines(): string;
  86438. /**
  86439. * Returns a string representing the class name
  86440. * @returns a string containing the class name
  86441. */
  86442. getClassName(): string;
  86443. /**
  86444. * Serializes the particle system to a JSON object.
  86445. * @returns the JSON object
  86446. */
  86447. serialize(): any;
  86448. /**
  86449. * Parse properties from a JSON object
  86450. * @param serializationObject defines the JSON object
  86451. */
  86452. parse(serializationObject: any): void;
  86453. }
  86454. }
  86455. declare module BABYLON {
  86456. /**
  86457. * Particle emitter emitting particles from the inside of a box.
  86458. * It emits the particles randomly between 2 given directions.
  86459. */
  86460. export class BoxParticleEmitter implements IParticleEmitterType {
  86461. /**
  86462. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86463. */
  86464. direction1: Vector3;
  86465. /**
  86466. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86467. */
  86468. direction2: Vector3;
  86469. /**
  86470. * 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.
  86471. */
  86472. minEmitBox: Vector3;
  86473. /**
  86474. * 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.
  86475. */
  86476. maxEmitBox: Vector3;
  86477. /**
  86478. * Creates a new instance BoxParticleEmitter
  86479. */
  86480. constructor();
  86481. /**
  86482. * Called by the particle System when the direction is computed for the created particle.
  86483. * @param worldMatrix is the world matrix of the particle system
  86484. * @param directionToUpdate is the direction vector to update with the result
  86485. * @param particle is the particle we are computed the direction for
  86486. */
  86487. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86488. /**
  86489. * Called by the particle System when the position is computed for the created particle.
  86490. * @param worldMatrix is the world matrix of the particle system
  86491. * @param positionToUpdate is the position vector to update with the result
  86492. * @param particle is the particle we are computed the position for
  86493. */
  86494. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86495. /**
  86496. * Clones the current emitter and returns a copy of it
  86497. * @returns the new emitter
  86498. */
  86499. clone(): BoxParticleEmitter;
  86500. /**
  86501. * Called by the GPUParticleSystem to setup the update shader
  86502. * @param effect defines the update shader
  86503. */
  86504. applyToShader(effect: Effect): void;
  86505. /**
  86506. * Returns a string to use to update the GPU particles update shader
  86507. * @returns a string containng the defines string
  86508. */
  86509. getEffectDefines(): string;
  86510. /**
  86511. * Returns the string "BoxParticleEmitter"
  86512. * @returns a string containing the class name
  86513. */
  86514. getClassName(): string;
  86515. /**
  86516. * Serializes the particle system to a JSON object.
  86517. * @returns the JSON object
  86518. */
  86519. serialize(): any;
  86520. /**
  86521. * Parse properties from a JSON object
  86522. * @param serializationObject defines the JSON object
  86523. */
  86524. parse(serializationObject: any): void;
  86525. }
  86526. }
  86527. declare module BABYLON {
  86528. /**
  86529. * Particle emitter emitting particles from the inside of a cone.
  86530. * It emits the particles alongside the cone volume from the base to the particle.
  86531. * The emission direction might be randomized.
  86532. */
  86533. export class ConeParticleEmitter implements IParticleEmitterType {
  86534. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86535. directionRandomizer: number;
  86536. private _radius;
  86537. private _angle;
  86538. private _height;
  86539. /**
  86540. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86541. */
  86542. radiusRange: number;
  86543. /**
  86544. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86545. */
  86546. heightRange: number;
  86547. /**
  86548. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86549. */
  86550. emitFromSpawnPointOnly: boolean;
  86551. /**
  86552. * Gets or sets the radius of the emission cone
  86553. */
  86554. radius: number;
  86555. /**
  86556. * Gets or sets the angle of the emission cone
  86557. */
  86558. angle: number;
  86559. private _buildHeight;
  86560. /**
  86561. * Creates a new instance ConeParticleEmitter
  86562. * @param radius the radius of the emission cone (1 by default)
  86563. * @param angle the cone base angle (PI by default)
  86564. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86565. */
  86566. constructor(radius?: number, angle?: number,
  86567. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86568. directionRandomizer?: number);
  86569. /**
  86570. * Called by the particle System when the direction is computed for the created particle.
  86571. * @param worldMatrix is the world matrix of the particle system
  86572. * @param directionToUpdate is the direction vector to update with the result
  86573. * @param particle is the particle we are computed the direction for
  86574. */
  86575. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86576. /**
  86577. * Called by the particle System when the position is computed for the created particle.
  86578. * @param worldMatrix is the world matrix of the particle system
  86579. * @param positionToUpdate is the position vector to update with the result
  86580. * @param particle is the particle we are computed the position for
  86581. */
  86582. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86583. /**
  86584. * Clones the current emitter and returns a copy of it
  86585. * @returns the new emitter
  86586. */
  86587. clone(): ConeParticleEmitter;
  86588. /**
  86589. * Called by the GPUParticleSystem to setup the update shader
  86590. * @param effect defines the update shader
  86591. */
  86592. applyToShader(effect: Effect): void;
  86593. /**
  86594. * Returns a string to use to update the GPU particles update shader
  86595. * @returns a string containng the defines string
  86596. */
  86597. getEffectDefines(): string;
  86598. /**
  86599. * Returns the string "ConeParticleEmitter"
  86600. * @returns a string containing the class name
  86601. */
  86602. getClassName(): string;
  86603. /**
  86604. * Serializes the particle system to a JSON object.
  86605. * @returns the JSON object
  86606. */
  86607. serialize(): any;
  86608. /**
  86609. * Parse properties from a JSON object
  86610. * @param serializationObject defines the JSON object
  86611. */
  86612. parse(serializationObject: any): void;
  86613. }
  86614. }
  86615. declare module BABYLON {
  86616. /**
  86617. * Particle emitter emitting particles from the inside of a cylinder.
  86618. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86619. */
  86620. export class CylinderParticleEmitter implements IParticleEmitterType {
  86621. /**
  86622. * The radius of the emission cylinder.
  86623. */
  86624. radius: number;
  86625. /**
  86626. * The height of the emission cylinder.
  86627. */
  86628. height: number;
  86629. /**
  86630. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86631. */
  86632. radiusRange: number;
  86633. /**
  86634. * How much to randomize the particle direction [0-1].
  86635. */
  86636. directionRandomizer: number;
  86637. /**
  86638. * Creates a new instance CylinderParticleEmitter
  86639. * @param radius the radius of the emission cylinder (1 by default)
  86640. * @param height the height of the emission cylinder (1 by default)
  86641. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86642. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86643. */
  86644. constructor(
  86645. /**
  86646. * The radius of the emission cylinder.
  86647. */
  86648. radius?: number,
  86649. /**
  86650. * The height of the emission cylinder.
  86651. */
  86652. height?: number,
  86653. /**
  86654. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86655. */
  86656. radiusRange?: number,
  86657. /**
  86658. * How much to randomize the particle direction [0-1].
  86659. */
  86660. directionRandomizer?: number);
  86661. /**
  86662. * Called by the particle System when the direction is computed for the created particle.
  86663. * @param worldMatrix is the world matrix of the particle system
  86664. * @param directionToUpdate is the direction vector to update with the result
  86665. * @param particle is the particle we are computed the direction for
  86666. */
  86667. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86668. /**
  86669. * Called by the particle System when the position is computed for the created particle.
  86670. * @param worldMatrix is the world matrix of the particle system
  86671. * @param positionToUpdate is the position vector to update with the result
  86672. * @param particle is the particle we are computed the position for
  86673. */
  86674. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86675. /**
  86676. * Clones the current emitter and returns a copy of it
  86677. * @returns the new emitter
  86678. */
  86679. clone(): CylinderParticleEmitter;
  86680. /**
  86681. * Called by the GPUParticleSystem to setup the update shader
  86682. * @param effect defines the update shader
  86683. */
  86684. applyToShader(effect: Effect): void;
  86685. /**
  86686. * Returns a string to use to update the GPU particles update shader
  86687. * @returns a string containng the defines string
  86688. */
  86689. getEffectDefines(): string;
  86690. /**
  86691. * Returns the string "CylinderParticleEmitter"
  86692. * @returns a string containing the class name
  86693. */
  86694. getClassName(): string;
  86695. /**
  86696. * Serializes the particle system to a JSON object.
  86697. * @returns the JSON object
  86698. */
  86699. serialize(): any;
  86700. /**
  86701. * Parse properties from a JSON object
  86702. * @param serializationObject defines the JSON object
  86703. */
  86704. parse(serializationObject: any): void;
  86705. }
  86706. /**
  86707. * Particle emitter emitting particles from the inside of a cylinder.
  86708. * It emits the particles randomly between two vectors.
  86709. */
  86710. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86711. /**
  86712. * The min limit of the emission direction.
  86713. */
  86714. direction1: Vector3;
  86715. /**
  86716. * The max limit of the emission direction.
  86717. */
  86718. direction2: Vector3;
  86719. /**
  86720. * Creates a new instance CylinderDirectedParticleEmitter
  86721. * @param radius the radius of the emission cylinder (1 by default)
  86722. * @param height the height of the emission cylinder (1 by default)
  86723. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86724. * @param direction1 the min limit of the emission direction (up vector by default)
  86725. * @param direction2 the max limit of the emission direction (up vector by default)
  86726. */
  86727. constructor(radius?: number, height?: number, radiusRange?: number,
  86728. /**
  86729. * The min limit of the emission direction.
  86730. */
  86731. direction1?: Vector3,
  86732. /**
  86733. * The max limit of the emission direction.
  86734. */
  86735. direction2?: Vector3);
  86736. /**
  86737. * Called by the particle System when the direction is computed for the created particle.
  86738. * @param worldMatrix is the world matrix of the particle system
  86739. * @param directionToUpdate is the direction vector to update with the result
  86740. * @param particle is the particle we are computed the direction for
  86741. */
  86742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86743. /**
  86744. * Clones the current emitter and returns a copy of it
  86745. * @returns the new emitter
  86746. */
  86747. clone(): CylinderDirectedParticleEmitter;
  86748. /**
  86749. * Called by the GPUParticleSystem to setup the update shader
  86750. * @param effect defines the update shader
  86751. */
  86752. applyToShader(effect: Effect): void;
  86753. /**
  86754. * Returns a string to use to update the GPU particles update shader
  86755. * @returns a string containng the defines string
  86756. */
  86757. getEffectDefines(): string;
  86758. /**
  86759. * Returns the string "CylinderDirectedParticleEmitter"
  86760. * @returns a string containing the class name
  86761. */
  86762. getClassName(): string;
  86763. /**
  86764. * Serializes the particle system to a JSON object.
  86765. * @returns the JSON object
  86766. */
  86767. serialize(): any;
  86768. /**
  86769. * Parse properties from a JSON object
  86770. * @param serializationObject defines the JSON object
  86771. */
  86772. parse(serializationObject: any): void;
  86773. }
  86774. }
  86775. declare module BABYLON {
  86776. /**
  86777. * Particle emitter emitting particles from the inside of a hemisphere.
  86778. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86779. */
  86780. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86781. /**
  86782. * The radius of the emission hemisphere.
  86783. */
  86784. radius: number;
  86785. /**
  86786. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86787. */
  86788. radiusRange: number;
  86789. /**
  86790. * How much to randomize the particle direction [0-1].
  86791. */
  86792. directionRandomizer: number;
  86793. /**
  86794. * Creates a new instance HemisphericParticleEmitter
  86795. * @param radius the radius of the emission hemisphere (1 by default)
  86796. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86797. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86798. */
  86799. constructor(
  86800. /**
  86801. * The radius of the emission hemisphere.
  86802. */
  86803. radius?: number,
  86804. /**
  86805. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86806. */
  86807. radiusRange?: number,
  86808. /**
  86809. * How much to randomize the particle direction [0-1].
  86810. */
  86811. directionRandomizer?: number);
  86812. /**
  86813. * Called by the particle System when the direction is computed for the created particle.
  86814. * @param worldMatrix is the world matrix of the particle system
  86815. * @param directionToUpdate is the direction vector to update with the result
  86816. * @param particle is the particle we are computed the direction for
  86817. */
  86818. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86819. /**
  86820. * Called by the particle System when the position is computed for the created particle.
  86821. * @param worldMatrix is the world matrix of the particle system
  86822. * @param positionToUpdate is the position vector to update with the result
  86823. * @param particle is the particle we are computed the position for
  86824. */
  86825. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86826. /**
  86827. * Clones the current emitter and returns a copy of it
  86828. * @returns the new emitter
  86829. */
  86830. clone(): HemisphericParticleEmitter;
  86831. /**
  86832. * Called by the GPUParticleSystem to setup the update shader
  86833. * @param effect defines the update shader
  86834. */
  86835. applyToShader(effect: Effect): void;
  86836. /**
  86837. * Returns a string to use to update the GPU particles update shader
  86838. * @returns a string containng the defines string
  86839. */
  86840. getEffectDefines(): string;
  86841. /**
  86842. * Returns the string "HemisphericParticleEmitter"
  86843. * @returns a string containing the class name
  86844. */
  86845. getClassName(): string;
  86846. /**
  86847. * Serializes the particle system to a JSON object.
  86848. * @returns the JSON object
  86849. */
  86850. serialize(): any;
  86851. /**
  86852. * Parse properties from a JSON object
  86853. * @param serializationObject defines the JSON object
  86854. */
  86855. parse(serializationObject: any): void;
  86856. }
  86857. }
  86858. declare module BABYLON {
  86859. /**
  86860. * Particle emitter emitting particles from a point.
  86861. * It emits the particles randomly between 2 given directions.
  86862. */
  86863. export class PointParticleEmitter implements IParticleEmitterType {
  86864. /**
  86865. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86866. */
  86867. direction1: Vector3;
  86868. /**
  86869. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86870. */
  86871. direction2: Vector3;
  86872. /**
  86873. * Creates a new instance PointParticleEmitter
  86874. */
  86875. constructor();
  86876. /**
  86877. * Called by the particle System when the direction is computed for the created particle.
  86878. * @param worldMatrix is the world matrix of the particle system
  86879. * @param directionToUpdate is the direction vector to update with the result
  86880. * @param particle is the particle we are computed the direction for
  86881. */
  86882. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86883. /**
  86884. * Called by the particle System when the position is computed for the created particle.
  86885. * @param worldMatrix is the world matrix of the particle system
  86886. * @param positionToUpdate is the position vector to update with the result
  86887. * @param particle is the particle we are computed the position for
  86888. */
  86889. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86890. /**
  86891. * Clones the current emitter and returns a copy of it
  86892. * @returns the new emitter
  86893. */
  86894. clone(): PointParticleEmitter;
  86895. /**
  86896. * Called by the GPUParticleSystem to setup the update shader
  86897. * @param effect defines the update shader
  86898. */
  86899. applyToShader(effect: Effect): void;
  86900. /**
  86901. * Returns a string to use to update the GPU particles update shader
  86902. * @returns a string containng the defines string
  86903. */
  86904. getEffectDefines(): string;
  86905. /**
  86906. * Returns the string "PointParticleEmitter"
  86907. * @returns a string containing the class name
  86908. */
  86909. getClassName(): string;
  86910. /**
  86911. * Serializes the particle system to a JSON object.
  86912. * @returns the JSON object
  86913. */
  86914. serialize(): any;
  86915. /**
  86916. * Parse properties from a JSON object
  86917. * @param serializationObject defines the JSON object
  86918. */
  86919. parse(serializationObject: any): void;
  86920. }
  86921. }
  86922. declare module BABYLON {
  86923. /**
  86924. * Particle emitter emitting particles from the inside of a sphere.
  86925. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86926. */
  86927. export class SphereParticleEmitter implements IParticleEmitterType {
  86928. /**
  86929. * The radius of the emission sphere.
  86930. */
  86931. radius: number;
  86932. /**
  86933. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86934. */
  86935. radiusRange: number;
  86936. /**
  86937. * How much to randomize the particle direction [0-1].
  86938. */
  86939. directionRandomizer: number;
  86940. /**
  86941. * Creates a new instance SphereParticleEmitter
  86942. * @param radius the radius of the emission sphere (1 by default)
  86943. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86944. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86945. */
  86946. constructor(
  86947. /**
  86948. * The radius of the emission sphere.
  86949. */
  86950. radius?: number,
  86951. /**
  86952. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86953. */
  86954. radiusRange?: number,
  86955. /**
  86956. * How much to randomize the particle direction [0-1].
  86957. */
  86958. directionRandomizer?: number);
  86959. /**
  86960. * Called by the particle System when the direction is computed for the created particle.
  86961. * @param worldMatrix is the world matrix of the particle system
  86962. * @param directionToUpdate is the direction vector to update with the result
  86963. * @param particle is the particle we are computed the direction for
  86964. */
  86965. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86966. /**
  86967. * Called by the particle System when the position is computed for the created particle.
  86968. * @param worldMatrix is the world matrix of the particle system
  86969. * @param positionToUpdate is the position vector to update with the result
  86970. * @param particle is the particle we are computed the position for
  86971. */
  86972. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86973. /**
  86974. * Clones the current emitter and returns a copy of it
  86975. * @returns the new emitter
  86976. */
  86977. clone(): SphereParticleEmitter;
  86978. /**
  86979. * Called by the GPUParticleSystem to setup the update shader
  86980. * @param effect defines the update shader
  86981. */
  86982. applyToShader(effect: Effect): void;
  86983. /**
  86984. * Returns a string to use to update the GPU particles update shader
  86985. * @returns a string containng the defines string
  86986. */
  86987. getEffectDefines(): string;
  86988. /**
  86989. * Returns the string "SphereParticleEmitter"
  86990. * @returns a string containing the class name
  86991. */
  86992. getClassName(): string;
  86993. /**
  86994. * Serializes the particle system to a JSON object.
  86995. * @returns the JSON object
  86996. */
  86997. serialize(): any;
  86998. /**
  86999. * Parse properties from a JSON object
  87000. * @param serializationObject defines the JSON object
  87001. */
  87002. parse(serializationObject: any): void;
  87003. }
  87004. /**
  87005. * Particle emitter emitting particles from the inside of a sphere.
  87006. * It emits the particles randomly between two vectors.
  87007. */
  87008. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87009. /**
  87010. * The min limit of the emission direction.
  87011. */
  87012. direction1: Vector3;
  87013. /**
  87014. * The max limit of the emission direction.
  87015. */
  87016. direction2: Vector3;
  87017. /**
  87018. * Creates a new instance SphereDirectedParticleEmitter
  87019. * @param radius the radius of the emission sphere (1 by default)
  87020. * @param direction1 the min limit of the emission direction (up vector by default)
  87021. * @param direction2 the max limit of the emission direction (up vector by default)
  87022. */
  87023. constructor(radius?: number,
  87024. /**
  87025. * The min limit of the emission direction.
  87026. */
  87027. direction1?: Vector3,
  87028. /**
  87029. * The max limit of the emission direction.
  87030. */
  87031. direction2?: Vector3);
  87032. /**
  87033. * Called by the particle System when the direction is computed for the created particle.
  87034. * @param worldMatrix is the world matrix of the particle system
  87035. * @param directionToUpdate is the direction vector to update with the result
  87036. * @param particle is the particle we are computed the direction for
  87037. */
  87038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87039. /**
  87040. * Clones the current emitter and returns a copy of it
  87041. * @returns the new emitter
  87042. */
  87043. clone(): SphereDirectedParticleEmitter;
  87044. /**
  87045. * Called by the GPUParticleSystem to setup the update shader
  87046. * @param effect defines the update shader
  87047. */
  87048. applyToShader(effect: Effect): void;
  87049. /**
  87050. * Returns a string to use to update the GPU particles update shader
  87051. * @returns a string containng the defines string
  87052. */
  87053. getEffectDefines(): string;
  87054. /**
  87055. * Returns the string "SphereDirectedParticleEmitter"
  87056. * @returns a string containing the class name
  87057. */
  87058. getClassName(): string;
  87059. /**
  87060. * Serializes the particle system to a JSON object.
  87061. * @returns the JSON object
  87062. */
  87063. serialize(): any;
  87064. /**
  87065. * Parse properties from a JSON object
  87066. * @param serializationObject defines the JSON object
  87067. */
  87068. parse(serializationObject: any): void;
  87069. }
  87070. }
  87071. declare module BABYLON {
  87072. /**
  87073. * Interface representing a particle system in Babylon.js.
  87074. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87075. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87076. */
  87077. export interface IParticleSystem {
  87078. /**
  87079. * List of animations used by the particle system.
  87080. */
  87081. animations: Animation[];
  87082. /**
  87083. * The id of the Particle system.
  87084. */
  87085. id: string;
  87086. /**
  87087. * The name of the Particle system.
  87088. */
  87089. name: string;
  87090. /**
  87091. * The emitter represents the Mesh or position we are attaching the particle system to.
  87092. */
  87093. emitter: Nullable<AbstractMesh | Vector3>;
  87094. /**
  87095. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87096. */
  87097. isBillboardBased: boolean;
  87098. /**
  87099. * The rendering group used by the Particle system to chose when to render.
  87100. */
  87101. renderingGroupId: number;
  87102. /**
  87103. * The layer mask we are rendering the particles through.
  87104. */
  87105. layerMask: number;
  87106. /**
  87107. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87108. */
  87109. updateSpeed: number;
  87110. /**
  87111. * The amount of time the particle system is running (depends of the overall update speed).
  87112. */
  87113. targetStopDuration: number;
  87114. /**
  87115. * The texture used to render each particle. (this can be a spritesheet)
  87116. */
  87117. particleTexture: Nullable<Texture>;
  87118. /**
  87119. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87120. */
  87121. blendMode: number;
  87122. /**
  87123. * Minimum life time of emitting particles.
  87124. */
  87125. minLifeTime: number;
  87126. /**
  87127. * Maximum life time of emitting particles.
  87128. */
  87129. maxLifeTime: number;
  87130. /**
  87131. * Minimum Size of emitting particles.
  87132. */
  87133. minSize: number;
  87134. /**
  87135. * Maximum Size of emitting particles.
  87136. */
  87137. maxSize: number;
  87138. /**
  87139. * Minimum scale of emitting particles on X axis.
  87140. */
  87141. minScaleX: number;
  87142. /**
  87143. * Maximum scale of emitting particles on X axis.
  87144. */
  87145. maxScaleX: number;
  87146. /**
  87147. * Minimum scale of emitting particles on Y axis.
  87148. */
  87149. minScaleY: number;
  87150. /**
  87151. * Maximum scale of emitting particles on Y axis.
  87152. */
  87153. maxScaleY: number;
  87154. /**
  87155. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87156. */
  87157. color1: Color4;
  87158. /**
  87159. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87160. */
  87161. color2: Color4;
  87162. /**
  87163. * Color the particle will have at the end of its lifetime.
  87164. */
  87165. colorDead: Color4;
  87166. /**
  87167. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87168. */
  87169. emitRate: number;
  87170. /**
  87171. * You can use gravity if you want to give an orientation to your particles.
  87172. */
  87173. gravity: Vector3;
  87174. /**
  87175. * Minimum power of emitting particles.
  87176. */
  87177. minEmitPower: number;
  87178. /**
  87179. * Maximum power of emitting particles.
  87180. */
  87181. maxEmitPower: number;
  87182. /**
  87183. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87184. */
  87185. minAngularSpeed: number;
  87186. /**
  87187. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87188. */
  87189. maxAngularSpeed: number;
  87190. /**
  87191. * Gets or sets the minimal initial rotation in radians.
  87192. */
  87193. minInitialRotation: number;
  87194. /**
  87195. * Gets or sets the maximal initial rotation in radians.
  87196. */
  87197. maxInitialRotation: number;
  87198. /**
  87199. * The particle emitter type defines the emitter used by the particle system.
  87200. * It can be for example box, sphere, or cone...
  87201. */
  87202. particleEmitterType: Nullable<IParticleEmitterType>;
  87203. /**
  87204. * Defines the delay in milliseconds before starting the system (0 by default)
  87205. */
  87206. startDelay: number;
  87207. /**
  87208. * 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
  87209. */
  87210. preWarmCycles: number;
  87211. /**
  87212. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87213. */
  87214. preWarmStepOffset: number;
  87215. /**
  87216. * 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)
  87217. */
  87218. spriteCellChangeSpeed: number;
  87219. /**
  87220. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87221. */
  87222. startSpriteCellID: number;
  87223. /**
  87224. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87225. */
  87226. endSpriteCellID: number;
  87227. /**
  87228. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87229. */
  87230. spriteCellWidth: number;
  87231. /**
  87232. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87233. */
  87234. spriteCellHeight: number;
  87235. /**
  87236. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87237. */
  87238. spriteRandomStartCell: boolean;
  87239. /**
  87240. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87241. */
  87242. isAnimationSheetEnabled: boolean;
  87243. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87244. translationPivot: Vector2;
  87245. /**
  87246. * Gets or sets a texture used to add random noise to particle positions
  87247. */
  87248. noiseTexture: Nullable<BaseTexture>;
  87249. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87250. noiseStrength: Vector3;
  87251. /**
  87252. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87253. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87254. */
  87255. billboardMode: number;
  87256. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87257. limitVelocityDamping: number;
  87258. /**
  87259. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87260. */
  87261. beginAnimationOnStart: boolean;
  87262. /**
  87263. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87264. */
  87265. beginAnimationFrom: number;
  87266. /**
  87267. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87268. */
  87269. beginAnimationTo: number;
  87270. /**
  87271. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87272. */
  87273. beginAnimationLoop: boolean;
  87274. /**
  87275. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87276. */
  87277. disposeOnStop: boolean;
  87278. /**
  87279. * Gets the maximum number of particles active at the same time.
  87280. * @returns The max number of active particles.
  87281. */
  87282. getCapacity(): number;
  87283. /**
  87284. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87285. * @returns True if it has been started, otherwise false.
  87286. */
  87287. isStarted(): boolean;
  87288. /**
  87289. * Animates the particle system for this frame.
  87290. */
  87291. animate(): void;
  87292. /**
  87293. * Renders the particle system in its current state.
  87294. * @returns the current number of particles
  87295. */
  87296. render(): number;
  87297. /**
  87298. * Dispose the particle system and frees its associated resources.
  87299. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87300. */
  87301. dispose(disposeTexture?: boolean): void;
  87302. /**
  87303. * Clones the particle system.
  87304. * @param name The name of the cloned object
  87305. * @param newEmitter The new emitter to use
  87306. * @returns the cloned particle system
  87307. */
  87308. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87309. /**
  87310. * Serializes the particle system to a JSON object.
  87311. * @returns the JSON object
  87312. */
  87313. serialize(): any;
  87314. /**
  87315. * Rebuild the particle system
  87316. */
  87317. rebuild(): void;
  87318. /**
  87319. * Starts the particle system and begins to emit
  87320. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87321. */
  87322. start(delay?: number): void;
  87323. /**
  87324. * Stops the particle system.
  87325. */
  87326. stop(): void;
  87327. /**
  87328. * Remove all active particles
  87329. */
  87330. reset(): void;
  87331. /**
  87332. * Is this system ready to be used/rendered
  87333. * @return true if the system is ready
  87334. */
  87335. isReady(): boolean;
  87336. /**
  87337. * Adds a new color gradient
  87338. * @param gradient defines the gradient to use (between 0 and 1)
  87339. * @param color1 defines the color to affect to the specified gradient
  87340. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87341. * @returns the current particle system
  87342. */
  87343. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87344. /**
  87345. * Remove a specific color gradient
  87346. * @param gradient defines the gradient to remove
  87347. * @returns the current particle system
  87348. */
  87349. removeColorGradient(gradient: number): IParticleSystem;
  87350. /**
  87351. * Adds a new size gradient
  87352. * @param gradient defines the gradient to use (between 0 and 1)
  87353. * @param factor defines the size factor to affect to the specified gradient
  87354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87355. * @returns the current particle system
  87356. */
  87357. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87358. /**
  87359. * Remove a specific size gradient
  87360. * @param gradient defines the gradient to remove
  87361. * @returns the current particle system
  87362. */
  87363. removeSizeGradient(gradient: number): IParticleSystem;
  87364. /**
  87365. * Gets the current list of color gradients.
  87366. * You must use addColorGradient and removeColorGradient to udpate this list
  87367. * @returns the list of color gradients
  87368. */
  87369. getColorGradients(): Nullable<Array<ColorGradient>>;
  87370. /**
  87371. * Gets the current list of size gradients.
  87372. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87373. * @returns the list of size gradients
  87374. */
  87375. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87376. /**
  87377. * Gets the current list of angular speed gradients.
  87378. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87379. * @returns the list of angular speed gradients
  87380. */
  87381. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87382. /**
  87383. * Adds a new angular speed gradient
  87384. * @param gradient defines the gradient to use (between 0 and 1)
  87385. * @param factor defines the angular speed to affect to the specified gradient
  87386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87387. * @returns the current particle system
  87388. */
  87389. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87390. /**
  87391. * Remove a specific angular speed gradient
  87392. * @param gradient defines the gradient to remove
  87393. * @returns the current particle system
  87394. */
  87395. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87396. /**
  87397. * Gets the current list of velocity gradients.
  87398. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87399. * @returns the list of velocity gradients
  87400. */
  87401. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87402. /**
  87403. * Adds a new velocity gradient
  87404. * @param gradient defines the gradient to use (between 0 and 1)
  87405. * @param factor defines the velocity to affect to the specified gradient
  87406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87407. * @returns the current particle system
  87408. */
  87409. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87410. /**
  87411. * Remove a specific velocity gradient
  87412. * @param gradient defines the gradient to remove
  87413. * @returns the current particle system
  87414. */
  87415. removeVelocityGradient(gradient: number): IParticleSystem;
  87416. /**
  87417. * Gets the current list of limit velocity gradients.
  87418. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87419. * @returns the list of limit velocity gradients
  87420. */
  87421. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87422. /**
  87423. * Adds a new limit velocity gradient
  87424. * @param gradient defines the gradient to use (between 0 and 1)
  87425. * @param factor defines the limit velocity to affect to the specified gradient
  87426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87427. * @returns the current particle system
  87428. */
  87429. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87430. /**
  87431. * Remove a specific limit velocity gradient
  87432. * @param gradient defines the gradient to remove
  87433. * @returns the current particle system
  87434. */
  87435. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87436. /**
  87437. * Adds a new drag gradient
  87438. * @param gradient defines the gradient to use (between 0 and 1)
  87439. * @param factor defines the drag to affect to the specified gradient
  87440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87441. * @returns the current particle system
  87442. */
  87443. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87444. /**
  87445. * Remove a specific drag gradient
  87446. * @param gradient defines the gradient to remove
  87447. * @returns the current particle system
  87448. */
  87449. removeDragGradient(gradient: number): IParticleSystem;
  87450. /**
  87451. * Gets the current list of drag gradients.
  87452. * You must use addDragGradient and removeDragGradient to udpate this list
  87453. * @returns the list of drag gradients
  87454. */
  87455. getDragGradients(): Nullable<Array<FactorGradient>>;
  87456. /**
  87457. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87458. * @param gradient defines the gradient to use (between 0 and 1)
  87459. * @param factor defines the emit rate to affect to the specified gradient
  87460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87461. * @returns the current particle system
  87462. */
  87463. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87464. /**
  87465. * Remove a specific emit rate gradient
  87466. * @param gradient defines the gradient to remove
  87467. * @returns the current particle system
  87468. */
  87469. removeEmitRateGradient(gradient: number): IParticleSystem;
  87470. /**
  87471. * Gets the current list of emit rate gradients.
  87472. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87473. * @returns the list of emit rate gradients
  87474. */
  87475. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87476. /**
  87477. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87478. * @param gradient defines the gradient to use (between 0 and 1)
  87479. * @param factor defines the start size to affect to the specified gradient
  87480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87481. * @returns the current particle system
  87482. */
  87483. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87484. /**
  87485. * Remove a specific start size gradient
  87486. * @param gradient defines the gradient to remove
  87487. * @returns the current particle system
  87488. */
  87489. removeStartSizeGradient(gradient: number): IParticleSystem;
  87490. /**
  87491. * Gets the current list of start size gradients.
  87492. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87493. * @returns the list of start size gradients
  87494. */
  87495. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87496. /**
  87497. * Adds a new life time gradient
  87498. * @param gradient defines the gradient to use (between 0 and 1)
  87499. * @param factor defines the life time factor to affect to the specified gradient
  87500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87501. * @returns the current particle system
  87502. */
  87503. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87504. /**
  87505. * Remove a specific life time gradient
  87506. * @param gradient defines the gradient to remove
  87507. * @returns the current particle system
  87508. */
  87509. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87510. /**
  87511. * Gets the current list of life time gradients.
  87512. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87513. * @returns the list of life time gradients
  87514. */
  87515. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87516. /**
  87517. * Gets the current list of color gradients.
  87518. * You must use addColorGradient and removeColorGradient to udpate this list
  87519. * @returns the list of color gradients
  87520. */
  87521. getColorGradients(): Nullable<Array<ColorGradient>>;
  87522. /**
  87523. * Adds a new ramp gradient used to remap particle colors
  87524. * @param gradient defines the gradient to use (between 0 and 1)
  87525. * @param color defines the color to affect to the specified gradient
  87526. * @returns the current particle system
  87527. */
  87528. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87529. /**
  87530. * Gets the current list of ramp gradients.
  87531. * You must use addRampGradient and removeRampGradient to udpate this list
  87532. * @returns the list of ramp gradients
  87533. */
  87534. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87535. /** Gets or sets a boolean indicating that ramp gradients must be used
  87536. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87537. */
  87538. useRampGradients: boolean;
  87539. /**
  87540. * Adds a new color remap gradient
  87541. * @param gradient defines the gradient to use (between 0 and 1)
  87542. * @param min defines the color remap minimal range
  87543. * @param max defines the color remap maximal range
  87544. * @returns the current particle system
  87545. */
  87546. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87547. /**
  87548. * Gets the current list of color remap gradients.
  87549. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87550. * @returns the list of color remap gradients
  87551. */
  87552. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87553. /**
  87554. * Adds a new alpha remap gradient
  87555. * @param gradient defines the gradient to use (between 0 and 1)
  87556. * @param min defines the alpha remap minimal range
  87557. * @param max defines the alpha remap maximal range
  87558. * @returns the current particle system
  87559. */
  87560. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87561. /**
  87562. * Gets the current list of alpha remap gradients.
  87563. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87564. * @returns the list of alpha remap gradients
  87565. */
  87566. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87567. /**
  87568. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87569. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87570. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87571. * @returns the emitter
  87572. */
  87573. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87574. /**
  87575. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87576. * @param radius The radius of the hemisphere to emit from
  87577. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87578. * @returns the emitter
  87579. */
  87580. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87581. /**
  87582. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87583. * @param radius The radius of the sphere to emit from
  87584. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87585. * @returns the emitter
  87586. */
  87587. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87588. /**
  87589. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87590. * @param radius The radius of the sphere to emit from
  87591. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87592. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87593. * @returns the emitter
  87594. */
  87595. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87596. /**
  87597. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87598. * @param radius The radius of the emission cylinder
  87599. * @param height The height of the emission cylinder
  87600. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87601. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87602. * @returns the emitter
  87603. */
  87604. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87605. /**
  87606. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87607. * @param radius The radius of the cylinder to emit from
  87608. * @param height The height of the emission cylinder
  87609. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87610. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87611. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87612. * @returns the emitter
  87613. */
  87614. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87615. /**
  87616. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87617. * @param radius The radius of the cone to emit from
  87618. * @param angle The base angle of the cone
  87619. * @returns the emitter
  87620. */
  87621. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87622. /**
  87623. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87624. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87625. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87626. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87627. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87628. * @returns the emitter
  87629. */
  87630. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87631. /**
  87632. * Get hosting scene
  87633. * @returns the scene
  87634. */
  87635. getScene(): Scene;
  87636. }
  87637. }
  87638. declare module BABYLON {
  87639. /**
  87640. * Creates an instance based on a source mesh.
  87641. */
  87642. export class InstancedMesh extends AbstractMesh {
  87643. private _sourceMesh;
  87644. private _currentLOD;
  87645. /** @hidden */
  87646. _indexInSourceMeshInstanceArray: number;
  87647. constructor(name: string, source: Mesh);
  87648. /**
  87649. * Returns the string "InstancedMesh".
  87650. */
  87651. getClassName(): string;
  87652. /** Gets the list of lights affecting that mesh */
  87653. readonly lightSources: Light[];
  87654. _resyncLightSources(): void;
  87655. _resyncLightSource(light: Light): void;
  87656. _removeLightSource(light: Light, dispose: boolean): void;
  87657. /**
  87658. * If the source mesh receives shadows
  87659. */
  87660. readonly receiveShadows: boolean;
  87661. /**
  87662. * The material of the source mesh
  87663. */
  87664. readonly material: Nullable<Material>;
  87665. /**
  87666. * Visibility of the source mesh
  87667. */
  87668. readonly visibility: number;
  87669. /**
  87670. * Skeleton of the source mesh
  87671. */
  87672. readonly skeleton: Nullable<Skeleton>;
  87673. /**
  87674. * Rendering ground id of the source mesh
  87675. */
  87676. renderingGroupId: number;
  87677. /**
  87678. * Returns the total number of vertices (integer).
  87679. */
  87680. getTotalVertices(): number;
  87681. /**
  87682. * Returns a positive integer : the total number of indices in this mesh geometry.
  87683. * @returns the numner of indices or zero if the mesh has no geometry.
  87684. */
  87685. getTotalIndices(): number;
  87686. /**
  87687. * The source mesh of the instance
  87688. */
  87689. readonly sourceMesh: Mesh;
  87690. /**
  87691. * Is this node ready to be used/rendered
  87692. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87693. * @return {boolean} is it ready
  87694. */
  87695. isReady(completeCheck?: boolean): boolean;
  87696. /**
  87697. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87698. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87699. * @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.
  87700. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87701. */
  87702. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87703. /**
  87704. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87705. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87706. * The `data` are either a numeric array either a Float32Array.
  87707. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87708. * 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).
  87709. * Note that a new underlying VertexBuffer object is created each call.
  87710. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87711. *
  87712. * Possible `kind` values :
  87713. * - VertexBuffer.PositionKind
  87714. * - VertexBuffer.UVKind
  87715. * - VertexBuffer.UV2Kind
  87716. * - VertexBuffer.UV3Kind
  87717. * - VertexBuffer.UV4Kind
  87718. * - VertexBuffer.UV5Kind
  87719. * - VertexBuffer.UV6Kind
  87720. * - VertexBuffer.ColorKind
  87721. * - VertexBuffer.MatricesIndicesKind
  87722. * - VertexBuffer.MatricesIndicesExtraKind
  87723. * - VertexBuffer.MatricesWeightsKind
  87724. * - VertexBuffer.MatricesWeightsExtraKind
  87725. *
  87726. * Returns the Mesh.
  87727. */
  87728. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87729. /**
  87730. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87731. * If the mesh has no geometry, it is simply returned as it is.
  87732. * The `data` are either a numeric array either a Float32Array.
  87733. * No new underlying VertexBuffer object is created.
  87734. * 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.
  87735. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87736. *
  87737. * Possible `kind` values :
  87738. * - VertexBuffer.PositionKind
  87739. * - VertexBuffer.UVKind
  87740. * - VertexBuffer.UV2Kind
  87741. * - VertexBuffer.UV3Kind
  87742. * - VertexBuffer.UV4Kind
  87743. * - VertexBuffer.UV5Kind
  87744. * - VertexBuffer.UV6Kind
  87745. * - VertexBuffer.ColorKind
  87746. * - VertexBuffer.MatricesIndicesKind
  87747. * - VertexBuffer.MatricesIndicesExtraKind
  87748. * - VertexBuffer.MatricesWeightsKind
  87749. * - VertexBuffer.MatricesWeightsExtraKind
  87750. *
  87751. * Returns the Mesh.
  87752. */
  87753. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87754. /**
  87755. * Sets the mesh indices.
  87756. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87757. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87758. * This method creates a new index buffer each call.
  87759. * Returns the Mesh.
  87760. */
  87761. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87762. /**
  87763. * Boolean : True if the mesh owns the requested kind of data.
  87764. */
  87765. isVerticesDataPresent(kind: string): boolean;
  87766. /**
  87767. * Returns an array of indices (IndicesArray).
  87768. */
  87769. getIndices(): Nullable<IndicesArray>;
  87770. readonly _positions: Nullable<Vector3[]>;
  87771. /**
  87772. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87773. * This means the mesh underlying bounding box and sphere are recomputed.
  87774. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87775. * @returns the current mesh
  87776. */
  87777. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87778. /** @hidden */
  87779. _preActivate(): InstancedMesh;
  87780. /** @hidden */
  87781. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87782. /** @hidden */
  87783. _postActivate(): void;
  87784. getWorldMatrix(): Matrix;
  87785. readonly isAnInstance: boolean;
  87786. /**
  87787. * Returns the current associated LOD AbstractMesh.
  87788. */
  87789. getLOD(camera: Camera): AbstractMesh;
  87790. /** @hidden */
  87791. _syncSubMeshes(): InstancedMesh;
  87792. /** @hidden */
  87793. _generatePointsArray(): boolean;
  87794. /**
  87795. * Creates a new InstancedMesh from the current mesh.
  87796. * - name (string) : the cloned mesh name
  87797. * - newParent (optional Node) : the optional Node to parent the clone to.
  87798. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87799. *
  87800. * Returns the clone.
  87801. */
  87802. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87803. /**
  87804. * Disposes the InstancedMesh.
  87805. * Returns nothing.
  87806. */
  87807. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87808. }
  87809. interface Mesh {
  87810. /**
  87811. * Register a custom buffer that will be instanced
  87812. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87813. * @param kind defines the buffer kind
  87814. * @param stride defines the stride in floats
  87815. */
  87816. registerInstancedBuffer(kind: string, stride: number): void;
  87817. /** @hidden */
  87818. _userInstancedBuffersStorage: {
  87819. data: {
  87820. [key: string]: Float32Array;
  87821. };
  87822. sizes: {
  87823. [key: string]: number;
  87824. };
  87825. vertexBuffers: {
  87826. [key: string]: Nullable<VertexBuffer>;
  87827. };
  87828. strides: {
  87829. [key: string]: number;
  87830. };
  87831. };
  87832. }
  87833. interface AbstractMesh {
  87834. /**
  87835. * Object used to store instanced buffers defined by user
  87836. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87837. */
  87838. instancedBuffers: {
  87839. [key: string]: any;
  87840. };
  87841. }
  87842. }
  87843. declare module BABYLON {
  87844. /**
  87845. * Defines the options associated with the creation of a shader material.
  87846. */
  87847. export interface IShaderMaterialOptions {
  87848. /**
  87849. * Does the material work in alpha blend mode
  87850. */
  87851. needAlphaBlending: boolean;
  87852. /**
  87853. * Does the material work in alpha test mode
  87854. */
  87855. needAlphaTesting: boolean;
  87856. /**
  87857. * The list of attribute names used in the shader
  87858. */
  87859. attributes: string[];
  87860. /**
  87861. * The list of unifrom names used in the shader
  87862. */
  87863. uniforms: string[];
  87864. /**
  87865. * The list of UBO names used in the shader
  87866. */
  87867. uniformBuffers: string[];
  87868. /**
  87869. * The list of sampler names used in the shader
  87870. */
  87871. samplers: string[];
  87872. /**
  87873. * The list of defines used in the shader
  87874. */
  87875. defines: string[];
  87876. }
  87877. /**
  87878. * 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.
  87879. *
  87880. * This returned material effects how the mesh will look based on the code in the shaders.
  87881. *
  87882. * @see http://doc.babylonjs.com/how_to/shader_material
  87883. */
  87884. export class ShaderMaterial extends Material {
  87885. private _shaderPath;
  87886. private _options;
  87887. private _textures;
  87888. private _textureArrays;
  87889. private _floats;
  87890. private _ints;
  87891. private _floatsArrays;
  87892. private _colors3;
  87893. private _colors3Arrays;
  87894. private _colors4;
  87895. private _colors4Arrays;
  87896. private _vectors2;
  87897. private _vectors3;
  87898. private _vectors4;
  87899. private _matrices;
  87900. private _matrixArrays;
  87901. private _matrices3x3;
  87902. private _matrices2x2;
  87903. private _vectors2Arrays;
  87904. private _vectors3Arrays;
  87905. private _vectors4Arrays;
  87906. private _cachedWorldViewMatrix;
  87907. private _cachedWorldViewProjectionMatrix;
  87908. private _renderId;
  87909. private _multiview;
  87910. /**
  87911. * Instantiate a new shader material.
  87912. * 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.
  87913. * This returned material effects how the mesh will look based on the code in the shaders.
  87914. * @see http://doc.babylonjs.com/how_to/shader_material
  87915. * @param name Define the name of the material in the scene
  87916. * @param scene Define the scene the material belongs to
  87917. * @param shaderPath Defines the route to the shader code in one of three ways:
  87918. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87919. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87920. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87921. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87922. * @param options Define the options used to create the shader
  87923. */
  87924. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87925. /**
  87926. * Gets the shader path used to define the shader code
  87927. * It can be modified to trigger a new compilation
  87928. */
  87929. /**
  87930. * Sets the shader path used to define the shader code
  87931. * It can be modified to trigger a new compilation
  87932. */
  87933. shaderPath: any;
  87934. /**
  87935. * Gets the options used to compile the shader.
  87936. * They can be modified to trigger a new compilation
  87937. */
  87938. readonly options: IShaderMaterialOptions;
  87939. /**
  87940. * Gets the current class name of the material e.g. "ShaderMaterial"
  87941. * Mainly use in serialization.
  87942. * @returns the class name
  87943. */
  87944. getClassName(): string;
  87945. /**
  87946. * Specifies if the material will require alpha blending
  87947. * @returns a boolean specifying if alpha blending is needed
  87948. */
  87949. needAlphaBlending(): boolean;
  87950. /**
  87951. * Specifies if this material should be rendered in alpha test mode
  87952. * @returns a boolean specifying if an alpha test is needed.
  87953. */
  87954. needAlphaTesting(): boolean;
  87955. private _checkUniform;
  87956. /**
  87957. * Set a texture in the shader.
  87958. * @param name Define the name of the uniform samplers as defined in the shader
  87959. * @param texture Define the texture to bind to this sampler
  87960. * @return the material itself allowing "fluent" like uniform updates
  87961. */
  87962. setTexture(name: string, texture: Texture): ShaderMaterial;
  87963. /**
  87964. * Set a texture array in the shader.
  87965. * @param name Define the name of the uniform sampler array as defined in the shader
  87966. * @param textures Define the list of textures to bind to this sampler
  87967. * @return the material itself allowing "fluent" like uniform updates
  87968. */
  87969. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87970. /**
  87971. * Set a float in the shader.
  87972. * @param name Define the name of the uniform as defined in the shader
  87973. * @param value Define the value to give to the uniform
  87974. * @return the material itself allowing "fluent" like uniform updates
  87975. */
  87976. setFloat(name: string, value: number): ShaderMaterial;
  87977. /**
  87978. * Set a int in the shader.
  87979. * @param name Define the name of the uniform as defined in the shader
  87980. * @param value Define the value to give to the uniform
  87981. * @return the material itself allowing "fluent" like uniform updates
  87982. */
  87983. setInt(name: string, value: number): ShaderMaterial;
  87984. /**
  87985. * Set an array of floats in the shader.
  87986. * @param name Define the name of the uniform as defined in the shader
  87987. * @param value Define the value to give to the uniform
  87988. * @return the material itself allowing "fluent" like uniform updates
  87989. */
  87990. setFloats(name: string, value: number[]): ShaderMaterial;
  87991. /**
  87992. * Set a vec3 in the shader from a Color3.
  87993. * @param name Define the name of the uniform as defined in the shader
  87994. * @param value Define the value to give to the uniform
  87995. * @return the material itself allowing "fluent" like uniform updates
  87996. */
  87997. setColor3(name: string, value: Color3): ShaderMaterial;
  87998. /**
  87999. * Set a vec3 array in the shader from a Color3 array.
  88000. * @param name Define the name of the uniform as defined in the shader
  88001. * @param value Define the value to give to the uniform
  88002. * @return the material itself allowing "fluent" like uniform updates
  88003. */
  88004. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88005. /**
  88006. * Set a vec4 in the shader from a Color4.
  88007. * @param name Define the name of the uniform as defined in the shader
  88008. * @param value Define the value to give to the uniform
  88009. * @return the material itself allowing "fluent" like uniform updates
  88010. */
  88011. setColor4(name: string, value: Color4): ShaderMaterial;
  88012. /**
  88013. * Set a vec4 array in the shader from a Color4 array.
  88014. * @param name Define the name of the uniform as defined in the shader
  88015. * @param value Define the value to give to the uniform
  88016. * @return the material itself allowing "fluent" like uniform updates
  88017. */
  88018. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88019. /**
  88020. * Set a vec2 in the shader from a Vector2.
  88021. * @param name Define the name of the uniform as defined in the shader
  88022. * @param value Define the value to give to the uniform
  88023. * @return the material itself allowing "fluent" like uniform updates
  88024. */
  88025. setVector2(name: string, value: Vector2): ShaderMaterial;
  88026. /**
  88027. * Set a vec3 in the shader from a Vector3.
  88028. * @param name Define the name of the uniform as defined in the shader
  88029. * @param value Define the value to give to the uniform
  88030. * @return the material itself allowing "fluent" like uniform updates
  88031. */
  88032. setVector3(name: string, value: Vector3): ShaderMaterial;
  88033. /**
  88034. * Set a vec4 in the shader from a Vector4.
  88035. * @param name Define the name of the uniform as defined in the shader
  88036. * @param value Define the value to give to the uniform
  88037. * @return the material itself allowing "fluent" like uniform updates
  88038. */
  88039. setVector4(name: string, value: Vector4): ShaderMaterial;
  88040. /**
  88041. * Set a mat4 in the shader from a Matrix.
  88042. * @param name Define the name of the uniform as defined in the shader
  88043. * @param value Define the value to give to the uniform
  88044. * @return the material itself allowing "fluent" like uniform updates
  88045. */
  88046. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88047. /**
  88048. * Set a float32Array in the shader from a matrix array.
  88049. * @param name Define the name of the uniform as defined in the shader
  88050. * @param value Define the value to give to the uniform
  88051. * @return the material itself allowing "fluent" like uniform updates
  88052. */
  88053. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88054. /**
  88055. * Set a mat3 in the shader from a Float32Array.
  88056. * @param name Define the name of the uniform as defined in the shader
  88057. * @param value Define the value to give to the uniform
  88058. * @return the material itself allowing "fluent" like uniform updates
  88059. */
  88060. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88061. /**
  88062. * Set a mat2 in the shader from a Float32Array.
  88063. * @param name Define the name of the uniform as defined in the shader
  88064. * @param value Define the value to give to the uniform
  88065. * @return the material itself allowing "fluent" like uniform updates
  88066. */
  88067. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88068. /**
  88069. * Set a vec2 array in the shader from a number array.
  88070. * @param name Define the name of the uniform as defined in the shader
  88071. * @param value Define the value to give to the uniform
  88072. * @return the material itself allowing "fluent" like uniform updates
  88073. */
  88074. setArray2(name: string, value: number[]): ShaderMaterial;
  88075. /**
  88076. * Set a vec3 array in the shader from a number array.
  88077. * @param name Define the name of the uniform as defined in the shader
  88078. * @param value Define the value to give to the uniform
  88079. * @return the material itself allowing "fluent" like uniform updates
  88080. */
  88081. setArray3(name: string, value: number[]): ShaderMaterial;
  88082. /**
  88083. * Set a vec4 array in the shader from a number array.
  88084. * @param name Define the name of the uniform as defined in the shader
  88085. * @param value Define the value to give to the uniform
  88086. * @return the material itself allowing "fluent" like uniform updates
  88087. */
  88088. setArray4(name: string, value: number[]): ShaderMaterial;
  88089. private _checkCache;
  88090. /**
  88091. * Specifies that the submesh is ready to be used
  88092. * @param mesh defines the mesh to check
  88093. * @param subMesh defines which submesh to check
  88094. * @param useInstances specifies that instances should be used
  88095. * @returns a boolean indicating that the submesh is ready or not
  88096. */
  88097. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88098. /**
  88099. * Checks if the material is ready to render the requested mesh
  88100. * @param mesh Define the mesh to render
  88101. * @param useInstances Define whether or not the material is used with instances
  88102. * @returns true if ready, otherwise false
  88103. */
  88104. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88105. /**
  88106. * Binds the world matrix to the material
  88107. * @param world defines the world transformation matrix
  88108. */
  88109. bindOnlyWorldMatrix(world: Matrix): void;
  88110. /**
  88111. * Binds the material to the mesh
  88112. * @param world defines the world transformation matrix
  88113. * @param mesh defines the mesh to bind the material to
  88114. */
  88115. bind(world: Matrix, mesh?: Mesh): void;
  88116. /**
  88117. * Gets the active textures from the material
  88118. * @returns an array of textures
  88119. */
  88120. getActiveTextures(): BaseTexture[];
  88121. /**
  88122. * Specifies if the material uses a texture
  88123. * @param texture defines the texture to check against the material
  88124. * @returns a boolean specifying if the material uses the texture
  88125. */
  88126. hasTexture(texture: BaseTexture): boolean;
  88127. /**
  88128. * Makes a duplicate of the material, and gives it a new name
  88129. * @param name defines the new name for the duplicated material
  88130. * @returns the cloned material
  88131. */
  88132. clone(name: string): ShaderMaterial;
  88133. /**
  88134. * Disposes the material
  88135. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88136. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88137. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88138. */
  88139. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88140. /**
  88141. * Serializes this material in a JSON representation
  88142. * @returns the serialized material object
  88143. */
  88144. serialize(): any;
  88145. /**
  88146. * Creates a shader material from parsed shader material data
  88147. * @param source defines the JSON represnetation of the material
  88148. * @param scene defines the hosting scene
  88149. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88150. * @returns a new material
  88151. */
  88152. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88153. }
  88154. }
  88155. declare module BABYLON {
  88156. /** @hidden */
  88157. export var colorPixelShader: {
  88158. name: string;
  88159. shader: string;
  88160. };
  88161. }
  88162. declare module BABYLON {
  88163. /** @hidden */
  88164. export var colorVertexShader: {
  88165. name: string;
  88166. shader: string;
  88167. };
  88168. }
  88169. declare module BABYLON {
  88170. /**
  88171. * Line mesh
  88172. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88173. */
  88174. export class LinesMesh extends Mesh {
  88175. /**
  88176. * If vertex color should be applied to the mesh
  88177. */
  88178. readonly useVertexColor?: boolean | undefined;
  88179. /**
  88180. * If vertex alpha should be applied to the mesh
  88181. */
  88182. readonly useVertexAlpha?: boolean | undefined;
  88183. /**
  88184. * Color of the line (Default: White)
  88185. */
  88186. color: Color3;
  88187. /**
  88188. * Alpha of the line (Default: 1)
  88189. */
  88190. alpha: number;
  88191. /**
  88192. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88193. * This margin is expressed in world space coordinates, so its value may vary.
  88194. * Default value is 0.1
  88195. */
  88196. intersectionThreshold: number;
  88197. private _colorShader;
  88198. private color4;
  88199. /**
  88200. * Creates a new LinesMesh
  88201. * @param name defines the name
  88202. * @param scene defines the hosting scene
  88203. * @param parent defines the parent mesh if any
  88204. * @param source defines the optional source LinesMesh used to clone data from
  88205. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88206. * When false, achieved by calling a clone(), also passing False.
  88207. * This will make creation of children, recursive.
  88208. * @param useVertexColor defines if this LinesMesh supports vertex color
  88209. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88210. */
  88211. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88212. /**
  88213. * If vertex color should be applied to the mesh
  88214. */
  88215. useVertexColor?: boolean | undefined,
  88216. /**
  88217. * If vertex alpha should be applied to the mesh
  88218. */
  88219. useVertexAlpha?: boolean | undefined);
  88220. private _addClipPlaneDefine;
  88221. private _removeClipPlaneDefine;
  88222. isReady(): boolean;
  88223. /**
  88224. * Returns the string "LineMesh"
  88225. */
  88226. getClassName(): string;
  88227. /**
  88228. * @hidden
  88229. */
  88230. /**
  88231. * @hidden
  88232. */
  88233. material: Material;
  88234. /**
  88235. * @hidden
  88236. */
  88237. readonly checkCollisions: boolean;
  88238. /** @hidden */
  88239. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88240. /** @hidden */
  88241. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88242. /**
  88243. * Disposes of the line mesh
  88244. * @param doNotRecurse If children should be disposed
  88245. */
  88246. dispose(doNotRecurse?: boolean): void;
  88247. /**
  88248. * Returns a new LineMesh object cloned from the current one.
  88249. */
  88250. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88251. /**
  88252. * Creates a new InstancedLinesMesh object from the mesh model.
  88253. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88254. * @param name defines the name of the new instance
  88255. * @returns a new InstancedLinesMesh
  88256. */
  88257. createInstance(name: string): InstancedLinesMesh;
  88258. }
  88259. /**
  88260. * Creates an instance based on a source LinesMesh
  88261. */
  88262. export class InstancedLinesMesh extends InstancedMesh {
  88263. /**
  88264. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88265. * This margin is expressed in world space coordinates, so its value may vary.
  88266. * Initilized with the intersectionThreshold value of the source LinesMesh
  88267. */
  88268. intersectionThreshold: number;
  88269. constructor(name: string, source: LinesMesh);
  88270. /**
  88271. * Returns the string "InstancedLinesMesh".
  88272. */
  88273. getClassName(): string;
  88274. }
  88275. }
  88276. declare module BABYLON {
  88277. /** @hidden */
  88278. export var linePixelShader: {
  88279. name: string;
  88280. shader: string;
  88281. };
  88282. }
  88283. declare module BABYLON {
  88284. /** @hidden */
  88285. export var lineVertexShader: {
  88286. name: string;
  88287. shader: string;
  88288. };
  88289. }
  88290. declare module BABYLON {
  88291. interface AbstractMesh {
  88292. /**
  88293. * Gets the edgesRenderer associated with the mesh
  88294. */
  88295. edgesRenderer: Nullable<EdgesRenderer>;
  88296. }
  88297. interface LinesMesh {
  88298. /**
  88299. * Enables the edge rendering mode on the mesh.
  88300. * This mode makes the mesh edges visible
  88301. * @param epsilon defines the maximal distance between two angles to detect a face
  88302. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88303. * @returns the currentAbstractMesh
  88304. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88305. */
  88306. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88307. }
  88308. interface InstancedLinesMesh {
  88309. /**
  88310. * Enables the edge rendering mode on the mesh.
  88311. * This mode makes the mesh edges visible
  88312. * @param epsilon defines the maximal distance between two angles to detect a face
  88313. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88314. * @returns the current InstancedLinesMesh
  88315. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88316. */
  88317. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88318. }
  88319. /**
  88320. * Defines the minimum contract an Edges renderer should follow.
  88321. */
  88322. export interface IEdgesRenderer extends IDisposable {
  88323. /**
  88324. * Gets or sets a boolean indicating if the edgesRenderer is active
  88325. */
  88326. isEnabled: boolean;
  88327. /**
  88328. * Renders the edges of the attached mesh,
  88329. */
  88330. render(): void;
  88331. /**
  88332. * Checks wether or not the edges renderer is ready to render.
  88333. * @return true if ready, otherwise false.
  88334. */
  88335. isReady(): boolean;
  88336. }
  88337. /**
  88338. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88339. */
  88340. export class EdgesRenderer implements IEdgesRenderer {
  88341. /**
  88342. * Define the size of the edges with an orthographic camera
  88343. */
  88344. edgesWidthScalerForOrthographic: number;
  88345. /**
  88346. * Define the size of the edges with a perspective camera
  88347. */
  88348. edgesWidthScalerForPerspective: number;
  88349. protected _source: AbstractMesh;
  88350. protected _linesPositions: number[];
  88351. protected _linesNormals: number[];
  88352. protected _linesIndices: number[];
  88353. protected _epsilon: number;
  88354. protected _indicesCount: number;
  88355. protected _lineShader: ShaderMaterial;
  88356. protected _ib: DataBuffer;
  88357. protected _buffers: {
  88358. [key: string]: Nullable<VertexBuffer>;
  88359. };
  88360. protected _checkVerticesInsteadOfIndices: boolean;
  88361. private _meshRebuildObserver;
  88362. private _meshDisposeObserver;
  88363. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88364. isEnabled: boolean;
  88365. /**
  88366. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88367. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88368. * @param source Mesh used to create edges
  88369. * @param epsilon sum of angles in adjacency to check for edge
  88370. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88371. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88372. */
  88373. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88374. protected _prepareRessources(): void;
  88375. /** @hidden */
  88376. _rebuild(): void;
  88377. /**
  88378. * Releases the required resources for the edges renderer
  88379. */
  88380. dispose(): void;
  88381. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88382. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88383. /**
  88384. * Checks if the pair of p0 and p1 is en edge
  88385. * @param faceIndex
  88386. * @param edge
  88387. * @param faceNormals
  88388. * @param p0
  88389. * @param p1
  88390. * @private
  88391. */
  88392. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88393. /**
  88394. * push line into the position, normal and index buffer
  88395. * @protected
  88396. */
  88397. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  88398. /**
  88399. * Generates lines edges from adjacencjes
  88400. * @private
  88401. */
  88402. _generateEdgesLines(): void;
  88403. /**
  88404. * Checks wether or not the edges renderer is ready to render.
  88405. * @return true if ready, otherwise false.
  88406. */
  88407. isReady(): boolean;
  88408. /**
  88409. * Renders the edges of the attached mesh,
  88410. */
  88411. render(): void;
  88412. }
  88413. /**
  88414. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  88415. */
  88416. export class LineEdgesRenderer extends EdgesRenderer {
  88417. /**
  88418. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  88419. * @param source LineMesh used to generate edges
  88420. * @param epsilon not important (specified angle for edge detection)
  88421. * @param checkVerticesInsteadOfIndices not important for LineMesh
  88422. */
  88423. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  88424. /**
  88425. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  88426. */
  88427. _generateEdgesLines(): void;
  88428. }
  88429. }
  88430. declare module BABYLON {
  88431. /**
  88432. * This represents the object necessary to create a rendering group.
  88433. * This is exclusively used and created by the rendering manager.
  88434. * To modify the behavior, you use the available helpers in your scene or meshes.
  88435. * @hidden
  88436. */
  88437. export class RenderingGroup {
  88438. index: number;
  88439. private static _zeroVector;
  88440. private _scene;
  88441. private _opaqueSubMeshes;
  88442. private _transparentSubMeshes;
  88443. private _alphaTestSubMeshes;
  88444. private _depthOnlySubMeshes;
  88445. private _particleSystems;
  88446. private _spriteManagers;
  88447. private _opaqueSortCompareFn;
  88448. private _alphaTestSortCompareFn;
  88449. private _transparentSortCompareFn;
  88450. private _renderOpaque;
  88451. private _renderAlphaTest;
  88452. private _renderTransparent;
  88453. /** @hidden */
  88454. _edgesRenderers: SmartArray<IEdgesRenderer>;
  88455. onBeforeTransparentRendering: () => void;
  88456. /**
  88457. * Set the opaque sort comparison function.
  88458. * If null the sub meshes will be render in the order they were created
  88459. */
  88460. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88461. /**
  88462. * Set the alpha test sort comparison function.
  88463. * If null the sub meshes will be render in the order they were created
  88464. */
  88465. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88466. /**
  88467. * Set the transparent sort comparison function.
  88468. * If null the sub meshes will be render in the order they were created
  88469. */
  88470. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88471. /**
  88472. * Creates a new rendering group.
  88473. * @param index The rendering group index
  88474. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  88475. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  88476. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  88477. */
  88478. 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>);
  88479. /**
  88480. * Render all the sub meshes contained in the group.
  88481. * @param customRenderFunction Used to override the default render behaviour of the group.
  88482. * @returns true if rendered some submeshes.
  88483. */
  88484. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  88485. /**
  88486. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  88487. * @param subMeshes The submeshes to render
  88488. */
  88489. private renderOpaqueSorted;
  88490. /**
  88491. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  88492. * @param subMeshes The submeshes to render
  88493. */
  88494. private renderAlphaTestSorted;
  88495. /**
  88496. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  88497. * @param subMeshes The submeshes to render
  88498. */
  88499. private renderTransparentSorted;
  88500. /**
  88501. * Renders the submeshes in a specified order.
  88502. * @param subMeshes The submeshes to sort before render
  88503. * @param sortCompareFn The comparison function use to sort
  88504. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  88505. * @param transparent Specifies to activate blending if true
  88506. */
  88507. private static renderSorted;
  88508. /**
  88509. * Renders the submeshes in the order they were dispatched (no sort applied).
  88510. * @param subMeshes The submeshes to render
  88511. */
  88512. private static renderUnsorted;
  88513. /**
  88514. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88515. * are rendered back to front if in the same alpha index.
  88516. *
  88517. * @param a The first submesh
  88518. * @param b The second submesh
  88519. * @returns The result of the comparison
  88520. */
  88521. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  88522. /**
  88523. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88524. * are rendered back to front.
  88525. *
  88526. * @param a The first submesh
  88527. * @param b The second submesh
  88528. * @returns The result of the comparison
  88529. */
  88530. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88531. /**
  88532. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88533. * are rendered front to back (prevent overdraw).
  88534. *
  88535. * @param a The first submesh
  88536. * @param b The second submesh
  88537. * @returns The result of the comparison
  88538. */
  88539. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88540. /**
  88541. * Resets the different lists of submeshes to prepare a new frame.
  88542. */
  88543. prepare(): void;
  88544. dispose(): void;
  88545. /**
  88546. * Inserts the submesh in its correct queue depending on its material.
  88547. * @param subMesh The submesh to dispatch
  88548. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88549. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88550. */
  88551. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88552. dispatchSprites(spriteManager: ISpriteManager): void;
  88553. dispatchParticles(particleSystem: IParticleSystem): void;
  88554. private _renderParticles;
  88555. private _renderSprites;
  88556. }
  88557. }
  88558. declare module BABYLON {
  88559. /**
  88560. * Interface describing the different options available in the rendering manager
  88561. * regarding Auto Clear between groups.
  88562. */
  88563. export interface IRenderingManagerAutoClearSetup {
  88564. /**
  88565. * Defines whether or not autoclear is enable.
  88566. */
  88567. autoClear: boolean;
  88568. /**
  88569. * Defines whether or not to autoclear the depth buffer.
  88570. */
  88571. depth: boolean;
  88572. /**
  88573. * Defines whether or not to autoclear the stencil buffer.
  88574. */
  88575. stencil: boolean;
  88576. }
  88577. /**
  88578. * This class is used by the onRenderingGroupObservable
  88579. */
  88580. export class RenderingGroupInfo {
  88581. /**
  88582. * The Scene that being rendered
  88583. */
  88584. scene: Scene;
  88585. /**
  88586. * The camera currently used for the rendering pass
  88587. */
  88588. camera: Nullable<Camera>;
  88589. /**
  88590. * The ID of the renderingGroup being processed
  88591. */
  88592. renderingGroupId: number;
  88593. }
  88594. /**
  88595. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88596. * It is enable to manage the different groups as well as the different necessary sort functions.
  88597. * This should not be used directly aside of the few static configurations
  88598. */
  88599. export class RenderingManager {
  88600. /**
  88601. * The max id used for rendering groups (not included)
  88602. */
  88603. static MAX_RENDERINGGROUPS: number;
  88604. /**
  88605. * The min id used for rendering groups (included)
  88606. */
  88607. static MIN_RENDERINGGROUPS: number;
  88608. /**
  88609. * Used to globally prevent autoclearing scenes.
  88610. */
  88611. static AUTOCLEAR: boolean;
  88612. /**
  88613. * @hidden
  88614. */
  88615. _useSceneAutoClearSetup: boolean;
  88616. private _scene;
  88617. private _renderingGroups;
  88618. private _depthStencilBufferAlreadyCleaned;
  88619. private _autoClearDepthStencil;
  88620. private _customOpaqueSortCompareFn;
  88621. private _customAlphaTestSortCompareFn;
  88622. private _customTransparentSortCompareFn;
  88623. private _renderingGroupInfo;
  88624. /**
  88625. * Instantiates a new rendering group for a particular scene
  88626. * @param scene Defines the scene the groups belongs to
  88627. */
  88628. constructor(scene: Scene);
  88629. private _clearDepthStencilBuffer;
  88630. /**
  88631. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88632. * @hidden
  88633. */
  88634. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88635. /**
  88636. * Resets the different information of the group to prepare a new frame
  88637. * @hidden
  88638. */
  88639. reset(): void;
  88640. /**
  88641. * Dispose and release the group and its associated resources.
  88642. * @hidden
  88643. */
  88644. dispose(): void;
  88645. /**
  88646. * Clear the info related to rendering groups preventing retention points during dispose.
  88647. */
  88648. freeRenderingGroups(): void;
  88649. private _prepareRenderingGroup;
  88650. /**
  88651. * Add a sprite manager to the rendering manager in order to render it this frame.
  88652. * @param spriteManager Define the sprite manager to render
  88653. */
  88654. dispatchSprites(spriteManager: ISpriteManager): void;
  88655. /**
  88656. * Add a particle system to the rendering manager in order to render it this frame.
  88657. * @param particleSystem Define the particle system to render
  88658. */
  88659. dispatchParticles(particleSystem: IParticleSystem): void;
  88660. /**
  88661. * Add a submesh to the manager in order to render it this frame
  88662. * @param subMesh The submesh to dispatch
  88663. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88664. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88665. */
  88666. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88667. /**
  88668. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88669. * This allowed control for front to back rendering or reversly depending of the special needs.
  88670. *
  88671. * @param renderingGroupId The rendering group id corresponding to its index
  88672. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88673. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88674. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88675. */
  88676. 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;
  88677. /**
  88678. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88679. *
  88680. * @param renderingGroupId The rendering group id corresponding to its index
  88681. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88682. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88683. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88684. */
  88685. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88686. /**
  88687. * Gets the current auto clear configuration for one rendering group of the rendering
  88688. * manager.
  88689. * @param index the rendering group index to get the information for
  88690. * @returns The auto clear setup for the requested rendering group
  88691. */
  88692. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88693. }
  88694. }
  88695. declare module BABYLON {
  88696. /**
  88697. * This Helps creating a texture that will be created from a camera in your scene.
  88698. * It is basically a dynamic texture that could be used to create special effects for instance.
  88699. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  88700. */
  88701. export class RenderTargetTexture extends Texture {
  88702. isCube: boolean;
  88703. /**
  88704. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  88705. */
  88706. static readonly REFRESHRATE_RENDER_ONCE: number;
  88707. /**
  88708. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  88709. */
  88710. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  88711. /**
  88712. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  88713. * the central point of your effect and can save a lot of performances.
  88714. */
  88715. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  88716. /**
  88717. * Use this predicate to dynamically define the list of mesh you want to render.
  88718. * If set, the renderList property will be overwritten.
  88719. */
  88720. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  88721. private _renderList;
  88722. /**
  88723. * Use this list to define the list of mesh you want to render.
  88724. */
  88725. renderList: Nullable<Array<AbstractMesh>>;
  88726. private _hookArray;
  88727. /**
  88728. * Define if particles should be rendered in your texture.
  88729. */
  88730. renderParticles: boolean;
  88731. /**
  88732. * Define if sprites should be rendered in your texture.
  88733. */
  88734. renderSprites: boolean;
  88735. /**
  88736. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  88737. */
  88738. coordinatesMode: number;
  88739. /**
  88740. * Define the camera used to render the texture.
  88741. */
  88742. activeCamera: Nullable<Camera>;
  88743. /**
  88744. * Override the render function of the texture with your own one.
  88745. */
  88746. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  88747. /**
  88748. * Define if camera post processes should be use while rendering the texture.
  88749. */
  88750. useCameraPostProcesses: boolean;
  88751. /**
  88752. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  88753. */
  88754. ignoreCameraViewport: boolean;
  88755. private _postProcessManager;
  88756. private _postProcesses;
  88757. private _resizeObserver;
  88758. /**
  88759. * An event triggered when the texture is unbind.
  88760. */
  88761. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88762. /**
  88763. * An event triggered when the texture is unbind.
  88764. */
  88765. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88766. private _onAfterUnbindObserver;
  88767. /**
  88768. * Set a after unbind callback in the texture.
  88769. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88770. */
  88771. onAfterUnbind: () => void;
  88772. /**
  88773. * An event triggered before rendering the texture
  88774. */
  88775. onBeforeRenderObservable: Observable<number>;
  88776. private _onBeforeRenderObserver;
  88777. /**
  88778. * Set a before render callback in the texture.
  88779. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88780. */
  88781. onBeforeRender: (faceIndex: number) => void;
  88782. /**
  88783. * An event triggered after rendering the texture
  88784. */
  88785. onAfterRenderObservable: Observable<number>;
  88786. private _onAfterRenderObserver;
  88787. /**
  88788. * Set a after render callback in the texture.
  88789. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88790. */
  88791. onAfterRender: (faceIndex: number) => void;
  88792. /**
  88793. * An event triggered after the texture clear
  88794. */
  88795. onClearObservable: Observable<Engine>;
  88796. private _onClearObserver;
  88797. /**
  88798. * Set a clear callback in the texture.
  88799. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88800. */
  88801. onClear: (Engine: Engine) => void;
  88802. /**
  88803. * An event triggered when the texture is resized.
  88804. */
  88805. onResizeObservable: Observable<RenderTargetTexture>;
  88806. /**
  88807. * Define the clear color of the Render Target if it should be different from the scene.
  88808. */
  88809. clearColor: Color4;
  88810. protected _size: number | {
  88811. width: number;
  88812. height: number;
  88813. };
  88814. protected _initialSizeParameter: number | {
  88815. width: number;
  88816. height: number;
  88817. } | {
  88818. ratio: number;
  88819. };
  88820. protected _sizeRatio: Nullable<number>;
  88821. /** @hidden */
  88822. _generateMipMaps: boolean;
  88823. protected _renderingManager: RenderingManager;
  88824. /** @hidden */
  88825. _waitingRenderList: string[];
  88826. protected _doNotChangeAspectRatio: boolean;
  88827. protected _currentRefreshId: number;
  88828. protected _refreshRate: number;
  88829. protected _textureMatrix: Matrix;
  88830. protected _samples: number;
  88831. protected _renderTargetOptions: RenderTargetCreationOptions;
  88832. /**
  88833. * Gets render target creation options that were used.
  88834. */
  88835. readonly renderTargetOptions: RenderTargetCreationOptions;
  88836. protected _engine: Engine;
  88837. protected _onRatioRescale(): void;
  88838. /**
  88839. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88840. * It must define where the camera used to render the texture is set
  88841. */
  88842. boundingBoxPosition: Vector3;
  88843. private _boundingBoxSize;
  88844. /**
  88845. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88846. * When defined, the cubemap will switch to local mode
  88847. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88848. * @example https://www.babylonjs-playground.com/#RNASML
  88849. */
  88850. boundingBoxSize: Vector3;
  88851. /**
  88852. * In case the RTT has been created with a depth texture, get the associated
  88853. * depth texture.
  88854. * Otherwise, return null.
  88855. */
  88856. depthStencilTexture: Nullable<InternalTexture>;
  88857. /**
  88858. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88859. * or used a shadow, depth texture...
  88860. * @param name The friendly name of the texture
  88861. * @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)
  88862. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88863. * @param generateMipMaps True if mip maps need to be generated after render.
  88864. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88865. * @param type The type of the buffer in the RTT (int, half float, float...)
  88866. * @param isCube True if a cube texture needs to be created
  88867. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88868. * @param generateDepthBuffer True to generate a depth buffer
  88869. * @param generateStencilBuffer True to generate a stencil buffer
  88870. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88871. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88872. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88873. */
  88874. constructor(name: string, size: number | {
  88875. width: number;
  88876. height: number;
  88877. } | {
  88878. ratio: number;
  88879. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88880. /**
  88881. * Creates a depth stencil texture.
  88882. * This is only available in WebGL 2 or with the depth texture extension available.
  88883. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88884. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88885. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88886. */
  88887. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88888. private _processSizeParameter;
  88889. /**
  88890. * Define the number of samples to use in case of MSAA.
  88891. * It defaults to one meaning no MSAA has been enabled.
  88892. */
  88893. samples: number;
  88894. /**
  88895. * Resets the refresh counter of the texture and start bak from scratch.
  88896. * Could be useful to regenerate the texture if it is setup to render only once.
  88897. */
  88898. resetRefreshCounter(): void;
  88899. /**
  88900. * Define the refresh rate of the texture or the rendering frequency.
  88901. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88902. */
  88903. refreshRate: number;
  88904. /**
  88905. * Adds a post process to the render target rendering passes.
  88906. * @param postProcess define the post process to add
  88907. */
  88908. addPostProcess(postProcess: PostProcess): void;
  88909. /**
  88910. * Clear all the post processes attached to the render target
  88911. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88912. */
  88913. clearPostProcesses(dispose?: boolean): void;
  88914. /**
  88915. * Remove one of the post process from the list of attached post processes to the texture
  88916. * @param postProcess define the post process to remove from the list
  88917. */
  88918. removePostProcess(postProcess: PostProcess): void;
  88919. /** @hidden */
  88920. _shouldRender(): boolean;
  88921. /**
  88922. * Gets the actual render size of the texture.
  88923. * @returns the width of the render size
  88924. */
  88925. getRenderSize(): number;
  88926. /**
  88927. * Gets the actual render width of the texture.
  88928. * @returns the width of the render size
  88929. */
  88930. getRenderWidth(): number;
  88931. /**
  88932. * Gets the actual render height of the texture.
  88933. * @returns the height of the render size
  88934. */
  88935. getRenderHeight(): number;
  88936. /**
  88937. * Get if the texture can be rescaled or not.
  88938. */
  88939. readonly canRescale: boolean;
  88940. /**
  88941. * Resize the texture using a ratio.
  88942. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88943. */
  88944. scale(ratio: number): void;
  88945. /**
  88946. * Get the texture reflection matrix used to rotate/transform the reflection.
  88947. * @returns the reflection matrix
  88948. */
  88949. getReflectionTextureMatrix(): Matrix;
  88950. /**
  88951. * Resize the texture to a new desired size.
  88952. * Be carrefull as it will recreate all the data in the new texture.
  88953. * @param size Define the new size. It can be:
  88954. * - a number for squared texture,
  88955. * - an object containing { width: number, height: number }
  88956. * - or an object containing a ratio { ratio: number }
  88957. */
  88958. resize(size: number | {
  88959. width: number;
  88960. height: number;
  88961. } | {
  88962. ratio: number;
  88963. }): void;
  88964. /**
  88965. * Renders all the objects from the render list into the texture.
  88966. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88967. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88968. */
  88969. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88970. private _bestReflectionRenderTargetDimension;
  88971. /**
  88972. * @hidden
  88973. * @param faceIndex face index to bind to if this is a cubetexture
  88974. */
  88975. _bindFrameBuffer(faceIndex?: number): void;
  88976. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88977. private renderToTarget;
  88978. /**
  88979. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88980. * This allowed control for front to back rendering or reversly depending of the special needs.
  88981. *
  88982. * @param renderingGroupId The rendering group id corresponding to its index
  88983. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88984. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88985. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88986. */
  88987. 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;
  88988. /**
  88989. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88990. *
  88991. * @param renderingGroupId The rendering group id corresponding to its index
  88992. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88993. */
  88994. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88995. /**
  88996. * Clones the texture.
  88997. * @returns the cloned texture
  88998. */
  88999. clone(): RenderTargetTexture;
  89000. /**
  89001. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89002. * @returns The JSON representation of the texture
  89003. */
  89004. serialize(): any;
  89005. /**
  89006. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  89007. */
  89008. disposeFramebufferObjects(): void;
  89009. /**
  89010. * Dispose the texture and release its associated resources.
  89011. */
  89012. dispose(): void;
  89013. /** @hidden */
  89014. _rebuild(): void;
  89015. /**
  89016. * Clear the info related to rendering groups preventing retention point in material dispose.
  89017. */
  89018. freeRenderingGroups(): void;
  89019. /**
  89020. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  89021. * @returns the view count
  89022. */
  89023. getViewCount(): number;
  89024. }
  89025. }
  89026. declare module BABYLON {
  89027. /**
  89028. * Options for compiling materials.
  89029. */
  89030. export interface IMaterialCompilationOptions {
  89031. /**
  89032. * Defines whether clip planes are enabled.
  89033. */
  89034. clipPlane: boolean;
  89035. /**
  89036. * Defines whether instances are enabled.
  89037. */
  89038. useInstances: boolean;
  89039. }
  89040. /**
  89041. * Base class for the main features of a material in Babylon.js
  89042. */
  89043. export class Material implements IAnimatable {
  89044. /**
  89045. * Returns the triangle fill mode
  89046. */
  89047. static readonly TriangleFillMode: number;
  89048. /**
  89049. * Returns the wireframe mode
  89050. */
  89051. static readonly WireFrameFillMode: number;
  89052. /**
  89053. * Returns the point fill mode
  89054. */
  89055. static readonly PointFillMode: number;
  89056. /**
  89057. * Returns the point list draw mode
  89058. */
  89059. static readonly PointListDrawMode: number;
  89060. /**
  89061. * Returns the line list draw mode
  89062. */
  89063. static readonly LineListDrawMode: number;
  89064. /**
  89065. * Returns the line loop draw mode
  89066. */
  89067. static readonly LineLoopDrawMode: number;
  89068. /**
  89069. * Returns the line strip draw mode
  89070. */
  89071. static readonly LineStripDrawMode: number;
  89072. /**
  89073. * Returns the triangle strip draw mode
  89074. */
  89075. static readonly TriangleStripDrawMode: number;
  89076. /**
  89077. * Returns the triangle fan draw mode
  89078. */
  89079. static readonly TriangleFanDrawMode: number;
  89080. /**
  89081. * Stores the clock-wise side orientation
  89082. */
  89083. static readonly ClockWiseSideOrientation: number;
  89084. /**
  89085. * Stores the counter clock-wise side orientation
  89086. */
  89087. static readonly CounterClockWiseSideOrientation: number;
  89088. /**
  89089. * The dirty texture flag value
  89090. */
  89091. static readonly TextureDirtyFlag: number;
  89092. /**
  89093. * The dirty light flag value
  89094. */
  89095. static readonly LightDirtyFlag: number;
  89096. /**
  89097. * The dirty fresnel flag value
  89098. */
  89099. static readonly FresnelDirtyFlag: number;
  89100. /**
  89101. * The dirty attribute flag value
  89102. */
  89103. static readonly AttributesDirtyFlag: number;
  89104. /**
  89105. * The dirty misc flag value
  89106. */
  89107. static readonly MiscDirtyFlag: number;
  89108. /**
  89109. * The all dirty flag value
  89110. */
  89111. static readonly AllDirtyFlag: number;
  89112. /**
  89113. * The ID of the material
  89114. */
  89115. id: string;
  89116. /**
  89117. * Gets or sets the unique id of the material
  89118. */
  89119. uniqueId: number;
  89120. /**
  89121. * The name of the material
  89122. */
  89123. name: string;
  89124. /**
  89125. * Gets or sets user defined metadata
  89126. */
  89127. metadata: any;
  89128. /**
  89129. * For internal use only. Please do not use.
  89130. */
  89131. reservedDataStore: any;
  89132. /**
  89133. * Specifies if the ready state should be checked on each call
  89134. */
  89135. checkReadyOnEveryCall: boolean;
  89136. /**
  89137. * Specifies if the ready state should be checked once
  89138. */
  89139. checkReadyOnlyOnce: boolean;
  89140. /**
  89141. * The state of the material
  89142. */
  89143. state: string;
  89144. /**
  89145. * The alpha value of the material
  89146. */
  89147. protected _alpha: number;
  89148. /**
  89149. * List of inspectable custom properties (used by the Inspector)
  89150. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89151. */
  89152. inspectableCustomProperties: IInspectable[];
  89153. /**
  89154. * Sets the alpha value of the material
  89155. */
  89156. /**
  89157. * Gets the alpha value of the material
  89158. */
  89159. alpha: number;
  89160. /**
  89161. * Specifies if back face culling is enabled
  89162. */
  89163. protected _backFaceCulling: boolean;
  89164. /**
  89165. * Sets the back-face culling state
  89166. */
  89167. /**
  89168. * Gets the back-face culling state
  89169. */
  89170. backFaceCulling: boolean;
  89171. /**
  89172. * Stores the value for side orientation
  89173. */
  89174. sideOrientation: number;
  89175. /**
  89176. * Callback triggered when the material is compiled
  89177. */
  89178. onCompiled: Nullable<(effect: Effect) => void>;
  89179. /**
  89180. * Callback triggered when an error occurs
  89181. */
  89182. onError: Nullable<(effect: Effect, errors: string) => void>;
  89183. /**
  89184. * Callback triggered to get the render target textures
  89185. */
  89186. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  89187. /**
  89188. * Gets a boolean indicating that current material needs to register RTT
  89189. */
  89190. readonly hasRenderTargetTextures: boolean;
  89191. /**
  89192. * Specifies if the material should be serialized
  89193. */
  89194. doNotSerialize: boolean;
  89195. /**
  89196. * @hidden
  89197. */
  89198. _storeEffectOnSubMeshes: boolean;
  89199. /**
  89200. * Stores the animations for the material
  89201. */
  89202. animations: Nullable<Array<Animation>>;
  89203. /**
  89204. * An event triggered when the material is disposed
  89205. */
  89206. onDisposeObservable: Observable<Material>;
  89207. /**
  89208. * An observer which watches for dispose events
  89209. */
  89210. private _onDisposeObserver;
  89211. private _onUnBindObservable;
  89212. /**
  89213. * Called during a dispose event
  89214. */
  89215. onDispose: () => void;
  89216. private _onBindObservable;
  89217. /**
  89218. * An event triggered when the material is bound
  89219. */
  89220. readonly onBindObservable: Observable<AbstractMesh>;
  89221. /**
  89222. * An observer which watches for bind events
  89223. */
  89224. private _onBindObserver;
  89225. /**
  89226. * Called during a bind event
  89227. */
  89228. onBind: (Mesh: AbstractMesh) => void;
  89229. /**
  89230. * An event triggered when the material is unbound
  89231. */
  89232. readonly onUnBindObservable: Observable<Material>;
  89233. /**
  89234. * Stores the value of the alpha mode
  89235. */
  89236. private _alphaMode;
  89237. /**
  89238. * Sets the value of the alpha mode.
  89239. *
  89240. * | Value | Type | Description |
  89241. * | --- | --- | --- |
  89242. * | 0 | ALPHA_DISABLE | |
  89243. * | 1 | ALPHA_ADD | |
  89244. * | 2 | ALPHA_COMBINE | |
  89245. * | 3 | ALPHA_SUBTRACT | |
  89246. * | 4 | ALPHA_MULTIPLY | |
  89247. * | 5 | ALPHA_MAXIMIZED | |
  89248. * | 6 | ALPHA_ONEONE | |
  89249. * | 7 | ALPHA_PREMULTIPLIED | |
  89250. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  89251. * | 9 | ALPHA_INTERPOLATE | |
  89252. * | 10 | ALPHA_SCREENMODE | |
  89253. *
  89254. */
  89255. /**
  89256. * Gets the value of the alpha mode
  89257. */
  89258. alphaMode: number;
  89259. /**
  89260. * Stores the state of the need depth pre-pass value
  89261. */
  89262. private _needDepthPrePass;
  89263. /**
  89264. * Sets the need depth pre-pass value
  89265. */
  89266. /**
  89267. * Gets the depth pre-pass value
  89268. */
  89269. needDepthPrePass: boolean;
  89270. /**
  89271. * Specifies if depth writing should be disabled
  89272. */
  89273. disableDepthWrite: boolean;
  89274. /**
  89275. * Specifies if depth writing should be forced
  89276. */
  89277. forceDepthWrite: boolean;
  89278. /**
  89279. * Specifies the depth function that should be used. 0 means the default engine function
  89280. */
  89281. depthFunction: number;
  89282. /**
  89283. * Specifies if there should be a separate pass for culling
  89284. */
  89285. separateCullingPass: boolean;
  89286. /**
  89287. * Stores the state specifing if fog should be enabled
  89288. */
  89289. private _fogEnabled;
  89290. /**
  89291. * Sets the state for enabling fog
  89292. */
  89293. /**
  89294. * Gets the value of the fog enabled state
  89295. */
  89296. fogEnabled: boolean;
  89297. /**
  89298. * Stores the size of points
  89299. */
  89300. pointSize: number;
  89301. /**
  89302. * Stores the z offset value
  89303. */
  89304. zOffset: number;
  89305. /**
  89306. * Gets a value specifying if wireframe mode is enabled
  89307. */
  89308. /**
  89309. * Sets the state of wireframe mode
  89310. */
  89311. wireframe: boolean;
  89312. /**
  89313. * Gets the value specifying if point clouds are enabled
  89314. */
  89315. /**
  89316. * Sets the state of point cloud mode
  89317. */
  89318. pointsCloud: boolean;
  89319. /**
  89320. * Gets the material fill mode
  89321. */
  89322. /**
  89323. * Sets the material fill mode
  89324. */
  89325. fillMode: number;
  89326. /**
  89327. * @hidden
  89328. * Stores the effects for the material
  89329. */
  89330. _effect: Nullable<Effect>;
  89331. /**
  89332. * @hidden
  89333. * Specifies if the material was previously ready
  89334. */
  89335. _wasPreviouslyReady: boolean;
  89336. /**
  89337. * Specifies if uniform buffers should be used
  89338. */
  89339. private _useUBO;
  89340. /**
  89341. * Stores a reference to the scene
  89342. */
  89343. private _scene;
  89344. /**
  89345. * Stores the fill mode state
  89346. */
  89347. private _fillMode;
  89348. /**
  89349. * Specifies if the depth write state should be cached
  89350. */
  89351. private _cachedDepthWriteState;
  89352. /**
  89353. * Specifies if the depth function state should be cached
  89354. */
  89355. private _cachedDepthFunctionState;
  89356. /**
  89357. * Stores the uniform buffer
  89358. */
  89359. protected _uniformBuffer: UniformBuffer;
  89360. /** @hidden */
  89361. _indexInSceneMaterialArray: number;
  89362. /** @hidden */
  89363. meshMap: Nullable<{
  89364. [id: string]: AbstractMesh | undefined;
  89365. }>;
  89366. /**
  89367. * Creates a material instance
  89368. * @param name defines the name of the material
  89369. * @param scene defines the scene to reference
  89370. * @param doNotAdd specifies if the material should be added to the scene
  89371. */
  89372. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  89373. /**
  89374. * Returns a string representation of the current material
  89375. * @param fullDetails defines a boolean indicating which levels of logging is desired
  89376. * @returns a string with material information
  89377. */
  89378. toString(fullDetails?: boolean): string;
  89379. /**
  89380. * Gets the class name of the material
  89381. * @returns a string with the class name of the material
  89382. */
  89383. getClassName(): string;
  89384. /**
  89385. * Specifies if updates for the material been locked
  89386. */
  89387. readonly isFrozen: boolean;
  89388. /**
  89389. * Locks updates for the material
  89390. */
  89391. freeze(): void;
  89392. /**
  89393. * Unlocks updates for the material
  89394. */
  89395. unfreeze(): void;
  89396. /**
  89397. * Specifies if the material is ready to be used
  89398. * @param mesh defines the mesh to check
  89399. * @param useInstances specifies if instances should be used
  89400. * @returns a boolean indicating if the material is ready to be used
  89401. */
  89402. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89403. /**
  89404. * Specifies that the submesh is ready to be used
  89405. * @param mesh defines the mesh to check
  89406. * @param subMesh defines which submesh to check
  89407. * @param useInstances specifies that instances should be used
  89408. * @returns a boolean indicating that the submesh is ready or not
  89409. */
  89410. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89411. /**
  89412. * Returns the material effect
  89413. * @returns the effect associated with the material
  89414. */
  89415. getEffect(): Nullable<Effect>;
  89416. /**
  89417. * Returns the current scene
  89418. * @returns a Scene
  89419. */
  89420. getScene(): Scene;
  89421. /**
  89422. * Specifies if the material will require alpha blending
  89423. * @returns a boolean specifying if alpha blending is needed
  89424. */
  89425. needAlphaBlending(): boolean;
  89426. /**
  89427. * Specifies if the mesh will require alpha blending
  89428. * @param mesh defines the mesh to check
  89429. * @returns a boolean specifying if alpha blending is needed for the mesh
  89430. */
  89431. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  89432. /**
  89433. * Specifies if this material should be rendered in alpha test mode
  89434. * @returns a boolean specifying if an alpha test is needed.
  89435. */
  89436. needAlphaTesting(): boolean;
  89437. /**
  89438. * Gets the texture used for the alpha test
  89439. * @returns the texture to use for alpha testing
  89440. */
  89441. getAlphaTestTexture(): Nullable<BaseTexture>;
  89442. /**
  89443. * Marks the material to indicate that it needs to be re-calculated
  89444. */
  89445. markDirty(): void;
  89446. /** @hidden */
  89447. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  89448. /**
  89449. * Binds the material to the mesh
  89450. * @param world defines the world transformation matrix
  89451. * @param mesh defines the mesh to bind the material to
  89452. */
  89453. bind(world: Matrix, mesh?: Mesh): void;
  89454. /**
  89455. * Binds the submesh to the material
  89456. * @param world defines the world transformation matrix
  89457. * @param mesh defines the mesh containing the submesh
  89458. * @param subMesh defines the submesh to bind the material to
  89459. */
  89460. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  89461. /**
  89462. * Binds the world matrix to the material
  89463. * @param world defines the world transformation matrix
  89464. */
  89465. bindOnlyWorldMatrix(world: Matrix): void;
  89466. /**
  89467. * Binds the scene's uniform buffer to the effect.
  89468. * @param effect defines the effect to bind to the scene uniform buffer
  89469. * @param sceneUbo defines the uniform buffer storing scene data
  89470. */
  89471. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  89472. /**
  89473. * Binds the view matrix to the effect
  89474. * @param effect defines the effect to bind the view matrix to
  89475. */
  89476. bindView(effect: Effect): void;
  89477. /**
  89478. * Binds the view projection matrix to the effect
  89479. * @param effect defines the effect to bind the view projection matrix to
  89480. */
  89481. bindViewProjection(effect: Effect): void;
  89482. /**
  89483. * Specifies if material alpha testing should be turned on for the mesh
  89484. * @param mesh defines the mesh to check
  89485. */
  89486. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  89487. /**
  89488. * Processes to execute after binding the material to a mesh
  89489. * @param mesh defines the rendered mesh
  89490. */
  89491. protected _afterBind(mesh?: Mesh): void;
  89492. /**
  89493. * Unbinds the material from the mesh
  89494. */
  89495. unbind(): void;
  89496. /**
  89497. * Gets the active textures from the material
  89498. * @returns an array of textures
  89499. */
  89500. getActiveTextures(): BaseTexture[];
  89501. /**
  89502. * Specifies if the material uses a texture
  89503. * @param texture defines the texture to check against the material
  89504. * @returns a boolean specifying if the material uses the texture
  89505. */
  89506. hasTexture(texture: BaseTexture): boolean;
  89507. /**
  89508. * Makes a duplicate of the material, and gives it a new name
  89509. * @param name defines the new name for the duplicated material
  89510. * @returns the cloned material
  89511. */
  89512. clone(name: string): Nullable<Material>;
  89513. /**
  89514. * Gets the meshes bound to the material
  89515. * @returns an array of meshes bound to the material
  89516. */
  89517. getBindedMeshes(): AbstractMesh[];
  89518. /**
  89519. * Force shader compilation
  89520. * @param mesh defines the mesh associated with this material
  89521. * @param onCompiled defines a function to execute once the material is compiled
  89522. * @param options defines the options to configure the compilation
  89523. * @param onError defines a function to execute if the material fails compiling
  89524. */
  89525. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  89526. /**
  89527. * Force shader compilation
  89528. * @param mesh defines the mesh that will use this material
  89529. * @param options defines additional options for compiling the shaders
  89530. * @returns a promise that resolves when the compilation completes
  89531. */
  89532. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89533. private static readonly _AllDirtyCallBack;
  89534. private static readonly _ImageProcessingDirtyCallBack;
  89535. private static readonly _TextureDirtyCallBack;
  89536. private static readonly _FresnelDirtyCallBack;
  89537. private static readonly _MiscDirtyCallBack;
  89538. private static readonly _LightsDirtyCallBack;
  89539. private static readonly _AttributeDirtyCallBack;
  89540. private static _FresnelAndMiscDirtyCallBack;
  89541. private static _TextureAndMiscDirtyCallBack;
  89542. private static readonly _DirtyCallbackArray;
  89543. private static readonly _RunDirtyCallBacks;
  89544. /**
  89545. * Marks a define in the material to indicate that it needs to be re-computed
  89546. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89547. */
  89548. markAsDirty(flag: number): void;
  89549. /**
  89550. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89551. * @param func defines a function which checks material defines against the submeshes
  89552. */
  89553. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89554. /**
  89555. * Indicates that we need to re-calculated for all submeshes
  89556. */
  89557. protected _markAllSubMeshesAsAllDirty(): void;
  89558. /**
  89559. * Indicates that image processing needs to be re-calculated for all submeshes
  89560. */
  89561. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89562. /**
  89563. * Indicates that textures need to be re-calculated for all submeshes
  89564. */
  89565. protected _markAllSubMeshesAsTexturesDirty(): void;
  89566. /**
  89567. * Indicates that fresnel needs to be re-calculated for all submeshes
  89568. */
  89569. protected _markAllSubMeshesAsFresnelDirty(): void;
  89570. /**
  89571. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89572. */
  89573. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89574. /**
  89575. * Indicates that lights need to be re-calculated for all submeshes
  89576. */
  89577. protected _markAllSubMeshesAsLightsDirty(): void;
  89578. /**
  89579. * Indicates that attributes need to be re-calculated for all submeshes
  89580. */
  89581. protected _markAllSubMeshesAsAttributesDirty(): void;
  89582. /**
  89583. * Indicates that misc needs to be re-calculated for all submeshes
  89584. */
  89585. protected _markAllSubMeshesAsMiscDirty(): void;
  89586. /**
  89587. * Indicates that textures and misc need to be re-calculated for all submeshes
  89588. */
  89589. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89590. /**
  89591. * Disposes the material
  89592. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89593. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89594. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89595. */
  89596. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89597. /** @hidden */
  89598. private releaseVertexArrayObject;
  89599. /**
  89600. * Serializes this material
  89601. * @returns the serialized material object
  89602. */
  89603. serialize(): any;
  89604. /**
  89605. * Creates a material from parsed material data
  89606. * @param parsedMaterial defines parsed material data
  89607. * @param scene defines the hosting scene
  89608. * @param rootUrl defines the root URL to use to load textures
  89609. * @returns a new material
  89610. */
  89611. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89612. }
  89613. }
  89614. declare module BABYLON {
  89615. /**
  89616. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89617. * separate meshes. This can be use to improve performances.
  89618. * @see http://doc.babylonjs.com/how_to/multi_materials
  89619. */
  89620. export class MultiMaterial extends Material {
  89621. private _subMaterials;
  89622. /**
  89623. * Gets or Sets the list of Materials used within the multi material.
  89624. * They need to be ordered according to the submeshes order in the associated mesh
  89625. */
  89626. subMaterials: Nullable<Material>[];
  89627. /**
  89628. * Function used to align with Node.getChildren()
  89629. * @returns the list of Materials used within the multi material
  89630. */
  89631. getChildren(): Nullable<Material>[];
  89632. /**
  89633. * Instantiates a new Multi Material
  89634. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89635. * separate meshes. This can be use to improve performances.
  89636. * @see http://doc.babylonjs.com/how_to/multi_materials
  89637. * @param name Define the name in the scene
  89638. * @param scene Define the scene the material belongs to
  89639. */
  89640. constructor(name: string, scene: Scene);
  89641. private _hookArray;
  89642. /**
  89643. * Get one of the submaterial by its index in the submaterials array
  89644. * @param index The index to look the sub material at
  89645. * @returns The Material if the index has been defined
  89646. */
  89647. getSubMaterial(index: number): Nullable<Material>;
  89648. /**
  89649. * Get the list of active textures for the whole sub materials list.
  89650. * @returns All the textures that will be used during the rendering
  89651. */
  89652. getActiveTextures(): BaseTexture[];
  89653. /**
  89654. * Gets the current class name of the material e.g. "MultiMaterial"
  89655. * Mainly use in serialization.
  89656. * @returns the class name
  89657. */
  89658. getClassName(): string;
  89659. /**
  89660. * Checks if the material is ready to render the requested sub mesh
  89661. * @param mesh Define the mesh the submesh belongs to
  89662. * @param subMesh Define the sub mesh to look readyness for
  89663. * @param useInstances Define whether or not the material is used with instances
  89664. * @returns true if ready, otherwise false
  89665. */
  89666. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89667. /**
  89668. * Clones the current material and its related sub materials
  89669. * @param name Define the name of the newly cloned material
  89670. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89671. * @returns the cloned material
  89672. */
  89673. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89674. /**
  89675. * Serializes the materials into a JSON representation.
  89676. * @returns the JSON representation
  89677. */
  89678. serialize(): any;
  89679. /**
  89680. * Dispose the material and release its associated resources
  89681. * @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)
  89682. * @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)
  89683. * @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)
  89684. */
  89685. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  89686. /**
  89687. * Creates a MultiMaterial from parsed MultiMaterial data.
  89688. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  89689. * @param scene defines the hosting scene
  89690. * @returns a new MultiMaterial
  89691. */
  89692. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  89693. }
  89694. }
  89695. declare module BABYLON {
  89696. /**
  89697. * Base class for submeshes
  89698. */
  89699. export class BaseSubMesh {
  89700. /** @hidden */
  89701. _materialDefines: Nullable<MaterialDefines>;
  89702. /** @hidden */
  89703. _materialEffect: Nullable<Effect>;
  89704. /**
  89705. * Gets associated effect
  89706. */
  89707. readonly effect: Nullable<Effect>;
  89708. /**
  89709. * Sets associated effect (effect used to render this submesh)
  89710. * @param effect defines the effect to associate with
  89711. * @param defines defines the set of defines used to compile this effect
  89712. */
  89713. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  89714. }
  89715. /**
  89716. * Defines a subdivision inside a mesh
  89717. */
  89718. export class SubMesh extends BaseSubMesh implements ICullable {
  89719. /** the material index to use */
  89720. materialIndex: number;
  89721. /** vertex index start */
  89722. verticesStart: number;
  89723. /** vertices count */
  89724. verticesCount: number;
  89725. /** index start */
  89726. indexStart: number;
  89727. /** indices count */
  89728. indexCount: number;
  89729. /** @hidden */
  89730. _linesIndexCount: number;
  89731. private _mesh;
  89732. private _renderingMesh;
  89733. private _boundingInfo;
  89734. private _linesIndexBuffer;
  89735. /** @hidden */
  89736. _lastColliderWorldVertices: Nullable<Vector3[]>;
  89737. /** @hidden */
  89738. _trianglePlanes: Plane[];
  89739. /** @hidden */
  89740. _lastColliderTransformMatrix: Nullable<Matrix>;
  89741. /** @hidden */
  89742. _renderId: number;
  89743. /** @hidden */
  89744. _alphaIndex: number;
  89745. /** @hidden */
  89746. _distanceToCamera: number;
  89747. /** @hidden */
  89748. _id: number;
  89749. private _currentMaterial;
  89750. /**
  89751. * Add a new submesh to a mesh
  89752. * @param materialIndex defines the material index to use
  89753. * @param verticesStart defines vertex index start
  89754. * @param verticesCount defines vertices count
  89755. * @param indexStart defines index start
  89756. * @param indexCount defines indices count
  89757. * @param mesh defines the parent mesh
  89758. * @param renderingMesh defines an optional rendering mesh
  89759. * @param createBoundingBox defines if bounding box should be created for this submesh
  89760. * @returns the new submesh
  89761. */
  89762. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  89763. /**
  89764. * Creates a new submesh
  89765. * @param materialIndex defines the material index to use
  89766. * @param verticesStart defines vertex index start
  89767. * @param verticesCount defines vertices count
  89768. * @param indexStart defines index start
  89769. * @param indexCount defines indices count
  89770. * @param mesh defines the parent mesh
  89771. * @param renderingMesh defines an optional rendering mesh
  89772. * @param createBoundingBox defines if bounding box should be created for this submesh
  89773. */
  89774. constructor(
  89775. /** the material index to use */
  89776. materialIndex: number,
  89777. /** vertex index start */
  89778. verticesStart: number,
  89779. /** vertices count */
  89780. verticesCount: number,
  89781. /** index start */
  89782. indexStart: number,
  89783. /** indices count */
  89784. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89785. /**
  89786. * Returns true if this submesh covers the entire parent mesh
  89787. * @ignorenaming
  89788. */
  89789. readonly IsGlobal: boolean;
  89790. /**
  89791. * Returns the submesh BoudingInfo object
  89792. * @returns current bounding info (or mesh's one if the submesh is global)
  89793. */
  89794. getBoundingInfo(): BoundingInfo;
  89795. /**
  89796. * Sets the submesh BoundingInfo
  89797. * @param boundingInfo defines the new bounding info to use
  89798. * @returns the SubMesh
  89799. */
  89800. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89801. /**
  89802. * Returns the mesh of the current submesh
  89803. * @return the parent mesh
  89804. */
  89805. getMesh(): AbstractMesh;
  89806. /**
  89807. * Returns the rendering mesh of the submesh
  89808. * @returns the rendering mesh (could be different from parent mesh)
  89809. */
  89810. getRenderingMesh(): Mesh;
  89811. /**
  89812. * Returns the submesh material
  89813. * @returns null or the current material
  89814. */
  89815. getMaterial(): Nullable<Material>;
  89816. /**
  89817. * Sets a new updated BoundingInfo object to the submesh
  89818. * @param data defines an optional position array to use to determine the bounding info
  89819. * @returns the SubMesh
  89820. */
  89821. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89822. /** @hidden */
  89823. _checkCollision(collider: Collider): boolean;
  89824. /**
  89825. * Updates the submesh BoundingInfo
  89826. * @param world defines the world matrix to use to update the bounding info
  89827. * @returns the submesh
  89828. */
  89829. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89830. /**
  89831. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89832. * @param frustumPlanes defines the frustum planes
  89833. * @returns true if the submesh is intersecting with the frustum
  89834. */
  89835. isInFrustum(frustumPlanes: Plane[]): boolean;
  89836. /**
  89837. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89838. * @param frustumPlanes defines the frustum planes
  89839. * @returns true if the submesh is inside the frustum
  89840. */
  89841. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89842. /**
  89843. * Renders the submesh
  89844. * @param enableAlphaMode defines if alpha needs to be used
  89845. * @returns the submesh
  89846. */
  89847. render(enableAlphaMode: boolean): SubMesh;
  89848. /**
  89849. * @hidden
  89850. */
  89851. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89852. /**
  89853. * Checks if the submesh intersects with a ray
  89854. * @param ray defines the ray to test
  89855. * @returns true is the passed ray intersects the submesh bounding box
  89856. */
  89857. canIntersects(ray: Ray): boolean;
  89858. /**
  89859. * Intersects current submesh with a ray
  89860. * @param ray defines the ray to test
  89861. * @param positions defines mesh's positions array
  89862. * @param indices defines mesh's indices array
  89863. * @param fastCheck defines if only bounding info should be used
  89864. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89865. * @returns intersection info or null if no intersection
  89866. */
  89867. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89868. /** @hidden */
  89869. private _intersectLines;
  89870. /** @hidden */
  89871. private _intersectUnIndexedLines;
  89872. /** @hidden */
  89873. private _intersectTriangles;
  89874. /** @hidden */
  89875. private _intersectUnIndexedTriangles;
  89876. /** @hidden */
  89877. _rebuild(): void;
  89878. /**
  89879. * Creates a new submesh from the passed mesh
  89880. * @param newMesh defines the new hosting mesh
  89881. * @param newRenderingMesh defines an optional rendering mesh
  89882. * @returns the new submesh
  89883. */
  89884. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89885. /**
  89886. * Release associated resources
  89887. */
  89888. dispose(): void;
  89889. /**
  89890. * Gets the class name
  89891. * @returns the string "SubMesh".
  89892. */
  89893. getClassName(): string;
  89894. /**
  89895. * Creates a new submesh from indices data
  89896. * @param materialIndex the index of the main mesh material
  89897. * @param startIndex the index where to start the copy in the mesh indices array
  89898. * @param indexCount the number of indices to copy then from the startIndex
  89899. * @param mesh the main mesh to create the submesh from
  89900. * @param renderingMesh the optional rendering mesh
  89901. * @returns a new submesh
  89902. */
  89903. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89904. }
  89905. }
  89906. declare module BABYLON {
  89907. /**
  89908. * Class used to represent data loading progression
  89909. */
  89910. export class SceneLoaderFlags {
  89911. private static _ForceFullSceneLoadingForIncremental;
  89912. private static _ShowLoadingScreen;
  89913. private static _CleanBoneMatrixWeights;
  89914. private static _loggingLevel;
  89915. /**
  89916. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89917. */
  89918. static ForceFullSceneLoadingForIncremental: boolean;
  89919. /**
  89920. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89921. */
  89922. static ShowLoadingScreen: boolean;
  89923. /**
  89924. * Defines the current logging level (while loading the scene)
  89925. * @ignorenaming
  89926. */
  89927. static loggingLevel: number;
  89928. /**
  89929. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89930. */
  89931. static CleanBoneMatrixWeights: boolean;
  89932. }
  89933. }
  89934. declare module BABYLON {
  89935. /**
  89936. * Class used to store geometry data (vertex buffers + index buffer)
  89937. */
  89938. export class Geometry implements IGetSetVerticesData {
  89939. /**
  89940. * Gets or sets the ID of the geometry
  89941. */
  89942. id: string;
  89943. /**
  89944. * Gets or sets the unique ID of the geometry
  89945. */
  89946. uniqueId: number;
  89947. /**
  89948. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89949. */
  89950. delayLoadState: number;
  89951. /**
  89952. * Gets the file containing the data to load when running in delay load state
  89953. */
  89954. delayLoadingFile: Nullable<string>;
  89955. /**
  89956. * Callback called when the geometry is updated
  89957. */
  89958. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89959. private _scene;
  89960. private _engine;
  89961. private _meshes;
  89962. private _totalVertices;
  89963. /** @hidden */
  89964. _indices: IndicesArray;
  89965. /** @hidden */
  89966. _vertexBuffers: {
  89967. [key: string]: VertexBuffer;
  89968. };
  89969. private _isDisposed;
  89970. private _extend;
  89971. private _boundingBias;
  89972. /** @hidden */
  89973. _delayInfo: Array<string>;
  89974. private _indexBuffer;
  89975. private _indexBufferIsUpdatable;
  89976. /** @hidden */
  89977. _boundingInfo: Nullable<BoundingInfo>;
  89978. /** @hidden */
  89979. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89980. /** @hidden */
  89981. _softwareSkinningFrameId: number;
  89982. private _vertexArrayObjects;
  89983. private _updatable;
  89984. /** @hidden */
  89985. _positions: Nullable<Vector3[]>;
  89986. /**
  89987. * 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
  89988. */
  89989. /**
  89990. * 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
  89991. */
  89992. boundingBias: Vector2;
  89993. /**
  89994. * Static function used to attach a new empty geometry to a mesh
  89995. * @param mesh defines the mesh to attach the geometry to
  89996. * @returns the new Geometry
  89997. */
  89998. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89999. /**
  90000. * Creates a new geometry
  90001. * @param id defines the unique ID
  90002. * @param scene defines the hosting scene
  90003. * @param vertexData defines the VertexData used to get geometry data
  90004. * @param updatable defines if geometry must be updatable (false by default)
  90005. * @param mesh defines the mesh that will be associated with the geometry
  90006. */
  90007. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  90008. /**
  90009. * Gets the current extend of the geometry
  90010. */
  90011. readonly extend: {
  90012. minimum: Vector3;
  90013. maximum: Vector3;
  90014. };
  90015. /**
  90016. * Gets the hosting scene
  90017. * @returns the hosting Scene
  90018. */
  90019. getScene(): Scene;
  90020. /**
  90021. * Gets the hosting engine
  90022. * @returns the hosting Engine
  90023. */
  90024. getEngine(): Engine;
  90025. /**
  90026. * Defines if the geometry is ready to use
  90027. * @returns true if the geometry is ready to be used
  90028. */
  90029. isReady(): boolean;
  90030. /**
  90031. * Gets a value indicating that the geometry should not be serialized
  90032. */
  90033. readonly doNotSerialize: boolean;
  90034. /** @hidden */
  90035. _rebuild(): void;
  90036. /**
  90037. * Affects all geometry data in one call
  90038. * @param vertexData defines the geometry data
  90039. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  90040. */
  90041. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  90042. /**
  90043. * Set specific vertex data
  90044. * @param kind defines the data kind (Position, normal, etc...)
  90045. * @param data defines the vertex data to use
  90046. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90047. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90048. */
  90049. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  90050. /**
  90051. * Removes a specific vertex data
  90052. * @param kind defines the data kind (Position, normal, etc...)
  90053. */
  90054. removeVerticesData(kind: string): void;
  90055. /**
  90056. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  90057. * @param buffer defines the vertex buffer to use
  90058. * @param totalVertices defines the total number of vertices for position kind (could be null)
  90059. */
  90060. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  90061. /**
  90062. * Update a specific vertex buffer
  90063. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  90064. * It will do nothing if the buffer is not updatable
  90065. * @param kind defines the data kind (Position, normal, etc...)
  90066. * @param data defines the data to use
  90067. * @param offset defines the offset in the target buffer where to store the data
  90068. * @param useBytes set to true if the offset is in bytes
  90069. */
  90070. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  90071. /**
  90072. * Update a specific vertex buffer
  90073. * This function will create a new buffer if the current one is not updatable
  90074. * @param kind defines the data kind (Position, normal, etc...)
  90075. * @param data defines the data to use
  90076. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  90077. */
  90078. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  90079. private _updateBoundingInfo;
  90080. /** @hidden */
  90081. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  90082. /**
  90083. * Gets total number of vertices
  90084. * @returns the total number of vertices
  90085. */
  90086. getTotalVertices(): number;
  90087. /**
  90088. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90089. * @param kind defines the data kind (Position, normal, etc...)
  90090. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90091. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90092. * @returns a float array containing vertex data
  90093. */
  90094. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90095. /**
  90096. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  90097. * @param kind defines the data kind (Position, normal, etc...)
  90098. * @returns true if the vertex buffer with the specified kind is updatable
  90099. */
  90100. isVertexBufferUpdatable(kind: string): boolean;
  90101. /**
  90102. * Gets a specific vertex buffer
  90103. * @param kind defines the data kind (Position, normal, etc...)
  90104. * @returns a VertexBuffer
  90105. */
  90106. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90107. /**
  90108. * Returns all vertex buffers
  90109. * @return an object holding all vertex buffers indexed by kind
  90110. */
  90111. getVertexBuffers(): Nullable<{
  90112. [key: string]: VertexBuffer;
  90113. }>;
  90114. /**
  90115. * Gets a boolean indicating if specific vertex buffer is present
  90116. * @param kind defines the data kind (Position, normal, etc...)
  90117. * @returns true if data is present
  90118. */
  90119. isVerticesDataPresent(kind: string): boolean;
  90120. /**
  90121. * Gets a list of all attached data kinds (Position, normal, etc...)
  90122. * @returns a list of string containing all kinds
  90123. */
  90124. getVerticesDataKinds(): string[];
  90125. /**
  90126. * Update index buffer
  90127. * @param indices defines the indices to store in the index buffer
  90128. * @param offset defines the offset in the target buffer where to store the data
  90129. * @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)
  90130. */
  90131. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  90132. /**
  90133. * Creates a new index buffer
  90134. * @param indices defines the indices to store in the index buffer
  90135. * @param totalVertices defines the total number of vertices (could be null)
  90136. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90137. */
  90138. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  90139. /**
  90140. * Return the total number of indices
  90141. * @returns the total number of indices
  90142. */
  90143. getTotalIndices(): number;
  90144. /**
  90145. * Gets the index buffer array
  90146. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90147. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90148. * @returns the index buffer array
  90149. */
  90150. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90151. /**
  90152. * Gets the index buffer
  90153. * @return the index buffer
  90154. */
  90155. getIndexBuffer(): Nullable<DataBuffer>;
  90156. /** @hidden */
  90157. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  90158. /**
  90159. * Release the associated resources for a specific mesh
  90160. * @param mesh defines the source mesh
  90161. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  90162. */
  90163. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  90164. /**
  90165. * Apply current geometry to a given mesh
  90166. * @param mesh defines the mesh to apply geometry to
  90167. */
  90168. applyToMesh(mesh: Mesh): void;
  90169. private _updateExtend;
  90170. private _applyToMesh;
  90171. private notifyUpdate;
  90172. /**
  90173. * Load the geometry if it was flagged as delay loaded
  90174. * @param scene defines the hosting scene
  90175. * @param onLoaded defines a callback called when the geometry is loaded
  90176. */
  90177. load(scene: Scene, onLoaded?: () => void): void;
  90178. private _queueLoad;
  90179. /**
  90180. * Invert the geometry to move from a right handed system to a left handed one.
  90181. */
  90182. toLeftHanded(): void;
  90183. /** @hidden */
  90184. _resetPointsArrayCache(): void;
  90185. /** @hidden */
  90186. _generatePointsArray(): boolean;
  90187. /**
  90188. * Gets a value indicating if the geometry is disposed
  90189. * @returns true if the geometry was disposed
  90190. */
  90191. isDisposed(): boolean;
  90192. private _disposeVertexArrayObjects;
  90193. /**
  90194. * Free all associated resources
  90195. */
  90196. dispose(): void;
  90197. /**
  90198. * Clone the current geometry into a new geometry
  90199. * @param id defines the unique ID of the new geometry
  90200. * @returns a new geometry object
  90201. */
  90202. copy(id: string): Geometry;
  90203. /**
  90204. * Serialize the current geometry info (and not the vertices data) into a JSON object
  90205. * @return a JSON representation of the current geometry data (without the vertices data)
  90206. */
  90207. serialize(): any;
  90208. private toNumberArray;
  90209. /**
  90210. * Serialize all vertices data into a JSON oject
  90211. * @returns a JSON representation of the current geometry data
  90212. */
  90213. serializeVerticeData(): any;
  90214. /**
  90215. * Extracts a clone of a mesh geometry
  90216. * @param mesh defines the source mesh
  90217. * @param id defines the unique ID of the new geometry object
  90218. * @returns the new geometry object
  90219. */
  90220. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  90221. /**
  90222. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  90223. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90224. * Be aware Math.random() could cause collisions, but:
  90225. * "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"
  90226. * @returns a string containing a new GUID
  90227. */
  90228. static RandomId(): string;
  90229. /** @hidden */
  90230. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  90231. private static _CleanMatricesWeights;
  90232. /**
  90233. * Create a new geometry from persisted data (Using .babylon file format)
  90234. * @param parsedVertexData defines the persisted data
  90235. * @param scene defines the hosting scene
  90236. * @param rootUrl defines the root url to use to load assets (like delayed data)
  90237. * @returns the new geometry object
  90238. */
  90239. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  90240. }
  90241. }
  90242. declare module BABYLON {
  90243. /**
  90244. * Define an interface for all classes that will get and set the data on vertices
  90245. */
  90246. export interface IGetSetVerticesData {
  90247. /**
  90248. * Gets a boolean indicating if specific vertex data is present
  90249. * @param kind defines the vertex data kind to use
  90250. * @returns true is data kind is present
  90251. */
  90252. isVerticesDataPresent(kind: string): boolean;
  90253. /**
  90254. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90255. * @param kind defines the data kind (Position, normal, etc...)
  90256. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90257. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90258. * @returns a float array containing vertex data
  90259. */
  90260. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90261. /**
  90262. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90263. * @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.
  90264. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90265. * @returns the indices array or an empty array if the mesh has no geometry
  90266. */
  90267. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90268. /**
  90269. * Set specific vertex data
  90270. * @param kind defines the data kind (Position, normal, etc...)
  90271. * @param data defines the vertex data to use
  90272. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90273. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90274. */
  90275. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  90276. /**
  90277. * Update a specific associated vertex buffer
  90278. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90279. * - VertexBuffer.PositionKind
  90280. * - VertexBuffer.UVKind
  90281. * - VertexBuffer.UV2Kind
  90282. * - VertexBuffer.UV3Kind
  90283. * - VertexBuffer.UV4Kind
  90284. * - VertexBuffer.UV5Kind
  90285. * - VertexBuffer.UV6Kind
  90286. * - VertexBuffer.ColorKind
  90287. * - VertexBuffer.MatricesIndicesKind
  90288. * - VertexBuffer.MatricesIndicesExtraKind
  90289. * - VertexBuffer.MatricesWeightsKind
  90290. * - VertexBuffer.MatricesWeightsExtraKind
  90291. * @param data defines the data source
  90292. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90293. * @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)
  90294. */
  90295. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  90296. /**
  90297. * Creates a new index buffer
  90298. * @param indices defines the indices to store in the index buffer
  90299. * @param totalVertices defines the total number of vertices (could be null)
  90300. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90301. */
  90302. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  90303. }
  90304. /**
  90305. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90306. */
  90307. export class VertexData {
  90308. /**
  90309. * Mesh side orientation : usually the external or front surface
  90310. */
  90311. static readonly FRONTSIDE: number;
  90312. /**
  90313. * Mesh side orientation : usually the internal or back surface
  90314. */
  90315. static readonly BACKSIDE: number;
  90316. /**
  90317. * Mesh side orientation : both internal and external or front and back surfaces
  90318. */
  90319. static readonly DOUBLESIDE: number;
  90320. /**
  90321. * Mesh side orientation : by default, `FRONTSIDE`
  90322. */
  90323. static readonly DEFAULTSIDE: number;
  90324. /**
  90325. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  90326. */
  90327. positions: Nullable<FloatArray>;
  90328. /**
  90329. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  90330. */
  90331. normals: Nullable<FloatArray>;
  90332. /**
  90333. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  90334. */
  90335. tangents: Nullable<FloatArray>;
  90336. /**
  90337. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90338. */
  90339. uvs: Nullable<FloatArray>;
  90340. /**
  90341. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90342. */
  90343. uvs2: Nullable<FloatArray>;
  90344. /**
  90345. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90346. */
  90347. uvs3: Nullable<FloatArray>;
  90348. /**
  90349. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90350. */
  90351. uvs4: Nullable<FloatArray>;
  90352. /**
  90353. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90354. */
  90355. uvs5: Nullable<FloatArray>;
  90356. /**
  90357. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90358. */
  90359. uvs6: Nullable<FloatArray>;
  90360. /**
  90361. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  90362. */
  90363. colors: Nullable<FloatArray>;
  90364. /**
  90365. * 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).
  90366. */
  90367. matricesIndices: Nullable<FloatArray>;
  90368. /**
  90369. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  90370. */
  90371. matricesWeights: Nullable<FloatArray>;
  90372. /**
  90373. * An array extending the number of possible indices
  90374. */
  90375. matricesIndicesExtra: Nullable<FloatArray>;
  90376. /**
  90377. * An array extending the number of possible weights when the number of indices is extended
  90378. */
  90379. matricesWeightsExtra: Nullable<FloatArray>;
  90380. /**
  90381. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  90382. */
  90383. indices: Nullable<IndicesArray>;
  90384. /**
  90385. * Uses the passed data array to set the set the values for the specified kind of data
  90386. * @param data a linear array of floating numbers
  90387. * @param kind the type of data that is being set, eg positions, colors etc
  90388. */
  90389. set(data: FloatArray, kind: string): void;
  90390. /**
  90391. * Associates the vertexData to the passed Mesh.
  90392. * Sets it as updatable or not (default `false`)
  90393. * @param mesh the mesh the vertexData is applied to
  90394. * @param updatable when used and having the value true allows new data to update the vertexData
  90395. * @returns the VertexData
  90396. */
  90397. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  90398. /**
  90399. * Associates the vertexData to the passed Geometry.
  90400. * Sets it as updatable or not (default `false`)
  90401. * @param geometry the geometry the vertexData is applied to
  90402. * @param updatable when used and having the value true allows new data to update the vertexData
  90403. * @returns VertexData
  90404. */
  90405. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  90406. /**
  90407. * Updates the associated mesh
  90408. * @param mesh the mesh to be updated
  90409. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90410. * @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
  90411. * @returns VertexData
  90412. */
  90413. updateMesh(mesh: Mesh): VertexData;
  90414. /**
  90415. * Updates the associated geometry
  90416. * @param geometry the geometry to be updated
  90417. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90418. * @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
  90419. * @returns VertexData.
  90420. */
  90421. updateGeometry(geometry: Geometry): VertexData;
  90422. private _applyTo;
  90423. private _update;
  90424. /**
  90425. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90426. * @param matrix the transforming matrix
  90427. * @returns the VertexData
  90428. */
  90429. transform(matrix: Matrix): VertexData;
  90430. /**
  90431. * Merges the passed VertexData into the current one
  90432. * @param other the VertexData to be merged into the current one
  90433. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90434. * @returns the modified VertexData
  90435. */
  90436. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  90437. private _mergeElement;
  90438. private _validate;
  90439. /**
  90440. * Serializes the VertexData
  90441. * @returns a serialized object
  90442. */
  90443. serialize(): any;
  90444. /**
  90445. * Extracts the vertexData from a mesh
  90446. * @param mesh the mesh from which to extract the VertexData
  90447. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90448. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90449. * @returns the object VertexData associated to the passed mesh
  90450. */
  90451. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90452. /**
  90453. * Extracts the vertexData from the geometry
  90454. * @param geometry the geometry from which to extract the VertexData
  90455. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90456. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90457. * @returns the object VertexData associated to the passed mesh
  90458. */
  90459. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90460. private static _ExtractFrom;
  90461. /**
  90462. * Creates the VertexData for a Ribbon
  90463. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90464. * * pathArray array of paths, each of which an array of successive Vector3
  90465. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90466. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90467. * * 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
  90468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90469. * * 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)
  90470. * * 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)
  90471. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90472. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90473. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90474. * @returns the VertexData of the ribbon
  90475. */
  90476. static CreateRibbon(options: {
  90477. pathArray: Vector3[][];
  90478. closeArray?: boolean;
  90479. closePath?: boolean;
  90480. offset?: number;
  90481. sideOrientation?: number;
  90482. frontUVs?: Vector4;
  90483. backUVs?: Vector4;
  90484. invertUV?: boolean;
  90485. uvs?: Vector2[];
  90486. colors?: Color4[];
  90487. }): VertexData;
  90488. /**
  90489. * Creates the VertexData for a box
  90490. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90491. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90492. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90493. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90494. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90495. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90496. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90498. * * 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)
  90499. * * 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)
  90500. * @returns the VertexData of the box
  90501. */
  90502. static CreateBox(options: {
  90503. size?: number;
  90504. width?: number;
  90505. height?: number;
  90506. depth?: number;
  90507. faceUV?: Vector4[];
  90508. faceColors?: Color4[];
  90509. sideOrientation?: number;
  90510. frontUVs?: Vector4;
  90511. backUVs?: Vector4;
  90512. }): VertexData;
  90513. /**
  90514. * Creates the VertexData for a tiled box
  90515. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90516. * * faceTiles sets the pattern, tile size and number of tiles for a face
  90517. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90518. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90520. * @returns the VertexData of the box
  90521. */
  90522. static CreateTiledBox(options: {
  90523. pattern?: number;
  90524. width?: number;
  90525. height?: number;
  90526. depth?: number;
  90527. tileSize?: number;
  90528. tileWidth?: number;
  90529. tileHeight?: number;
  90530. alignHorizontal?: number;
  90531. alignVertical?: number;
  90532. faceUV?: Vector4[];
  90533. faceColors?: Color4[];
  90534. sideOrientation?: number;
  90535. }): VertexData;
  90536. /**
  90537. * Creates the VertexData for a tiled plane
  90538. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90539. * * pattern a limited pattern arrangement depending on the number
  90540. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90541. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90542. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90543. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90544. * * 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)
  90545. * * 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)
  90546. * @returns the VertexData of the tiled plane
  90547. */
  90548. static CreateTiledPlane(options: {
  90549. pattern?: number;
  90550. tileSize?: number;
  90551. tileWidth?: number;
  90552. tileHeight?: number;
  90553. size?: number;
  90554. width?: number;
  90555. height?: number;
  90556. alignHorizontal?: number;
  90557. alignVertical?: number;
  90558. sideOrientation?: number;
  90559. frontUVs?: Vector4;
  90560. backUVs?: Vector4;
  90561. }): VertexData;
  90562. /**
  90563. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90564. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90565. * * segments sets the number of horizontal strips optional, default 32
  90566. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90567. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90568. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90569. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90570. * * 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
  90571. * * 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
  90572. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90573. * * 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)
  90574. * * 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)
  90575. * @returns the VertexData of the ellipsoid
  90576. */
  90577. static CreateSphere(options: {
  90578. segments?: number;
  90579. diameter?: number;
  90580. diameterX?: number;
  90581. diameterY?: number;
  90582. diameterZ?: number;
  90583. arc?: number;
  90584. slice?: number;
  90585. sideOrientation?: number;
  90586. frontUVs?: Vector4;
  90587. backUVs?: Vector4;
  90588. }): VertexData;
  90589. /**
  90590. * Creates the VertexData for a cylinder, cone or prism
  90591. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90592. * * height sets the height (y direction) of the cylinder, optional, default 2
  90593. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90594. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90595. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90596. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90597. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90598. * * 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
  90599. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90600. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90601. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90602. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90603. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90604. * * 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)
  90605. * * 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)
  90606. * @returns the VertexData of the cylinder, cone or prism
  90607. */
  90608. static CreateCylinder(options: {
  90609. height?: number;
  90610. diameterTop?: number;
  90611. diameterBottom?: number;
  90612. diameter?: number;
  90613. tessellation?: number;
  90614. subdivisions?: number;
  90615. arc?: number;
  90616. faceColors?: Color4[];
  90617. faceUV?: Vector4[];
  90618. hasRings?: boolean;
  90619. enclose?: boolean;
  90620. sideOrientation?: number;
  90621. frontUVs?: Vector4;
  90622. backUVs?: Vector4;
  90623. }): VertexData;
  90624. /**
  90625. * Creates the VertexData for a torus
  90626. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90627. * * diameter the diameter of the torus, optional default 1
  90628. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90629. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90630. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90631. * * 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)
  90632. * * 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)
  90633. * @returns the VertexData of the torus
  90634. */
  90635. static CreateTorus(options: {
  90636. diameter?: number;
  90637. thickness?: number;
  90638. tessellation?: number;
  90639. sideOrientation?: number;
  90640. frontUVs?: Vector4;
  90641. backUVs?: Vector4;
  90642. }): VertexData;
  90643. /**
  90644. * Creates the VertexData of the LineSystem
  90645. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90646. * - lines an array of lines, each line being an array of successive Vector3
  90647. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90648. * @returns the VertexData of the LineSystem
  90649. */
  90650. static CreateLineSystem(options: {
  90651. lines: Vector3[][];
  90652. colors?: Nullable<Color4[][]>;
  90653. }): VertexData;
  90654. /**
  90655. * Create the VertexData for a DashedLines
  90656. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90657. * - points an array successive Vector3
  90658. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90659. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90660. * - dashNb the intended total number of dashes, optional, default 200
  90661. * @returns the VertexData for the DashedLines
  90662. */
  90663. static CreateDashedLines(options: {
  90664. points: Vector3[];
  90665. dashSize?: number;
  90666. gapSize?: number;
  90667. dashNb?: number;
  90668. }): VertexData;
  90669. /**
  90670. * Creates the VertexData for a Ground
  90671. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90672. * - width the width (x direction) of the ground, optional, default 1
  90673. * - height the height (z direction) of the ground, optional, default 1
  90674. * - subdivisions the number of subdivisions per side, optional, default 1
  90675. * @returns the VertexData of the Ground
  90676. */
  90677. static CreateGround(options: {
  90678. width?: number;
  90679. height?: number;
  90680. subdivisions?: number;
  90681. subdivisionsX?: number;
  90682. subdivisionsY?: number;
  90683. }): VertexData;
  90684. /**
  90685. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90686. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90687. * * xmin the ground minimum X coordinate, optional, default -1
  90688. * * zmin the ground minimum Z coordinate, optional, default -1
  90689. * * xmax the ground maximum X coordinate, optional, default 1
  90690. * * zmax the ground maximum Z coordinate, optional, default 1
  90691. * * 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}
  90692. * * 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}
  90693. * @returns the VertexData of the TiledGround
  90694. */
  90695. static CreateTiledGround(options: {
  90696. xmin: number;
  90697. zmin: number;
  90698. xmax: number;
  90699. zmax: number;
  90700. subdivisions?: {
  90701. w: number;
  90702. h: number;
  90703. };
  90704. precision?: {
  90705. w: number;
  90706. h: number;
  90707. };
  90708. }): VertexData;
  90709. /**
  90710. * Creates the VertexData of the Ground designed from a heightmap
  90711. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90712. * * width the width (x direction) of the ground
  90713. * * height the height (z direction) of the ground
  90714. * * subdivisions the number of subdivisions per side
  90715. * * minHeight the minimum altitude on the ground, optional, default 0
  90716. * * maxHeight the maximum altitude on the ground, optional default 1
  90717. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90718. * * buffer the array holding the image color data
  90719. * * bufferWidth the width of image
  90720. * * bufferHeight the height of image
  90721. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90722. * @returns the VertexData of the Ground designed from a heightmap
  90723. */
  90724. static CreateGroundFromHeightMap(options: {
  90725. width: number;
  90726. height: number;
  90727. subdivisions: number;
  90728. minHeight: number;
  90729. maxHeight: number;
  90730. colorFilter: Color3;
  90731. buffer: Uint8Array;
  90732. bufferWidth: number;
  90733. bufferHeight: number;
  90734. alphaFilter: number;
  90735. }): VertexData;
  90736. /**
  90737. * Creates the VertexData for a Plane
  90738. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90739. * * size sets the width and height of the plane to the value of size, optional default 1
  90740. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90741. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90742. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90743. * * 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)
  90744. * * 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)
  90745. * @returns the VertexData of the box
  90746. */
  90747. static CreatePlane(options: {
  90748. size?: number;
  90749. width?: number;
  90750. height?: number;
  90751. sideOrientation?: number;
  90752. frontUVs?: Vector4;
  90753. backUVs?: Vector4;
  90754. }): VertexData;
  90755. /**
  90756. * Creates the VertexData of the Disc or regular Polygon
  90757. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90758. * * radius the radius of the disc, optional default 0.5
  90759. * * tessellation the number of polygon sides, optional, default 64
  90760. * * 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
  90761. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90762. * * 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)
  90763. * * 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)
  90764. * @returns the VertexData of the box
  90765. */
  90766. static CreateDisc(options: {
  90767. radius?: number;
  90768. tessellation?: number;
  90769. arc?: number;
  90770. sideOrientation?: number;
  90771. frontUVs?: Vector4;
  90772. backUVs?: Vector4;
  90773. }): VertexData;
  90774. /**
  90775. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90776. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90777. * @param polygon a mesh built from polygonTriangulation.build()
  90778. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90779. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90780. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90781. * @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)
  90782. * @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)
  90783. * @returns the VertexData of the Polygon
  90784. */
  90785. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90786. /**
  90787. * Creates the VertexData of the IcoSphere
  90788. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90789. * * radius the radius of the IcoSphere, optional default 1
  90790. * * radiusX allows stretching in the x direction, optional, default radius
  90791. * * radiusY allows stretching in the y direction, optional, default radius
  90792. * * radiusZ allows stretching in the z direction, optional, default radius
  90793. * * flat when true creates a flat shaded mesh, optional, default true
  90794. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90796. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  90797. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  90798. * @returns the VertexData of the IcoSphere
  90799. */
  90800. static CreateIcoSphere(options: {
  90801. radius?: number;
  90802. radiusX?: number;
  90803. radiusY?: number;
  90804. radiusZ?: number;
  90805. flat?: boolean;
  90806. subdivisions?: number;
  90807. sideOrientation?: number;
  90808. frontUVs?: Vector4;
  90809. backUVs?: Vector4;
  90810. }): VertexData;
  90811. /**
  90812. * Creates the VertexData for a Polyhedron
  90813. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90814. * * type provided types are:
  90815. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90816. * * 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)
  90817. * * size the size of the IcoSphere, optional default 1
  90818. * * sizeX allows stretching in the x direction, optional, default size
  90819. * * sizeY allows stretching in the y direction, optional, default size
  90820. * * sizeZ allows stretching in the z direction, optional, default size
  90821. * * 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
  90822. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90823. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90824. * * flat when true creates a flat shaded mesh, optional, default true
  90825. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90827. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  90828. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  90829. * @returns the VertexData of the Polyhedron
  90830. */
  90831. static CreatePolyhedron(options: {
  90832. type?: number;
  90833. size?: number;
  90834. sizeX?: number;
  90835. sizeY?: number;
  90836. sizeZ?: number;
  90837. custom?: any;
  90838. faceUV?: Vector4[];
  90839. faceColors?: Color4[];
  90840. flat?: boolean;
  90841. sideOrientation?: number;
  90842. frontUVs?: Vector4;
  90843. backUVs?: Vector4;
  90844. }): VertexData;
  90845. /**
  90846. * Creates the VertexData for a TorusKnot
  90847. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90848. * * radius the radius of the torus knot, optional, default 2
  90849. * * tube the thickness of the tube, optional, default 0.5
  90850. * * radialSegments the number of sides on each tube segments, optional, default 32
  90851. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90852. * * p the number of windings around the z axis, optional, default 2
  90853. * * q the number of windings around the x axis, optional, default 3
  90854. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90855. * * 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)
  90856. * * 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)
  90857. * @returns the VertexData of the Torus Knot
  90858. */
  90859. static CreateTorusKnot(options: {
  90860. radius?: number;
  90861. tube?: number;
  90862. radialSegments?: number;
  90863. tubularSegments?: number;
  90864. p?: number;
  90865. q?: number;
  90866. sideOrientation?: number;
  90867. frontUVs?: Vector4;
  90868. backUVs?: Vector4;
  90869. }): VertexData;
  90870. /**
  90871. * Compute normals for given positions and indices
  90872. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90873. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90874. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90875. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90876. * * facetNormals : optional array of facet normals (vector3)
  90877. * * facetPositions : optional array of facet positions (vector3)
  90878. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90879. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90880. * * bInfo : optional bounding info, required for facetPartitioning computation
  90881. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90882. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90883. * * useRightHandedSystem: optional boolean to for right handed system computation
  90884. * * depthSort : optional boolean to enable the facet depth sort computation
  90885. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90886. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90887. */
  90888. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90889. facetNormals?: any;
  90890. facetPositions?: any;
  90891. facetPartitioning?: any;
  90892. ratio?: number;
  90893. bInfo?: any;
  90894. bbSize?: Vector3;
  90895. subDiv?: any;
  90896. useRightHandedSystem?: boolean;
  90897. depthSort?: boolean;
  90898. distanceTo?: Vector3;
  90899. depthSortedFacets?: any;
  90900. }): void;
  90901. /** @hidden */
  90902. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90903. /**
  90904. * Applies VertexData created from the imported parameters to the geometry
  90905. * @param parsedVertexData the parsed data from an imported file
  90906. * @param geometry the geometry to apply the VertexData to
  90907. */
  90908. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90909. }
  90910. }
  90911. declare module BABYLON {
  90912. /**
  90913. * Defines a target to use with MorphTargetManager
  90914. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90915. */
  90916. export class MorphTarget implements IAnimatable {
  90917. /** defines the name of the target */
  90918. name: string;
  90919. /**
  90920. * Gets or sets the list of animations
  90921. */
  90922. animations: Animation[];
  90923. private _scene;
  90924. private _positions;
  90925. private _normals;
  90926. private _tangents;
  90927. private _uvs;
  90928. private _influence;
  90929. private _uniqueId;
  90930. /**
  90931. * Observable raised when the influence changes
  90932. */
  90933. onInfluenceChanged: Observable<boolean>;
  90934. /** @hidden */
  90935. _onDataLayoutChanged: Observable<void>;
  90936. /**
  90937. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90938. */
  90939. influence: number;
  90940. /**
  90941. * Gets or sets the id of the morph Target
  90942. */
  90943. id: string;
  90944. private _animationPropertiesOverride;
  90945. /**
  90946. * Gets or sets the animation properties override
  90947. */
  90948. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90949. /**
  90950. * Creates a new MorphTarget
  90951. * @param name defines the name of the target
  90952. * @param influence defines the influence to use
  90953. * @param scene defines the scene the morphtarget belongs to
  90954. */
  90955. constructor(
  90956. /** defines the name of the target */
  90957. name: string, influence?: number, scene?: Nullable<Scene>);
  90958. /**
  90959. * Gets the unique ID of this manager
  90960. */
  90961. readonly uniqueId: number;
  90962. /**
  90963. * Gets a boolean defining if the target contains position data
  90964. */
  90965. readonly hasPositions: boolean;
  90966. /**
  90967. * Gets a boolean defining if the target contains normal data
  90968. */
  90969. readonly hasNormals: boolean;
  90970. /**
  90971. * Gets a boolean defining if the target contains tangent data
  90972. */
  90973. readonly hasTangents: boolean;
  90974. /**
  90975. * Gets a boolean defining if the target contains texture coordinates data
  90976. */
  90977. readonly hasUVs: boolean;
  90978. /**
  90979. * Affects position data to this target
  90980. * @param data defines the position data to use
  90981. */
  90982. setPositions(data: Nullable<FloatArray>): void;
  90983. /**
  90984. * Gets the position data stored in this target
  90985. * @returns a FloatArray containing the position data (or null if not present)
  90986. */
  90987. getPositions(): Nullable<FloatArray>;
  90988. /**
  90989. * Affects normal data to this target
  90990. * @param data defines the normal data to use
  90991. */
  90992. setNormals(data: Nullable<FloatArray>): void;
  90993. /**
  90994. * Gets the normal data stored in this target
  90995. * @returns a FloatArray containing the normal data (or null if not present)
  90996. */
  90997. getNormals(): Nullable<FloatArray>;
  90998. /**
  90999. * Affects tangent data to this target
  91000. * @param data defines the tangent data to use
  91001. */
  91002. setTangents(data: Nullable<FloatArray>): void;
  91003. /**
  91004. * Gets the tangent data stored in this target
  91005. * @returns a FloatArray containing the tangent data (or null if not present)
  91006. */
  91007. getTangents(): Nullable<FloatArray>;
  91008. /**
  91009. * Affects texture coordinates data to this target
  91010. * @param data defines the texture coordinates data to use
  91011. */
  91012. setUVs(data: Nullable<FloatArray>): void;
  91013. /**
  91014. * Gets the texture coordinates data stored in this target
  91015. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  91016. */
  91017. getUVs(): Nullable<FloatArray>;
  91018. /**
  91019. * Clone the current target
  91020. * @returns a new MorphTarget
  91021. */
  91022. clone(): MorphTarget;
  91023. /**
  91024. * Serializes the current target into a Serialization object
  91025. * @returns the serialized object
  91026. */
  91027. serialize(): any;
  91028. /**
  91029. * Returns the string "MorphTarget"
  91030. * @returns "MorphTarget"
  91031. */
  91032. getClassName(): string;
  91033. /**
  91034. * Creates a new target from serialized data
  91035. * @param serializationObject defines the serialized data to use
  91036. * @returns a new MorphTarget
  91037. */
  91038. static Parse(serializationObject: any): MorphTarget;
  91039. /**
  91040. * Creates a MorphTarget from mesh data
  91041. * @param mesh defines the source mesh
  91042. * @param name defines the name to use for the new target
  91043. * @param influence defines the influence to attach to the target
  91044. * @returns a new MorphTarget
  91045. */
  91046. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  91047. }
  91048. }
  91049. declare module BABYLON {
  91050. /**
  91051. * This class is used to deform meshes using morphing between different targets
  91052. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91053. */
  91054. export class MorphTargetManager {
  91055. private _targets;
  91056. private _targetInfluenceChangedObservers;
  91057. private _targetDataLayoutChangedObservers;
  91058. private _activeTargets;
  91059. private _scene;
  91060. private _influences;
  91061. private _supportsNormals;
  91062. private _supportsTangents;
  91063. private _supportsUVs;
  91064. private _vertexCount;
  91065. private _uniqueId;
  91066. private _tempInfluences;
  91067. /**
  91068. * Gets or sets a boolean indicating if normals must be morphed
  91069. */
  91070. enableNormalMorphing: boolean;
  91071. /**
  91072. * Gets or sets a boolean indicating if tangents must be morphed
  91073. */
  91074. enableTangentMorphing: boolean;
  91075. /**
  91076. * Gets or sets a boolean indicating if UV must be morphed
  91077. */
  91078. enableUVMorphing: boolean;
  91079. /**
  91080. * Creates a new MorphTargetManager
  91081. * @param scene defines the current scene
  91082. */
  91083. constructor(scene?: Nullable<Scene>);
  91084. /**
  91085. * Gets the unique ID of this manager
  91086. */
  91087. readonly uniqueId: number;
  91088. /**
  91089. * Gets the number of vertices handled by this manager
  91090. */
  91091. readonly vertexCount: number;
  91092. /**
  91093. * Gets a boolean indicating if this manager supports morphing of normals
  91094. */
  91095. readonly supportsNormals: boolean;
  91096. /**
  91097. * Gets a boolean indicating if this manager supports morphing of tangents
  91098. */
  91099. readonly supportsTangents: boolean;
  91100. /**
  91101. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  91102. */
  91103. readonly supportsUVs: boolean;
  91104. /**
  91105. * Gets the number of targets stored in this manager
  91106. */
  91107. readonly numTargets: number;
  91108. /**
  91109. * Gets the number of influencers (ie. the number of targets with influences > 0)
  91110. */
  91111. readonly numInfluencers: number;
  91112. /**
  91113. * Gets the list of influences (one per target)
  91114. */
  91115. readonly influences: Float32Array;
  91116. /**
  91117. * Gets the active target at specified index. An active target is a target with an influence > 0
  91118. * @param index defines the index to check
  91119. * @returns the requested target
  91120. */
  91121. getActiveTarget(index: number): MorphTarget;
  91122. /**
  91123. * Gets the target at specified index
  91124. * @param index defines the index to check
  91125. * @returns the requested target
  91126. */
  91127. getTarget(index: number): MorphTarget;
  91128. /**
  91129. * Add a new target to this manager
  91130. * @param target defines the target to add
  91131. */
  91132. addTarget(target: MorphTarget): void;
  91133. /**
  91134. * Removes a target from the manager
  91135. * @param target defines the target to remove
  91136. */
  91137. removeTarget(target: MorphTarget): void;
  91138. /**
  91139. * Clone the current manager
  91140. * @returns a new MorphTargetManager
  91141. */
  91142. clone(): MorphTargetManager;
  91143. /**
  91144. * Serializes the current manager into a Serialization object
  91145. * @returns the serialized object
  91146. */
  91147. serialize(): any;
  91148. private _syncActiveTargets;
  91149. /**
  91150. * Syncrhonize the targets with all the meshes using this morph target manager
  91151. */
  91152. synchronize(): void;
  91153. /**
  91154. * Creates a new MorphTargetManager from serialized data
  91155. * @param serializationObject defines the serialized data
  91156. * @param scene defines the hosting scene
  91157. * @returns the new MorphTargetManager
  91158. */
  91159. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  91160. }
  91161. }
  91162. declare module BABYLON {
  91163. /**
  91164. * Class used to represent a specific level of detail of a mesh
  91165. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91166. */
  91167. export class MeshLODLevel {
  91168. /** Defines the distance where this level should start being displayed */
  91169. distance: number;
  91170. /** Defines the mesh to use to render this level */
  91171. mesh: Nullable<Mesh>;
  91172. /**
  91173. * Creates a new LOD level
  91174. * @param distance defines the distance where this level should star being displayed
  91175. * @param mesh defines the mesh to use to render this level
  91176. */
  91177. constructor(
  91178. /** Defines the distance where this level should start being displayed */
  91179. distance: number,
  91180. /** Defines the mesh to use to render this level */
  91181. mesh: Nullable<Mesh>);
  91182. }
  91183. }
  91184. declare module BABYLON {
  91185. /**
  91186. * Mesh representing the gorund
  91187. */
  91188. export class GroundMesh extends Mesh {
  91189. /** If octree should be generated */
  91190. generateOctree: boolean;
  91191. private _heightQuads;
  91192. /** @hidden */
  91193. _subdivisionsX: number;
  91194. /** @hidden */
  91195. _subdivisionsY: number;
  91196. /** @hidden */
  91197. _width: number;
  91198. /** @hidden */
  91199. _height: number;
  91200. /** @hidden */
  91201. _minX: number;
  91202. /** @hidden */
  91203. _maxX: number;
  91204. /** @hidden */
  91205. _minZ: number;
  91206. /** @hidden */
  91207. _maxZ: number;
  91208. constructor(name: string, scene: Scene);
  91209. /**
  91210. * "GroundMesh"
  91211. * @returns "GroundMesh"
  91212. */
  91213. getClassName(): string;
  91214. /**
  91215. * The minimum of x and y subdivisions
  91216. */
  91217. readonly subdivisions: number;
  91218. /**
  91219. * X subdivisions
  91220. */
  91221. readonly subdivisionsX: number;
  91222. /**
  91223. * Y subdivisions
  91224. */
  91225. readonly subdivisionsY: number;
  91226. /**
  91227. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  91228. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  91229. * @param chunksCount the number of subdivisions for x and y
  91230. * @param octreeBlocksSize (Default: 32)
  91231. */
  91232. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  91233. /**
  91234. * Returns a height (y) value in the Worl system :
  91235. * the ground altitude at the coordinates (x, z) expressed in the World system.
  91236. * @param x x coordinate
  91237. * @param z z coordinate
  91238. * @returns the ground y position if (x, z) are outside the ground surface.
  91239. */
  91240. getHeightAtCoordinates(x: number, z: number): number;
  91241. /**
  91242. * Returns a normalized vector (Vector3) orthogonal to the ground
  91243. * at the ground coordinates (x, z) expressed in the World system.
  91244. * @param x x coordinate
  91245. * @param z z coordinate
  91246. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  91247. */
  91248. getNormalAtCoordinates(x: number, z: number): Vector3;
  91249. /**
  91250. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  91251. * at the ground coordinates (x, z) expressed in the World system.
  91252. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  91253. * @param x x coordinate
  91254. * @param z z coordinate
  91255. * @param ref vector to store the result
  91256. * @returns the GroundMesh.
  91257. */
  91258. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  91259. /**
  91260. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  91261. * if the ground has been updated.
  91262. * This can be used in the render loop.
  91263. * @returns the GroundMesh.
  91264. */
  91265. updateCoordinateHeights(): GroundMesh;
  91266. private _getFacetAt;
  91267. private _initHeightQuads;
  91268. private _computeHeightQuads;
  91269. /**
  91270. * Serializes this ground mesh
  91271. * @param serializationObject object to write serialization to
  91272. */
  91273. serialize(serializationObject: any): void;
  91274. /**
  91275. * Parses a serialized ground mesh
  91276. * @param parsedMesh the serialized mesh
  91277. * @param scene the scene to create the ground mesh in
  91278. * @returns the created ground mesh
  91279. */
  91280. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  91281. }
  91282. }
  91283. declare module BABYLON {
  91284. /**
  91285. * Interface for Physics-Joint data
  91286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91287. */
  91288. export interface PhysicsJointData {
  91289. /**
  91290. * The main pivot of the joint
  91291. */
  91292. mainPivot?: Vector3;
  91293. /**
  91294. * The connected pivot of the joint
  91295. */
  91296. connectedPivot?: Vector3;
  91297. /**
  91298. * The main axis of the joint
  91299. */
  91300. mainAxis?: Vector3;
  91301. /**
  91302. * The connected axis of the joint
  91303. */
  91304. connectedAxis?: Vector3;
  91305. /**
  91306. * The collision of the joint
  91307. */
  91308. collision?: boolean;
  91309. /**
  91310. * Native Oimo/Cannon/Energy data
  91311. */
  91312. nativeParams?: any;
  91313. }
  91314. /**
  91315. * This is a holder class for the physics joint created by the physics plugin
  91316. * It holds a set of functions to control the underlying joint
  91317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91318. */
  91319. export class PhysicsJoint {
  91320. /**
  91321. * The type of the physics joint
  91322. */
  91323. type: number;
  91324. /**
  91325. * The data for the physics joint
  91326. */
  91327. jointData: PhysicsJointData;
  91328. private _physicsJoint;
  91329. protected _physicsPlugin: IPhysicsEnginePlugin;
  91330. /**
  91331. * Initializes the physics joint
  91332. * @param type The type of the physics joint
  91333. * @param jointData The data for the physics joint
  91334. */
  91335. constructor(
  91336. /**
  91337. * The type of the physics joint
  91338. */
  91339. type: number,
  91340. /**
  91341. * The data for the physics joint
  91342. */
  91343. jointData: PhysicsJointData);
  91344. /**
  91345. * Gets the physics joint
  91346. */
  91347. /**
  91348. * Sets the physics joint
  91349. */
  91350. physicsJoint: any;
  91351. /**
  91352. * Sets the physics plugin
  91353. */
  91354. physicsPlugin: IPhysicsEnginePlugin;
  91355. /**
  91356. * Execute a function that is physics-plugin specific.
  91357. * @param {Function} func the function that will be executed.
  91358. * It accepts two parameters: the physics world and the physics joint
  91359. */
  91360. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  91361. /**
  91362. * Distance-Joint type
  91363. */
  91364. static DistanceJoint: number;
  91365. /**
  91366. * Hinge-Joint type
  91367. */
  91368. static HingeJoint: number;
  91369. /**
  91370. * Ball-and-Socket joint type
  91371. */
  91372. static BallAndSocketJoint: number;
  91373. /**
  91374. * Wheel-Joint type
  91375. */
  91376. static WheelJoint: number;
  91377. /**
  91378. * Slider-Joint type
  91379. */
  91380. static SliderJoint: number;
  91381. /**
  91382. * Prismatic-Joint type
  91383. */
  91384. static PrismaticJoint: number;
  91385. /**
  91386. * Universal-Joint type
  91387. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  91388. */
  91389. static UniversalJoint: number;
  91390. /**
  91391. * Hinge-Joint 2 type
  91392. */
  91393. static Hinge2Joint: number;
  91394. /**
  91395. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  91396. */
  91397. static PointToPointJoint: number;
  91398. /**
  91399. * Spring-Joint type
  91400. */
  91401. static SpringJoint: number;
  91402. /**
  91403. * Lock-Joint type
  91404. */
  91405. static LockJoint: number;
  91406. }
  91407. /**
  91408. * A class representing a physics distance joint
  91409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91410. */
  91411. export class DistanceJoint extends PhysicsJoint {
  91412. /**
  91413. *
  91414. * @param jointData The data for the Distance-Joint
  91415. */
  91416. constructor(jointData: DistanceJointData);
  91417. /**
  91418. * Update the predefined distance.
  91419. * @param maxDistance The maximum preferred distance
  91420. * @param minDistance The minimum preferred distance
  91421. */
  91422. updateDistance(maxDistance: number, minDistance?: number): void;
  91423. }
  91424. /**
  91425. * Represents a Motor-Enabled Joint
  91426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91427. */
  91428. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  91429. /**
  91430. * Initializes the Motor-Enabled Joint
  91431. * @param type The type of the joint
  91432. * @param jointData The physica joint data for the joint
  91433. */
  91434. constructor(type: number, jointData: PhysicsJointData);
  91435. /**
  91436. * Set the motor values.
  91437. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91438. * @param force the force to apply
  91439. * @param maxForce max force for this motor.
  91440. */
  91441. setMotor(force?: number, maxForce?: number): void;
  91442. /**
  91443. * Set the motor's limits.
  91444. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91445. * @param upperLimit The upper limit of the motor
  91446. * @param lowerLimit The lower limit of the motor
  91447. */
  91448. setLimit(upperLimit: number, lowerLimit?: number): void;
  91449. }
  91450. /**
  91451. * This class represents a single physics Hinge-Joint
  91452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91453. */
  91454. export class HingeJoint extends MotorEnabledJoint {
  91455. /**
  91456. * Initializes the Hinge-Joint
  91457. * @param jointData The joint data for the Hinge-Joint
  91458. */
  91459. constructor(jointData: PhysicsJointData);
  91460. /**
  91461. * Set the motor values.
  91462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91463. * @param {number} force the force to apply
  91464. * @param {number} maxForce max force for this motor.
  91465. */
  91466. setMotor(force?: number, maxForce?: number): void;
  91467. /**
  91468. * Set the motor's limits.
  91469. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91470. * @param upperLimit The upper limit of the motor
  91471. * @param lowerLimit The lower limit of the motor
  91472. */
  91473. setLimit(upperLimit: number, lowerLimit?: number): void;
  91474. }
  91475. /**
  91476. * This class represents a dual hinge physics joint (same as wheel joint)
  91477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91478. */
  91479. export class Hinge2Joint extends MotorEnabledJoint {
  91480. /**
  91481. * Initializes the Hinge2-Joint
  91482. * @param jointData The joint data for the Hinge2-Joint
  91483. */
  91484. constructor(jointData: PhysicsJointData);
  91485. /**
  91486. * Set the motor values.
  91487. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91488. * @param {number} targetSpeed the speed the motor is to reach
  91489. * @param {number} maxForce max force for this motor.
  91490. * @param {motorIndex} the motor's index, 0 or 1.
  91491. */
  91492. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  91493. /**
  91494. * Set the motor limits.
  91495. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91496. * @param {number} upperLimit the upper limit
  91497. * @param {number} lowerLimit lower limit
  91498. * @param {motorIndex} the motor's index, 0 or 1.
  91499. */
  91500. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91501. }
  91502. /**
  91503. * Interface for a motor enabled joint
  91504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91505. */
  91506. export interface IMotorEnabledJoint {
  91507. /**
  91508. * Physics joint
  91509. */
  91510. physicsJoint: any;
  91511. /**
  91512. * Sets the motor of the motor-enabled joint
  91513. * @param force The force of the motor
  91514. * @param maxForce The maximum force of the motor
  91515. * @param motorIndex The index of the motor
  91516. */
  91517. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  91518. /**
  91519. * Sets the limit of the motor
  91520. * @param upperLimit The upper limit of the motor
  91521. * @param lowerLimit The lower limit of the motor
  91522. * @param motorIndex The index of the motor
  91523. */
  91524. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91525. }
  91526. /**
  91527. * Joint data for a Distance-Joint
  91528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91529. */
  91530. export interface DistanceJointData extends PhysicsJointData {
  91531. /**
  91532. * Max distance the 2 joint objects can be apart
  91533. */
  91534. maxDistance: number;
  91535. }
  91536. /**
  91537. * Joint data from a spring joint
  91538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91539. */
  91540. export interface SpringJointData extends PhysicsJointData {
  91541. /**
  91542. * Length of the spring
  91543. */
  91544. length: number;
  91545. /**
  91546. * Stiffness of the spring
  91547. */
  91548. stiffness: number;
  91549. /**
  91550. * Damping of the spring
  91551. */
  91552. damping: number;
  91553. /** this callback will be called when applying the force to the impostors. */
  91554. forceApplicationCallback: () => void;
  91555. }
  91556. }
  91557. declare module BABYLON {
  91558. /**
  91559. * Holds the data for the raycast result
  91560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91561. */
  91562. export class PhysicsRaycastResult {
  91563. private _hasHit;
  91564. private _hitDistance;
  91565. private _hitNormalWorld;
  91566. private _hitPointWorld;
  91567. private _rayFromWorld;
  91568. private _rayToWorld;
  91569. /**
  91570. * Gets if there was a hit
  91571. */
  91572. readonly hasHit: boolean;
  91573. /**
  91574. * Gets the distance from the hit
  91575. */
  91576. readonly hitDistance: number;
  91577. /**
  91578. * Gets the hit normal/direction in the world
  91579. */
  91580. readonly hitNormalWorld: Vector3;
  91581. /**
  91582. * Gets the hit point in the world
  91583. */
  91584. readonly hitPointWorld: Vector3;
  91585. /**
  91586. * Gets the ray "start point" of the ray in the world
  91587. */
  91588. readonly rayFromWorld: Vector3;
  91589. /**
  91590. * Gets the ray "end point" of the ray in the world
  91591. */
  91592. readonly rayToWorld: Vector3;
  91593. /**
  91594. * Sets the hit data (normal & point in world space)
  91595. * @param hitNormalWorld defines the normal in world space
  91596. * @param hitPointWorld defines the point in world space
  91597. */
  91598. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91599. /**
  91600. * Sets the distance from the start point to the hit point
  91601. * @param distance
  91602. */
  91603. setHitDistance(distance: number): void;
  91604. /**
  91605. * Calculates the distance manually
  91606. */
  91607. calculateHitDistance(): void;
  91608. /**
  91609. * Resets all the values to default
  91610. * @param from The from point on world space
  91611. * @param to The to point on world space
  91612. */
  91613. reset(from?: Vector3, to?: Vector3): void;
  91614. }
  91615. /**
  91616. * Interface for the size containing width and height
  91617. */
  91618. interface IXYZ {
  91619. /**
  91620. * X
  91621. */
  91622. x: number;
  91623. /**
  91624. * Y
  91625. */
  91626. y: number;
  91627. /**
  91628. * Z
  91629. */
  91630. z: number;
  91631. }
  91632. }
  91633. declare module BABYLON {
  91634. /**
  91635. * Interface used to describe a physics joint
  91636. */
  91637. export interface PhysicsImpostorJoint {
  91638. /** Defines the main impostor to which the joint is linked */
  91639. mainImpostor: PhysicsImpostor;
  91640. /** Defines the impostor that is connected to the main impostor using this joint */
  91641. connectedImpostor: PhysicsImpostor;
  91642. /** Defines the joint itself */
  91643. joint: PhysicsJoint;
  91644. }
  91645. /** @hidden */
  91646. export interface IPhysicsEnginePlugin {
  91647. world: any;
  91648. name: string;
  91649. setGravity(gravity: Vector3): void;
  91650. setTimeStep(timeStep: number): void;
  91651. getTimeStep(): number;
  91652. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91653. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91654. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91655. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91656. removePhysicsBody(impostor: PhysicsImpostor): void;
  91657. generateJoint(joint: PhysicsImpostorJoint): void;
  91658. removeJoint(joint: PhysicsImpostorJoint): void;
  91659. isSupported(): boolean;
  91660. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91661. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91663. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91664. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91665. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91667. getBodyMass(impostor: PhysicsImpostor): number;
  91668. getBodyFriction(impostor: PhysicsImpostor): number;
  91669. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91670. getBodyRestitution(impostor: PhysicsImpostor): number;
  91671. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91672. getBodyPressure?(impostor: PhysicsImpostor): number;
  91673. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  91674. getBodyStiffness?(impostor: PhysicsImpostor): number;
  91675. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  91676. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  91677. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  91678. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  91679. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  91680. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91681. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91682. sleepBody(impostor: PhysicsImpostor): void;
  91683. wakeUpBody(impostor: PhysicsImpostor): void;
  91684. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91685. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  91686. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  91687. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91688. getRadius(impostor: PhysicsImpostor): number;
  91689. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  91690. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  91691. dispose(): void;
  91692. }
  91693. /**
  91694. * Interface used to define a physics engine
  91695. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  91696. */
  91697. export interface IPhysicsEngine {
  91698. /**
  91699. * Gets the gravity vector used by the simulation
  91700. */
  91701. gravity: Vector3;
  91702. /**
  91703. * Sets the gravity vector used by the simulation
  91704. * @param gravity defines the gravity vector to use
  91705. */
  91706. setGravity(gravity: Vector3): void;
  91707. /**
  91708. * Set the time step of the physics engine.
  91709. * Default is 1/60.
  91710. * To slow it down, enter 1/600 for example.
  91711. * To speed it up, 1/30
  91712. * @param newTimeStep the new timestep to apply to this world.
  91713. */
  91714. setTimeStep(newTimeStep: number): void;
  91715. /**
  91716. * Get the time step of the physics engine.
  91717. * @returns the current time step
  91718. */
  91719. getTimeStep(): number;
  91720. /**
  91721. * Release all resources
  91722. */
  91723. dispose(): void;
  91724. /**
  91725. * Gets the name of the current physics plugin
  91726. * @returns the name of the plugin
  91727. */
  91728. getPhysicsPluginName(): string;
  91729. /**
  91730. * Adding a new impostor for the impostor tracking.
  91731. * This will be done by the impostor itself.
  91732. * @param impostor the impostor to add
  91733. */
  91734. addImpostor(impostor: PhysicsImpostor): void;
  91735. /**
  91736. * Remove an impostor from the engine.
  91737. * This impostor and its mesh will not longer be updated by the physics engine.
  91738. * @param impostor the impostor to remove
  91739. */
  91740. removeImpostor(impostor: PhysicsImpostor): void;
  91741. /**
  91742. * Add a joint to the physics engine
  91743. * @param mainImpostor defines the main impostor to which the joint is added.
  91744. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  91745. * @param joint defines the joint that will connect both impostors.
  91746. */
  91747. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91748. /**
  91749. * Removes a joint from the simulation
  91750. * @param mainImpostor defines the impostor used with the joint
  91751. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  91752. * @param joint defines the joint to remove
  91753. */
  91754. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91755. /**
  91756. * Gets the current plugin used to run the simulation
  91757. * @returns current plugin
  91758. */
  91759. getPhysicsPlugin(): IPhysicsEnginePlugin;
  91760. /**
  91761. * Gets the list of physic impostors
  91762. * @returns an array of PhysicsImpostor
  91763. */
  91764. getImpostors(): Array<PhysicsImpostor>;
  91765. /**
  91766. * Gets the impostor for a physics enabled object
  91767. * @param object defines the object impersonated by the impostor
  91768. * @returns the PhysicsImpostor or null if not found
  91769. */
  91770. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91771. /**
  91772. * Gets the impostor for a physics body object
  91773. * @param body defines physics body used by the impostor
  91774. * @returns the PhysicsImpostor or null if not found
  91775. */
  91776. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91777. /**
  91778. * Does a raycast in the physics world
  91779. * @param from when should the ray start?
  91780. * @param to when should the ray end?
  91781. * @returns PhysicsRaycastResult
  91782. */
  91783. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91784. /**
  91785. * Called by the scene. No need to call it.
  91786. * @param delta defines the timespam between frames
  91787. */
  91788. _step(delta: number): void;
  91789. }
  91790. }
  91791. declare module BABYLON {
  91792. /**
  91793. * The interface for the physics imposter parameters
  91794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91795. */
  91796. export interface PhysicsImpostorParameters {
  91797. /**
  91798. * The mass of the physics imposter
  91799. */
  91800. mass: number;
  91801. /**
  91802. * The friction of the physics imposter
  91803. */
  91804. friction?: number;
  91805. /**
  91806. * The coefficient of restitution of the physics imposter
  91807. */
  91808. restitution?: number;
  91809. /**
  91810. * The native options of the physics imposter
  91811. */
  91812. nativeOptions?: any;
  91813. /**
  91814. * Specifies if the parent should be ignored
  91815. */
  91816. ignoreParent?: boolean;
  91817. /**
  91818. * Specifies if bi-directional transformations should be disabled
  91819. */
  91820. disableBidirectionalTransformation?: boolean;
  91821. /**
  91822. * The pressure inside the physics imposter, soft object only
  91823. */
  91824. pressure?: number;
  91825. /**
  91826. * The stiffness the physics imposter, soft object only
  91827. */
  91828. stiffness?: number;
  91829. /**
  91830. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91831. */
  91832. velocityIterations?: number;
  91833. /**
  91834. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91835. */
  91836. positionIterations?: number;
  91837. /**
  91838. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91839. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91840. * Add to fix multiple points
  91841. */
  91842. fixedPoints?: number;
  91843. /**
  91844. * The collision margin around a soft object
  91845. */
  91846. margin?: number;
  91847. /**
  91848. * The collision margin around a soft object
  91849. */
  91850. damping?: number;
  91851. /**
  91852. * The path for a rope based on an extrusion
  91853. */
  91854. path?: any;
  91855. /**
  91856. * The shape of an extrusion used for a rope based on an extrusion
  91857. */
  91858. shape?: any;
  91859. }
  91860. /**
  91861. * Interface for a physics-enabled object
  91862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91863. */
  91864. export interface IPhysicsEnabledObject {
  91865. /**
  91866. * The position of the physics-enabled object
  91867. */
  91868. position: Vector3;
  91869. /**
  91870. * The rotation of the physics-enabled object
  91871. */
  91872. rotationQuaternion: Nullable<Quaternion>;
  91873. /**
  91874. * The scale of the physics-enabled object
  91875. */
  91876. scaling: Vector3;
  91877. /**
  91878. * The rotation of the physics-enabled object
  91879. */
  91880. rotation?: Vector3;
  91881. /**
  91882. * The parent of the physics-enabled object
  91883. */
  91884. parent?: any;
  91885. /**
  91886. * The bounding info of the physics-enabled object
  91887. * @returns The bounding info of the physics-enabled object
  91888. */
  91889. getBoundingInfo(): BoundingInfo;
  91890. /**
  91891. * Computes the world matrix
  91892. * @param force Specifies if the world matrix should be computed by force
  91893. * @returns A world matrix
  91894. */
  91895. computeWorldMatrix(force: boolean): Matrix;
  91896. /**
  91897. * Gets the world matrix
  91898. * @returns A world matrix
  91899. */
  91900. getWorldMatrix?(): Matrix;
  91901. /**
  91902. * Gets the child meshes
  91903. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91904. * @returns An array of abstract meshes
  91905. */
  91906. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91907. /**
  91908. * Gets the vertex data
  91909. * @param kind The type of vertex data
  91910. * @returns A nullable array of numbers, or a float32 array
  91911. */
  91912. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91913. /**
  91914. * Gets the indices from the mesh
  91915. * @returns A nullable array of index arrays
  91916. */
  91917. getIndices?(): Nullable<IndicesArray>;
  91918. /**
  91919. * Gets the scene from the mesh
  91920. * @returns the indices array or null
  91921. */
  91922. getScene?(): Scene;
  91923. /**
  91924. * Gets the absolute position from the mesh
  91925. * @returns the absolute position
  91926. */
  91927. getAbsolutePosition(): Vector3;
  91928. /**
  91929. * Gets the absolute pivot point from the mesh
  91930. * @returns the absolute pivot point
  91931. */
  91932. getAbsolutePivotPoint(): Vector3;
  91933. /**
  91934. * Rotates the mesh
  91935. * @param axis The axis of rotation
  91936. * @param amount The amount of rotation
  91937. * @param space The space of the rotation
  91938. * @returns The rotation transform node
  91939. */
  91940. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91941. /**
  91942. * Translates the mesh
  91943. * @param axis The axis of translation
  91944. * @param distance The distance of translation
  91945. * @param space The space of the translation
  91946. * @returns The transform node
  91947. */
  91948. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91949. /**
  91950. * Sets the absolute position of the mesh
  91951. * @param absolutePosition The absolute position of the mesh
  91952. * @returns The transform node
  91953. */
  91954. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91955. /**
  91956. * Gets the class name of the mesh
  91957. * @returns The class name
  91958. */
  91959. getClassName(): string;
  91960. }
  91961. /**
  91962. * Represents a physics imposter
  91963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91964. */
  91965. export class PhysicsImpostor {
  91966. /**
  91967. * The physics-enabled object used as the physics imposter
  91968. */
  91969. object: IPhysicsEnabledObject;
  91970. /**
  91971. * The type of the physics imposter
  91972. */
  91973. type: number;
  91974. private _options;
  91975. private _scene?;
  91976. /**
  91977. * The default object size of the imposter
  91978. */
  91979. static DEFAULT_OBJECT_SIZE: Vector3;
  91980. /**
  91981. * The identity quaternion of the imposter
  91982. */
  91983. static IDENTITY_QUATERNION: Quaternion;
  91984. /** @hidden */
  91985. _pluginData: any;
  91986. private _physicsEngine;
  91987. private _physicsBody;
  91988. private _bodyUpdateRequired;
  91989. private _onBeforePhysicsStepCallbacks;
  91990. private _onAfterPhysicsStepCallbacks;
  91991. /** @hidden */
  91992. _onPhysicsCollideCallbacks: Array<{
  91993. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91994. otherImpostors: Array<PhysicsImpostor>;
  91995. }>;
  91996. private _deltaPosition;
  91997. private _deltaRotation;
  91998. private _deltaRotationConjugated;
  91999. /** @hidden */
  92000. _isFromLine: boolean;
  92001. private _parent;
  92002. private _isDisposed;
  92003. private static _tmpVecs;
  92004. private static _tmpQuat;
  92005. /**
  92006. * Specifies if the physics imposter is disposed
  92007. */
  92008. readonly isDisposed: boolean;
  92009. /**
  92010. * Gets the mass of the physics imposter
  92011. */
  92012. mass: number;
  92013. /**
  92014. * Gets the coefficient of friction
  92015. */
  92016. /**
  92017. * Sets the coefficient of friction
  92018. */
  92019. friction: number;
  92020. /**
  92021. * Gets the coefficient of restitution
  92022. */
  92023. /**
  92024. * Sets the coefficient of restitution
  92025. */
  92026. restitution: number;
  92027. /**
  92028. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  92029. */
  92030. /**
  92031. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  92032. */
  92033. pressure: number;
  92034. /**
  92035. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92036. */
  92037. /**
  92038. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92039. */
  92040. stiffness: number;
  92041. /**
  92042. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92043. */
  92044. /**
  92045. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92046. */
  92047. velocityIterations: number;
  92048. /**
  92049. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92050. */
  92051. /**
  92052. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92053. */
  92054. positionIterations: number;
  92055. /**
  92056. * The unique id of the physics imposter
  92057. * set by the physics engine when adding this impostor to the array
  92058. */
  92059. uniqueId: number;
  92060. /**
  92061. * @hidden
  92062. */
  92063. soft: boolean;
  92064. /**
  92065. * @hidden
  92066. */
  92067. segments: number;
  92068. private _joints;
  92069. /**
  92070. * Initializes the physics imposter
  92071. * @param object The physics-enabled object used as the physics imposter
  92072. * @param type The type of the physics imposter
  92073. * @param _options The options for the physics imposter
  92074. * @param _scene The Babylon scene
  92075. */
  92076. constructor(
  92077. /**
  92078. * The physics-enabled object used as the physics imposter
  92079. */
  92080. object: IPhysicsEnabledObject,
  92081. /**
  92082. * The type of the physics imposter
  92083. */
  92084. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  92085. /**
  92086. * This function will completly initialize this impostor.
  92087. * It will create a new body - but only if this mesh has no parent.
  92088. * If it has, this impostor will not be used other than to define the impostor
  92089. * of the child mesh.
  92090. * @hidden
  92091. */
  92092. _init(): void;
  92093. private _getPhysicsParent;
  92094. /**
  92095. * Should a new body be generated.
  92096. * @returns boolean specifying if body initialization is required
  92097. */
  92098. isBodyInitRequired(): boolean;
  92099. /**
  92100. * Sets the updated scaling
  92101. * @param updated Specifies if the scaling is updated
  92102. */
  92103. setScalingUpdated(): void;
  92104. /**
  92105. * Force a regeneration of this or the parent's impostor's body.
  92106. * Use under cautious - This will remove all joints already implemented.
  92107. */
  92108. forceUpdate(): void;
  92109. /**
  92110. * Gets the body that holds this impostor. Either its own, or its parent.
  92111. */
  92112. /**
  92113. * Set the physics body. Used mainly by the physics engine/plugin
  92114. */
  92115. physicsBody: any;
  92116. /**
  92117. * Get the parent of the physics imposter
  92118. * @returns Physics imposter or null
  92119. */
  92120. /**
  92121. * Sets the parent of the physics imposter
  92122. */
  92123. parent: Nullable<PhysicsImpostor>;
  92124. /**
  92125. * Resets the update flags
  92126. */
  92127. resetUpdateFlags(): void;
  92128. /**
  92129. * Gets the object extend size
  92130. * @returns the object extend size
  92131. */
  92132. getObjectExtendSize(): Vector3;
  92133. /**
  92134. * Gets the object center
  92135. * @returns The object center
  92136. */
  92137. getObjectCenter(): Vector3;
  92138. /**
  92139. * Get a specific parametes from the options parameter
  92140. * @param paramName The object parameter name
  92141. * @returns The object parameter
  92142. */
  92143. getParam(paramName: string): any;
  92144. /**
  92145. * Sets a specific parameter in the options given to the physics plugin
  92146. * @param paramName The parameter name
  92147. * @param value The value of the parameter
  92148. */
  92149. setParam(paramName: string, value: number): void;
  92150. /**
  92151. * Specifically change the body's mass option. Won't recreate the physics body object
  92152. * @param mass The mass of the physics imposter
  92153. */
  92154. setMass(mass: number): void;
  92155. /**
  92156. * Gets the linear velocity
  92157. * @returns linear velocity or null
  92158. */
  92159. getLinearVelocity(): Nullable<Vector3>;
  92160. /**
  92161. * Sets the linear velocity
  92162. * @param velocity linear velocity or null
  92163. */
  92164. setLinearVelocity(velocity: Nullable<Vector3>): void;
  92165. /**
  92166. * Gets the angular velocity
  92167. * @returns angular velocity or null
  92168. */
  92169. getAngularVelocity(): Nullable<Vector3>;
  92170. /**
  92171. * Sets the angular velocity
  92172. * @param velocity The velocity or null
  92173. */
  92174. setAngularVelocity(velocity: Nullable<Vector3>): void;
  92175. /**
  92176. * Execute a function with the physics plugin native code
  92177. * Provide a function the will have two variables - the world object and the physics body object
  92178. * @param func The function to execute with the physics plugin native code
  92179. */
  92180. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  92181. /**
  92182. * Register a function that will be executed before the physics world is stepping forward
  92183. * @param func The function to execute before the physics world is stepped forward
  92184. */
  92185. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92186. /**
  92187. * Unregister a function that will be executed before the physics world is stepping forward
  92188. * @param func The function to execute before the physics world is stepped forward
  92189. */
  92190. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92191. /**
  92192. * Register a function that will be executed after the physics step
  92193. * @param func The function to execute after physics step
  92194. */
  92195. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92196. /**
  92197. * Unregisters a function that will be executed after the physics step
  92198. * @param func The function to execute after physics step
  92199. */
  92200. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92201. /**
  92202. * register a function that will be executed when this impostor collides against a different body
  92203. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  92204. * @param func Callback that is executed on collision
  92205. */
  92206. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  92207. /**
  92208. * Unregisters the physics imposter on contact
  92209. * @param collideAgainst The physics object to collide against
  92210. * @param func Callback to execute on collision
  92211. */
  92212. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  92213. private _tmpQuat;
  92214. private _tmpQuat2;
  92215. /**
  92216. * Get the parent rotation
  92217. * @returns The parent rotation
  92218. */
  92219. getParentsRotation(): Quaternion;
  92220. /**
  92221. * this function is executed by the physics engine.
  92222. */
  92223. beforeStep: () => void;
  92224. /**
  92225. * this function is executed by the physics engine
  92226. */
  92227. afterStep: () => void;
  92228. /**
  92229. * Legacy collision detection event support
  92230. */
  92231. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  92232. /**
  92233. * event and body object due to cannon's event-based architecture.
  92234. */
  92235. onCollide: (e: {
  92236. body: any;
  92237. }) => void;
  92238. /**
  92239. * Apply a force
  92240. * @param force The force to apply
  92241. * @param contactPoint The contact point for the force
  92242. * @returns The physics imposter
  92243. */
  92244. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92245. /**
  92246. * Apply an impulse
  92247. * @param force The impulse force
  92248. * @param contactPoint The contact point for the impulse force
  92249. * @returns The physics imposter
  92250. */
  92251. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92252. /**
  92253. * A help function to create a joint
  92254. * @param otherImpostor A physics imposter used to create a joint
  92255. * @param jointType The type of joint
  92256. * @param jointData The data for the joint
  92257. * @returns The physics imposter
  92258. */
  92259. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  92260. /**
  92261. * Add a joint to this impostor with a different impostor
  92262. * @param otherImpostor A physics imposter used to add a joint
  92263. * @param joint The joint to add
  92264. * @returns The physics imposter
  92265. */
  92266. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  92267. /**
  92268. * Add an anchor to a cloth impostor
  92269. * @param otherImpostor rigid impostor to anchor to
  92270. * @param width ratio across width from 0 to 1
  92271. * @param height ratio up height from 0 to 1
  92272. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  92273. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  92274. * @returns impostor the soft imposter
  92275. */
  92276. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92277. /**
  92278. * Add a hook to a rope impostor
  92279. * @param otherImpostor rigid impostor to anchor to
  92280. * @param length ratio across rope from 0 to 1
  92281. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  92282. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  92283. * @returns impostor the rope imposter
  92284. */
  92285. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92286. /**
  92287. * Will keep this body still, in a sleep mode.
  92288. * @returns the physics imposter
  92289. */
  92290. sleep(): PhysicsImpostor;
  92291. /**
  92292. * Wake the body up.
  92293. * @returns The physics imposter
  92294. */
  92295. wakeUp(): PhysicsImpostor;
  92296. /**
  92297. * Clones the physics imposter
  92298. * @param newObject The physics imposter clones to this physics-enabled object
  92299. * @returns A nullable physics imposter
  92300. */
  92301. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92302. /**
  92303. * Disposes the physics imposter
  92304. */
  92305. dispose(): void;
  92306. /**
  92307. * Sets the delta position
  92308. * @param position The delta position amount
  92309. */
  92310. setDeltaPosition(position: Vector3): void;
  92311. /**
  92312. * Sets the delta rotation
  92313. * @param rotation The delta rotation amount
  92314. */
  92315. setDeltaRotation(rotation: Quaternion): void;
  92316. /**
  92317. * Gets the box size of the physics imposter and stores the result in the input parameter
  92318. * @param result Stores the box size
  92319. * @returns The physics imposter
  92320. */
  92321. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  92322. /**
  92323. * Gets the radius of the physics imposter
  92324. * @returns Radius of the physics imposter
  92325. */
  92326. getRadius(): number;
  92327. /**
  92328. * Sync a bone with this impostor
  92329. * @param bone The bone to sync to the impostor.
  92330. * @param boneMesh The mesh that the bone is influencing.
  92331. * @param jointPivot The pivot of the joint / bone in local space.
  92332. * @param distToJoint Optional distance from the impostor to the joint.
  92333. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92334. */
  92335. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  92336. /**
  92337. * Sync impostor to a bone
  92338. * @param bone The bone that the impostor will be synced to.
  92339. * @param boneMesh The mesh that the bone is influencing.
  92340. * @param jointPivot The pivot of the joint / bone in local space.
  92341. * @param distToJoint Optional distance from the impostor to the joint.
  92342. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92343. * @param boneAxis Optional vector3 axis the bone is aligned with
  92344. */
  92345. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  92346. /**
  92347. * No-Imposter type
  92348. */
  92349. static NoImpostor: number;
  92350. /**
  92351. * Sphere-Imposter type
  92352. */
  92353. static SphereImpostor: number;
  92354. /**
  92355. * Box-Imposter type
  92356. */
  92357. static BoxImpostor: number;
  92358. /**
  92359. * Plane-Imposter type
  92360. */
  92361. static PlaneImpostor: number;
  92362. /**
  92363. * Mesh-imposter type
  92364. */
  92365. static MeshImpostor: number;
  92366. /**
  92367. * Capsule-Impostor type (Ammo.js plugin only)
  92368. */
  92369. static CapsuleImpostor: number;
  92370. /**
  92371. * Cylinder-Imposter type
  92372. */
  92373. static CylinderImpostor: number;
  92374. /**
  92375. * Particle-Imposter type
  92376. */
  92377. static ParticleImpostor: number;
  92378. /**
  92379. * Heightmap-Imposter type
  92380. */
  92381. static HeightmapImpostor: number;
  92382. /**
  92383. * ConvexHull-Impostor type (Ammo.js plugin only)
  92384. */
  92385. static ConvexHullImpostor: number;
  92386. /**
  92387. * Rope-Imposter type
  92388. */
  92389. static RopeImpostor: number;
  92390. /**
  92391. * Cloth-Imposter type
  92392. */
  92393. static ClothImpostor: number;
  92394. /**
  92395. * Softbody-Imposter type
  92396. */
  92397. static SoftbodyImpostor: number;
  92398. }
  92399. }
  92400. declare module BABYLON {
  92401. /**
  92402. * @hidden
  92403. **/
  92404. export class _CreationDataStorage {
  92405. closePath?: boolean;
  92406. closeArray?: boolean;
  92407. idx: number[];
  92408. dashSize: number;
  92409. gapSize: number;
  92410. path3D: Path3D;
  92411. pathArray: Vector3[][];
  92412. arc: number;
  92413. radius: number;
  92414. cap: number;
  92415. tessellation: number;
  92416. }
  92417. /**
  92418. * @hidden
  92419. **/
  92420. class _InstanceDataStorage {
  92421. visibleInstances: any;
  92422. batchCache: _InstancesBatch;
  92423. instancesBufferSize: number;
  92424. instancesBuffer: Nullable<Buffer>;
  92425. instancesData: Float32Array;
  92426. overridenInstanceCount: number;
  92427. isFrozen: boolean;
  92428. previousBatch: Nullable<_InstancesBatch>;
  92429. hardwareInstancedRendering: boolean;
  92430. sideOrientation: number;
  92431. manualUpdate: boolean;
  92432. }
  92433. /**
  92434. * @hidden
  92435. **/
  92436. export class _InstancesBatch {
  92437. mustReturn: boolean;
  92438. visibleInstances: Nullable<InstancedMesh[]>[];
  92439. renderSelf: boolean[];
  92440. hardwareInstancedRendering: boolean[];
  92441. }
  92442. /**
  92443. * Class used to represent renderable models
  92444. */
  92445. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  92446. /**
  92447. * Mesh side orientation : usually the external or front surface
  92448. */
  92449. static readonly FRONTSIDE: number;
  92450. /**
  92451. * Mesh side orientation : usually the internal or back surface
  92452. */
  92453. static readonly BACKSIDE: number;
  92454. /**
  92455. * Mesh side orientation : both internal and external or front and back surfaces
  92456. */
  92457. static readonly DOUBLESIDE: number;
  92458. /**
  92459. * Mesh side orientation : by default, `FRONTSIDE`
  92460. */
  92461. static readonly DEFAULTSIDE: number;
  92462. /**
  92463. * Mesh cap setting : no cap
  92464. */
  92465. static readonly NO_CAP: number;
  92466. /**
  92467. * Mesh cap setting : one cap at the beginning of the mesh
  92468. */
  92469. static readonly CAP_START: number;
  92470. /**
  92471. * Mesh cap setting : one cap at the end of the mesh
  92472. */
  92473. static readonly CAP_END: number;
  92474. /**
  92475. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  92476. */
  92477. static readonly CAP_ALL: number;
  92478. /**
  92479. * Mesh pattern setting : no flip or rotate
  92480. */
  92481. static readonly NO_FLIP: number;
  92482. /**
  92483. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  92484. */
  92485. static readonly FLIP_TILE: number;
  92486. /**
  92487. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  92488. */
  92489. static readonly ROTATE_TILE: number;
  92490. /**
  92491. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  92492. */
  92493. static readonly FLIP_ROW: number;
  92494. /**
  92495. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  92496. */
  92497. static readonly ROTATE_ROW: number;
  92498. /**
  92499. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  92500. */
  92501. static readonly FLIP_N_ROTATE_TILE: number;
  92502. /**
  92503. * Mesh pattern setting : rotate pattern and rotate
  92504. */
  92505. static readonly FLIP_N_ROTATE_ROW: number;
  92506. /**
  92507. * Mesh tile positioning : part tiles same on left/right or top/bottom
  92508. */
  92509. static readonly CENTER: number;
  92510. /**
  92511. * Mesh tile positioning : part tiles on left
  92512. */
  92513. static readonly LEFT: number;
  92514. /**
  92515. * Mesh tile positioning : part tiles on right
  92516. */
  92517. static readonly RIGHT: number;
  92518. /**
  92519. * Mesh tile positioning : part tiles on top
  92520. */
  92521. static readonly TOP: number;
  92522. /**
  92523. * Mesh tile positioning : part tiles on bottom
  92524. */
  92525. static readonly BOTTOM: number;
  92526. /**
  92527. * Gets the default side orientation.
  92528. * @param orientation the orientation to value to attempt to get
  92529. * @returns the default orientation
  92530. * @hidden
  92531. */
  92532. static _GetDefaultSideOrientation(orientation?: number): number;
  92533. private _internalMeshDataInfo;
  92534. /**
  92535. * An event triggered before rendering the mesh
  92536. */
  92537. readonly onBeforeRenderObservable: Observable<Mesh>;
  92538. /**
  92539. * An event triggered before binding the mesh
  92540. */
  92541. readonly onBeforeBindObservable: Observable<Mesh>;
  92542. /**
  92543. * An event triggered after rendering the mesh
  92544. */
  92545. readonly onAfterRenderObservable: Observable<Mesh>;
  92546. /**
  92547. * An event triggered before drawing the mesh
  92548. */
  92549. readonly onBeforeDrawObservable: Observable<Mesh>;
  92550. private _onBeforeDrawObserver;
  92551. /**
  92552. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92553. */
  92554. onBeforeDraw: () => void;
  92555. readonly hasInstances: boolean;
  92556. /**
  92557. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92558. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92559. */
  92560. delayLoadState: number;
  92561. /**
  92562. * Gets the list of instances created from this mesh
  92563. * it is not supposed to be modified manually.
  92564. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92565. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92566. */
  92567. instances: InstancedMesh[];
  92568. /**
  92569. * Gets the file containing delay loading data for this mesh
  92570. */
  92571. delayLoadingFile: string;
  92572. /** @hidden */
  92573. _binaryInfo: any;
  92574. /**
  92575. * User defined function used to change how LOD level selection is done
  92576. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92577. */
  92578. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92579. /**
  92580. * Gets or sets the morph target manager
  92581. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92582. */
  92583. morphTargetManager: Nullable<MorphTargetManager>;
  92584. /** @hidden */
  92585. _creationDataStorage: Nullable<_CreationDataStorage>;
  92586. /** @hidden */
  92587. _geometry: Nullable<Geometry>;
  92588. /** @hidden */
  92589. _delayInfo: Array<string>;
  92590. /** @hidden */
  92591. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92592. /** @hidden */
  92593. _instanceDataStorage: _InstanceDataStorage;
  92594. private _effectiveMaterial;
  92595. /** @hidden */
  92596. _shouldGenerateFlatShading: boolean;
  92597. /** @hidden */
  92598. _originalBuilderSideOrientation: number;
  92599. /**
  92600. * Use this property to change the original side orientation defined at construction time
  92601. */
  92602. overrideMaterialSideOrientation: Nullable<number>;
  92603. /**
  92604. * Gets the source mesh (the one used to clone this one from)
  92605. */
  92606. readonly source: Nullable<Mesh>;
  92607. /**
  92608. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92609. */
  92610. isUnIndexed: boolean;
  92611. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92612. readonly worldMatrixInstancedBuffer: Float32Array;
  92613. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92614. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92615. /**
  92616. * @constructor
  92617. * @param name The value used by scene.getMeshByName() to do a lookup.
  92618. * @param scene The scene to add this mesh to.
  92619. * @param parent The parent of this mesh, if it has one
  92620. * @param source An optional Mesh from which geometry is shared, cloned.
  92621. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92622. * When false, achieved by calling a clone(), also passing False.
  92623. * This will make creation of children, recursive.
  92624. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92625. */
  92626. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92627. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92628. doNotInstantiate: boolean;
  92629. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92630. /**
  92631. * Gets the class name
  92632. * @returns the string "Mesh".
  92633. */
  92634. getClassName(): string;
  92635. /** @hidden */
  92636. readonly _isMesh: boolean;
  92637. /**
  92638. * Returns a description of this mesh
  92639. * @param fullDetails define if full details about this mesh must be used
  92640. * @returns a descriptive string representing this mesh
  92641. */
  92642. toString(fullDetails?: boolean): string;
  92643. /** @hidden */
  92644. _unBindEffect(): void;
  92645. /**
  92646. * Gets a boolean indicating if this mesh has LOD
  92647. */
  92648. readonly hasLODLevels: boolean;
  92649. /**
  92650. * Gets the list of MeshLODLevel associated with the current mesh
  92651. * @returns an array of MeshLODLevel
  92652. */
  92653. getLODLevels(): MeshLODLevel[];
  92654. private _sortLODLevels;
  92655. /**
  92656. * Add a mesh as LOD level triggered at the given distance.
  92657. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92658. * @param distance The distance from the center of the object to show this level
  92659. * @param mesh The mesh to be added as LOD level (can be null)
  92660. * @return This mesh (for chaining)
  92661. */
  92662. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  92663. /**
  92664. * Returns the LOD level mesh at the passed distance or null if not found.
  92665. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92666. * @param distance The distance from the center of the object to show this level
  92667. * @returns a Mesh or `null`
  92668. */
  92669. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  92670. /**
  92671. * Remove a mesh from the LOD array
  92672. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92673. * @param mesh defines the mesh to be removed
  92674. * @return This mesh (for chaining)
  92675. */
  92676. removeLODLevel(mesh: Mesh): Mesh;
  92677. /**
  92678. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  92679. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92680. * @param camera defines the camera to use to compute distance
  92681. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  92682. * @return This mesh (for chaining)
  92683. */
  92684. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  92685. /**
  92686. * Gets the mesh internal Geometry object
  92687. */
  92688. readonly geometry: Nullable<Geometry>;
  92689. /**
  92690. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  92691. * @returns the total number of vertices
  92692. */
  92693. getTotalVertices(): number;
  92694. /**
  92695. * Returns the content of an associated vertex buffer
  92696. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92697. * - VertexBuffer.PositionKind
  92698. * - VertexBuffer.UVKind
  92699. * - VertexBuffer.UV2Kind
  92700. * - VertexBuffer.UV3Kind
  92701. * - VertexBuffer.UV4Kind
  92702. * - VertexBuffer.UV5Kind
  92703. * - VertexBuffer.UV6Kind
  92704. * - VertexBuffer.ColorKind
  92705. * - VertexBuffer.MatricesIndicesKind
  92706. * - VertexBuffer.MatricesIndicesExtraKind
  92707. * - VertexBuffer.MatricesWeightsKind
  92708. * - VertexBuffer.MatricesWeightsExtraKind
  92709. * @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
  92710. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  92711. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  92712. */
  92713. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92714. /**
  92715. * Returns the mesh VertexBuffer object from the requested `kind`
  92716. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92717. * - VertexBuffer.PositionKind
  92718. * - VertexBuffer.NormalKind
  92719. * - VertexBuffer.UVKind
  92720. * - VertexBuffer.UV2Kind
  92721. * - VertexBuffer.UV3Kind
  92722. * - VertexBuffer.UV4Kind
  92723. * - VertexBuffer.UV5Kind
  92724. * - VertexBuffer.UV6Kind
  92725. * - VertexBuffer.ColorKind
  92726. * - VertexBuffer.MatricesIndicesKind
  92727. * - VertexBuffer.MatricesIndicesExtraKind
  92728. * - VertexBuffer.MatricesWeightsKind
  92729. * - VertexBuffer.MatricesWeightsExtraKind
  92730. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  92731. */
  92732. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92733. /**
  92734. * Tests if a specific vertex buffer is associated with this mesh
  92735. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92736. * - VertexBuffer.PositionKind
  92737. * - VertexBuffer.NormalKind
  92738. * - VertexBuffer.UVKind
  92739. * - VertexBuffer.UV2Kind
  92740. * - VertexBuffer.UV3Kind
  92741. * - VertexBuffer.UV4Kind
  92742. * - VertexBuffer.UV5Kind
  92743. * - VertexBuffer.UV6Kind
  92744. * - VertexBuffer.ColorKind
  92745. * - VertexBuffer.MatricesIndicesKind
  92746. * - VertexBuffer.MatricesIndicesExtraKind
  92747. * - VertexBuffer.MatricesWeightsKind
  92748. * - VertexBuffer.MatricesWeightsExtraKind
  92749. * @returns a boolean
  92750. */
  92751. isVerticesDataPresent(kind: string): boolean;
  92752. /**
  92753. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  92754. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92755. * - VertexBuffer.PositionKind
  92756. * - VertexBuffer.UVKind
  92757. * - VertexBuffer.UV2Kind
  92758. * - VertexBuffer.UV3Kind
  92759. * - VertexBuffer.UV4Kind
  92760. * - VertexBuffer.UV5Kind
  92761. * - VertexBuffer.UV6Kind
  92762. * - VertexBuffer.ColorKind
  92763. * - VertexBuffer.MatricesIndicesKind
  92764. * - VertexBuffer.MatricesIndicesExtraKind
  92765. * - VertexBuffer.MatricesWeightsKind
  92766. * - VertexBuffer.MatricesWeightsExtraKind
  92767. * @returns a boolean
  92768. */
  92769. isVertexBufferUpdatable(kind: string): boolean;
  92770. /**
  92771. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  92772. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92773. * - VertexBuffer.PositionKind
  92774. * - VertexBuffer.NormalKind
  92775. * - VertexBuffer.UVKind
  92776. * - VertexBuffer.UV2Kind
  92777. * - VertexBuffer.UV3Kind
  92778. * - VertexBuffer.UV4Kind
  92779. * - VertexBuffer.UV5Kind
  92780. * - VertexBuffer.UV6Kind
  92781. * - VertexBuffer.ColorKind
  92782. * - VertexBuffer.MatricesIndicesKind
  92783. * - VertexBuffer.MatricesIndicesExtraKind
  92784. * - VertexBuffer.MatricesWeightsKind
  92785. * - VertexBuffer.MatricesWeightsExtraKind
  92786. * @returns an array of strings
  92787. */
  92788. getVerticesDataKinds(): string[];
  92789. /**
  92790. * Returns a positive integer : the total number of indices in this mesh geometry.
  92791. * @returns the numner of indices or zero if the mesh has no geometry.
  92792. */
  92793. getTotalIndices(): number;
  92794. /**
  92795. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92796. * @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.
  92797. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92798. * @returns the indices array or an empty array if the mesh has no geometry
  92799. */
  92800. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92801. readonly isBlocked: boolean;
  92802. /**
  92803. * Determine if the current mesh is ready to be rendered
  92804. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92805. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92806. * @returns true if all associated assets are ready (material, textures, shaders)
  92807. */
  92808. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92809. /**
  92810. * 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.
  92811. */
  92812. readonly areNormalsFrozen: boolean;
  92813. /**
  92814. * 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.
  92815. * @returns the current mesh
  92816. */
  92817. freezeNormals(): Mesh;
  92818. /**
  92819. * 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
  92820. * @returns the current mesh
  92821. */
  92822. unfreezeNormals(): Mesh;
  92823. /**
  92824. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92825. */
  92826. overridenInstanceCount: number;
  92827. /** @hidden */
  92828. _preActivate(): Mesh;
  92829. /** @hidden */
  92830. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92831. /** @hidden */
  92832. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92833. /**
  92834. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92835. * This means the mesh underlying bounding box and sphere are recomputed.
  92836. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92837. * @returns the current mesh
  92838. */
  92839. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92840. /** @hidden */
  92841. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92842. /**
  92843. * This function will subdivide the mesh into multiple submeshes
  92844. * @param count defines the expected number of submeshes
  92845. */
  92846. subdivide(count: number): void;
  92847. /**
  92848. * Copy a FloatArray into a specific associated vertex buffer
  92849. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92850. * - VertexBuffer.PositionKind
  92851. * - VertexBuffer.UVKind
  92852. * - VertexBuffer.UV2Kind
  92853. * - VertexBuffer.UV3Kind
  92854. * - VertexBuffer.UV4Kind
  92855. * - VertexBuffer.UV5Kind
  92856. * - VertexBuffer.UV6Kind
  92857. * - VertexBuffer.ColorKind
  92858. * - VertexBuffer.MatricesIndicesKind
  92859. * - VertexBuffer.MatricesIndicesExtraKind
  92860. * - VertexBuffer.MatricesWeightsKind
  92861. * - VertexBuffer.MatricesWeightsExtraKind
  92862. * @param data defines the data source
  92863. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92864. * @param stride defines the data stride size (can be null)
  92865. * @returns the current mesh
  92866. */
  92867. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92868. /**
  92869. * Delete a vertex buffer associated with this mesh
  92870. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92871. * - VertexBuffer.PositionKind
  92872. * - VertexBuffer.UVKind
  92873. * - VertexBuffer.UV2Kind
  92874. * - VertexBuffer.UV3Kind
  92875. * - VertexBuffer.UV4Kind
  92876. * - VertexBuffer.UV5Kind
  92877. * - VertexBuffer.UV6Kind
  92878. * - VertexBuffer.ColorKind
  92879. * - VertexBuffer.MatricesIndicesKind
  92880. * - VertexBuffer.MatricesIndicesExtraKind
  92881. * - VertexBuffer.MatricesWeightsKind
  92882. * - VertexBuffer.MatricesWeightsExtraKind
  92883. */
  92884. removeVerticesData(kind: string): void;
  92885. /**
  92886. * Flags an associated vertex buffer as updatable
  92887. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92888. * - VertexBuffer.PositionKind
  92889. * - VertexBuffer.UVKind
  92890. * - VertexBuffer.UV2Kind
  92891. * - VertexBuffer.UV3Kind
  92892. * - VertexBuffer.UV4Kind
  92893. * - VertexBuffer.UV5Kind
  92894. * - VertexBuffer.UV6Kind
  92895. * - VertexBuffer.ColorKind
  92896. * - VertexBuffer.MatricesIndicesKind
  92897. * - VertexBuffer.MatricesIndicesExtraKind
  92898. * - VertexBuffer.MatricesWeightsKind
  92899. * - VertexBuffer.MatricesWeightsExtraKind
  92900. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92901. */
  92902. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92903. /**
  92904. * Sets the mesh global Vertex Buffer
  92905. * @param buffer defines the buffer to use
  92906. * @returns the current mesh
  92907. */
  92908. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92909. /**
  92910. * Update a specific associated vertex buffer
  92911. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92912. * - VertexBuffer.PositionKind
  92913. * - VertexBuffer.UVKind
  92914. * - VertexBuffer.UV2Kind
  92915. * - VertexBuffer.UV3Kind
  92916. * - VertexBuffer.UV4Kind
  92917. * - VertexBuffer.UV5Kind
  92918. * - VertexBuffer.UV6Kind
  92919. * - VertexBuffer.ColorKind
  92920. * - VertexBuffer.MatricesIndicesKind
  92921. * - VertexBuffer.MatricesIndicesExtraKind
  92922. * - VertexBuffer.MatricesWeightsKind
  92923. * - VertexBuffer.MatricesWeightsExtraKind
  92924. * @param data defines the data source
  92925. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92926. * @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)
  92927. * @returns the current mesh
  92928. */
  92929. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92930. /**
  92931. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92932. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92933. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92934. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92935. * @returns the current mesh
  92936. */
  92937. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92938. /**
  92939. * Creates a un-shared specific occurence of the geometry for the mesh.
  92940. * @returns the current mesh
  92941. */
  92942. makeGeometryUnique(): Mesh;
  92943. /**
  92944. * Set the index buffer of this mesh
  92945. * @param indices defines the source data
  92946. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92947. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92948. * @returns the current mesh
  92949. */
  92950. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92951. /**
  92952. * Update the current index buffer
  92953. * @param indices defines the source data
  92954. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92955. * @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)
  92956. * @returns the current mesh
  92957. */
  92958. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92959. /**
  92960. * Invert the geometry to move from a right handed system to a left handed one.
  92961. * @returns the current mesh
  92962. */
  92963. toLeftHanded(): Mesh;
  92964. /** @hidden */
  92965. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92966. /** @hidden */
  92967. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92968. /**
  92969. * Registers for this mesh a javascript function called just before the rendering process
  92970. * @param func defines the function to call before rendering this mesh
  92971. * @returns the current mesh
  92972. */
  92973. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92974. /**
  92975. * Disposes a previously registered javascript function called before the rendering
  92976. * @param func defines the function to remove
  92977. * @returns the current mesh
  92978. */
  92979. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92980. /**
  92981. * Registers for this mesh a javascript function called just after the rendering is complete
  92982. * @param func defines the function to call after rendering this mesh
  92983. * @returns the current mesh
  92984. */
  92985. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92986. /**
  92987. * Disposes a previously registered javascript function called after the rendering.
  92988. * @param func defines the function to remove
  92989. * @returns the current mesh
  92990. */
  92991. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92992. /** @hidden */
  92993. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  92994. /** @hidden */
  92995. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92996. /** @hidden */
  92997. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92998. /** @hidden */
  92999. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  93000. /** @hidden */
  93001. _rebuild(): void;
  93002. /** @hidden */
  93003. _freeze(): void;
  93004. /** @hidden */
  93005. _unFreeze(): void;
  93006. /**
  93007. * 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
  93008. * @param subMesh defines the subMesh to render
  93009. * @param enableAlphaMode defines if alpha mode can be changed
  93010. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  93011. * @returns the current mesh
  93012. */
  93013. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  93014. private _onBeforeDraw;
  93015. /**
  93016. * Renormalize the mesh and patch it up if there are no weights
  93017. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  93018. * However in the case of zero weights then we set just a single influence to 1.
  93019. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  93020. */
  93021. cleanMatrixWeights(): void;
  93022. private normalizeSkinFourWeights;
  93023. private normalizeSkinWeightsAndExtra;
  93024. /**
  93025. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  93026. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  93027. * the user know there was an issue with importing the mesh
  93028. * @returns a validation object with skinned, valid and report string
  93029. */
  93030. validateSkinning(): {
  93031. skinned: boolean;
  93032. valid: boolean;
  93033. report: string;
  93034. };
  93035. /** @hidden */
  93036. _checkDelayState(): Mesh;
  93037. private _queueLoad;
  93038. /**
  93039. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93040. * A mesh is in the frustum if its bounding box intersects the frustum
  93041. * @param frustumPlanes defines the frustum to test
  93042. * @returns true if the mesh is in the frustum planes
  93043. */
  93044. isInFrustum(frustumPlanes: Plane[]): boolean;
  93045. /**
  93046. * Sets the mesh material by the material or multiMaterial `id` property
  93047. * @param id is a string identifying the material or the multiMaterial
  93048. * @returns the current mesh
  93049. */
  93050. setMaterialByID(id: string): Mesh;
  93051. /**
  93052. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  93053. * @returns an array of IAnimatable
  93054. */
  93055. getAnimatables(): IAnimatable[];
  93056. /**
  93057. * Modifies the mesh geometry according to the passed transformation matrix.
  93058. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  93059. * The mesh normals are modified using the same transformation.
  93060. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93061. * @param transform defines the transform matrix to use
  93062. * @see http://doc.babylonjs.com/resources/baking_transformations
  93063. * @returns the current mesh
  93064. */
  93065. bakeTransformIntoVertices(transform: Matrix): Mesh;
  93066. /**
  93067. * Modifies the mesh geometry according to its own current World Matrix.
  93068. * The mesh World Matrix is then reset.
  93069. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  93070. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93071. * @see http://doc.babylonjs.com/resources/baking_transformations
  93072. * @returns the current mesh
  93073. */
  93074. bakeCurrentTransformIntoVertices(): Mesh;
  93075. /** @hidden */
  93076. readonly _positions: Nullable<Vector3[]>;
  93077. /** @hidden */
  93078. _resetPointsArrayCache(): Mesh;
  93079. /** @hidden */
  93080. _generatePointsArray(): boolean;
  93081. /**
  93082. * Returns a new Mesh object generated from the current mesh properties.
  93083. * This method must not get confused with createInstance()
  93084. * @param name is a string, the name given to the new mesh
  93085. * @param newParent can be any Node object (default `null`)
  93086. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  93087. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  93088. * @returns a new mesh
  93089. */
  93090. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  93091. /**
  93092. * Releases resources associated with this mesh.
  93093. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93094. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93095. */
  93096. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93097. /** @hidden */
  93098. _disposeInstanceSpecificData(): void;
  93099. /**
  93100. * Modifies the mesh geometry according to a displacement map.
  93101. * 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.
  93102. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93103. * @param url is a string, the URL from the image file is to be downloaded.
  93104. * @param minHeight is the lower limit of the displacement.
  93105. * @param maxHeight is the upper limit of the displacement.
  93106. * @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.
  93107. * @param uvOffset is an optional vector2 used to offset UV.
  93108. * @param uvScale is an optional vector2 used to scale UV.
  93109. * @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.
  93110. * @returns the Mesh.
  93111. */
  93112. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93113. /**
  93114. * Modifies the mesh geometry according to a displacementMap buffer.
  93115. * 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.
  93116. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93117. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  93118. * @param heightMapWidth is the width of the buffer image.
  93119. * @param heightMapHeight is the height of the buffer image.
  93120. * @param minHeight is the lower limit of the displacement.
  93121. * @param maxHeight is the upper limit of the displacement.
  93122. * @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.
  93123. * @param uvOffset is an optional vector2 used to offset UV.
  93124. * @param uvScale is an optional vector2 used to scale UV.
  93125. * @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.
  93126. * @returns the Mesh.
  93127. */
  93128. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93129. /**
  93130. * Modify the mesh to get a flat shading rendering.
  93131. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  93132. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  93133. * @returns current mesh
  93134. */
  93135. convertToFlatShadedMesh(): Mesh;
  93136. /**
  93137. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  93138. * In other words, more vertices, no more indices and a single bigger VBO.
  93139. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  93140. * @returns current mesh
  93141. */
  93142. convertToUnIndexedMesh(): Mesh;
  93143. /**
  93144. * Inverses facet orientations.
  93145. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93146. * @param flipNormals will also inverts the normals
  93147. * @returns current mesh
  93148. */
  93149. flipFaces(flipNormals?: boolean): Mesh;
  93150. /**
  93151. * Increase the number of facets and hence vertices in a mesh
  93152. * Vertex normals are interpolated from existing vertex normals
  93153. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93154. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  93155. */
  93156. increaseVertices(numberPerEdge: number): void;
  93157. /**
  93158. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  93159. * This will undo any application of covertToFlatShadedMesh
  93160. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93161. */
  93162. forceSharedVertices(): void;
  93163. /** @hidden */
  93164. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  93165. /** @hidden */
  93166. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  93167. /**
  93168. * Creates a new InstancedMesh object from the mesh model.
  93169. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93170. * @param name defines the name of the new instance
  93171. * @returns a new InstancedMesh
  93172. */
  93173. createInstance(name: string): InstancedMesh;
  93174. /**
  93175. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  93176. * After this call, all the mesh instances have the same submeshes than the current mesh.
  93177. * @returns the current mesh
  93178. */
  93179. synchronizeInstances(): Mesh;
  93180. /**
  93181. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  93182. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  93183. * This should be used together with the simplification to avoid disappearing triangles.
  93184. * @param successCallback an optional success callback to be called after the optimization finished.
  93185. * @returns the current mesh
  93186. */
  93187. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  93188. /**
  93189. * Serialize current mesh
  93190. * @param serializationObject defines the object which will receive the serialization data
  93191. */
  93192. serialize(serializationObject: any): void;
  93193. /** @hidden */
  93194. _syncGeometryWithMorphTargetManager(): void;
  93195. /** @hidden */
  93196. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  93197. /**
  93198. * Returns a new Mesh object parsed from the source provided.
  93199. * @param parsedMesh is the source
  93200. * @param scene defines the hosting scene
  93201. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  93202. * @returns a new Mesh
  93203. */
  93204. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  93205. /**
  93206. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  93207. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93208. * @param name defines the name of the mesh to create
  93209. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  93210. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  93211. * @param closePath creates a seam between the first and the last points of each path of the path array
  93212. * @param offset is taken in account only if the `pathArray` is containing a single path
  93213. * @param scene defines the hosting scene
  93214. * @param updatable defines if the mesh must be flagged as updatable
  93215. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93216. * @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)
  93217. * @returns a new Mesh
  93218. */
  93219. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93220. /**
  93221. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  93222. * @param name defines the name of the mesh to create
  93223. * @param radius sets the radius size (float) of the polygon (default 0.5)
  93224. * @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
  93225. * @param scene defines the hosting scene
  93226. * @param updatable defines if the mesh must be flagged as updatable
  93227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93228. * @returns a new Mesh
  93229. */
  93230. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93231. /**
  93232. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  93233. * @param name defines the name of the mesh to create
  93234. * @param size sets the size (float) of each box side (default 1)
  93235. * @param scene defines the hosting scene
  93236. * @param updatable defines if the mesh must be flagged as updatable
  93237. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93238. * @returns a new Mesh
  93239. */
  93240. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93241. /**
  93242. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  93243. * @param name defines the name of the mesh to create
  93244. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93245. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93246. * @param scene defines the hosting scene
  93247. * @param updatable defines if the mesh must be flagged as updatable
  93248. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93249. * @returns a new Mesh
  93250. */
  93251. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93252. /**
  93253. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  93254. * @param name defines the name of the mesh to create
  93255. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93256. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93257. * @param scene defines the hosting scene
  93258. * @returns a new Mesh
  93259. */
  93260. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  93261. /**
  93262. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  93263. * @param name defines the name of the mesh to create
  93264. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  93265. * @param diameterTop set the top cap diameter (floats, default 1)
  93266. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  93267. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  93268. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  93269. * @param scene defines the hosting scene
  93270. * @param updatable defines if the mesh must be flagged as updatable
  93271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93272. * @returns a new Mesh
  93273. */
  93274. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  93275. /**
  93276. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  93277. * @param name defines the name of the mesh to create
  93278. * @param diameter sets the diameter size (float) of the torus (default 1)
  93279. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  93280. * @param tessellation sets the number of torus sides (postive integer, default 16)
  93281. * @param scene defines the hosting scene
  93282. * @param updatable defines if the mesh must be flagged as updatable
  93283. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93284. * @returns a new Mesh
  93285. */
  93286. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93287. /**
  93288. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  93289. * @param name defines the name of the mesh to create
  93290. * @param radius sets the global radius size (float) of the torus knot (default 2)
  93291. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  93292. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  93293. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  93294. * @param p the number of windings on X axis (positive integers, default 2)
  93295. * @param q the number of windings on Y axis (positive integers, default 3)
  93296. * @param scene defines the hosting scene
  93297. * @param updatable defines if the mesh must be flagged as updatable
  93298. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93299. * @returns a new Mesh
  93300. */
  93301. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93302. /**
  93303. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  93304. * @param name defines the name of the mesh to create
  93305. * @param points is an array successive Vector3
  93306. * @param scene defines the hosting scene
  93307. * @param updatable defines if the mesh must be flagged as updatable
  93308. * @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).
  93309. * @returns a new Mesh
  93310. */
  93311. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  93312. /**
  93313. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  93314. * @param name defines the name of the mesh to create
  93315. * @param points is an array successive Vector3
  93316. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  93317. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  93318. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  93319. * @param scene defines the hosting scene
  93320. * @param updatable defines if the mesh must be flagged as updatable
  93321. * @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)
  93322. * @returns a new Mesh
  93323. */
  93324. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  93325. /**
  93326. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  93327. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  93328. * 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.
  93329. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93330. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  93331. * Remember you can only change the shape positions, not their number when updating a polygon.
  93332. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93333. * @param name defines the name of the mesh to create
  93334. * @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
  93335. * @param scene defines the hosting scene
  93336. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93337. * @param updatable defines if the mesh must be flagged as updatable
  93338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93339. * @param earcutInjection can be used to inject your own earcut reference
  93340. * @returns a new Mesh
  93341. */
  93342. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93343. /**
  93344. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  93345. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  93346. * @param name defines the name of the mesh to create
  93347. * @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
  93348. * @param depth defines the height of extrusion
  93349. * @param scene defines the hosting scene
  93350. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93351. * @param updatable defines if the mesh must be flagged as updatable
  93352. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93353. * @param earcutInjection can be used to inject your own earcut reference
  93354. * @returns a new Mesh
  93355. */
  93356. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93357. /**
  93358. * Creates an extruded shape mesh.
  93359. * 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
  93360. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93361. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93362. * @param name defines the name of the mesh to create
  93363. * @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
  93364. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93365. * @param scale is the value to scale the shape
  93366. * @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
  93367. * @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
  93368. * @param scene defines the hosting scene
  93369. * @param updatable defines if the mesh must be flagged as updatable
  93370. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93371. * @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)
  93372. * @returns a new Mesh
  93373. */
  93374. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93375. /**
  93376. * Creates an custom extruded shape mesh.
  93377. * The custom extrusion is a parametric shape.
  93378. * It has no predefined shape. Its final shape will depend on the input parameters.
  93379. * Please consider using the same method from the MeshBuilder class instead
  93380. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93381. * @param name defines the name of the mesh to create
  93382. * @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
  93383. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93384. * @param scaleFunction is a custom Javascript function called on each path point
  93385. * @param rotationFunction is a custom Javascript function called on each path point
  93386. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  93387. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  93388. * @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
  93389. * @param scene defines the hosting scene
  93390. * @param updatable defines if the mesh must be flagged as updatable
  93391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93392. * @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)
  93393. * @returns a new Mesh
  93394. */
  93395. 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;
  93396. /**
  93397. * Creates lathe mesh.
  93398. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  93399. * Please consider using the same method from the MeshBuilder class instead
  93400. * @param name defines the name of the mesh to create
  93401. * @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
  93402. * @param radius is the radius value of the lathe
  93403. * @param tessellation is the side number of the lathe.
  93404. * @param scene defines the hosting scene
  93405. * @param updatable defines if the mesh must be flagged as updatable
  93406. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93407. * @returns a new Mesh
  93408. */
  93409. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93410. /**
  93411. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  93412. * @param name defines the name of the mesh to create
  93413. * @param size sets the size (float) of both sides of the plane at once (default 1)
  93414. * @param scene defines the hosting scene
  93415. * @param updatable defines if the mesh must be flagged as updatable
  93416. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93417. * @returns a new Mesh
  93418. */
  93419. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93420. /**
  93421. * Creates a ground mesh.
  93422. * Please consider using the same method from the MeshBuilder class instead
  93423. * @param name defines the name of the mesh to create
  93424. * @param width set the width of the ground
  93425. * @param height set the height of the ground
  93426. * @param subdivisions sets the number of subdivisions per side
  93427. * @param scene defines the hosting scene
  93428. * @param updatable defines if the mesh must be flagged as updatable
  93429. * @returns a new Mesh
  93430. */
  93431. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  93432. /**
  93433. * Creates a tiled ground mesh.
  93434. * Please consider using the same method from the MeshBuilder class instead
  93435. * @param name defines the name of the mesh to create
  93436. * @param xmin set the ground minimum X coordinate
  93437. * @param zmin set the ground minimum Y coordinate
  93438. * @param xmax set the ground maximum X coordinate
  93439. * @param zmax set the ground maximum Z coordinate
  93440. * @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
  93441. * @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
  93442. * @param scene defines the hosting scene
  93443. * @param updatable defines if the mesh must be flagged as updatable
  93444. * @returns a new Mesh
  93445. */
  93446. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  93447. w: number;
  93448. h: number;
  93449. }, precision: {
  93450. w: number;
  93451. h: number;
  93452. }, scene: Scene, updatable?: boolean): Mesh;
  93453. /**
  93454. * Creates a ground mesh from a height map.
  93455. * Please consider using the same method from the MeshBuilder class instead
  93456. * @see http://doc.babylonjs.com/babylon101/height_map
  93457. * @param name defines the name of the mesh to create
  93458. * @param url sets the URL of the height map image resource
  93459. * @param width set the ground width size
  93460. * @param height set the ground height size
  93461. * @param subdivisions sets the number of subdivision per side
  93462. * @param minHeight is the minimum altitude on the ground
  93463. * @param maxHeight is the maximum altitude on the ground
  93464. * @param scene defines the hosting scene
  93465. * @param updatable defines if the mesh must be flagged as updatable
  93466. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  93467. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  93468. * @returns a new Mesh
  93469. */
  93470. 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;
  93471. /**
  93472. * Creates a tube mesh.
  93473. * The tube is a parametric shape.
  93474. * It has no predefined shape. Its final shape will depend on the input parameters.
  93475. * Please consider using the same method from the MeshBuilder class instead
  93476. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93477. * @param name defines the name of the mesh to create
  93478. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  93479. * @param radius sets the tube radius size
  93480. * @param tessellation is the number of sides on the tubular surface
  93481. * @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
  93482. * @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
  93483. * @param scene defines the hosting scene
  93484. * @param updatable defines if the mesh must be flagged as updatable
  93485. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93486. * @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)
  93487. * @returns a new Mesh
  93488. */
  93489. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  93490. (i: number, distance: number): number;
  93491. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93492. /**
  93493. * Creates a polyhedron mesh.
  93494. * Please consider using the same method from the MeshBuilder class instead.
  93495. * * 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
  93496. * * The parameter `size` (positive float, default 1) sets the polygon size
  93497. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  93498. * * 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`
  93499. * * 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
  93500. * * 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)`)
  93501. * * 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
  93502. * * 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
  93503. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93504. * * If you create a double-sided mesh, you can choose what parts of 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
  93505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93506. * @param name defines the name of the mesh to create
  93507. * @param options defines the options used to create the mesh
  93508. * @param scene defines the hosting scene
  93509. * @returns a new Mesh
  93510. */
  93511. static CreatePolyhedron(name: string, options: {
  93512. type?: number;
  93513. size?: number;
  93514. sizeX?: number;
  93515. sizeY?: number;
  93516. sizeZ?: number;
  93517. custom?: any;
  93518. faceUV?: Vector4[];
  93519. faceColors?: Color4[];
  93520. updatable?: boolean;
  93521. sideOrientation?: number;
  93522. }, scene: Scene): Mesh;
  93523. /**
  93524. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  93525. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  93526. * * 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`)
  93527. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  93528. * * 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
  93529. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93530. * * If you create a double-sided mesh, you can choose what parts of 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
  93531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93532. * @param name defines the name of the mesh
  93533. * @param options defines the options used to create the mesh
  93534. * @param scene defines the hosting scene
  93535. * @returns a new Mesh
  93536. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93537. */
  93538. static CreateIcoSphere(name: string, options: {
  93539. radius?: number;
  93540. flat?: boolean;
  93541. subdivisions?: number;
  93542. sideOrientation?: number;
  93543. updatable?: boolean;
  93544. }, scene: Scene): Mesh;
  93545. /**
  93546. * Creates a decal mesh.
  93547. * Please consider using the same method from the MeshBuilder class instead.
  93548. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93549. * @param name defines the name of the mesh
  93550. * @param sourceMesh defines the mesh receiving the decal
  93551. * @param position sets the position of the decal in world coordinates
  93552. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93553. * @param size sets the decal scaling
  93554. * @param angle sets the angle to rotate the decal
  93555. * @returns a new Mesh
  93556. */
  93557. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93558. /**
  93559. * Prepare internal position array for software CPU skinning
  93560. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93561. */
  93562. setPositionsForCPUSkinning(): Float32Array;
  93563. /**
  93564. * Prepare internal normal array for software CPU skinning
  93565. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93566. */
  93567. setNormalsForCPUSkinning(): Float32Array;
  93568. /**
  93569. * Updates the vertex buffer by applying transformation from the bones
  93570. * @param skeleton defines the skeleton to apply to current mesh
  93571. * @returns the current mesh
  93572. */
  93573. applySkeleton(skeleton: Skeleton): Mesh;
  93574. /**
  93575. * 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
  93576. * @param meshes defines the list of meshes to scan
  93577. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93578. */
  93579. static MinMax(meshes: AbstractMesh[]): {
  93580. min: Vector3;
  93581. max: Vector3;
  93582. };
  93583. /**
  93584. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93585. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93586. * @returns a vector3
  93587. */
  93588. static Center(meshesOrMinMaxVector: {
  93589. min: Vector3;
  93590. max: Vector3;
  93591. } | AbstractMesh[]): Vector3;
  93592. /**
  93593. * Merge the array of meshes into a single mesh for performance reasons.
  93594. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93595. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93596. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93597. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93598. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93599. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93600. * @returns a new mesh
  93601. */
  93602. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93603. /** @hidden */
  93604. addInstance(instance: InstancedMesh): void;
  93605. /** @hidden */
  93606. removeInstance(instance: InstancedMesh): void;
  93607. }
  93608. }
  93609. declare module BABYLON {
  93610. /**
  93611. * This is the base class of all the camera used in the application.
  93612. * @see http://doc.babylonjs.com/features/cameras
  93613. */
  93614. export class Camera extends Node {
  93615. /** @hidden */
  93616. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93617. /**
  93618. * This is the default projection mode used by the cameras.
  93619. * It helps recreating a feeling of perspective and better appreciate depth.
  93620. * This is the best way to simulate real life cameras.
  93621. */
  93622. static readonly PERSPECTIVE_CAMERA: number;
  93623. /**
  93624. * This helps creating camera with an orthographic mode.
  93625. * 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.
  93626. */
  93627. static readonly ORTHOGRAPHIC_CAMERA: number;
  93628. /**
  93629. * This is the default FOV mode for perspective cameras.
  93630. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93631. */
  93632. static readonly FOVMODE_VERTICAL_FIXED: number;
  93633. /**
  93634. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93635. */
  93636. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93637. /**
  93638. * This specifies ther is no need for a camera rig.
  93639. * Basically only one eye is rendered corresponding to the camera.
  93640. */
  93641. static readonly RIG_MODE_NONE: number;
  93642. /**
  93643. * Simulates a camera Rig with one blue eye and one red eye.
  93644. * This can be use with 3d blue and red glasses.
  93645. */
  93646. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93647. /**
  93648. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93649. */
  93650. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93651. /**
  93652. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93653. */
  93654. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93655. /**
  93656. * Defines that both eyes of the camera will be rendered over under each other.
  93657. */
  93658. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93659. /**
  93660. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93661. */
  93662. static readonly RIG_MODE_VR: number;
  93663. /**
  93664. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93665. */
  93666. static readonly RIG_MODE_WEBVR: number;
  93667. /**
  93668. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93669. */
  93670. static readonly RIG_MODE_CUSTOM: number;
  93671. /**
  93672. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93673. */
  93674. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93675. /**
  93676. * Define the input manager associated with the camera.
  93677. */
  93678. inputs: CameraInputsManager<Camera>;
  93679. /** @hidden */
  93680. _position: Vector3;
  93681. /**
  93682. * Define the current local position of the camera in the scene
  93683. */
  93684. position: Vector3;
  93685. /**
  93686. * The vector the camera should consider as up.
  93687. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93688. */
  93689. upVector: Vector3;
  93690. /**
  93691. * Define the current limit on the left side for an orthographic camera
  93692. * In scene unit
  93693. */
  93694. orthoLeft: Nullable<number>;
  93695. /**
  93696. * Define the current limit on the right side for an orthographic camera
  93697. * In scene unit
  93698. */
  93699. orthoRight: Nullable<number>;
  93700. /**
  93701. * Define the current limit on the bottom side for an orthographic camera
  93702. * In scene unit
  93703. */
  93704. orthoBottom: Nullable<number>;
  93705. /**
  93706. * Define the current limit on the top side for an orthographic camera
  93707. * In scene unit
  93708. */
  93709. orthoTop: Nullable<number>;
  93710. /**
  93711. * Field Of View is set in Radians. (default is 0.8)
  93712. */
  93713. fov: number;
  93714. /**
  93715. * Define the minimum distance the camera can see from.
  93716. * This is important to note that the depth buffer are not infinite and the closer it starts
  93717. * the more your scene might encounter depth fighting issue.
  93718. */
  93719. minZ: number;
  93720. /**
  93721. * Define the maximum distance the camera can see to.
  93722. * This is important to note that the depth buffer are not infinite and the further it end
  93723. * the more your scene might encounter depth fighting issue.
  93724. */
  93725. maxZ: number;
  93726. /**
  93727. * Define the default inertia of the camera.
  93728. * This helps giving a smooth feeling to the camera movement.
  93729. */
  93730. inertia: number;
  93731. /**
  93732. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93733. */
  93734. mode: number;
  93735. /**
  93736. * Define wether the camera is intermediate.
  93737. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93738. */
  93739. isIntermediate: boolean;
  93740. /**
  93741. * Define the viewport of the camera.
  93742. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93743. */
  93744. viewport: Viewport;
  93745. /**
  93746. * Restricts the camera to viewing objects with the same layerMask.
  93747. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93748. */
  93749. layerMask: number;
  93750. /**
  93751. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93752. */
  93753. fovMode: number;
  93754. /**
  93755. * Rig mode of the camera.
  93756. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93757. * This is normally controlled byt the camera themselves as internal use.
  93758. */
  93759. cameraRigMode: number;
  93760. /**
  93761. * Defines the distance between both "eyes" in case of a RIG
  93762. */
  93763. interaxialDistance: number;
  93764. /**
  93765. * Defines if stereoscopic rendering is done side by side or over under.
  93766. */
  93767. isStereoscopicSideBySide: boolean;
  93768. /**
  93769. * 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
  93770. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93771. * else in the scene. (Eg. security camera)
  93772. *
  93773. * 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)
  93774. */
  93775. customRenderTargets: RenderTargetTexture[];
  93776. /**
  93777. * When set, the camera will render to this render target instead of the default canvas
  93778. *
  93779. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93780. */
  93781. outputRenderTarget: Nullable<RenderTargetTexture>;
  93782. /**
  93783. * Observable triggered when the camera view matrix has changed.
  93784. */
  93785. onViewMatrixChangedObservable: Observable<Camera>;
  93786. /**
  93787. * Observable triggered when the camera Projection matrix has changed.
  93788. */
  93789. onProjectionMatrixChangedObservable: Observable<Camera>;
  93790. /**
  93791. * Observable triggered when the inputs have been processed.
  93792. */
  93793. onAfterCheckInputsObservable: Observable<Camera>;
  93794. /**
  93795. * Observable triggered when reset has been called and applied to the camera.
  93796. */
  93797. onRestoreStateObservable: Observable<Camera>;
  93798. /** @hidden */
  93799. _cameraRigParams: any;
  93800. /** @hidden */
  93801. _rigCameras: Camera[];
  93802. /** @hidden */
  93803. _rigPostProcess: Nullable<PostProcess>;
  93804. protected _webvrViewMatrix: Matrix;
  93805. /** @hidden */
  93806. _skipRendering: boolean;
  93807. /** @hidden */
  93808. _projectionMatrix: Matrix;
  93809. /** @hidden */
  93810. _postProcesses: Nullable<PostProcess>[];
  93811. /** @hidden */
  93812. _activeMeshes: SmartArray<AbstractMesh>;
  93813. protected _globalPosition: Vector3;
  93814. /** @hidden */
  93815. _computedViewMatrix: Matrix;
  93816. private _doNotComputeProjectionMatrix;
  93817. private _transformMatrix;
  93818. private _frustumPlanes;
  93819. private _refreshFrustumPlanes;
  93820. private _storedFov;
  93821. private _stateStored;
  93822. /**
  93823. * Instantiates a new camera object.
  93824. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93825. * @see http://doc.babylonjs.com/features/cameras
  93826. * @param name Defines the name of the camera in the scene
  93827. * @param position Defines the position of the camera
  93828. * @param scene Defines the scene the camera belongs too
  93829. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93830. */
  93831. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93832. /**
  93833. * Store current camera state (fov, position, etc..)
  93834. * @returns the camera
  93835. */
  93836. storeState(): Camera;
  93837. /**
  93838. * Restores the camera state values if it has been stored. You must call storeState() first
  93839. */
  93840. protected _restoreStateValues(): boolean;
  93841. /**
  93842. * Restored camera state. You must call storeState() first.
  93843. * @returns true if restored and false otherwise
  93844. */
  93845. restoreState(): boolean;
  93846. /**
  93847. * Gets the class name of the camera.
  93848. * @returns the class name
  93849. */
  93850. getClassName(): string;
  93851. /** @hidden */
  93852. readonly _isCamera: boolean;
  93853. /**
  93854. * Gets a string representation of the camera useful for debug purpose.
  93855. * @param fullDetails Defines that a more verboe level of logging is required
  93856. * @returns the string representation
  93857. */
  93858. toString(fullDetails?: boolean): string;
  93859. /**
  93860. * Gets the current world space position of the camera.
  93861. */
  93862. readonly globalPosition: Vector3;
  93863. /**
  93864. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93865. * @returns the active meshe list
  93866. */
  93867. getActiveMeshes(): SmartArray<AbstractMesh>;
  93868. /**
  93869. * Check wether a mesh is part of the current active mesh list of the camera
  93870. * @param mesh Defines the mesh to check
  93871. * @returns true if active, false otherwise
  93872. */
  93873. isActiveMesh(mesh: Mesh): boolean;
  93874. /**
  93875. * Is this camera ready to be used/rendered
  93876. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93877. * @return true if the camera is ready
  93878. */
  93879. isReady(completeCheck?: boolean): boolean;
  93880. /** @hidden */
  93881. _initCache(): void;
  93882. /** @hidden */
  93883. _updateCache(ignoreParentClass?: boolean): void;
  93884. /** @hidden */
  93885. _isSynchronized(): boolean;
  93886. /** @hidden */
  93887. _isSynchronizedViewMatrix(): boolean;
  93888. /** @hidden */
  93889. _isSynchronizedProjectionMatrix(): boolean;
  93890. /**
  93891. * Attach the input controls to a specific dom element to get the input from.
  93892. * @param element Defines the element the controls should be listened from
  93893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93894. */
  93895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93896. /**
  93897. * Detach the current controls from the specified dom element.
  93898. * @param element Defines the element to stop listening the inputs from
  93899. */
  93900. detachControl(element: HTMLElement): void;
  93901. /**
  93902. * Update the camera state according to the different inputs gathered during the frame.
  93903. */
  93904. update(): void;
  93905. /** @hidden */
  93906. _checkInputs(): void;
  93907. /** @hidden */
  93908. readonly rigCameras: Camera[];
  93909. /**
  93910. * Gets the post process used by the rig cameras
  93911. */
  93912. readonly rigPostProcess: Nullable<PostProcess>;
  93913. /**
  93914. * Internal, gets the first post proces.
  93915. * @returns the first post process to be run on this camera.
  93916. */
  93917. _getFirstPostProcess(): Nullable<PostProcess>;
  93918. private _cascadePostProcessesToRigCams;
  93919. /**
  93920. * Attach a post process to the camera.
  93921. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93922. * @param postProcess The post process to attach to the camera
  93923. * @param insertAt The position of the post process in case several of them are in use in the scene
  93924. * @returns the position the post process has been inserted at
  93925. */
  93926. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93927. /**
  93928. * Detach a post process to the camera.
  93929. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93930. * @param postProcess The post process to detach from the camera
  93931. */
  93932. detachPostProcess(postProcess: PostProcess): void;
  93933. /**
  93934. * Gets the current world matrix of the camera
  93935. */
  93936. getWorldMatrix(): Matrix;
  93937. /** @hidden */
  93938. _getViewMatrix(): Matrix;
  93939. /**
  93940. * Gets the current view matrix of the camera.
  93941. * @param force forces the camera to recompute the matrix without looking at the cached state
  93942. * @returns the view matrix
  93943. */
  93944. getViewMatrix(force?: boolean): Matrix;
  93945. /**
  93946. * Freeze the projection matrix.
  93947. * It will prevent the cache check of the camera projection compute and can speed up perf
  93948. * if no parameter of the camera are meant to change
  93949. * @param projection Defines manually a projection if necessary
  93950. */
  93951. freezeProjectionMatrix(projection?: Matrix): void;
  93952. /**
  93953. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93954. */
  93955. unfreezeProjectionMatrix(): void;
  93956. /**
  93957. * Gets the current projection matrix of the camera.
  93958. * @param force forces the camera to recompute the matrix without looking at the cached state
  93959. * @returns the projection matrix
  93960. */
  93961. getProjectionMatrix(force?: boolean): Matrix;
  93962. /**
  93963. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93964. * @returns a Matrix
  93965. */
  93966. getTransformationMatrix(): Matrix;
  93967. private _updateFrustumPlanes;
  93968. /**
  93969. * Checks if a cullable object (mesh...) is in the camera frustum
  93970. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93971. * @param target The object to check
  93972. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93973. * @returns true if the object is in frustum otherwise false
  93974. */
  93975. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93976. /**
  93977. * Checks if a cullable object (mesh...) is in the camera frustum
  93978. * Unlike isInFrustum this cheks the full bounding box
  93979. * @param target The object to check
  93980. * @returns true if the object is in frustum otherwise false
  93981. */
  93982. isCompletelyInFrustum(target: ICullable): boolean;
  93983. /**
  93984. * Gets a ray in the forward direction from the camera.
  93985. * @param length Defines the length of the ray to create
  93986. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93987. * @param origin Defines the start point of the ray which defaults to the camera position
  93988. * @returns the forward ray
  93989. */
  93990. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93991. /**
  93992. * Releases resources associated with this node.
  93993. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93994. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93995. */
  93996. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93997. /** @hidden */
  93998. _isLeftCamera: boolean;
  93999. /**
  94000. * Gets the left camera of a rig setup in case of Rigged Camera
  94001. */
  94002. readonly isLeftCamera: boolean;
  94003. /** @hidden */
  94004. _isRightCamera: boolean;
  94005. /**
  94006. * Gets the right camera of a rig setup in case of Rigged Camera
  94007. */
  94008. readonly isRightCamera: boolean;
  94009. /**
  94010. * Gets the left camera of a rig setup in case of Rigged Camera
  94011. */
  94012. readonly leftCamera: Nullable<FreeCamera>;
  94013. /**
  94014. * Gets the right camera of a rig setup in case of Rigged Camera
  94015. */
  94016. readonly rightCamera: Nullable<FreeCamera>;
  94017. /**
  94018. * Gets the left camera target of a rig setup in case of Rigged Camera
  94019. * @returns the target position
  94020. */
  94021. getLeftTarget(): Nullable<Vector3>;
  94022. /**
  94023. * Gets the right camera target of a rig setup in case of Rigged Camera
  94024. * @returns the target position
  94025. */
  94026. getRightTarget(): Nullable<Vector3>;
  94027. /**
  94028. * @hidden
  94029. */
  94030. setCameraRigMode(mode: number, rigParams: any): void;
  94031. /** @hidden */
  94032. static _setStereoscopicRigMode(camera: Camera): void;
  94033. /** @hidden */
  94034. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  94035. /** @hidden */
  94036. static _setVRRigMode(camera: Camera, rigParams: any): void;
  94037. /** @hidden */
  94038. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  94039. /** @hidden */
  94040. _getVRProjectionMatrix(): Matrix;
  94041. protected _updateCameraRotationMatrix(): void;
  94042. protected _updateWebVRCameraRotationMatrix(): void;
  94043. /**
  94044. * This function MUST be overwritten by the different WebVR cameras available.
  94045. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94046. * @hidden
  94047. */
  94048. _getWebVRProjectionMatrix(): Matrix;
  94049. /**
  94050. * This function MUST be overwritten by the different WebVR cameras available.
  94051. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94052. * @hidden
  94053. */
  94054. _getWebVRViewMatrix(): Matrix;
  94055. /** @hidden */
  94056. setCameraRigParameter(name: string, value: any): void;
  94057. /**
  94058. * needs to be overridden by children so sub has required properties to be copied
  94059. * @hidden
  94060. */
  94061. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94062. /**
  94063. * May need to be overridden by children
  94064. * @hidden
  94065. */
  94066. _updateRigCameras(): void;
  94067. /** @hidden */
  94068. _setupInputs(): void;
  94069. /**
  94070. * Serialiaze the camera setup to a json represention
  94071. * @returns the JSON representation
  94072. */
  94073. serialize(): any;
  94074. /**
  94075. * Clones the current camera.
  94076. * @param name The cloned camera name
  94077. * @returns the cloned camera
  94078. */
  94079. clone(name: string): Camera;
  94080. /**
  94081. * Gets the direction of the camera relative to a given local axis.
  94082. * @param localAxis Defines the reference axis to provide a relative direction.
  94083. * @return the direction
  94084. */
  94085. getDirection(localAxis: Vector3): Vector3;
  94086. /**
  94087. * Returns the current camera absolute rotation
  94088. */
  94089. readonly absoluteRotation: Quaternion;
  94090. /**
  94091. * Gets the direction of the camera relative to a given local axis into a passed vector.
  94092. * @param localAxis Defines the reference axis to provide a relative direction.
  94093. * @param result Defines the vector to store the result in
  94094. */
  94095. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  94096. /**
  94097. * Gets a camera constructor for a given camera type
  94098. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  94099. * @param name The name of the camera the result will be able to instantiate
  94100. * @param scene The scene the result will construct the camera in
  94101. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  94102. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  94103. * @returns a factory method to construc the camera
  94104. */
  94105. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  94106. /**
  94107. * Compute the world matrix of the camera.
  94108. * @returns the camera world matrix
  94109. */
  94110. computeWorldMatrix(): Matrix;
  94111. /**
  94112. * Parse a JSON and creates the camera from the parsed information
  94113. * @param parsedCamera The JSON to parse
  94114. * @param scene The scene to instantiate the camera in
  94115. * @returns the newly constructed camera
  94116. */
  94117. static Parse(parsedCamera: any, scene: Scene): Camera;
  94118. }
  94119. }
  94120. declare module BABYLON {
  94121. /**
  94122. * Class containing static functions to help procedurally build meshes
  94123. */
  94124. export class DiscBuilder {
  94125. /**
  94126. * Creates a plane polygonal mesh. By default, this is a disc
  94127. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  94128. * * 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
  94129. * * 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
  94130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94133. * @param name defines the name of the mesh
  94134. * @param options defines the options used to create the mesh
  94135. * @param scene defines the hosting scene
  94136. * @returns the plane polygonal mesh
  94137. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  94138. */
  94139. static CreateDisc(name: string, options: {
  94140. radius?: number;
  94141. tessellation?: number;
  94142. arc?: number;
  94143. updatable?: boolean;
  94144. sideOrientation?: number;
  94145. frontUVs?: Vector4;
  94146. backUVs?: Vector4;
  94147. }, scene?: Nullable<Scene>): Mesh;
  94148. }
  94149. }
  94150. declare module BABYLON {
  94151. /**
  94152. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  94153. *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.
  94154. * The SPS is also a particle system. It provides some methods to manage the particles.
  94155. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  94156. *
  94157. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  94158. */
  94159. export class SolidParticleSystem implements IDisposable {
  94160. /**
  94161. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  94162. * Example : var p = SPS.particles[i];
  94163. */
  94164. particles: SolidParticle[];
  94165. /**
  94166. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  94167. */
  94168. nbParticles: number;
  94169. /**
  94170. * If the particles must ever face the camera (default false). Useful for planar particles.
  94171. */
  94172. billboard: boolean;
  94173. /**
  94174. * Recompute normals when adding a shape
  94175. */
  94176. recomputeNormals: boolean;
  94177. /**
  94178. * This a counter ofr your own usage. It's not set by any SPS functions.
  94179. */
  94180. counter: number;
  94181. /**
  94182. * The SPS name. This name is also given to the underlying mesh.
  94183. */
  94184. name: string;
  94185. /**
  94186. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  94187. */
  94188. mesh: Mesh;
  94189. /**
  94190. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  94191. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  94192. */
  94193. vars: any;
  94194. /**
  94195. * This array is populated when the SPS is set as 'pickable'.
  94196. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  94197. * Each element of this array is an object `{idx: int, faceId: int}`.
  94198. * `idx` is the picked particle index in the `SPS.particles` array
  94199. * `faceId` is the picked face index counted within this particle.
  94200. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  94201. */
  94202. pickedParticles: {
  94203. idx: number;
  94204. faceId: number;
  94205. }[];
  94206. /**
  94207. * This array is populated when `enableDepthSort` is set to true.
  94208. * Each element of this array is an instance of the class DepthSortedParticle.
  94209. */
  94210. depthSortedParticles: DepthSortedParticle[];
  94211. /**
  94212. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  94213. * @hidden
  94214. */
  94215. _bSphereOnly: boolean;
  94216. /**
  94217. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  94218. * @hidden
  94219. */
  94220. _bSphereRadiusFactor: number;
  94221. private _scene;
  94222. private _positions;
  94223. private _indices;
  94224. private _normals;
  94225. private _colors;
  94226. private _uvs;
  94227. private _indices32;
  94228. private _positions32;
  94229. private _normals32;
  94230. private _fixedNormal32;
  94231. private _colors32;
  94232. private _uvs32;
  94233. private _index;
  94234. private _updatable;
  94235. private _pickable;
  94236. private _isVisibilityBoxLocked;
  94237. private _alwaysVisible;
  94238. private _depthSort;
  94239. private _expandable;
  94240. private _shapeCounter;
  94241. private _copy;
  94242. private _color;
  94243. private _computeParticleColor;
  94244. private _computeParticleTexture;
  94245. private _computeParticleRotation;
  94246. private _computeParticleVertex;
  94247. private _computeBoundingBox;
  94248. private _depthSortParticles;
  94249. private _camera;
  94250. private _mustUnrotateFixedNormals;
  94251. private _particlesIntersect;
  94252. private _needs32Bits;
  94253. private _isNotBuilt;
  94254. private _lastParticleId;
  94255. private _idxOfId;
  94256. private _multimaterialEnabled;
  94257. private _indicesByMaterial;
  94258. private _materialIndexes;
  94259. private _depthSortFunction;
  94260. private _materialSortFunction;
  94261. /**
  94262. * Creates a SPS (Solid Particle System) object.
  94263. * @param name (String) is the SPS name, this will be the underlying mesh name.
  94264. * @param scene (Scene) is the scene in which the SPS is added.
  94265. * @param options defines the options of the sps e.g.
  94266. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  94267. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  94268. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  94269. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  94270. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  94271. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  94272. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  94273. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  94274. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  94275. */
  94276. constructor(name: string, scene: Scene, options?: {
  94277. updatable?: boolean;
  94278. isPickable?: boolean;
  94279. enableDepthSort?: boolean;
  94280. particleIntersection?: boolean;
  94281. boundingSphereOnly?: boolean;
  94282. bSphereRadiusFactor?: number;
  94283. expandable?: boolean;
  94284. enableMultiMaterial?: boolean;
  94285. });
  94286. /**
  94287. * Builds the SPS underlying mesh. Returns a standard Mesh.
  94288. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  94289. * @returns the created mesh
  94290. */
  94291. buildMesh(): Mesh;
  94292. /**
  94293. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  94294. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  94295. * Thus the particles generated from `digest()` have their property `position` set yet.
  94296. * @param mesh ( Mesh ) is the mesh to be digested
  94297. * @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
  94298. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  94299. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  94300. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  94301. * @returns the current SPS
  94302. */
  94303. digest(mesh: Mesh, options?: {
  94304. facetNb?: number;
  94305. number?: number;
  94306. delta?: number;
  94307. storage?: [];
  94308. }): SolidParticleSystem;
  94309. /**
  94310. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  94311. * @hidden
  94312. */
  94313. private _unrotateFixedNormals;
  94314. /**
  94315. * Resets the temporary working copy particle
  94316. * @hidden
  94317. */
  94318. private _resetCopy;
  94319. /**
  94320. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  94321. * @param p the current index in the positions array to be updated
  94322. * @param ind the current index in the indices array
  94323. * @param shape a Vector3 array, the shape geometry
  94324. * @param positions the positions array to be updated
  94325. * @param meshInd the shape indices array
  94326. * @param indices the indices array to be updated
  94327. * @param meshUV the shape uv array
  94328. * @param uvs the uv array to be updated
  94329. * @param meshCol the shape color array
  94330. * @param colors the color array to be updated
  94331. * @param meshNor the shape normals array
  94332. * @param normals the normals array to be updated
  94333. * @param idx the particle index
  94334. * @param idxInShape the particle index in its shape
  94335. * @param options the addShape() method passed options
  94336. * @hidden
  94337. */
  94338. private _meshBuilder;
  94339. /**
  94340. * Returns a shape Vector3 array from positions float array
  94341. * @param positions float array
  94342. * @returns a vector3 array
  94343. * @hidden
  94344. */
  94345. private _posToShape;
  94346. /**
  94347. * Returns a shapeUV array from a float uvs (array deep copy)
  94348. * @param uvs as a float array
  94349. * @returns a shapeUV array
  94350. * @hidden
  94351. */
  94352. private _uvsToShapeUV;
  94353. /**
  94354. * Adds a new particle object in the particles array
  94355. * @param idx particle index in particles array
  94356. * @param id particle id
  94357. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  94358. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  94359. * @param model particle ModelShape object
  94360. * @param shapeId model shape identifier
  94361. * @param idxInShape index of the particle in the current model
  94362. * @param bInfo model bounding info object
  94363. * @param storage target storage array, if any
  94364. * @hidden
  94365. */
  94366. private _addParticle;
  94367. /**
  94368. * Adds some particles to the SPS from the model shape. Returns the shape id.
  94369. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  94370. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  94371. * @param nb (positive integer) the number of particles to be created from this model
  94372. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  94373. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  94374. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  94375. * @returns the number of shapes in the system
  94376. */
  94377. addShape(mesh: Mesh, nb: number, options?: {
  94378. positionFunction?: any;
  94379. vertexFunction?: any;
  94380. storage?: [];
  94381. }): number;
  94382. /**
  94383. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  94384. * @hidden
  94385. */
  94386. private _rebuildParticle;
  94387. /**
  94388. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  94389. * @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.
  94390. * @returns the SPS.
  94391. */
  94392. rebuildMesh(reset?: boolean): SolidParticleSystem;
  94393. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  94394. * Returns an array with the removed particles.
  94395. * 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.
  94396. * The SPS can't be empty so at least one particle needs to remain in place.
  94397. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  94398. * @param start index of the first particle to remove
  94399. * @param end index of the last particle to remove (included)
  94400. * @returns an array populated with the removed particles
  94401. */
  94402. removeParticles(start: number, end: number): SolidParticle[];
  94403. /**
  94404. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  94405. * @param solidParticleArray an array populated with Solid Particles objects
  94406. * @returns the SPS
  94407. */
  94408. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  94409. /**
  94410. * Creates a new particle and modifies the SPS mesh geometry :
  94411. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  94412. * - calls _addParticle() to populate the particle array
  94413. * factorized code from addShape() and insertParticlesFromArray()
  94414. * @param idx particle index in the particles array
  94415. * @param i particle index in its shape
  94416. * @param modelShape particle ModelShape object
  94417. * @param shape shape vertex array
  94418. * @param meshInd shape indices array
  94419. * @param meshUV shape uv array
  94420. * @param meshCol shape color array
  94421. * @param meshNor shape normals array
  94422. * @param bbInfo shape bounding info
  94423. * @param storage target particle storage
  94424. * @options addShape() passed options
  94425. * @hidden
  94426. */
  94427. private _insertNewParticle;
  94428. /**
  94429. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  94430. * This method calls `updateParticle()` for each particle of the SPS.
  94431. * For an animated SPS, it is usually called within the render loop.
  94432. * 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.
  94433. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  94434. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  94435. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  94436. * @returns the SPS.
  94437. */
  94438. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  94439. /**
  94440. * Disposes the SPS.
  94441. */
  94442. dispose(): void;
  94443. /**
  94444. * Returns a SolidParticle object from its identifier : particle.id
  94445. * @param id (integer) the particle Id
  94446. * @returns the searched particle or null if not found in the SPS.
  94447. */
  94448. getParticleById(id: number): Nullable<SolidParticle>;
  94449. /**
  94450. * Returns a new array populated with the particles having the passed shapeId.
  94451. * @param shapeId (integer) the shape identifier
  94452. * @returns a new solid particle array
  94453. */
  94454. getParticlesByShapeId(shapeId: number): SolidParticle[];
  94455. /**
  94456. * Populates the passed array "ref" with the particles having the passed shapeId.
  94457. * @param shapeId the shape identifier
  94458. * @returns the SPS
  94459. * @param ref
  94460. */
  94461. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  94462. /**
  94463. * Computes the required SubMeshes according the materials assigned to the particles.
  94464. * @returns the solid particle system.
  94465. * Does nothing if called before the SPS mesh is built.
  94466. */
  94467. computeSubMeshes(): SolidParticleSystem;
  94468. /**
  94469. * Sorts the solid particles by material when MultiMaterial is enabled.
  94470. * Updates the indices32 array.
  94471. * Updates the indicesByMaterial array.
  94472. * Updates the mesh indices array.
  94473. * @returns the SPS
  94474. * @hidden
  94475. */
  94476. private _sortParticlesByMaterial;
  94477. /**
  94478. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  94479. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94480. * @returns the SPS.
  94481. */
  94482. refreshVisibleSize(): SolidParticleSystem;
  94483. /**
  94484. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  94485. * @param size the size (float) of the visibility box
  94486. * note : this doesn't lock the SPS mesh bounding box.
  94487. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94488. */
  94489. setVisibilityBox(size: number): void;
  94490. /**
  94491. * Gets whether the SPS as always visible or not
  94492. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94493. */
  94494. /**
  94495. * Sets the SPS as always visible or not
  94496. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94497. */
  94498. isAlwaysVisible: boolean;
  94499. /**
  94500. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  94501. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94502. */
  94503. /**
  94504. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  94505. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94506. */
  94507. isVisibilityBoxLocked: boolean;
  94508. /**
  94509. * Tells to `setParticles()` to compute the particle rotations or not.
  94510. * Default value : true. The SPS is faster when it's set to false.
  94511. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  94512. */
  94513. /**
  94514. * Gets if `setParticles()` computes the particle rotations or not.
  94515. * Default value : true. The SPS is faster when it's set to false.
  94516. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  94517. */
  94518. computeParticleRotation: boolean;
  94519. /**
  94520. * Tells to `setParticles()` to compute the particle colors or not.
  94521. * Default value : true. The SPS is faster when it's set to false.
  94522. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  94523. */
  94524. /**
  94525. * Gets if `setParticles()` computes the particle colors or not.
  94526. * Default value : true. The SPS is faster when it's set to false.
  94527. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  94528. */
  94529. computeParticleColor: boolean;
  94530. /**
  94531. * Gets if `setParticles()` computes the particle textures or not.
  94532. * Default value : true. The SPS is faster when it's set to false.
  94533. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  94534. */
  94535. computeParticleTexture: boolean;
  94536. /**
  94537. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  94538. * Default value : false. The SPS is faster when it's set to false.
  94539. * Note : the particle custom vertex positions aren't stored values.
  94540. */
  94541. /**
  94542. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  94543. * Default value : false. The SPS is faster when it's set to false.
  94544. * Note : the particle custom vertex positions aren't stored values.
  94545. */
  94546. computeParticleVertex: boolean;
  94547. /**
  94548. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  94549. */
  94550. /**
  94551. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  94552. */
  94553. computeBoundingBox: boolean;
  94554. /**
  94555. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  94556. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94557. * Default : `true`
  94558. */
  94559. /**
  94560. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  94561. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94562. * Default : `true`
  94563. */
  94564. depthSortParticles: boolean;
  94565. /**
  94566. * Gets if the SPS is created as expandable at construction time.
  94567. * Default : `false`
  94568. */
  94569. readonly expandable: boolean;
  94570. /**
  94571. * Gets if the SPS supports the Multi Materials
  94572. */
  94573. readonly multimaterialEnabled: boolean;
  94574. /**
  94575. * This function does nothing. It may be overwritten to set all the particle first values.
  94576. * The SPS doesn't call this function, you may have to call it by your own.
  94577. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94578. */
  94579. initParticles(): void;
  94580. /**
  94581. * This function does nothing. It may be overwritten to recycle a particle.
  94582. * The SPS doesn't call this function, you may have to call it by your own.
  94583. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94584. * @param particle The particle to recycle
  94585. * @returns the recycled particle
  94586. */
  94587. recycleParticle(particle: SolidParticle): SolidParticle;
  94588. /**
  94589. * Updates a particle : this function should be overwritten by the user.
  94590. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  94591. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94592. * @example : just set a particle position or velocity and recycle conditions
  94593. * @param particle The particle to update
  94594. * @returns the updated particle
  94595. */
  94596. updateParticle(particle: SolidParticle): SolidParticle;
  94597. /**
  94598. * Updates a vertex of a particle : it can be overwritten by the user.
  94599. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  94600. * @param particle the current particle
  94601. * @param vertex the current index of the current particle
  94602. * @param pt the index of the current vertex in the particle shape
  94603. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  94604. * @example : just set a vertex particle position
  94605. * @returns the updated vertex
  94606. */
  94607. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  94608. /**
  94609. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  94610. * This does nothing and may be overwritten by the user.
  94611. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94612. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94613. * @param update the boolean update value actually passed to setParticles()
  94614. */
  94615. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94616. /**
  94617. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  94618. * This will be passed three parameters.
  94619. * This does nothing and may be overwritten by the user.
  94620. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94621. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94622. * @param update the boolean update value actually passed to setParticles()
  94623. */
  94624. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94625. }
  94626. }
  94627. declare module BABYLON {
  94628. /**
  94629. * Represents one particle of a solid particle system.
  94630. */
  94631. export class SolidParticle {
  94632. /**
  94633. * particle global index
  94634. */
  94635. idx: number;
  94636. /**
  94637. * particle identifier
  94638. */
  94639. id: number;
  94640. /**
  94641. * The color of the particle
  94642. */
  94643. color: Nullable<Color4>;
  94644. /**
  94645. * The world space position of the particle.
  94646. */
  94647. position: Vector3;
  94648. /**
  94649. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  94650. */
  94651. rotation: Vector3;
  94652. /**
  94653. * The world space rotation quaternion of the particle.
  94654. */
  94655. rotationQuaternion: Nullable<Quaternion>;
  94656. /**
  94657. * The scaling of the particle.
  94658. */
  94659. scaling: Vector3;
  94660. /**
  94661. * The uvs of the particle.
  94662. */
  94663. uvs: Vector4;
  94664. /**
  94665. * The current speed of the particle.
  94666. */
  94667. velocity: Vector3;
  94668. /**
  94669. * The pivot point in the particle local space.
  94670. */
  94671. pivot: Vector3;
  94672. /**
  94673. * Must the particle be translated from its pivot point in its local space ?
  94674. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  94675. * Default : false
  94676. */
  94677. translateFromPivot: boolean;
  94678. /**
  94679. * Is the particle active or not ?
  94680. */
  94681. alive: boolean;
  94682. /**
  94683. * Is the particle visible or not ?
  94684. */
  94685. isVisible: boolean;
  94686. /**
  94687. * Index of this particle in the global "positions" array (Internal use)
  94688. * @hidden
  94689. */
  94690. _pos: number;
  94691. /**
  94692. * @hidden Index of this particle in the global "indices" array (Internal use)
  94693. */
  94694. _ind: number;
  94695. /**
  94696. * @hidden ModelShape of this particle (Internal use)
  94697. */
  94698. _model: ModelShape;
  94699. /**
  94700. * ModelShape id of this particle
  94701. */
  94702. shapeId: number;
  94703. /**
  94704. * Index of the particle in its shape id
  94705. */
  94706. idxInShape: number;
  94707. /**
  94708. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  94709. */
  94710. _modelBoundingInfo: BoundingInfo;
  94711. /**
  94712. * @hidden Particle BoundingInfo object (Internal use)
  94713. */
  94714. _boundingInfo: BoundingInfo;
  94715. /**
  94716. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  94717. */
  94718. _sps: SolidParticleSystem;
  94719. /**
  94720. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  94721. */
  94722. _stillInvisible: boolean;
  94723. /**
  94724. * @hidden Last computed particle rotation matrix
  94725. */
  94726. _rotationMatrix: number[];
  94727. /**
  94728. * Parent particle Id, if any.
  94729. * Default null.
  94730. */
  94731. parentId: Nullable<number>;
  94732. /**
  94733. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  94734. */
  94735. materialIndex: Nullable<number>;
  94736. /**
  94737. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  94738. * The possible values are :
  94739. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94740. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94741. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94742. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94743. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94744. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  94745. * */
  94746. cullingStrategy: number;
  94747. /**
  94748. * @hidden Internal global position in the SPS.
  94749. */
  94750. _globalPosition: Vector3;
  94751. /**
  94752. * Creates a Solid Particle object.
  94753. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  94754. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  94755. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  94756. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  94757. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  94758. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  94759. * @param shapeId (integer) is the model shape identifier in the SPS.
  94760. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  94761. * @param sps defines the sps it is associated to
  94762. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  94763. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  94764. */
  94765. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  94766. /**
  94767. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  94768. * @param target the particle target
  94769. * @returns the current particle
  94770. */
  94771. copyToRef(target: SolidParticle): SolidParticle;
  94772. /**
  94773. * Legacy support, changed scale to scaling
  94774. */
  94775. /**
  94776. * Legacy support, changed scale to scaling
  94777. */
  94778. scale: Vector3;
  94779. /**
  94780. * Legacy support, changed quaternion to rotationQuaternion
  94781. */
  94782. /**
  94783. * Legacy support, changed quaternion to rotationQuaternion
  94784. */
  94785. quaternion: Nullable<Quaternion>;
  94786. /**
  94787. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  94788. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  94789. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  94790. * @returns true if it intersects
  94791. */
  94792. intersectsMesh(target: Mesh | SolidParticle): boolean;
  94793. /**
  94794. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  94795. * A particle is in the frustum if its bounding box intersects the frustum
  94796. * @param frustumPlanes defines the frustum to test
  94797. * @returns true if the particle is in the frustum planes
  94798. */
  94799. isInFrustum(frustumPlanes: Plane[]): boolean;
  94800. /**
  94801. * get the rotation matrix of the particle
  94802. * @hidden
  94803. */
  94804. getRotationMatrix(m: Matrix): void;
  94805. }
  94806. /**
  94807. * Represents the shape of the model used by one particle of a solid particle system.
  94808. * SPS internal tool, don't use it manually.
  94809. */
  94810. export class ModelShape {
  94811. /**
  94812. * The shape id
  94813. * @hidden
  94814. */
  94815. shapeID: number;
  94816. /**
  94817. * flat array of model positions (internal use)
  94818. * @hidden
  94819. */
  94820. _shape: Vector3[];
  94821. /**
  94822. * flat array of model UVs (internal use)
  94823. * @hidden
  94824. */
  94825. _shapeUV: number[];
  94826. /**
  94827. * color array of the model
  94828. * @hidden
  94829. */
  94830. _shapeColors: number[];
  94831. /**
  94832. * indices array of the model
  94833. * @hidden
  94834. */
  94835. _indices: number[];
  94836. /**
  94837. * normals array of the model
  94838. * @hidden
  94839. */
  94840. _normals: number[];
  94841. /**
  94842. * length of the shape in the model indices array (internal use)
  94843. * @hidden
  94844. */
  94845. _indicesLength: number;
  94846. /**
  94847. * Custom position function (internal use)
  94848. * @hidden
  94849. */
  94850. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94851. /**
  94852. * Custom vertex function (internal use)
  94853. * @hidden
  94854. */
  94855. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94856. /**
  94857. * 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.
  94858. * SPS internal tool, don't use it manually.
  94859. * @hidden
  94860. */
  94861. 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>);
  94862. }
  94863. /**
  94864. * Represents a Depth Sorted Particle in the solid particle system.
  94865. * @hidden
  94866. */
  94867. export class DepthSortedParticle {
  94868. /**
  94869. * Index of the particle in the "indices" array
  94870. */
  94871. ind: number;
  94872. /**
  94873. * Length of the particle shape in the "indices" array
  94874. */
  94875. indicesLength: number;
  94876. /**
  94877. * Squared distance from the particle to the camera
  94878. */
  94879. sqDistance: number;
  94880. /**
  94881. * Material index when used with MultiMaterials
  94882. */
  94883. materialIndex: number;
  94884. /**
  94885. * Creates a new sorted particle
  94886. * @param materialIndex
  94887. */
  94888. constructor(ind: number, indLength: number, materialIndex: number);
  94889. }
  94890. }
  94891. declare module BABYLON {
  94892. /**
  94893. * @hidden
  94894. */
  94895. export class _MeshCollisionData {
  94896. _checkCollisions: boolean;
  94897. _collisionMask: number;
  94898. _collisionGroup: number;
  94899. _collider: Nullable<Collider>;
  94900. _oldPositionForCollisions: Vector3;
  94901. _diffPositionForCollisions: Vector3;
  94902. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94903. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94904. }
  94905. }
  94906. declare module BABYLON {
  94907. /** @hidden */
  94908. class _FacetDataStorage {
  94909. facetPositions: Vector3[];
  94910. facetNormals: Vector3[];
  94911. facetPartitioning: number[][];
  94912. facetNb: number;
  94913. partitioningSubdivisions: number;
  94914. partitioningBBoxRatio: number;
  94915. facetDataEnabled: boolean;
  94916. facetParameters: any;
  94917. bbSize: Vector3;
  94918. subDiv: {
  94919. max: number;
  94920. X: number;
  94921. Y: number;
  94922. Z: number;
  94923. };
  94924. facetDepthSort: boolean;
  94925. facetDepthSortEnabled: boolean;
  94926. depthSortedIndices: IndicesArray;
  94927. depthSortedFacets: {
  94928. ind: number;
  94929. sqDistance: number;
  94930. }[];
  94931. facetDepthSortFunction: (f1: {
  94932. ind: number;
  94933. sqDistance: number;
  94934. }, f2: {
  94935. ind: number;
  94936. sqDistance: number;
  94937. }) => number;
  94938. facetDepthSortFrom: Vector3;
  94939. facetDepthSortOrigin: Vector3;
  94940. invertedMatrix: Matrix;
  94941. }
  94942. /**
  94943. * @hidden
  94944. **/
  94945. class _InternalAbstractMeshDataInfo {
  94946. _hasVertexAlpha: boolean;
  94947. _useVertexColors: boolean;
  94948. _numBoneInfluencers: number;
  94949. _applyFog: boolean;
  94950. _receiveShadows: boolean;
  94951. _facetData: _FacetDataStorage;
  94952. _visibility: number;
  94953. _skeleton: Nullable<Skeleton>;
  94954. _layerMask: number;
  94955. _computeBonesUsingShaders: boolean;
  94956. _isActive: boolean;
  94957. _onlyForInstances: boolean;
  94958. _isActiveIntermediate: boolean;
  94959. _onlyForInstancesIntermediate: boolean;
  94960. _actAsRegularMesh: boolean;
  94961. }
  94962. /**
  94963. * Class used to store all common mesh properties
  94964. */
  94965. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94966. /** No occlusion */
  94967. static OCCLUSION_TYPE_NONE: number;
  94968. /** Occlusion set to optimisitic */
  94969. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94970. /** Occlusion set to strict */
  94971. static OCCLUSION_TYPE_STRICT: number;
  94972. /** Use an accurante occlusion algorithm */
  94973. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94974. /** Use a conservative occlusion algorithm */
  94975. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94976. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94977. * Test order :
  94978. * Is the bounding sphere outside the frustum ?
  94979. * If not, are the bounding box vertices outside the frustum ?
  94980. * It not, then the cullable object is in the frustum.
  94981. */
  94982. static readonly CULLINGSTRATEGY_STANDARD: number;
  94983. /** Culling strategy : Bounding Sphere Only.
  94984. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94985. * It's also less accurate than the standard because some not visible objects can still be selected.
  94986. * Test : is the bounding sphere outside the frustum ?
  94987. * If not, then the cullable object is in the frustum.
  94988. */
  94989. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94990. /** Culling strategy : Optimistic Inclusion.
  94991. * This in an inclusion test first, then the standard exclusion test.
  94992. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94993. * 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.
  94994. * Anyway, it's as accurate as the standard strategy.
  94995. * Test :
  94996. * Is the cullable object bounding sphere center in the frustum ?
  94997. * If not, apply the default culling strategy.
  94998. */
  94999. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  95000. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  95001. * This in an inclusion test first, then the bounding sphere only exclusion test.
  95002. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  95003. * 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.
  95004. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  95005. * Test :
  95006. * Is the cullable object bounding sphere center in the frustum ?
  95007. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  95008. */
  95009. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  95010. /**
  95011. * No billboard
  95012. */
  95013. static readonly BILLBOARDMODE_NONE: number;
  95014. /** Billboard on X axis */
  95015. static readonly BILLBOARDMODE_X: number;
  95016. /** Billboard on Y axis */
  95017. static readonly BILLBOARDMODE_Y: number;
  95018. /** Billboard on Z axis */
  95019. static readonly BILLBOARDMODE_Z: number;
  95020. /** Billboard on all axes */
  95021. static readonly BILLBOARDMODE_ALL: number;
  95022. /** Billboard on using position instead of orientation */
  95023. static readonly BILLBOARDMODE_USE_POSITION: number;
  95024. /** @hidden */
  95025. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  95026. /**
  95027. * The culling strategy to use to check whether the mesh must be rendered or not.
  95028. * This value can be changed at any time and will be used on the next render mesh selection.
  95029. * The possible values are :
  95030. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  95031. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  95032. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  95033. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  95034. * Please read each static variable documentation to get details about the culling process.
  95035. * */
  95036. cullingStrategy: number;
  95037. /**
  95038. * Gets the number of facets in the mesh
  95039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  95040. */
  95041. readonly facetNb: number;
  95042. /**
  95043. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  95044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  95045. */
  95046. partitioningSubdivisions: number;
  95047. /**
  95048. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  95049. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  95050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  95051. */
  95052. partitioningBBoxRatio: number;
  95053. /**
  95054. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  95055. * Works only for updatable meshes.
  95056. * Doesn't work with multi-materials
  95057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  95058. */
  95059. mustDepthSortFacets: boolean;
  95060. /**
  95061. * The location (Vector3) where the facet depth sort must be computed from.
  95062. * By default, the active camera position.
  95063. * Used only when facet depth sort is enabled
  95064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  95065. */
  95066. facetDepthSortFrom: Vector3;
  95067. /**
  95068. * gets a boolean indicating if facetData is enabled
  95069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  95070. */
  95071. readonly isFacetDataEnabled: boolean;
  95072. /** @hidden */
  95073. _updateNonUniformScalingState(value: boolean): boolean;
  95074. /**
  95075. * An event triggered when this mesh collides with another one
  95076. */
  95077. onCollideObservable: Observable<AbstractMesh>;
  95078. /** Set a function to call when this mesh collides with another one */
  95079. onCollide: () => void;
  95080. /**
  95081. * An event triggered when the collision's position changes
  95082. */
  95083. onCollisionPositionChangeObservable: Observable<Vector3>;
  95084. /** Set a function to call when the collision's position changes */
  95085. onCollisionPositionChange: () => void;
  95086. /**
  95087. * An event triggered when material is changed
  95088. */
  95089. onMaterialChangedObservable: Observable<AbstractMesh>;
  95090. /**
  95091. * Gets or sets the orientation for POV movement & rotation
  95092. */
  95093. definedFacingForward: boolean;
  95094. /** @hidden */
  95095. _occlusionQuery: Nullable<WebGLQuery>;
  95096. /** @hidden */
  95097. _renderingGroup: Nullable<RenderingGroup>;
  95098. /**
  95099. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  95100. */
  95101. /**
  95102. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  95103. */
  95104. visibility: number;
  95105. /** Gets or sets the alpha index used to sort transparent meshes
  95106. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  95107. */
  95108. alphaIndex: number;
  95109. /**
  95110. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  95111. */
  95112. isVisible: boolean;
  95113. /**
  95114. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  95115. */
  95116. isPickable: boolean;
  95117. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  95118. showSubMeshesBoundingBox: boolean;
  95119. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  95120. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  95121. */
  95122. isBlocker: boolean;
  95123. /**
  95124. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  95125. */
  95126. enablePointerMoveEvents: boolean;
  95127. /**
  95128. * Specifies the rendering group id for this mesh (0 by default)
  95129. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  95130. */
  95131. renderingGroupId: number;
  95132. private _material;
  95133. /** Gets or sets current material */
  95134. material: Nullable<Material>;
  95135. /**
  95136. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  95137. * @see http://doc.babylonjs.com/babylon101/shadows
  95138. */
  95139. receiveShadows: boolean;
  95140. /** Defines color to use when rendering outline */
  95141. outlineColor: Color3;
  95142. /** Define width to use when rendering outline */
  95143. outlineWidth: number;
  95144. /** Defines color to use when rendering overlay */
  95145. overlayColor: Color3;
  95146. /** Defines alpha to use when rendering overlay */
  95147. overlayAlpha: number;
  95148. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  95149. hasVertexAlpha: boolean;
  95150. /** 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) */
  95151. useVertexColors: boolean;
  95152. /**
  95153. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  95154. */
  95155. computeBonesUsingShaders: boolean;
  95156. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  95157. numBoneInfluencers: number;
  95158. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  95159. applyFog: boolean;
  95160. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  95161. useOctreeForRenderingSelection: boolean;
  95162. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  95163. useOctreeForPicking: boolean;
  95164. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  95165. useOctreeForCollisions: boolean;
  95166. /**
  95167. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  95168. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  95169. */
  95170. layerMask: number;
  95171. /**
  95172. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  95173. */
  95174. alwaysSelectAsActiveMesh: boolean;
  95175. /**
  95176. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  95177. */
  95178. doNotSyncBoundingInfo: boolean;
  95179. /**
  95180. * Gets or sets the current action manager
  95181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95182. */
  95183. actionManager: Nullable<AbstractActionManager>;
  95184. private _meshCollisionData;
  95185. /**
  95186. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  95187. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95188. */
  95189. ellipsoid: Vector3;
  95190. /**
  95191. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  95192. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95193. */
  95194. ellipsoidOffset: Vector3;
  95195. /**
  95196. * Gets or sets a collision mask used to mask collisions (default is -1).
  95197. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  95198. */
  95199. collisionMask: number;
  95200. /**
  95201. * Gets or sets the current collision group mask (-1 by default).
  95202. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  95203. */
  95204. collisionGroup: number;
  95205. /**
  95206. * Defines edge width used when edgesRenderer is enabled
  95207. * @see https://www.babylonjs-playground.com/#10OJSG#13
  95208. */
  95209. edgesWidth: number;
  95210. /**
  95211. * Defines edge color used when edgesRenderer is enabled
  95212. * @see https://www.babylonjs-playground.com/#10OJSG#13
  95213. */
  95214. edgesColor: Color4;
  95215. /** @hidden */
  95216. _edgesRenderer: Nullable<IEdgesRenderer>;
  95217. /** @hidden */
  95218. _masterMesh: Nullable<AbstractMesh>;
  95219. /** @hidden */
  95220. _boundingInfo: Nullable<BoundingInfo>;
  95221. /** @hidden */
  95222. _renderId: number;
  95223. /**
  95224. * Gets or sets the list of subMeshes
  95225. * @see http://doc.babylonjs.com/how_to/multi_materials
  95226. */
  95227. subMeshes: SubMesh[];
  95228. /** @hidden */
  95229. _intersectionsInProgress: AbstractMesh[];
  95230. /** @hidden */
  95231. _unIndexed: boolean;
  95232. /** @hidden */
  95233. _lightSources: Light[];
  95234. /** Gets the list of lights affecting that mesh */
  95235. readonly lightSources: Light[];
  95236. /** @hidden */
  95237. readonly _positions: Nullable<Vector3[]>;
  95238. /** @hidden */
  95239. _waitingData: {
  95240. lods: Nullable<any>;
  95241. actions: Nullable<any>;
  95242. freezeWorldMatrix: Nullable<boolean>;
  95243. };
  95244. /** @hidden */
  95245. _bonesTransformMatrices: Nullable<Float32Array>;
  95246. /** @hidden */
  95247. _transformMatrixTexture: Nullable<RawTexture>;
  95248. /**
  95249. * Gets or sets a skeleton to apply skining transformations
  95250. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95251. */
  95252. skeleton: Nullable<Skeleton>;
  95253. /**
  95254. * An event triggered when the mesh is rebuilt.
  95255. */
  95256. onRebuildObservable: Observable<AbstractMesh>;
  95257. /**
  95258. * Creates a new AbstractMesh
  95259. * @param name defines the name of the mesh
  95260. * @param scene defines the hosting scene
  95261. */
  95262. constructor(name: string, scene?: Nullable<Scene>);
  95263. /**
  95264. * Returns the string "AbstractMesh"
  95265. * @returns "AbstractMesh"
  95266. */
  95267. getClassName(): string;
  95268. /**
  95269. * Gets a string representation of the current mesh
  95270. * @param fullDetails defines a boolean indicating if full details must be included
  95271. * @returns a string representation of the current mesh
  95272. */
  95273. toString(fullDetails?: boolean): string;
  95274. /**
  95275. * @hidden
  95276. */
  95277. protected _getEffectiveParent(): Nullable<Node>;
  95278. /** @hidden */
  95279. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95280. /** @hidden */
  95281. _rebuild(): void;
  95282. /** @hidden */
  95283. _resyncLightSources(): void;
  95284. /** @hidden */
  95285. _resyncLightSource(light: Light): void;
  95286. /** @hidden */
  95287. _unBindEffect(): void;
  95288. /** @hidden */
  95289. _removeLightSource(light: Light, dispose: boolean): void;
  95290. private _markSubMeshesAsDirty;
  95291. /** @hidden */
  95292. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  95293. /** @hidden */
  95294. _markSubMeshesAsAttributesDirty(): void;
  95295. /** @hidden */
  95296. _markSubMeshesAsMiscDirty(): void;
  95297. /**
  95298. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  95299. */
  95300. scaling: Vector3;
  95301. /**
  95302. * Returns true if the mesh is blocked. Implemented by child classes
  95303. */
  95304. readonly isBlocked: boolean;
  95305. /**
  95306. * Returns the mesh itself by default. Implemented by child classes
  95307. * @param camera defines the camera to use to pick the right LOD level
  95308. * @returns the currentAbstractMesh
  95309. */
  95310. getLOD(camera: Camera): Nullable<AbstractMesh>;
  95311. /**
  95312. * Returns 0 by default. Implemented by child classes
  95313. * @returns an integer
  95314. */
  95315. getTotalVertices(): number;
  95316. /**
  95317. * Returns a positive integer : the total number of indices in this mesh geometry.
  95318. * @returns the numner of indices or zero if the mesh has no geometry.
  95319. */
  95320. getTotalIndices(): number;
  95321. /**
  95322. * Returns null by default. Implemented by child classes
  95323. * @returns null
  95324. */
  95325. getIndices(): Nullable<IndicesArray>;
  95326. /**
  95327. * Returns the array of the requested vertex data kind. Implemented by child classes
  95328. * @param kind defines the vertex data kind to use
  95329. * @returns null
  95330. */
  95331. getVerticesData(kind: string): Nullable<FloatArray>;
  95332. /**
  95333. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95334. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95335. * Note that a new underlying VertexBuffer object is created each call.
  95336. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95337. * @param kind defines vertex data kind:
  95338. * * VertexBuffer.PositionKind
  95339. * * VertexBuffer.UVKind
  95340. * * VertexBuffer.UV2Kind
  95341. * * VertexBuffer.UV3Kind
  95342. * * VertexBuffer.UV4Kind
  95343. * * VertexBuffer.UV5Kind
  95344. * * VertexBuffer.UV6Kind
  95345. * * VertexBuffer.ColorKind
  95346. * * VertexBuffer.MatricesIndicesKind
  95347. * * VertexBuffer.MatricesIndicesExtraKind
  95348. * * VertexBuffer.MatricesWeightsKind
  95349. * * VertexBuffer.MatricesWeightsExtraKind
  95350. * @param data defines the data source
  95351. * @param updatable defines if the data must be flagged as updatable (or static)
  95352. * @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
  95353. * @returns the current mesh
  95354. */
  95355. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95356. /**
  95357. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95358. * If the mesh has no geometry, it is simply returned as it is.
  95359. * @param kind defines vertex data kind:
  95360. * * VertexBuffer.PositionKind
  95361. * * VertexBuffer.UVKind
  95362. * * VertexBuffer.UV2Kind
  95363. * * VertexBuffer.UV3Kind
  95364. * * VertexBuffer.UV4Kind
  95365. * * VertexBuffer.UV5Kind
  95366. * * VertexBuffer.UV6Kind
  95367. * * VertexBuffer.ColorKind
  95368. * * VertexBuffer.MatricesIndicesKind
  95369. * * VertexBuffer.MatricesIndicesExtraKind
  95370. * * VertexBuffer.MatricesWeightsKind
  95371. * * VertexBuffer.MatricesWeightsExtraKind
  95372. * @param data defines the data source
  95373. * @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
  95374. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  95375. * @returns the current mesh
  95376. */
  95377. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95378. /**
  95379. * Sets the mesh indices,
  95380. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95381. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  95382. * @param totalVertices Defines the total number of vertices
  95383. * @returns the current mesh
  95384. */
  95385. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  95386. /**
  95387. * Gets a boolean indicating if specific vertex data is present
  95388. * @param kind defines the vertex data kind to use
  95389. * @returns true is data kind is present
  95390. */
  95391. isVerticesDataPresent(kind: string): boolean;
  95392. /**
  95393. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  95394. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  95395. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  95396. * @returns a BoundingInfo
  95397. */
  95398. getBoundingInfo(): BoundingInfo;
  95399. /**
  95400. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95401. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95402. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95403. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95404. * @returns the current mesh
  95405. */
  95406. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  95407. /**
  95408. * Overwrite the current bounding info
  95409. * @param boundingInfo defines the new bounding info
  95410. * @returns the current mesh
  95411. */
  95412. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  95413. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  95414. readonly useBones: boolean;
  95415. /** @hidden */
  95416. _preActivate(): void;
  95417. /** @hidden */
  95418. _preActivateForIntermediateRendering(renderId: number): void;
  95419. /** @hidden */
  95420. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95421. /** @hidden */
  95422. _postActivate(): void;
  95423. /** @hidden */
  95424. _freeze(): void;
  95425. /** @hidden */
  95426. _unFreeze(): void;
  95427. /**
  95428. * Gets the current world matrix
  95429. * @returns a Matrix
  95430. */
  95431. getWorldMatrix(): Matrix;
  95432. /** @hidden */
  95433. _getWorldMatrixDeterminant(): number;
  95434. /**
  95435. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  95436. */
  95437. readonly isAnInstance: boolean;
  95438. /**
  95439. * Gets a boolean indicating if this mesh has instances
  95440. */
  95441. readonly hasInstances: boolean;
  95442. /**
  95443. * Perform relative position change from the point of view of behind the front of the mesh.
  95444. * This is performed taking into account the meshes current rotation, so you do not have to care.
  95445. * Supports definition of mesh facing forward or backward
  95446. * @param amountRight defines the distance on the right axis
  95447. * @param amountUp defines the distance on the up axis
  95448. * @param amountForward defines the distance on the forward axis
  95449. * @returns the current mesh
  95450. */
  95451. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  95452. /**
  95453. * Calculate relative position change from the point of view of behind the front of the mesh.
  95454. * This is performed taking into account the meshes current rotation, so you do not have to care.
  95455. * Supports definition of mesh facing forward or backward
  95456. * @param amountRight defines the distance on the right axis
  95457. * @param amountUp defines the distance on the up axis
  95458. * @param amountForward defines the distance on the forward axis
  95459. * @returns the new displacement vector
  95460. */
  95461. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  95462. /**
  95463. * Perform relative rotation change from the point of view of behind the front of the mesh.
  95464. * Supports definition of mesh facing forward or backward
  95465. * @param flipBack defines the flip
  95466. * @param twirlClockwise defines the twirl
  95467. * @param tiltRight defines the tilt
  95468. * @returns the current mesh
  95469. */
  95470. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  95471. /**
  95472. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  95473. * Supports definition of mesh facing forward or backward.
  95474. * @param flipBack defines the flip
  95475. * @param twirlClockwise defines the twirl
  95476. * @param tiltRight defines the tilt
  95477. * @returns the new rotation vector
  95478. */
  95479. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  95480. /**
  95481. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95482. * This means the mesh underlying bounding box and sphere are recomputed.
  95483. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95484. * @returns the current mesh
  95485. */
  95486. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  95487. /** @hidden */
  95488. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  95489. /** @hidden */
  95490. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  95491. /** @hidden */
  95492. _updateBoundingInfo(): AbstractMesh;
  95493. /** @hidden */
  95494. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  95495. /** @hidden */
  95496. protected _afterComputeWorldMatrix(): void;
  95497. /** @hidden */
  95498. readonly _effectiveMesh: AbstractMesh;
  95499. /**
  95500. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95501. * A mesh is in the frustum if its bounding box intersects the frustum
  95502. * @param frustumPlanes defines the frustum to test
  95503. * @returns true if the mesh is in the frustum planes
  95504. */
  95505. isInFrustum(frustumPlanes: Plane[]): boolean;
  95506. /**
  95507. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  95508. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  95509. * @param frustumPlanes defines the frustum to test
  95510. * @returns true if the mesh is completely in the frustum planes
  95511. */
  95512. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95513. /**
  95514. * True if the mesh intersects another mesh or a SolidParticle object
  95515. * @param mesh defines a target mesh or SolidParticle to test
  95516. * @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)
  95517. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  95518. * @returns true if there is an intersection
  95519. */
  95520. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  95521. /**
  95522. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  95523. * @param point defines the point to test
  95524. * @returns true if there is an intersection
  95525. */
  95526. intersectsPoint(point: Vector3): boolean;
  95527. /**
  95528. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  95529. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95530. */
  95531. checkCollisions: boolean;
  95532. /**
  95533. * Gets Collider object used to compute collisions (not physics)
  95534. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95535. */
  95536. readonly collider: Nullable<Collider>;
  95537. /**
  95538. * Move the mesh using collision engine
  95539. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95540. * @param displacement defines the requested displacement vector
  95541. * @returns the current mesh
  95542. */
  95543. moveWithCollisions(displacement: Vector3): AbstractMesh;
  95544. private _onCollisionPositionChange;
  95545. /** @hidden */
  95546. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  95547. /** @hidden */
  95548. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  95549. /** @hidden */
  95550. _checkCollision(collider: Collider): AbstractMesh;
  95551. /** @hidden */
  95552. _generatePointsArray(): boolean;
  95553. /**
  95554. * Checks if the passed Ray intersects with the mesh
  95555. * @param ray defines the ray to use
  95556. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  95557. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95558. * @returns the picking info
  95559. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  95560. */
  95561. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  95562. /**
  95563. * Clones the current mesh
  95564. * @param name defines the mesh name
  95565. * @param newParent defines the new mesh parent
  95566. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  95567. * @returns the new mesh
  95568. */
  95569. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  95570. /**
  95571. * Disposes all the submeshes of the current meshnp
  95572. * @returns the current mesh
  95573. */
  95574. releaseSubMeshes(): AbstractMesh;
  95575. /**
  95576. * Releases resources associated with this abstract mesh.
  95577. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95578. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95579. */
  95580. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95581. /**
  95582. * Adds the passed mesh as a child to the current mesh
  95583. * @param mesh defines the child mesh
  95584. * @returns the current mesh
  95585. */
  95586. addChild(mesh: AbstractMesh): AbstractMesh;
  95587. /**
  95588. * Removes the passed mesh from the current mesh children list
  95589. * @param mesh defines the child mesh
  95590. * @returns the current mesh
  95591. */
  95592. removeChild(mesh: AbstractMesh): AbstractMesh;
  95593. /** @hidden */
  95594. private _initFacetData;
  95595. /**
  95596. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  95597. * This method can be called within the render loop.
  95598. * 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
  95599. * @returns the current mesh
  95600. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95601. */
  95602. updateFacetData(): AbstractMesh;
  95603. /**
  95604. * Returns the facetLocalNormals array.
  95605. * The normals are expressed in the mesh local spac
  95606. * @returns an array of Vector3
  95607. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95608. */
  95609. getFacetLocalNormals(): Vector3[];
  95610. /**
  95611. * Returns the facetLocalPositions array.
  95612. * The facet positions are expressed in the mesh local space
  95613. * @returns an array of Vector3
  95614. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95615. */
  95616. getFacetLocalPositions(): Vector3[];
  95617. /**
  95618. * Returns the facetLocalPartioning array
  95619. * @returns an array of array of numbers
  95620. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95621. */
  95622. getFacetLocalPartitioning(): number[][];
  95623. /**
  95624. * Returns the i-th facet position in the world system.
  95625. * This method allocates a new Vector3 per call
  95626. * @param i defines the facet index
  95627. * @returns a new Vector3
  95628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95629. */
  95630. getFacetPosition(i: number): Vector3;
  95631. /**
  95632. * Sets the reference Vector3 with the i-th facet position in the world system
  95633. * @param i defines the facet index
  95634. * @param ref defines the target vector
  95635. * @returns the current mesh
  95636. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95637. */
  95638. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  95639. /**
  95640. * Returns the i-th facet normal in the world system.
  95641. * This method allocates a new Vector3 per call
  95642. * @param i defines the facet index
  95643. * @returns a new Vector3
  95644. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95645. */
  95646. getFacetNormal(i: number): Vector3;
  95647. /**
  95648. * Sets the reference Vector3 with the i-th facet normal in the world system
  95649. * @param i defines the facet index
  95650. * @param ref defines the target vector
  95651. * @returns the current mesh
  95652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95653. */
  95654. getFacetNormalToRef(i: number, ref: Vector3): this;
  95655. /**
  95656. * 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)
  95657. * @param x defines x coordinate
  95658. * @param y defines y coordinate
  95659. * @param z defines z coordinate
  95660. * @returns the array of facet indexes
  95661. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95662. */
  95663. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  95664. /**
  95665. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  95666. * @param projected sets as the (x,y,z) world projection on the facet
  95667. * @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
  95668. * @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
  95669. * @param x defines x coordinate
  95670. * @param y defines y coordinate
  95671. * @param z defines z coordinate
  95672. * @returns the face index if found (or null instead)
  95673. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95674. */
  95675. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95676. /**
  95677. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  95678. * @param projected sets as the (x,y,z) local projection on the facet
  95679. * @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
  95680. * @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
  95681. * @param x defines x coordinate
  95682. * @param y defines y coordinate
  95683. * @param z defines z coordinate
  95684. * @returns the face index if found (or null instead)
  95685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95686. */
  95687. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95688. /**
  95689. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  95690. * @returns the parameters
  95691. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95692. */
  95693. getFacetDataParameters(): any;
  95694. /**
  95695. * Disables the feature FacetData and frees the related memory
  95696. * @returns the current mesh
  95697. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95698. */
  95699. disableFacetData(): AbstractMesh;
  95700. /**
  95701. * Updates the AbstractMesh indices array
  95702. * @param indices defines the data source
  95703. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95704. * @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)
  95705. * @returns the current mesh
  95706. */
  95707. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95708. /**
  95709. * Creates new normals data for the mesh
  95710. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  95711. * @returns the current mesh
  95712. */
  95713. createNormals(updatable: boolean): AbstractMesh;
  95714. /**
  95715. * Align the mesh with a normal
  95716. * @param normal defines the normal to use
  95717. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  95718. * @returns the current mesh
  95719. */
  95720. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  95721. /** @hidden */
  95722. _checkOcclusionQuery(): boolean;
  95723. /**
  95724. * Disables the mesh edge rendering mode
  95725. * @returns the currentAbstractMesh
  95726. */
  95727. disableEdgesRendering(): AbstractMesh;
  95728. /**
  95729. * Enables the edge rendering mode on the mesh.
  95730. * This mode makes the mesh edges visible
  95731. * @param epsilon defines the maximal distance between two angles to detect a face
  95732. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95733. * @returns the currentAbstractMesh
  95734. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95735. */
  95736. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95737. }
  95738. }
  95739. declare module BABYLON {
  95740. /**
  95741. * Interface used to define ActionEvent
  95742. */
  95743. export interface IActionEvent {
  95744. /** The mesh or sprite that triggered the action */
  95745. source: any;
  95746. /** The X mouse cursor position at the time of the event */
  95747. pointerX: number;
  95748. /** The Y mouse cursor position at the time of the event */
  95749. pointerY: number;
  95750. /** The mesh that is currently pointed at (can be null) */
  95751. meshUnderPointer: Nullable<AbstractMesh>;
  95752. /** the original (browser) event that triggered the ActionEvent */
  95753. sourceEvent?: any;
  95754. /** additional data for the event */
  95755. additionalData?: any;
  95756. }
  95757. /**
  95758. * ActionEvent is the event being sent when an action is triggered.
  95759. */
  95760. export class ActionEvent implements IActionEvent {
  95761. /** The mesh or sprite that triggered the action */
  95762. source: any;
  95763. /** The X mouse cursor position at the time of the event */
  95764. pointerX: number;
  95765. /** The Y mouse cursor position at the time of the event */
  95766. pointerY: number;
  95767. /** The mesh that is currently pointed at (can be null) */
  95768. meshUnderPointer: Nullable<AbstractMesh>;
  95769. /** the original (browser) event that triggered the ActionEvent */
  95770. sourceEvent?: any;
  95771. /** additional data for the event */
  95772. additionalData?: any;
  95773. /**
  95774. * Creates a new ActionEvent
  95775. * @param source The mesh or sprite that triggered the action
  95776. * @param pointerX The X mouse cursor position at the time of the event
  95777. * @param pointerY The Y mouse cursor position at the time of the event
  95778. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  95779. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  95780. * @param additionalData additional data for the event
  95781. */
  95782. constructor(
  95783. /** The mesh or sprite that triggered the action */
  95784. source: any,
  95785. /** The X mouse cursor position at the time of the event */
  95786. pointerX: number,
  95787. /** The Y mouse cursor position at the time of the event */
  95788. pointerY: number,
  95789. /** The mesh that is currently pointed at (can be null) */
  95790. meshUnderPointer: Nullable<AbstractMesh>,
  95791. /** the original (browser) event that triggered the ActionEvent */
  95792. sourceEvent?: any,
  95793. /** additional data for the event */
  95794. additionalData?: any);
  95795. /**
  95796. * Helper function to auto-create an ActionEvent from a source mesh.
  95797. * @param source The source mesh that triggered the event
  95798. * @param evt The original (browser) event
  95799. * @param additionalData additional data for the event
  95800. * @returns the new ActionEvent
  95801. */
  95802. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  95803. /**
  95804. * Helper function to auto-create an ActionEvent from a source sprite
  95805. * @param source The source sprite that triggered the event
  95806. * @param scene Scene associated with the sprite
  95807. * @param evt The original (browser) event
  95808. * @param additionalData additional data for the event
  95809. * @returns the new ActionEvent
  95810. */
  95811. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  95812. /**
  95813. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  95814. * @param scene the scene where the event occurred
  95815. * @param evt The original (browser) event
  95816. * @returns the new ActionEvent
  95817. */
  95818. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95819. /**
  95820. * Helper function to auto-create an ActionEvent from a primitive
  95821. * @param prim defines the target primitive
  95822. * @param pointerPos defines the pointer position
  95823. * @param evt The original (browser) event
  95824. * @param additionalData additional data for the event
  95825. * @returns the new ActionEvent
  95826. */
  95827. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95828. }
  95829. }
  95830. declare module BABYLON {
  95831. /**
  95832. * Abstract class used to decouple action Manager from scene and meshes.
  95833. * Do not instantiate.
  95834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95835. */
  95836. export abstract class AbstractActionManager implements IDisposable {
  95837. /** Gets the list of active triggers */
  95838. static Triggers: {
  95839. [key: string]: number;
  95840. };
  95841. /** Gets the cursor to use when hovering items */
  95842. hoverCursor: string;
  95843. /** Gets the list of actions */
  95844. actions: IAction[];
  95845. /**
  95846. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95847. */
  95848. isRecursive: boolean;
  95849. /**
  95850. * Releases all associated resources
  95851. */
  95852. abstract dispose(): void;
  95853. /**
  95854. * Does this action manager has pointer triggers
  95855. */
  95856. abstract readonly hasPointerTriggers: boolean;
  95857. /**
  95858. * Does this action manager has pick triggers
  95859. */
  95860. abstract readonly hasPickTriggers: boolean;
  95861. /**
  95862. * Process a specific trigger
  95863. * @param trigger defines the trigger to process
  95864. * @param evt defines the event details to be processed
  95865. */
  95866. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95867. /**
  95868. * Does this action manager handles actions of any of the given triggers
  95869. * @param triggers defines the triggers to be tested
  95870. * @return a boolean indicating whether one (or more) of the triggers is handled
  95871. */
  95872. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95873. /**
  95874. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95875. * speed.
  95876. * @param triggerA defines the trigger to be tested
  95877. * @param triggerB defines the trigger to be tested
  95878. * @return a boolean indicating whether one (or more) of the triggers is handled
  95879. */
  95880. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95881. /**
  95882. * Does this action manager handles actions of a given trigger
  95883. * @param trigger defines the trigger to be tested
  95884. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95885. * @return whether the trigger is handled
  95886. */
  95887. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95888. /**
  95889. * Serialize this manager to a JSON object
  95890. * @param name defines the property name to store this manager
  95891. * @returns a JSON representation of this manager
  95892. */
  95893. abstract serialize(name: string): any;
  95894. /**
  95895. * Registers an action to this action manager
  95896. * @param action defines the action to be registered
  95897. * @return the action amended (prepared) after registration
  95898. */
  95899. abstract registerAction(action: IAction): Nullable<IAction>;
  95900. /**
  95901. * Unregisters an action to this action manager
  95902. * @param action defines the action to be unregistered
  95903. * @return a boolean indicating whether the action has been unregistered
  95904. */
  95905. abstract unregisterAction(action: IAction): Boolean;
  95906. /**
  95907. * Does exist one action manager with at least one trigger
  95908. **/
  95909. static readonly HasTriggers: boolean;
  95910. /**
  95911. * Does exist one action manager with at least one pick trigger
  95912. **/
  95913. static readonly HasPickTriggers: boolean;
  95914. /**
  95915. * Does exist one action manager that handles actions of a given trigger
  95916. * @param trigger defines the trigger to be tested
  95917. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95918. **/
  95919. static HasSpecificTrigger(trigger: number): boolean;
  95920. }
  95921. }
  95922. declare module BABYLON {
  95923. /**
  95924. * Defines how a node can be built from a string name.
  95925. */
  95926. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95927. /**
  95928. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95929. */
  95930. export class Node implements IBehaviorAware<Node> {
  95931. /** @hidden */
  95932. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95933. private static _NodeConstructors;
  95934. /**
  95935. * Add a new node constructor
  95936. * @param type defines the type name of the node to construct
  95937. * @param constructorFunc defines the constructor function
  95938. */
  95939. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95940. /**
  95941. * Returns a node constructor based on type name
  95942. * @param type defines the type name
  95943. * @param name defines the new node name
  95944. * @param scene defines the hosting scene
  95945. * @param options defines optional options to transmit to constructors
  95946. * @returns the new constructor or null
  95947. */
  95948. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95949. /**
  95950. * Gets or sets the name of the node
  95951. */
  95952. name: string;
  95953. /**
  95954. * Gets or sets the id of the node
  95955. */
  95956. id: string;
  95957. /**
  95958. * Gets or sets the unique id of the node
  95959. */
  95960. uniqueId: number;
  95961. /**
  95962. * Gets or sets a string used to store user defined state for the node
  95963. */
  95964. state: string;
  95965. /**
  95966. * Gets or sets an object used to store user defined information for the node
  95967. */
  95968. metadata: any;
  95969. /**
  95970. * For internal use only. Please do not use.
  95971. */
  95972. reservedDataStore: any;
  95973. /**
  95974. * List of inspectable custom properties (used by the Inspector)
  95975. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95976. */
  95977. inspectableCustomProperties: IInspectable[];
  95978. private _doNotSerialize;
  95979. /**
  95980. * Gets or sets a boolean used to define if the node must be serialized
  95981. */
  95982. doNotSerialize: boolean;
  95983. /** @hidden */
  95984. _isDisposed: boolean;
  95985. /**
  95986. * Gets a list of Animations associated with the node
  95987. */
  95988. animations: Animation[];
  95989. protected _ranges: {
  95990. [name: string]: Nullable<AnimationRange>;
  95991. };
  95992. /**
  95993. * Callback raised when the node is ready to be used
  95994. */
  95995. onReady: Nullable<(node: Node) => void>;
  95996. private _isEnabled;
  95997. private _isParentEnabled;
  95998. private _isReady;
  95999. /** @hidden */
  96000. _currentRenderId: number;
  96001. private _parentUpdateId;
  96002. /** @hidden */
  96003. _childUpdateId: number;
  96004. /** @hidden */
  96005. _waitingParentId: Nullable<string>;
  96006. /** @hidden */
  96007. _scene: Scene;
  96008. /** @hidden */
  96009. _cache: any;
  96010. private _parentNode;
  96011. private _children;
  96012. /** @hidden */
  96013. _worldMatrix: Matrix;
  96014. /** @hidden */
  96015. _worldMatrixDeterminant: number;
  96016. /** @hidden */
  96017. _worldMatrixDeterminantIsDirty: boolean;
  96018. /** @hidden */
  96019. private _sceneRootNodesIndex;
  96020. /**
  96021. * Gets a boolean indicating if the node has been disposed
  96022. * @returns true if the node was disposed
  96023. */
  96024. isDisposed(): boolean;
  96025. /**
  96026. * Gets or sets the parent of the node (without keeping the current position in the scene)
  96027. * @see https://doc.babylonjs.com/how_to/parenting
  96028. */
  96029. parent: Nullable<Node>;
  96030. /** @hidden */
  96031. _addToSceneRootNodes(): void;
  96032. /** @hidden */
  96033. _removeFromSceneRootNodes(): void;
  96034. private _animationPropertiesOverride;
  96035. /**
  96036. * Gets or sets the animation properties override
  96037. */
  96038. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  96039. /**
  96040. * Gets a string idenfifying the name of the class
  96041. * @returns "Node" string
  96042. */
  96043. getClassName(): string;
  96044. /** @hidden */
  96045. readonly _isNode: boolean;
  96046. /**
  96047. * An event triggered when the mesh is disposed
  96048. */
  96049. onDisposeObservable: Observable<Node>;
  96050. private _onDisposeObserver;
  96051. /**
  96052. * Sets a callback that will be raised when the node will be disposed
  96053. */
  96054. onDispose: () => void;
  96055. /**
  96056. * Creates a new Node
  96057. * @param name the name and id to be given to this node
  96058. * @param scene the scene this node will be added to
  96059. */
  96060. constructor(name: string, scene?: Nullable<Scene>);
  96061. /**
  96062. * Gets the scene of the node
  96063. * @returns a scene
  96064. */
  96065. getScene(): Scene;
  96066. /**
  96067. * Gets the engine of the node
  96068. * @returns a Engine
  96069. */
  96070. getEngine(): Engine;
  96071. private _behaviors;
  96072. /**
  96073. * Attach a behavior to the node
  96074. * @see http://doc.babylonjs.com/features/behaviour
  96075. * @param behavior defines the behavior to attach
  96076. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  96077. * @returns the current Node
  96078. */
  96079. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  96080. /**
  96081. * Remove an attached behavior
  96082. * @see http://doc.babylonjs.com/features/behaviour
  96083. * @param behavior defines the behavior to attach
  96084. * @returns the current Node
  96085. */
  96086. removeBehavior(behavior: Behavior<Node>): Node;
  96087. /**
  96088. * Gets the list of attached behaviors
  96089. * @see http://doc.babylonjs.com/features/behaviour
  96090. */
  96091. readonly behaviors: Behavior<Node>[];
  96092. /**
  96093. * Gets an attached behavior by name
  96094. * @param name defines the name of the behavior to look for
  96095. * @see http://doc.babylonjs.com/features/behaviour
  96096. * @returns null if behavior was not found else the requested behavior
  96097. */
  96098. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  96099. /**
  96100. * Returns the latest update of the World matrix
  96101. * @returns a Matrix
  96102. */
  96103. getWorldMatrix(): Matrix;
  96104. /** @hidden */
  96105. _getWorldMatrixDeterminant(): number;
  96106. /**
  96107. * Returns directly the latest state of the mesh World matrix.
  96108. * A Matrix is returned.
  96109. */
  96110. readonly worldMatrixFromCache: Matrix;
  96111. /** @hidden */
  96112. _initCache(): void;
  96113. /** @hidden */
  96114. updateCache(force?: boolean): void;
  96115. /** @hidden */
  96116. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  96117. /** @hidden */
  96118. _updateCache(ignoreParentClass?: boolean): void;
  96119. /** @hidden */
  96120. _isSynchronized(): boolean;
  96121. /** @hidden */
  96122. _markSyncedWithParent(): void;
  96123. /** @hidden */
  96124. isSynchronizedWithParent(): boolean;
  96125. /** @hidden */
  96126. isSynchronized(): boolean;
  96127. /**
  96128. * Is this node ready to be used/rendered
  96129. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96130. * @return true if the node is ready
  96131. */
  96132. isReady(completeCheck?: boolean): boolean;
  96133. /**
  96134. * Is this node enabled?
  96135. * 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
  96136. * @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
  96137. * @return whether this node (and its parent) is enabled
  96138. */
  96139. isEnabled(checkAncestors?: boolean): boolean;
  96140. /** @hidden */
  96141. protected _syncParentEnabledState(): void;
  96142. /**
  96143. * Set the enabled state of this node
  96144. * @param value defines the new enabled state
  96145. */
  96146. setEnabled(value: boolean): void;
  96147. /**
  96148. * Is this node a descendant of the given node?
  96149. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  96150. * @param ancestor defines the parent node to inspect
  96151. * @returns a boolean indicating if this node is a descendant of the given node
  96152. */
  96153. isDescendantOf(ancestor: Node): boolean;
  96154. /** @hidden */
  96155. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  96156. /**
  96157. * Will return all nodes that have this node as ascendant
  96158. * @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
  96159. * @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
  96160. * @return all children nodes of all types
  96161. */
  96162. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  96163. /**
  96164. * Get all child-meshes of this node
  96165. * @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)
  96166. * @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
  96167. * @returns an array of AbstractMesh
  96168. */
  96169. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  96170. /**
  96171. * Get all direct children of this node
  96172. * @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
  96173. * @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)
  96174. * @returns an array of Node
  96175. */
  96176. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  96177. /** @hidden */
  96178. _setReady(state: boolean): void;
  96179. /**
  96180. * Get an animation by name
  96181. * @param name defines the name of the animation to look for
  96182. * @returns null if not found else the requested animation
  96183. */
  96184. getAnimationByName(name: string): Nullable<Animation>;
  96185. /**
  96186. * Creates an animation range for this node
  96187. * @param name defines the name of the range
  96188. * @param from defines the starting key
  96189. * @param to defines the end key
  96190. */
  96191. createAnimationRange(name: string, from: number, to: number): void;
  96192. /**
  96193. * Delete a specific animation range
  96194. * @param name defines the name of the range to delete
  96195. * @param deleteFrames defines if animation frames from the range must be deleted as well
  96196. */
  96197. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96198. /**
  96199. * Get an animation range by name
  96200. * @param name defines the name of the animation range to look for
  96201. * @returns null if not found else the requested animation range
  96202. */
  96203. getAnimationRange(name: string): Nullable<AnimationRange>;
  96204. /**
  96205. * Gets the list of all animation ranges defined on this node
  96206. * @returns an array
  96207. */
  96208. getAnimationRanges(): Nullable<AnimationRange>[];
  96209. /**
  96210. * Will start the animation sequence
  96211. * @param name defines the range frames for animation sequence
  96212. * @param loop defines if the animation should loop (false by default)
  96213. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  96214. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  96215. * @returns the object created for this animation. If range does not exist, it will return null
  96216. */
  96217. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96218. /**
  96219. * Serialize animation ranges into a JSON compatible object
  96220. * @returns serialization object
  96221. */
  96222. serializeAnimationRanges(): any;
  96223. /**
  96224. * Computes the world matrix of the node
  96225. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96226. * @returns the world matrix
  96227. */
  96228. computeWorldMatrix(force?: boolean): Matrix;
  96229. /**
  96230. * Releases resources associated with this node.
  96231. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96232. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96233. */
  96234. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96235. /**
  96236. * Parse animation range data from a serialization object and store them into a given node
  96237. * @param node defines where to store the animation ranges
  96238. * @param parsedNode defines the serialization object to read data from
  96239. * @param scene defines the hosting scene
  96240. */
  96241. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  96242. /**
  96243. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  96244. * @param includeDescendants Include bounding info from descendants as well (true by default)
  96245. * @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
  96246. * @returns the new bounding vectors
  96247. */
  96248. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  96249. min: Vector3;
  96250. max: Vector3;
  96251. };
  96252. }
  96253. }
  96254. declare module BABYLON {
  96255. /**
  96256. * @hidden
  96257. */
  96258. export class _IAnimationState {
  96259. key: number;
  96260. repeatCount: number;
  96261. workValue?: any;
  96262. loopMode?: number;
  96263. offsetValue?: any;
  96264. highLimitValue?: any;
  96265. }
  96266. /**
  96267. * Class used to store any kind of animation
  96268. */
  96269. export class Animation {
  96270. /**Name of the animation */
  96271. name: string;
  96272. /**Property to animate */
  96273. targetProperty: string;
  96274. /**The frames per second of the animation */
  96275. framePerSecond: number;
  96276. /**The data type of the animation */
  96277. dataType: number;
  96278. /**The loop mode of the animation */
  96279. loopMode?: number | undefined;
  96280. /**Specifies if blending should be enabled */
  96281. enableBlending?: boolean | undefined;
  96282. /**
  96283. * Use matrix interpolation instead of using direct key value when animating matrices
  96284. */
  96285. static AllowMatricesInterpolation: boolean;
  96286. /**
  96287. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  96288. */
  96289. static AllowMatrixDecomposeForInterpolation: boolean;
  96290. /**
  96291. * Stores the key frames of the animation
  96292. */
  96293. private _keys;
  96294. /**
  96295. * Stores the easing function of the animation
  96296. */
  96297. private _easingFunction;
  96298. /**
  96299. * @hidden Internal use only
  96300. */
  96301. _runtimeAnimations: RuntimeAnimation[];
  96302. /**
  96303. * The set of event that will be linked to this animation
  96304. */
  96305. private _events;
  96306. /**
  96307. * Stores an array of target property paths
  96308. */
  96309. targetPropertyPath: string[];
  96310. /**
  96311. * Stores the blending speed of the animation
  96312. */
  96313. blendingSpeed: number;
  96314. /**
  96315. * Stores the animation ranges for the animation
  96316. */
  96317. private _ranges;
  96318. /**
  96319. * @hidden Internal use
  96320. */
  96321. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  96322. /**
  96323. * Sets up an animation
  96324. * @param property The property to animate
  96325. * @param animationType The animation type to apply
  96326. * @param framePerSecond The frames per second of the animation
  96327. * @param easingFunction The easing function used in the animation
  96328. * @returns The created animation
  96329. */
  96330. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  96331. /**
  96332. * Create and start an animation on a node
  96333. * @param name defines the name of the global animation that will be run on all nodes
  96334. * @param node defines the root node where the animation will take place
  96335. * @param targetProperty defines property to animate
  96336. * @param framePerSecond defines the number of frame per second yo use
  96337. * @param totalFrame defines the number of frames in total
  96338. * @param from defines the initial value
  96339. * @param to defines the final value
  96340. * @param loopMode defines which loop mode you want to use (off by default)
  96341. * @param easingFunction defines the easing function to use (linear by default)
  96342. * @param onAnimationEnd defines the callback to call when animation end
  96343. * @returns the animatable created for this animation
  96344. */
  96345. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  96346. /**
  96347. * Create and start an animation on a node and its descendants
  96348. * @param name defines the name of the global animation that will be run on all nodes
  96349. * @param node defines the root node where the animation will take place
  96350. * @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
  96351. * @param targetProperty defines property to animate
  96352. * @param framePerSecond defines the number of frame per second to use
  96353. * @param totalFrame defines the number of frames in total
  96354. * @param from defines the initial value
  96355. * @param to defines the final value
  96356. * @param loopMode defines which loop mode you want to use (off by default)
  96357. * @param easingFunction defines the easing function to use (linear by default)
  96358. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96359. * @returns the list of animatables created for all nodes
  96360. * @example https://www.babylonjs-playground.com/#MH0VLI
  96361. */
  96362. 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[]>;
  96363. /**
  96364. * Creates a new animation, merges it with the existing animations and starts it
  96365. * @param name Name of the animation
  96366. * @param node Node which contains the scene that begins the animations
  96367. * @param targetProperty Specifies which property to animate
  96368. * @param framePerSecond The frames per second of the animation
  96369. * @param totalFrame The total number of frames
  96370. * @param from The frame at the beginning of the animation
  96371. * @param to The frame at the end of the animation
  96372. * @param loopMode Specifies the loop mode of the animation
  96373. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  96374. * @param onAnimationEnd Callback to run once the animation is complete
  96375. * @returns Nullable animation
  96376. */
  96377. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  96378. /**
  96379. * Transition property of an host to the target Value
  96380. * @param property The property to transition
  96381. * @param targetValue The target Value of the property
  96382. * @param host The object where the property to animate belongs
  96383. * @param scene Scene used to run the animation
  96384. * @param frameRate Framerate (in frame/s) to use
  96385. * @param transition The transition type we want to use
  96386. * @param duration The duration of the animation, in milliseconds
  96387. * @param onAnimationEnd Callback trigger at the end of the animation
  96388. * @returns Nullable animation
  96389. */
  96390. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  96391. /**
  96392. * Return the array of runtime animations currently using this animation
  96393. */
  96394. readonly runtimeAnimations: RuntimeAnimation[];
  96395. /**
  96396. * Specifies if any of the runtime animations are currently running
  96397. */
  96398. readonly hasRunningRuntimeAnimations: boolean;
  96399. /**
  96400. * Initializes the animation
  96401. * @param name Name of the animation
  96402. * @param targetProperty Property to animate
  96403. * @param framePerSecond The frames per second of the animation
  96404. * @param dataType The data type of the animation
  96405. * @param loopMode The loop mode of the animation
  96406. * @param enableBlending Specifies if blending should be enabled
  96407. */
  96408. constructor(
  96409. /**Name of the animation */
  96410. name: string,
  96411. /**Property to animate */
  96412. targetProperty: string,
  96413. /**The frames per second of the animation */
  96414. framePerSecond: number,
  96415. /**The data type of the animation */
  96416. dataType: number,
  96417. /**The loop mode of the animation */
  96418. loopMode?: number | undefined,
  96419. /**Specifies if blending should be enabled */
  96420. enableBlending?: boolean | undefined);
  96421. /**
  96422. * Converts the animation to a string
  96423. * @param fullDetails support for multiple levels of logging within scene loading
  96424. * @returns String form of the animation
  96425. */
  96426. toString(fullDetails?: boolean): string;
  96427. /**
  96428. * Add an event to this animation
  96429. * @param event Event to add
  96430. */
  96431. addEvent(event: AnimationEvent): void;
  96432. /**
  96433. * Remove all events found at the given frame
  96434. * @param frame The frame to remove events from
  96435. */
  96436. removeEvents(frame: number): void;
  96437. /**
  96438. * Retrieves all the events from the animation
  96439. * @returns Events from the animation
  96440. */
  96441. getEvents(): AnimationEvent[];
  96442. /**
  96443. * Creates an animation range
  96444. * @param name Name of the animation range
  96445. * @param from Starting frame of the animation range
  96446. * @param to Ending frame of the animation
  96447. */
  96448. createRange(name: string, from: number, to: number): void;
  96449. /**
  96450. * Deletes an animation range by name
  96451. * @param name Name of the animation range to delete
  96452. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  96453. */
  96454. deleteRange(name: string, deleteFrames?: boolean): void;
  96455. /**
  96456. * Gets the animation range by name, or null if not defined
  96457. * @param name Name of the animation range
  96458. * @returns Nullable animation range
  96459. */
  96460. getRange(name: string): Nullable<AnimationRange>;
  96461. /**
  96462. * Gets the key frames from the animation
  96463. * @returns The key frames of the animation
  96464. */
  96465. getKeys(): Array<IAnimationKey>;
  96466. /**
  96467. * Gets the highest frame rate of the animation
  96468. * @returns Highest frame rate of the animation
  96469. */
  96470. getHighestFrame(): number;
  96471. /**
  96472. * Gets the easing function of the animation
  96473. * @returns Easing function of the animation
  96474. */
  96475. getEasingFunction(): IEasingFunction;
  96476. /**
  96477. * Sets the easing function of the animation
  96478. * @param easingFunction A custom mathematical formula for animation
  96479. */
  96480. setEasingFunction(easingFunction: EasingFunction): void;
  96481. /**
  96482. * Interpolates a scalar linearly
  96483. * @param startValue Start value of the animation curve
  96484. * @param endValue End value of the animation curve
  96485. * @param gradient Scalar amount to interpolate
  96486. * @returns Interpolated scalar value
  96487. */
  96488. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  96489. /**
  96490. * Interpolates a scalar cubically
  96491. * @param startValue Start value of the animation curve
  96492. * @param outTangent End tangent of the animation
  96493. * @param endValue End value of the animation curve
  96494. * @param inTangent Start tangent of the animation curve
  96495. * @param gradient Scalar amount to interpolate
  96496. * @returns Interpolated scalar value
  96497. */
  96498. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  96499. /**
  96500. * Interpolates a quaternion using a spherical linear interpolation
  96501. * @param startValue Start value of the animation curve
  96502. * @param endValue End value of the animation curve
  96503. * @param gradient Scalar amount to interpolate
  96504. * @returns Interpolated quaternion value
  96505. */
  96506. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  96507. /**
  96508. * Interpolates a quaternion cubically
  96509. * @param startValue Start value of the animation curve
  96510. * @param outTangent End tangent of the animation curve
  96511. * @param endValue End value of the animation curve
  96512. * @param inTangent Start tangent of the animation curve
  96513. * @param gradient Scalar amount to interpolate
  96514. * @returns Interpolated quaternion value
  96515. */
  96516. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  96517. /**
  96518. * Interpolates a Vector3 linearl
  96519. * @param startValue Start value of the animation curve
  96520. * @param endValue End value of the animation curve
  96521. * @param gradient Scalar amount to interpolate
  96522. * @returns Interpolated scalar value
  96523. */
  96524. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  96525. /**
  96526. * Interpolates a Vector3 cubically
  96527. * @param startValue Start value of the animation curve
  96528. * @param outTangent End tangent of the animation
  96529. * @param endValue End value of the animation curve
  96530. * @param inTangent Start tangent of the animation curve
  96531. * @param gradient Scalar amount to interpolate
  96532. * @returns InterpolatedVector3 value
  96533. */
  96534. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  96535. /**
  96536. * Interpolates a Vector2 linearly
  96537. * @param startValue Start value of the animation curve
  96538. * @param endValue End value of the animation curve
  96539. * @param gradient Scalar amount to interpolate
  96540. * @returns Interpolated Vector2 value
  96541. */
  96542. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  96543. /**
  96544. * Interpolates a Vector2 cubically
  96545. * @param startValue Start value of the animation curve
  96546. * @param outTangent End tangent of the animation
  96547. * @param endValue End value of the animation curve
  96548. * @param inTangent Start tangent of the animation curve
  96549. * @param gradient Scalar amount to interpolate
  96550. * @returns Interpolated Vector2 value
  96551. */
  96552. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  96553. /**
  96554. * Interpolates a size linearly
  96555. * @param startValue Start value of the animation curve
  96556. * @param endValue End value of the animation curve
  96557. * @param gradient Scalar amount to interpolate
  96558. * @returns Interpolated Size value
  96559. */
  96560. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  96561. /**
  96562. * Interpolates a Color3 linearly
  96563. * @param startValue Start value of the animation curve
  96564. * @param endValue End value of the animation curve
  96565. * @param gradient Scalar amount to interpolate
  96566. * @returns Interpolated Color3 value
  96567. */
  96568. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  96569. /**
  96570. * Interpolates a Color4 linearly
  96571. * @param startValue Start value of the animation curve
  96572. * @param endValue End value of the animation curve
  96573. * @param gradient Scalar amount to interpolate
  96574. * @returns Interpolated Color3 value
  96575. */
  96576. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  96577. /**
  96578. * @hidden Internal use only
  96579. */
  96580. _getKeyValue(value: any): any;
  96581. /**
  96582. * @hidden Internal use only
  96583. */
  96584. _interpolate(currentFrame: number, state: _IAnimationState): any;
  96585. /**
  96586. * Defines the function to use to interpolate matrices
  96587. * @param startValue defines the start matrix
  96588. * @param endValue defines the end matrix
  96589. * @param gradient defines the gradient between both matrices
  96590. * @param result defines an optional target matrix where to store the interpolation
  96591. * @returns the interpolated matrix
  96592. */
  96593. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  96594. /**
  96595. * Makes a copy of the animation
  96596. * @returns Cloned animation
  96597. */
  96598. clone(): Animation;
  96599. /**
  96600. * Sets the key frames of the animation
  96601. * @param values The animation key frames to set
  96602. */
  96603. setKeys(values: Array<IAnimationKey>): void;
  96604. /**
  96605. * Serializes the animation to an object
  96606. * @returns Serialized object
  96607. */
  96608. serialize(): any;
  96609. /**
  96610. * Float animation type
  96611. */
  96612. static readonly ANIMATIONTYPE_FLOAT: number;
  96613. /**
  96614. * Vector3 animation type
  96615. */
  96616. static readonly ANIMATIONTYPE_VECTOR3: number;
  96617. /**
  96618. * Quaternion animation type
  96619. */
  96620. static readonly ANIMATIONTYPE_QUATERNION: number;
  96621. /**
  96622. * Matrix animation type
  96623. */
  96624. static readonly ANIMATIONTYPE_MATRIX: number;
  96625. /**
  96626. * Color3 animation type
  96627. */
  96628. static readonly ANIMATIONTYPE_COLOR3: number;
  96629. /**
  96630. * Color3 animation type
  96631. */
  96632. static readonly ANIMATIONTYPE_COLOR4: number;
  96633. /**
  96634. * Vector2 animation type
  96635. */
  96636. static readonly ANIMATIONTYPE_VECTOR2: number;
  96637. /**
  96638. * Size animation type
  96639. */
  96640. static readonly ANIMATIONTYPE_SIZE: number;
  96641. /**
  96642. * Relative Loop Mode
  96643. */
  96644. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  96645. /**
  96646. * Cycle Loop Mode
  96647. */
  96648. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  96649. /**
  96650. * Constant Loop Mode
  96651. */
  96652. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  96653. /** @hidden */
  96654. static _UniversalLerp(left: any, right: any, amount: number): any;
  96655. /**
  96656. * Parses an animation object and creates an animation
  96657. * @param parsedAnimation Parsed animation object
  96658. * @returns Animation object
  96659. */
  96660. static Parse(parsedAnimation: any): Animation;
  96661. /**
  96662. * Appends the serialized animations from the source animations
  96663. * @param source Source containing the animations
  96664. * @param destination Target to store the animations
  96665. */
  96666. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96667. }
  96668. }
  96669. declare module BABYLON {
  96670. /**
  96671. * Interface containing an array of animations
  96672. */
  96673. export interface IAnimatable {
  96674. /**
  96675. * Array of animations
  96676. */
  96677. animations: Nullable<Array<Animation>>;
  96678. }
  96679. }
  96680. declare module BABYLON {
  96681. /**
  96682. * This represents all the required information to add a fresnel effect on a material:
  96683. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96684. */
  96685. export class FresnelParameters {
  96686. private _isEnabled;
  96687. /**
  96688. * Define if the fresnel effect is enable or not.
  96689. */
  96690. isEnabled: boolean;
  96691. /**
  96692. * Define the color used on edges (grazing angle)
  96693. */
  96694. leftColor: Color3;
  96695. /**
  96696. * Define the color used on center
  96697. */
  96698. rightColor: Color3;
  96699. /**
  96700. * Define bias applied to computed fresnel term
  96701. */
  96702. bias: number;
  96703. /**
  96704. * Defined the power exponent applied to fresnel term
  96705. */
  96706. power: number;
  96707. /**
  96708. * Clones the current fresnel and its valuues
  96709. * @returns a clone fresnel configuration
  96710. */
  96711. clone(): FresnelParameters;
  96712. /**
  96713. * Serializes the current fresnel parameters to a JSON representation.
  96714. * @return the JSON serialization
  96715. */
  96716. serialize(): any;
  96717. /**
  96718. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96719. * @param parsedFresnelParameters Define the JSON representation
  96720. * @returns the parsed parameters
  96721. */
  96722. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96723. }
  96724. }
  96725. declare module BABYLON {
  96726. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  96727. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96728. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96729. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96730. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96731. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96732. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96733. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96734. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96735. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96736. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96737. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96738. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96739. /**
  96740. * Decorator used to define property that can be serialized as reference to a camera
  96741. * @param sourceName defines the name of the property to decorate
  96742. */
  96743. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96744. /**
  96745. * Class used to help serialization objects
  96746. */
  96747. export class SerializationHelper {
  96748. /** @hidden */
  96749. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  96750. /** @hidden */
  96751. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  96752. /** @hidden */
  96753. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  96754. /** @hidden */
  96755. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  96756. /**
  96757. * Appends the serialized animations from the source animations
  96758. * @param source Source containing the animations
  96759. * @param destination Target to store the animations
  96760. */
  96761. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96762. /**
  96763. * Static function used to serialized a specific entity
  96764. * @param entity defines the entity to serialize
  96765. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  96766. * @returns a JSON compatible object representing the serialization of the entity
  96767. */
  96768. static Serialize<T>(entity: T, serializationObject?: any): any;
  96769. /**
  96770. * Creates a new entity from a serialization data object
  96771. * @param creationFunction defines a function used to instanciated the new entity
  96772. * @param source defines the source serialization data
  96773. * @param scene defines the hosting scene
  96774. * @param rootUrl defines the root url for resources
  96775. * @returns a new entity
  96776. */
  96777. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  96778. /**
  96779. * Clones an object
  96780. * @param creationFunction defines the function used to instanciate the new object
  96781. * @param source defines the source object
  96782. * @returns the cloned object
  96783. */
  96784. static Clone<T>(creationFunction: () => T, source: T): T;
  96785. /**
  96786. * Instanciates a new object based on a source one (some data will be shared between both object)
  96787. * @param creationFunction defines the function used to instanciate the new object
  96788. * @param source defines the source object
  96789. * @returns the new object
  96790. */
  96791. static Instanciate<T>(creationFunction: () => T, source: T): T;
  96792. }
  96793. }
  96794. declare module BABYLON {
  96795. /**
  96796. * Class used to manipulate GUIDs
  96797. */
  96798. export class GUID {
  96799. /**
  96800. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96801. * Be aware Math.random() could cause collisions, but:
  96802. * "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"
  96803. * @returns a pseudo random id
  96804. */
  96805. static RandomId(): string;
  96806. }
  96807. }
  96808. declare module BABYLON {
  96809. /**
  96810. * Base class of all the textures in babylon.
  96811. * It groups all the common properties the materials, post process, lights... might need
  96812. * in order to make a correct use of the texture.
  96813. */
  96814. export class BaseTexture implements IAnimatable {
  96815. /**
  96816. * Default anisotropic filtering level for the application.
  96817. * It is set to 4 as a good tradeoff between perf and quality.
  96818. */
  96819. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96820. /**
  96821. * Gets or sets the unique id of the texture
  96822. */
  96823. uniqueId: number;
  96824. /**
  96825. * Define the name of the texture.
  96826. */
  96827. name: string;
  96828. /**
  96829. * Gets or sets an object used to store user defined information.
  96830. */
  96831. metadata: any;
  96832. /**
  96833. * For internal use only. Please do not use.
  96834. */
  96835. reservedDataStore: any;
  96836. private _hasAlpha;
  96837. /**
  96838. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96839. */
  96840. hasAlpha: boolean;
  96841. /**
  96842. * Defines if the alpha value should be determined via the rgb values.
  96843. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96844. */
  96845. getAlphaFromRGB: boolean;
  96846. /**
  96847. * Intensity or strength of the texture.
  96848. * It is commonly used by materials to fine tune the intensity of the texture
  96849. */
  96850. level: number;
  96851. /**
  96852. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96853. * This is part of the texture as textures usually maps to one uv set.
  96854. */
  96855. coordinatesIndex: number;
  96856. private _coordinatesMode;
  96857. /**
  96858. * How a texture is mapped.
  96859. *
  96860. * | Value | Type | Description |
  96861. * | ----- | ----------------------------------- | ----------- |
  96862. * | 0 | EXPLICIT_MODE | |
  96863. * | 1 | SPHERICAL_MODE | |
  96864. * | 2 | PLANAR_MODE | |
  96865. * | 3 | CUBIC_MODE | |
  96866. * | 4 | PROJECTION_MODE | |
  96867. * | 5 | SKYBOX_MODE | |
  96868. * | 6 | INVCUBIC_MODE | |
  96869. * | 7 | EQUIRECTANGULAR_MODE | |
  96870. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96871. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96872. */
  96873. coordinatesMode: number;
  96874. /**
  96875. * | Value | Type | Description |
  96876. * | ----- | ------------------ | ----------- |
  96877. * | 0 | CLAMP_ADDRESSMODE | |
  96878. * | 1 | WRAP_ADDRESSMODE | |
  96879. * | 2 | MIRROR_ADDRESSMODE | |
  96880. */
  96881. wrapU: number;
  96882. /**
  96883. * | Value | Type | Description |
  96884. * | ----- | ------------------ | ----------- |
  96885. * | 0 | CLAMP_ADDRESSMODE | |
  96886. * | 1 | WRAP_ADDRESSMODE | |
  96887. * | 2 | MIRROR_ADDRESSMODE | |
  96888. */
  96889. wrapV: number;
  96890. /**
  96891. * | Value | Type | Description |
  96892. * | ----- | ------------------ | ----------- |
  96893. * | 0 | CLAMP_ADDRESSMODE | |
  96894. * | 1 | WRAP_ADDRESSMODE | |
  96895. * | 2 | MIRROR_ADDRESSMODE | |
  96896. */
  96897. wrapR: number;
  96898. /**
  96899. * With compliant hardware and browser (supporting anisotropic filtering)
  96900. * this defines the level of anisotropic filtering in the texture.
  96901. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96902. */
  96903. anisotropicFilteringLevel: number;
  96904. /**
  96905. * Define if the texture is a cube texture or if false a 2d texture.
  96906. */
  96907. isCube: boolean;
  96908. /**
  96909. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96910. */
  96911. is3D: boolean;
  96912. /**
  96913. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96914. */
  96915. is2DArray: boolean;
  96916. /**
  96917. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96918. * HDR texture are usually stored in linear space.
  96919. * This only impacts the PBR and Background materials
  96920. */
  96921. gammaSpace: boolean;
  96922. /**
  96923. * Gets or sets whether or not the texture contains RGBD data.
  96924. */
  96925. isRGBD: boolean;
  96926. /**
  96927. * Is Z inverted in the texture (useful in a cube texture).
  96928. */
  96929. invertZ: boolean;
  96930. /**
  96931. * Are mip maps generated for this texture or not.
  96932. */
  96933. readonly noMipmap: boolean;
  96934. /**
  96935. * @hidden
  96936. */
  96937. lodLevelInAlpha: boolean;
  96938. /**
  96939. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96940. */
  96941. lodGenerationOffset: number;
  96942. /**
  96943. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96944. */
  96945. lodGenerationScale: number;
  96946. /**
  96947. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96948. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96949. * average roughness values.
  96950. */
  96951. linearSpecularLOD: boolean;
  96952. /**
  96953. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96954. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96955. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96956. */
  96957. irradianceTexture: Nullable<BaseTexture>;
  96958. /**
  96959. * Define if the texture is a render target.
  96960. */
  96961. isRenderTarget: boolean;
  96962. /**
  96963. * Define the unique id of the texture in the scene.
  96964. */
  96965. readonly uid: string;
  96966. /**
  96967. * Return a string representation of the texture.
  96968. * @returns the texture as a string
  96969. */
  96970. toString(): string;
  96971. /**
  96972. * Get the class name of the texture.
  96973. * @returns "BaseTexture"
  96974. */
  96975. getClassName(): string;
  96976. /**
  96977. * Define the list of animation attached to the texture.
  96978. */
  96979. animations: Animation[];
  96980. /**
  96981. * An event triggered when the texture is disposed.
  96982. */
  96983. onDisposeObservable: Observable<BaseTexture>;
  96984. private _onDisposeObserver;
  96985. /**
  96986. * Callback triggered when the texture has been disposed.
  96987. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96988. */
  96989. onDispose: () => void;
  96990. /**
  96991. * Define the current state of the loading sequence when in delayed load mode.
  96992. */
  96993. delayLoadState: number;
  96994. private _scene;
  96995. /** @hidden */
  96996. _texture: Nullable<InternalTexture>;
  96997. private _uid;
  96998. /**
  96999. * Define if the texture is preventinga material to render or not.
  97000. * If not and the texture is not ready, the engine will use a default black texture instead.
  97001. */
  97002. readonly isBlocking: boolean;
  97003. /**
  97004. * Instantiates a new BaseTexture.
  97005. * Base class of all the textures in babylon.
  97006. * It groups all the common properties the materials, post process, lights... might need
  97007. * in order to make a correct use of the texture.
  97008. * @param scene Define the scene the texture blongs to
  97009. */
  97010. constructor(scene: Nullable<Scene>);
  97011. /**
  97012. * Get the scene the texture belongs to.
  97013. * @returns the scene or null if undefined
  97014. */
  97015. getScene(): Nullable<Scene>;
  97016. /**
  97017. * Get the texture transform matrix used to offset tile the texture for istance.
  97018. * @returns the transformation matrix
  97019. */
  97020. getTextureMatrix(): Matrix;
  97021. /**
  97022. * Get the texture reflection matrix used to rotate/transform the reflection.
  97023. * @returns the reflection matrix
  97024. */
  97025. getReflectionTextureMatrix(): Matrix;
  97026. /**
  97027. * Get the underlying lower level texture from Babylon.
  97028. * @returns the insternal texture
  97029. */
  97030. getInternalTexture(): Nullable<InternalTexture>;
  97031. /**
  97032. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  97033. * @returns true if ready or not blocking
  97034. */
  97035. isReadyOrNotBlocking(): boolean;
  97036. /**
  97037. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  97038. * @returns true if fully ready
  97039. */
  97040. isReady(): boolean;
  97041. private _cachedSize;
  97042. /**
  97043. * Get the size of the texture.
  97044. * @returns the texture size.
  97045. */
  97046. getSize(): ISize;
  97047. /**
  97048. * Get the base size of the texture.
  97049. * It can be different from the size if the texture has been resized for POT for instance
  97050. * @returns the base size
  97051. */
  97052. getBaseSize(): ISize;
  97053. /**
  97054. * Update the sampling mode of the texture.
  97055. * Default is Trilinear mode.
  97056. *
  97057. * | Value | Type | Description |
  97058. * | ----- | ------------------ | ----------- |
  97059. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  97060. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  97061. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  97062. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  97063. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  97064. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  97065. * | 7 | NEAREST_LINEAR | |
  97066. * | 8 | NEAREST_NEAREST | |
  97067. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  97068. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  97069. * | 11 | LINEAR_LINEAR | |
  97070. * | 12 | LINEAR_NEAREST | |
  97071. *
  97072. * > _mag_: magnification filter (close to the viewer)
  97073. * > _min_: minification filter (far from the viewer)
  97074. * > _mip_: filter used between mip map levels
  97075. *@param samplingMode Define the new sampling mode of the texture
  97076. */
  97077. updateSamplingMode(samplingMode: number): void;
  97078. /**
  97079. * Scales the texture if is `canRescale()`
  97080. * @param ratio the resize factor we want to use to rescale
  97081. */
  97082. scale(ratio: number): void;
  97083. /**
  97084. * Get if the texture can rescale.
  97085. */
  97086. readonly canRescale: boolean;
  97087. /** @hidden */
  97088. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  97089. /** @hidden */
  97090. _rebuild(): void;
  97091. /**
  97092. * Triggers the load sequence in delayed load mode.
  97093. */
  97094. delayLoad(): void;
  97095. /**
  97096. * Clones the texture.
  97097. * @returns the cloned texture
  97098. */
  97099. clone(): Nullable<BaseTexture>;
  97100. /**
  97101. * Get the texture underlying type (INT, FLOAT...)
  97102. */
  97103. readonly textureType: number;
  97104. /**
  97105. * Get the texture underlying format (RGB, RGBA...)
  97106. */
  97107. readonly textureFormat: number;
  97108. /**
  97109. * Indicates that textures need to be re-calculated for all materials
  97110. */
  97111. protected _markAllSubMeshesAsTexturesDirty(): void;
  97112. /**
  97113. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  97114. * This will returns an RGBA array buffer containing either in values (0-255) or
  97115. * float values (0-1) depending of the underlying buffer type.
  97116. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  97117. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  97118. * @param buffer defines a user defined buffer to fill with data (can be null)
  97119. * @returns The Array buffer containing the pixels data.
  97120. */
  97121. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  97122. /**
  97123. * Release and destroy the underlying lower level texture aka internalTexture.
  97124. */
  97125. releaseInternalTexture(): void;
  97126. /** @hidden */
  97127. readonly _lodTextureHigh: Nullable<BaseTexture>;
  97128. /** @hidden */
  97129. readonly _lodTextureMid: Nullable<BaseTexture>;
  97130. /** @hidden */
  97131. readonly _lodTextureLow: Nullable<BaseTexture>;
  97132. /**
  97133. * Dispose the texture and release its associated resources.
  97134. */
  97135. dispose(): void;
  97136. /**
  97137. * Serialize the texture into a JSON representation that can be parsed later on.
  97138. * @returns the JSON representation of the texture
  97139. */
  97140. serialize(): any;
  97141. /**
  97142. * Helper function to be called back once a list of texture contains only ready textures.
  97143. * @param textures Define the list of textures to wait for
  97144. * @param callback Define the callback triggered once the entire list will be ready
  97145. */
  97146. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  97147. }
  97148. }
  97149. declare module BABYLON {
  97150. /**
  97151. * Options to be used when creating an effect.
  97152. */
  97153. export interface IEffectCreationOptions {
  97154. /**
  97155. * Atrributes that will be used in the shader.
  97156. */
  97157. attributes: string[];
  97158. /**
  97159. * Uniform varible names that will be set in the shader.
  97160. */
  97161. uniformsNames: string[];
  97162. /**
  97163. * Uniform buffer variable names that will be set in the shader.
  97164. */
  97165. uniformBuffersNames: string[];
  97166. /**
  97167. * Sampler texture variable names that will be set in the shader.
  97168. */
  97169. samplers: string[];
  97170. /**
  97171. * Define statements that will be set in the shader.
  97172. */
  97173. defines: any;
  97174. /**
  97175. * Possible fallbacks for this effect to improve performance when needed.
  97176. */
  97177. fallbacks: Nullable<IEffectFallbacks>;
  97178. /**
  97179. * Callback that will be called when the shader is compiled.
  97180. */
  97181. onCompiled: Nullable<(effect: Effect) => void>;
  97182. /**
  97183. * Callback that will be called if an error occurs during shader compilation.
  97184. */
  97185. onError: Nullable<(effect: Effect, errors: string) => void>;
  97186. /**
  97187. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  97188. */
  97189. indexParameters?: any;
  97190. /**
  97191. * Max number of lights that can be used in the shader.
  97192. */
  97193. maxSimultaneousLights?: number;
  97194. /**
  97195. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  97196. */
  97197. transformFeedbackVaryings?: Nullable<string[]>;
  97198. }
  97199. /**
  97200. * Effect containing vertex and fragment shader that can be executed on an object.
  97201. */
  97202. export class Effect implements IDisposable {
  97203. /**
  97204. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97205. */
  97206. static ShadersRepository: string;
  97207. /**
  97208. * Name of the effect.
  97209. */
  97210. name: any;
  97211. /**
  97212. * String container all the define statements that should be set on the shader.
  97213. */
  97214. defines: string;
  97215. /**
  97216. * Callback that will be called when the shader is compiled.
  97217. */
  97218. onCompiled: Nullable<(effect: Effect) => void>;
  97219. /**
  97220. * Callback that will be called if an error occurs during shader compilation.
  97221. */
  97222. onError: Nullable<(effect: Effect, errors: string) => void>;
  97223. /**
  97224. * Callback that will be called when effect is bound.
  97225. */
  97226. onBind: Nullable<(effect: Effect) => void>;
  97227. /**
  97228. * Unique ID of the effect.
  97229. */
  97230. uniqueId: number;
  97231. /**
  97232. * Observable that will be called when the shader is compiled.
  97233. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  97234. */
  97235. onCompileObservable: Observable<Effect>;
  97236. /**
  97237. * Observable that will be called if an error occurs during shader compilation.
  97238. */
  97239. onErrorObservable: Observable<Effect>;
  97240. /** @hidden */
  97241. _onBindObservable: Nullable<Observable<Effect>>;
  97242. /**
  97243. * Observable that will be called when effect is bound.
  97244. */
  97245. readonly onBindObservable: Observable<Effect>;
  97246. /** @hidden */
  97247. _bonesComputationForcedToCPU: boolean;
  97248. private static _uniqueIdSeed;
  97249. private _engine;
  97250. private _uniformBuffersNames;
  97251. private _uniformsNames;
  97252. private _samplerList;
  97253. private _samplers;
  97254. private _isReady;
  97255. private _compilationError;
  97256. private _allFallbacksProcessed;
  97257. private _attributesNames;
  97258. private _attributes;
  97259. private _uniforms;
  97260. /**
  97261. * Key for the effect.
  97262. * @hidden
  97263. */
  97264. _key: string;
  97265. private _indexParameters;
  97266. private _fallbacks;
  97267. private _vertexSourceCode;
  97268. private _fragmentSourceCode;
  97269. private _vertexSourceCodeOverride;
  97270. private _fragmentSourceCodeOverride;
  97271. private _transformFeedbackVaryings;
  97272. /**
  97273. * Compiled shader to webGL program.
  97274. * @hidden
  97275. */
  97276. _pipelineContext: Nullable<IPipelineContext>;
  97277. private _valueCache;
  97278. private static _baseCache;
  97279. /**
  97280. * Instantiates an effect.
  97281. * An effect can be used to create/manage/execute vertex and fragment shaders.
  97282. * @param baseName Name of the effect.
  97283. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  97284. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  97285. * @param samplers List of sampler variables that will be passed to the shader.
  97286. * @param engine Engine to be used to render the effect
  97287. * @param defines Define statements to be added to the shader.
  97288. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  97289. * @param onCompiled Callback that will be called when the shader is compiled.
  97290. * @param onError Callback that will be called if an error occurs during shader compilation.
  97291. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  97292. */
  97293. 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);
  97294. private _useFinalCode;
  97295. /**
  97296. * Unique key for this effect
  97297. */
  97298. readonly key: string;
  97299. /**
  97300. * If the effect has been compiled and prepared.
  97301. * @returns if the effect is compiled and prepared.
  97302. */
  97303. isReady(): boolean;
  97304. private _isReadyInternal;
  97305. /**
  97306. * The engine the effect was initialized with.
  97307. * @returns the engine.
  97308. */
  97309. getEngine(): Engine;
  97310. /**
  97311. * The pipeline context for this effect
  97312. * @returns the associated pipeline context
  97313. */
  97314. getPipelineContext(): Nullable<IPipelineContext>;
  97315. /**
  97316. * The set of names of attribute variables for the shader.
  97317. * @returns An array of attribute names.
  97318. */
  97319. getAttributesNames(): string[];
  97320. /**
  97321. * Returns the attribute at the given index.
  97322. * @param index The index of the attribute.
  97323. * @returns The location of the attribute.
  97324. */
  97325. getAttributeLocation(index: number): number;
  97326. /**
  97327. * Returns the attribute based on the name of the variable.
  97328. * @param name of the attribute to look up.
  97329. * @returns the attribute location.
  97330. */
  97331. getAttributeLocationByName(name: string): number;
  97332. /**
  97333. * The number of attributes.
  97334. * @returns the numnber of attributes.
  97335. */
  97336. getAttributesCount(): number;
  97337. /**
  97338. * Gets the index of a uniform variable.
  97339. * @param uniformName of the uniform to look up.
  97340. * @returns the index.
  97341. */
  97342. getUniformIndex(uniformName: string): number;
  97343. /**
  97344. * Returns the attribute based on the name of the variable.
  97345. * @param uniformName of the uniform to look up.
  97346. * @returns the location of the uniform.
  97347. */
  97348. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  97349. /**
  97350. * Returns an array of sampler variable names
  97351. * @returns The array of sampler variable neames.
  97352. */
  97353. getSamplers(): string[];
  97354. /**
  97355. * The error from the last compilation.
  97356. * @returns the error string.
  97357. */
  97358. getCompilationError(): string;
  97359. /**
  97360. * Gets a boolean indicating that all fallbacks were used during compilation
  97361. * @returns true if all fallbacks were used
  97362. */
  97363. allFallbacksProcessed(): boolean;
  97364. /**
  97365. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  97366. * @param func The callback to be used.
  97367. */
  97368. executeWhenCompiled(func: (effect: Effect) => void): void;
  97369. private _checkIsReady;
  97370. private _loadShader;
  97371. /**
  97372. * Recompiles the webGL program
  97373. * @param vertexSourceCode The source code for the vertex shader.
  97374. * @param fragmentSourceCode The source code for the fragment shader.
  97375. * @param onCompiled Callback called when completed.
  97376. * @param onError Callback called on error.
  97377. * @hidden
  97378. */
  97379. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  97380. /**
  97381. * Prepares the effect
  97382. * @hidden
  97383. */
  97384. _prepareEffect(): void;
  97385. private _processCompilationErrors;
  97386. /**
  97387. * Checks if the effect is supported. (Must be called after compilation)
  97388. */
  97389. readonly isSupported: boolean;
  97390. /**
  97391. * Binds a texture to the engine to be used as output of the shader.
  97392. * @param channel Name of the output variable.
  97393. * @param texture Texture to bind.
  97394. * @hidden
  97395. */
  97396. _bindTexture(channel: string, texture: InternalTexture): void;
  97397. /**
  97398. * Sets a texture on the engine to be used in the shader.
  97399. * @param channel Name of the sampler variable.
  97400. * @param texture Texture to set.
  97401. */
  97402. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  97403. /**
  97404. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  97405. * @param channel Name of the sampler variable.
  97406. * @param texture Texture to set.
  97407. */
  97408. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  97409. /**
  97410. * Sets an array of textures on the engine to be used in the shader.
  97411. * @param channel Name of the variable.
  97412. * @param textures Textures to set.
  97413. */
  97414. setTextureArray(channel: string, textures: BaseTexture[]): void;
  97415. /**
  97416. * 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)
  97417. * @param channel Name of the sampler variable.
  97418. * @param postProcess Post process to get the input texture from.
  97419. */
  97420. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  97421. /**
  97422. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  97423. * 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)
  97424. * @param channel Name of the sampler variable.
  97425. * @param postProcess Post process to get the output texture from.
  97426. */
  97427. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  97428. /** @hidden */
  97429. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  97430. /** @hidden */
  97431. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  97432. /** @hidden */
  97433. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  97434. /** @hidden */
  97435. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  97436. /**
  97437. * Binds a buffer to a uniform.
  97438. * @param buffer Buffer to bind.
  97439. * @param name Name of the uniform variable to bind to.
  97440. */
  97441. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  97442. /**
  97443. * Binds block to a uniform.
  97444. * @param blockName Name of the block to bind.
  97445. * @param index Index to bind.
  97446. */
  97447. bindUniformBlock(blockName: string, index: number): void;
  97448. /**
  97449. * Sets an interger value on a uniform variable.
  97450. * @param uniformName Name of the variable.
  97451. * @param value Value to be set.
  97452. * @returns this effect.
  97453. */
  97454. setInt(uniformName: string, value: number): Effect;
  97455. /**
  97456. * Sets an int array on a uniform variable.
  97457. * @param uniformName Name of the variable.
  97458. * @param array array to be set.
  97459. * @returns this effect.
  97460. */
  97461. setIntArray(uniformName: string, array: Int32Array): Effect;
  97462. /**
  97463. * 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)
  97464. * @param uniformName Name of the variable.
  97465. * @param array array to be set.
  97466. * @returns this effect.
  97467. */
  97468. setIntArray2(uniformName: string, array: Int32Array): Effect;
  97469. /**
  97470. * 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)
  97471. * @param uniformName Name of the variable.
  97472. * @param array array to be set.
  97473. * @returns this effect.
  97474. */
  97475. setIntArray3(uniformName: string, array: Int32Array): Effect;
  97476. /**
  97477. * 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)
  97478. * @param uniformName Name of the variable.
  97479. * @param array array to be set.
  97480. * @returns this effect.
  97481. */
  97482. setIntArray4(uniformName: string, array: Int32Array): Effect;
  97483. /**
  97484. * Sets an float array on a uniform variable.
  97485. * @param uniformName Name of the variable.
  97486. * @param array array to be set.
  97487. * @returns this effect.
  97488. */
  97489. setFloatArray(uniformName: string, array: Float32Array): Effect;
  97490. /**
  97491. * 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)
  97492. * @param uniformName Name of the variable.
  97493. * @param array array to be set.
  97494. * @returns this effect.
  97495. */
  97496. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  97497. /**
  97498. * 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)
  97499. * @param uniformName Name of the variable.
  97500. * @param array array to be set.
  97501. * @returns this effect.
  97502. */
  97503. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  97504. /**
  97505. * 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)
  97506. * @param uniformName Name of the variable.
  97507. * @param array array to be set.
  97508. * @returns this effect.
  97509. */
  97510. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  97511. /**
  97512. * Sets an array on a uniform variable.
  97513. * @param uniformName Name of the variable.
  97514. * @param array array to be set.
  97515. * @returns this effect.
  97516. */
  97517. setArray(uniformName: string, array: number[]): Effect;
  97518. /**
  97519. * 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)
  97520. * @param uniformName Name of the variable.
  97521. * @param array array to be set.
  97522. * @returns this effect.
  97523. */
  97524. setArray2(uniformName: string, array: number[]): Effect;
  97525. /**
  97526. * 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)
  97527. * @param uniformName Name of the variable.
  97528. * @param array array to be set.
  97529. * @returns this effect.
  97530. */
  97531. setArray3(uniformName: string, array: number[]): Effect;
  97532. /**
  97533. * 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)
  97534. * @param uniformName Name of the variable.
  97535. * @param array array to be set.
  97536. * @returns this effect.
  97537. */
  97538. setArray4(uniformName: string, array: number[]): Effect;
  97539. /**
  97540. * Sets matrices on a uniform variable.
  97541. * @param uniformName Name of the variable.
  97542. * @param matrices matrices to be set.
  97543. * @returns this effect.
  97544. */
  97545. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  97546. /**
  97547. * Sets matrix on a uniform variable.
  97548. * @param uniformName Name of the variable.
  97549. * @param matrix matrix to be set.
  97550. * @returns this effect.
  97551. */
  97552. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  97553. /**
  97554. * 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)
  97555. * @param uniformName Name of the variable.
  97556. * @param matrix matrix to be set.
  97557. * @returns this effect.
  97558. */
  97559. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  97560. /**
  97561. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  97562. * @param uniformName Name of the variable.
  97563. * @param matrix matrix to be set.
  97564. * @returns this effect.
  97565. */
  97566. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  97567. /**
  97568. * Sets a float on a uniform variable.
  97569. * @param uniformName Name of the variable.
  97570. * @param value value to be set.
  97571. * @returns this effect.
  97572. */
  97573. setFloat(uniformName: string, value: number): Effect;
  97574. /**
  97575. * Sets a boolean on a uniform variable.
  97576. * @param uniformName Name of the variable.
  97577. * @param bool value to be set.
  97578. * @returns this effect.
  97579. */
  97580. setBool(uniformName: string, bool: boolean): Effect;
  97581. /**
  97582. * Sets a Vector2 on a uniform variable.
  97583. * @param uniformName Name of the variable.
  97584. * @param vector2 vector2 to be set.
  97585. * @returns this effect.
  97586. */
  97587. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  97588. /**
  97589. * Sets a float2 on a uniform variable.
  97590. * @param uniformName Name of the variable.
  97591. * @param x First float in float2.
  97592. * @param y Second float in float2.
  97593. * @returns this effect.
  97594. */
  97595. setFloat2(uniformName: string, x: number, y: number): Effect;
  97596. /**
  97597. * Sets a Vector3 on a uniform variable.
  97598. * @param uniformName Name of the variable.
  97599. * @param vector3 Value to be set.
  97600. * @returns this effect.
  97601. */
  97602. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  97603. /**
  97604. * Sets a float3 on a uniform variable.
  97605. * @param uniformName Name of the variable.
  97606. * @param x First float in float3.
  97607. * @param y Second float in float3.
  97608. * @param z Third float in float3.
  97609. * @returns this effect.
  97610. */
  97611. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  97612. /**
  97613. * Sets a Vector4 on a uniform variable.
  97614. * @param uniformName Name of the variable.
  97615. * @param vector4 Value to be set.
  97616. * @returns this effect.
  97617. */
  97618. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  97619. /**
  97620. * Sets a float4 on a uniform variable.
  97621. * @param uniformName Name of the variable.
  97622. * @param x First float in float4.
  97623. * @param y Second float in float4.
  97624. * @param z Third float in float4.
  97625. * @param w Fourth float in float4.
  97626. * @returns this effect.
  97627. */
  97628. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  97629. /**
  97630. * Sets a Color3 on a uniform variable.
  97631. * @param uniformName Name of the variable.
  97632. * @param color3 Value to be set.
  97633. * @returns this effect.
  97634. */
  97635. setColor3(uniformName: string, color3: IColor3Like): Effect;
  97636. /**
  97637. * Sets a Color4 on a uniform variable.
  97638. * @param uniformName Name of the variable.
  97639. * @param color3 Value to be set.
  97640. * @param alpha Alpha value to be set.
  97641. * @returns this effect.
  97642. */
  97643. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  97644. /**
  97645. * Sets a Color4 on a uniform variable
  97646. * @param uniformName defines the name of the variable
  97647. * @param color4 defines the value to be set
  97648. * @returns this effect.
  97649. */
  97650. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  97651. /** Release all associated resources */
  97652. dispose(): void;
  97653. /**
  97654. * This function will add a new shader to the shader store
  97655. * @param name the name of the shader
  97656. * @param pixelShader optional pixel shader content
  97657. * @param vertexShader optional vertex shader content
  97658. */
  97659. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  97660. /**
  97661. * Store of each shader (The can be looked up using effect.key)
  97662. */
  97663. static ShadersStore: {
  97664. [key: string]: string;
  97665. };
  97666. /**
  97667. * Store of each included file for a shader (The can be looked up using effect.key)
  97668. */
  97669. static IncludesShadersStore: {
  97670. [key: string]: string;
  97671. };
  97672. /**
  97673. * Resets the cache of effects.
  97674. */
  97675. static ResetCache(): void;
  97676. }
  97677. }
  97678. declare module BABYLON {
  97679. /**
  97680. * Interface used to describe the capabilities of the engine relatively to the current browser
  97681. */
  97682. export interface EngineCapabilities {
  97683. /** Maximum textures units per fragment shader */
  97684. maxTexturesImageUnits: number;
  97685. /** Maximum texture units per vertex shader */
  97686. maxVertexTextureImageUnits: number;
  97687. /** Maximum textures units in the entire pipeline */
  97688. maxCombinedTexturesImageUnits: number;
  97689. /** Maximum texture size */
  97690. maxTextureSize: number;
  97691. /** Maximum texture samples */
  97692. maxSamples?: number;
  97693. /** Maximum cube texture size */
  97694. maxCubemapTextureSize: number;
  97695. /** Maximum render texture size */
  97696. maxRenderTextureSize: number;
  97697. /** Maximum number of vertex attributes */
  97698. maxVertexAttribs: number;
  97699. /** Maximum number of varyings */
  97700. maxVaryingVectors: number;
  97701. /** Maximum number of uniforms per vertex shader */
  97702. maxVertexUniformVectors: number;
  97703. /** Maximum number of uniforms per fragment shader */
  97704. maxFragmentUniformVectors: number;
  97705. /** Defines if standard derivates (dx/dy) are supported */
  97706. standardDerivatives: boolean;
  97707. /** Defines if s3tc texture compression is supported */
  97708. s3tc?: WEBGL_compressed_texture_s3tc;
  97709. /** Defines if pvrtc texture compression is supported */
  97710. pvrtc: any;
  97711. /** Defines if etc1 texture compression is supported */
  97712. etc1: any;
  97713. /** Defines if etc2 texture compression is supported */
  97714. etc2: any;
  97715. /** Defines if astc texture compression is supported */
  97716. astc: any;
  97717. /** Defines if float textures are supported */
  97718. textureFloat: boolean;
  97719. /** Defines if vertex array objects are supported */
  97720. vertexArrayObject: boolean;
  97721. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  97722. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  97723. /** Gets the maximum level of anisotropy supported */
  97724. maxAnisotropy: number;
  97725. /** Defines if instancing is supported */
  97726. instancedArrays: boolean;
  97727. /** Defines if 32 bits indices are supported */
  97728. uintIndices: boolean;
  97729. /** Defines if high precision shaders are supported */
  97730. highPrecisionShaderSupported: boolean;
  97731. /** Defines if depth reading in the fragment shader is supported */
  97732. fragmentDepthSupported: boolean;
  97733. /** Defines if float texture linear filtering is supported*/
  97734. textureFloatLinearFiltering: boolean;
  97735. /** Defines if rendering to float textures is supported */
  97736. textureFloatRender: boolean;
  97737. /** Defines if half float textures are supported*/
  97738. textureHalfFloat: boolean;
  97739. /** Defines if half float texture linear filtering is supported*/
  97740. textureHalfFloatLinearFiltering: boolean;
  97741. /** Defines if rendering to half float textures is supported */
  97742. textureHalfFloatRender: boolean;
  97743. /** Defines if textureLOD shader command is supported */
  97744. textureLOD: boolean;
  97745. /** Defines if draw buffers extension is supported */
  97746. drawBuffersExtension: boolean;
  97747. /** Defines if depth textures are supported */
  97748. depthTextureExtension: boolean;
  97749. /** Defines if float color buffer are supported */
  97750. colorBufferFloat: boolean;
  97751. /** Gets disjoint timer query extension (null if not supported) */
  97752. timerQuery?: EXT_disjoint_timer_query;
  97753. /** Defines if timestamp can be used with timer query */
  97754. canUseTimestampForTimerQuery: boolean;
  97755. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  97756. multiview?: any;
  97757. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  97758. oculusMultiview?: any;
  97759. /** Function used to let the system compiles shaders in background */
  97760. parallelShaderCompile?: {
  97761. COMPLETION_STATUS_KHR: number;
  97762. };
  97763. /** Max number of texture samples for MSAA */
  97764. maxMSAASamples: number;
  97765. /** Defines if the blend min max extension is supported */
  97766. blendMinMax: boolean;
  97767. }
  97768. }
  97769. declare module BABYLON {
  97770. /**
  97771. * @hidden
  97772. **/
  97773. export class DepthCullingState {
  97774. private _isDepthTestDirty;
  97775. private _isDepthMaskDirty;
  97776. private _isDepthFuncDirty;
  97777. private _isCullFaceDirty;
  97778. private _isCullDirty;
  97779. private _isZOffsetDirty;
  97780. private _isFrontFaceDirty;
  97781. private _depthTest;
  97782. private _depthMask;
  97783. private _depthFunc;
  97784. private _cull;
  97785. private _cullFace;
  97786. private _zOffset;
  97787. private _frontFace;
  97788. /**
  97789. * Initializes the state.
  97790. */
  97791. constructor();
  97792. readonly isDirty: boolean;
  97793. zOffset: number;
  97794. cullFace: Nullable<number>;
  97795. cull: Nullable<boolean>;
  97796. depthFunc: Nullable<number>;
  97797. depthMask: boolean;
  97798. depthTest: boolean;
  97799. frontFace: Nullable<number>;
  97800. reset(): void;
  97801. apply(gl: WebGLRenderingContext): void;
  97802. }
  97803. }
  97804. declare module BABYLON {
  97805. /**
  97806. * @hidden
  97807. **/
  97808. export class StencilState {
  97809. /** 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 */
  97810. static readonly ALWAYS: number;
  97811. /** Passed to stencilOperation to specify that stencil value must be kept */
  97812. static readonly KEEP: number;
  97813. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97814. static readonly REPLACE: number;
  97815. private _isStencilTestDirty;
  97816. private _isStencilMaskDirty;
  97817. private _isStencilFuncDirty;
  97818. private _isStencilOpDirty;
  97819. private _stencilTest;
  97820. private _stencilMask;
  97821. private _stencilFunc;
  97822. private _stencilFuncRef;
  97823. private _stencilFuncMask;
  97824. private _stencilOpStencilFail;
  97825. private _stencilOpDepthFail;
  97826. private _stencilOpStencilDepthPass;
  97827. readonly isDirty: boolean;
  97828. stencilFunc: number;
  97829. stencilFuncRef: number;
  97830. stencilFuncMask: number;
  97831. stencilOpStencilFail: number;
  97832. stencilOpDepthFail: number;
  97833. stencilOpStencilDepthPass: number;
  97834. stencilMask: number;
  97835. stencilTest: boolean;
  97836. constructor();
  97837. reset(): void;
  97838. apply(gl: WebGLRenderingContext): void;
  97839. }
  97840. }
  97841. declare module BABYLON {
  97842. /**
  97843. * @hidden
  97844. **/
  97845. export class AlphaState {
  97846. private _isAlphaBlendDirty;
  97847. private _isBlendFunctionParametersDirty;
  97848. private _isBlendEquationParametersDirty;
  97849. private _isBlendConstantsDirty;
  97850. private _alphaBlend;
  97851. private _blendFunctionParameters;
  97852. private _blendEquationParameters;
  97853. private _blendConstants;
  97854. /**
  97855. * Initializes the state.
  97856. */
  97857. constructor();
  97858. readonly isDirty: boolean;
  97859. alphaBlend: boolean;
  97860. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97861. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97862. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97863. reset(): void;
  97864. apply(gl: WebGLRenderingContext): void;
  97865. }
  97866. }
  97867. declare module BABYLON {
  97868. /** @hidden */
  97869. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97870. attributeProcessor(attribute: string): string;
  97871. varyingProcessor(varying: string, isFragment: boolean): string;
  97872. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97873. }
  97874. }
  97875. declare module BABYLON {
  97876. /**
  97877. * Interface for attribute information associated with buffer instanciation
  97878. */
  97879. export interface InstancingAttributeInfo {
  97880. /**
  97881. * Index/offset of the attribute in the vertex shader
  97882. */
  97883. index: number;
  97884. /**
  97885. * size of the attribute, 1, 2, 3 or 4
  97886. */
  97887. attributeSize: number;
  97888. /**
  97889. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97890. * default is FLOAT
  97891. */
  97892. attributeType: number;
  97893. /**
  97894. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97895. */
  97896. normalized: boolean;
  97897. /**
  97898. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97899. */
  97900. offset: number;
  97901. /**
  97902. * Name of the GLSL attribute, for debugging purpose only
  97903. */
  97904. attributeName: string;
  97905. }
  97906. }
  97907. declare module BABYLON {
  97908. interface ThinEngine {
  97909. /**
  97910. * Update a video texture
  97911. * @param texture defines the texture to update
  97912. * @param video defines the video element to use
  97913. * @param invertY defines if data must be stored with Y axis inverted
  97914. */
  97915. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97916. }
  97917. }
  97918. declare module BABYLON {
  97919. /**
  97920. * Settings for finer control over video usage
  97921. */
  97922. export interface VideoTextureSettings {
  97923. /**
  97924. * Applies `autoplay` to video, if specified
  97925. */
  97926. autoPlay?: boolean;
  97927. /**
  97928. * Applies `loop` to video, if specified
  97929. */
  97930. loop?: boolean;
  97931. /**
  97932. * Automatically updates internal texture from video at every frame in the render loop
  97933. */
  97934. autoUpdateTexture: boolean;
  97935. /**
  97936. * Image src displayed during the video loading or until the user interacts with the video.
  97937. */
  97938. poster?: string;
  97939. }
  97940. /**
  97941. * If you want to display a video in your scene, this is the special texture for that.
  97942. * This special texture works similar to other textures, with the exception of a few parameters.
  97943. * @see https://doc.babylonjs.com/how_to/video_texture
  97944. */
  97945. export class VideoTexture extends Texture {
  97946. /**
  97947. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97948. */
  97949. readonly autoUpdateTexture: boolean;
  97950. /**
  97951. * The video instance used by the texture internally
  97952. */
  97953. readonly video: HTMLVideoElement;
  97954. private _onUserActionRequestedObservable;
  97955. /**
  97956. * Event triggerd when a dom action is required by the user to play the video.
  97957. * This happens due to recent changes in browser policies preventing video to auto start.
  97958. */
  97959. readonly onUserActionRequestedObservable: Observable<Texture>;
  97960. private _generateMipMaps;
  97961. private _engine;
  97962. private _stillImageCaptured;
  97963. private _displayingPosterTexture;
  97964. private _settings;
  97965. private _createInternalTextureOnEvent;
  97966. private _frameId;
  97967. /**
  97968. * Creates a video texture.
  97969. * If you want to display a video in your scene, this is the special texture for that.
  97970. * This special texture works similar to other textures, with the exception of a few parameters.
  97971. * @see https://doc.babylonjs.com/how_to/video_texture
  97972. * @param name optional name, will detect from video source, if not defined
  97973. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97974. * @param scene is obviously the current scene.
  97975. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97976. * @param invertY is false by default but can be used to invert video on Y axis
  97977. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97978. * @param settings allows finer control over video usage
  97979. */
  97980. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97981. private _getName;
  97982. private _getVideo;
  97983. private _createInternalTexture;
  97984. private reset;
  97985. /**
  97986. * @hidden Internal method to initiate `update`.
  97987. */
  97988. _rebuild(): void;
  97989. /**
  97990. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97991. */
  97992. update(): void;
  97993. /**
  97994. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97995. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97996. */
  97997. updateTexture(isVisible: boolean): void;
  97998. protected _updateInternalTexture: () => void;
  97999. /**
  98000. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  98001. * @param url New url.
  98002. */
  98003. updateURL(url: string): void;
  98004. /**
  98005. * Dispose the texture and release its associated resources.
  98006. */
  98007. dispose(): void;
  98008. /**
  98009. * Creates a video texture straight from a stream.
  98010. * @param scene Define the scene the texture should be created in
  98011. * @param stream Define the stream the texture should be created from
  98012. * @returns The created video texture as a promise
  98013. */
  98014. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  98015. /**
  98016. * Creates a video texture straight from your WebCam video feed.
  98017. * @param scene Define the scene the texture should be created in
  98018. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  98019. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  98020. * @returns The created video texture as a promise
  98021. */
  98022. static CreateFromWebCamAsync(scene: Scene, constraints: {
  98023. minWidth: number;
  98024. maxWidth: number;
  98025. minHeight: number;
  98026. maxHeight: number;
  98027. deviceId: string;
  98028. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  98029. /**
  98030. * Creates a video texture straight from your WebCam video feed.
  98031. * @param scene Define the scene the texture should be created in
  98032. * @param onReady Define a callback to triggered once the texture will be ready
  98033. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  98034. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  98035. */
  98036. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  98037. minWidth: number;
  98038. maxWidth: number;
  98039. minHeight: number;
  98040. maxHeight: number;
  98041. deviceId: string;
  98042. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  98043. }
  98044. }
  98045. declare module BABYLON {
  98046. /**
  98047. * Defines the interface used by objects working like Scene
  98048. * @hidden
  98049. */
  98050. interface ISceneLike {
  98051. _addPendingData(data: any): void;
  98052. _removePendingData(data: any): void;
  98053. offlineProvider: IOfflineProvider;
  98054. }
  98055. /** Interface defining initialization parameters for Engine class */
  98056. export interface EngineOptions extends WebGLContextAttributes {
  98057. /**
  98058. * Defines if the engine should no exceed a specified device ratio
  98059. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  98060. */
  98061. limitDeviceRatio?: number;
  98062. /**
  98063. * Defines if webvr should be enabled automatically
  98064. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98065. */
  98066. autoEnableWebVR?: boolean;
  98067. /**
  98068. * Defines if webgl2 should be turned off even if supported
  98069. * @see http://doc.babylonjs.com/features/webgl2
  98070. */
  98071. disableWebGL2Support?: boolean;
  98072. /**
  98073. * Defines if webaudio should be initialized as well
  98074. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98075. */
  98076. audioEngine?: boolean;
  98077. /**
  98078. * Defines if animations should run using a deterministic lock step
  98079. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98080. */
  98081. deterministicLockstep?: boolean;
  98082. /** Defines the maximum steps to use with deterministic lock step mode */
  98083. lockstepMaxSteps?: number;
  98084. /** Defines the seconds between each deterministic lock step */
  98085. timeStep?: number;
  98086. /**
  98087. * Defines that engine should ignore context lost events
  98088. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  98089. */
  98090. doNotHandleContextLost?: boolean;
  98091. /**
  98092. * Defines that engine should ignore modifying touch action attribute and style
  98093. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  98094. */
  98095. doNotHandleTouchAction?: boolean;
  98096. /**
  98097. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  98098. */
  98099. useHighPrecisionFloats?: boolean;
  98100. }
  98101. /**
  98102. * The base engine class (root of all engines)
  98103. */
  98104. export class ThinEngine {
  98105. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  98106. static ExceptionList: ({
  98107. key: string;
  98108. capture: string;
  98109. captureConstraint: number;
  98110. targets: string[];
  98111. } | {
  98112. key: string;
  98113. capture: null;
  98114. captureConstraint: null;
  98115. targets: string[];
  98116. })[];
  98117. /** @hidden */
  98118. static _TextureLoaders: IInternalTextureLoader[];
  98119. /**
  98120. * Returns the current npm package of the sdk
  98121. */
  98122. static readonly NpmPackage: string;
  98123. /**
  98124. * Returns the current version of the framework
  98125. */
  98126. static readonly Version: string;
  98127. /**
  98128. * Returns a string describing the current engine
  98129. */
  98130. readonly description: string;
  98131. /**
  98132. * Gets or sets the epsilon value used by collision engine
  98133. */
  98134. static CollisionsEpsilon: number;
  98135. /**
  98136. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  98137. */
  98138. static ShadersRepository: string;
  98139. /** @hidden */
  98140. _shaderProcessor: IShaderProcessor;
  98141. /**
  98142. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  98143. */
  98144. forcePOTTextures: boolean;
  98145. /**
  98146. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  98147. */
  98148. isFullscreen: boolean;
  98149. /**
  98150. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  98151. */
  98152. cullBackFaces: boolean;
  98153. /**
  98154. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  98155. */
  98156. renderEvenInBackground: boolean;
  98157. /**
  98158. * Gets or sets a boolean indicating that cache can be kept between frames
  98159. */
  98160. preventCacheWipeBetweenFrames: boolean;
  98161. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  98162. validateShaderPrograms: boolean;
  98163. /**
  98164. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  98165. * This can provide greater z depth for distant objects.
  98166. */
  98167. useReverseDepthBuffer: boolean;
  98168. /**
  98169. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  98170. */
  98171. disableUniformBuffers: boolean;
  98172. /** @hidden */
  98173. _uniformBuffers: UniformBuffer[];
  98174. /**
  98175. * Gets a boolean indicating that the engine supports uniform buffers
  98176. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  98177. */
  98178. readonly supportsUniformBuffers: boolean;
  98179. /** @hidden */
  98180. _gl: WebGLRenderingContext;
  98181. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  98182. protected _windowIsBackground: boolean;
  98183. protected _webGLVersion: number;
  98184. protected _creationOptions: EngineOptions;
  98185. protected _highPrecisionShadersAllowed: boolean;
  98186. /** @hidden */
  98187. readonly _shouldUseHighPrecisionShader: boolean;
  98188. /**
  98189. * Gets a boolean indicating that only power of 2 textures are supported
  98190. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  98191. */
  98192. readonly needPOTTextures: boolean;
  98193. /** @hidden */
  98194. _badOS: boolean;
  98195. /** @hidden */
  98196. _badDesktopOS: boolean;
  98197. private _hardwareScalingLevel;
  98198. /** @hidden */
  98199. _caps: EngineCapabilities;
  98200. private _isStencilEnable;
  98201. protected _colorWrite: boolean;
  98202. private _glVersion;
  98203. private _glRenderer;
  98204. private _glVendor;
  98205. /** @hidden */
  98206. _videoTextureSupported: boolean;
  98207. protected _renderingQueueLaunched: boolean;
  98208. protected _activeRenderLoops: (() => void)[];
  98209. /**
  98210. * Observable signaled when a context lost event is raised
  98211. */
  98212. onContextLostObservable: Observable<ThinEngine>;
  98213. /**
  98214. * Observable signaled when a context restored event is raised
  98215. */
  98216. onContextRestoredObservable: Observable<ThinEngine>;
  98217. private _onContextLost;
  98218. private _onContextRestored;
  98219. protected _contextWasLost: boolean;
  98220. /** @hidden */
  98221. _doNotHandleContextLost: boolean;
  98222. /**
  98223. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  98224. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  98225. */
  98226. doNotHandleContextLost: boolean;
  98227. /**
  98228. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  98229. */
  98230. disableVertexArrayObjects: boolean;
  98231. /** @hidden */
  98232. protected _depthCullingState: DepthCullingState;
  98233. /** @hidden */
  98234. protected _stencilState: StencilState;
  98235. /** @hidden */
  98236. protected _alphaState: AlphaState;
  98237. /** @hidden */
  98238. _internalTexturesCache: InternalTexture[];
  98239. /** @hidden */
  98240. protected _activeChannel: number;
  98241. private _currentTextureChannel;
  98242. /** @hidden */
  98243. protected _boundTexturesCache: {
  98244. [key: string]: Nullable<InternalTexture>;
  98245. };
  98246. /** @hidden */
  98247. protected _currentEffect: Nullable<Effect>;
  98248. /** @hidden */
  98249. protected _currentProgram: Nullable<WebGLProgram>;
  98250. private _compiledEffects;
  98251. private _vertexAttribArraysEnabled;
  98252. /** @hidden */
  98253. protected _cachedViewport: Nullable<IViewportLike>;
  98254. private _cachedVertexArrayObject;
  98255. /** @hidden */
  98256. protected _cachedVertexBuffers: any;
  98257. /** @hidden */
  98258. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  98259. /** @hidden */
  98260. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  98261. /** @hidden */
  98262. _currentRenderTarget: Nullable<InternalTexture>;
  98263. private _uintIndicesCurrentlySet;
  98264. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  98265. /** @hidden */
  98266. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  98267. private _currentBufferPointers;
  98268. private _currentInstanceLocations;
  98269. private _currentInstanceBuffers;
  98270. private _textureUnits;
  98271. /** @hidden */
  98272. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98273. /** @hidden */
  98274. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98275. /** @hidden */
  98276. _boundRenderFunction: any;
  98277. private _vaoRecordInProgress;
  98278. private _mustWipeVertexAttributes;
  98279. private _emptyTexture;
  98280. private _emptyCubeTexture;
  98281. private _emptyTexture3D;
  98282. private _emptyTexture2DArray;
  98283. /** @hidden */
  98284. _frameHandler: number;
  98285. private _nextFreeTextureSlots;
  98286. private _maxSimultaneousTextures;
  98287. private _activeRequests;
  98288. protected _texturesSupported: string[];
  98289. /** @hidden */
  98290. _textureFormatInUse: Nullable<string>;
  98291. protected readonly _supportsHardwareTextureRescaling: boolean;
  98292. /**
  98293. * Gets the list of texture formats supported
  98294. */
  98295. readonly texturesSupported: Array<string>;
  98296. /**
  98297. * Gets the list of texture formats in use
  98298. */
  98299. readonly textureFormatInUse: Nullable<string>;
  98300. /**
  98301. * Gets the current viewport
  98302. */
  98303. readonly currentViewport: Nullable<IViewportLike>;
  98304. /**
  98305. * Gets the default empty texture
  98306. */
  98307. readonly emptyTexture: InternalTexture;
  98308. /**
  98309. * Gets the default empty 3D texture
  98310. */
  98311. readonly emptyTexture3D: InternalTexture;
  98312. /**
  98313. * Gets the default empty 2D array texture
  98314. */
  98315. readonly emptyTexture2DArray: InternalTexture;
  98316. /**
  98317. * Gets the default empty cube texture
  98318. */
  98319. readonly emptyCubeTexture: InternalTexture;
  98320. /**
  98321. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  98322. */
  98323. readonly premultipliedAlpha: boolean;
  98324. /**
  98325. * Observable event triggered before each texture is initialized
  98326. */
  98327. onBeforeTextureInitObservable: Observable<Texture>;
  98328. /**
  98329. * Creates a new engine
  98330. * @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
  98331. * @param antialias defines enable antialiasing (default: false)
  98332. * @param options defines further options to be sent to the getContext() function
  98333. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98334. */
  98335. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98336. private _rebuildInternalTextures;
  98337. private _rebuildEffects;
  98338. /**
  98339. * Gets a boolean indicating if all created effects are ready
  98340. * @returns true if all effects are ready
  98341. */
  98342. areAllEffectsReady(): boolean;
  98343. protected _rebuildBuffers(): void;
  98344. private _initGLContext;
  98345. /**
  98346. * Gets version of the current webGL context
  98347. */
  98348. readonly webGLVersion: number;
  98349. /**
  98350. * Gets a string idenfifying the name of the class
  98351. * @returns "Engine" string
  98352. */
  98353. getClassName(): string;
  98354. /**
  98355. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  98356. */
  98357. readonly isStencilEnable: boolean;
  98358. /** @hidden */
  98359. _prepareWorkingCanvas(): void;
  98360. /**
  98361. * Reset the texture cache to empty state
  98362. */
  98363. resetTextureCache(): void;
  98364. /**
  98365. * Gets an object containing information about the current webGL context
  98366. * @returns an object containing the vender, the renderer and the version of the current webGL context
  98367. */
  98368. getGlInfo(): {
  98369. vendor: string;
  98370. renderer: string;
  98371. version: string;
  98372. };
  98373. /**
  98374. * Defines the hardware scaling level.
  98375. * By default the hardware scaling level is computed from the window device ratio.
  98376. * 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.
  98377. * @param level defines the level to use
  98378. */
  98379. setHardwareScalingLevel(level: number): void;
  98380. /**
  98381. * Gets the current hardware scaling level.
  98382. * By default the hardware scaling level is computed from the window device ratio.
  98383. * 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.
  98384. * @returns a number indicating the current hardware scaling level
  98385. */
  98386. getHardwareScalingLevel(): number;
  98387. /**
  98388. * Gets the list of loaded textures
  98389. * @returns an array containing all loaded textures
  98390. */
  98391. getLoadedTexturesCache(): InternalTexture[];
  98392. /**
  98393. * Gets the object containing all engine capabilities
  98394. * @returns the EngineCapabilities object
  98395. */
  98396. getCaps(): EngineCapabilities;
  98397. /**
  98398. * stop executing a render loop function and remove it from the execution array
  98399. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  98400. */
  98401. stopRenderLoop(renderFunction?: () => void): void;
  98402. /** @hidden */
  98403. _renderLoop(): void;
  98404. /**
  98405. * Gets the HTML canvas attached with the current webGL context
  98406. * @returns a HTML canvas
  98407. */
  98408. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  98409. /**
  98410. * Gets host window
  98411. * @returns the host window object
  98412. */
  98413. getHostWindow(): Nullable<Window>;
  98414. /**
  98415. * Gets the current render width
  98416. * @param useScreen defines if screen size must be used (or the current render target if any)
  98417. * @returns a number defining the current render width
  98418. */
  98419. getRenderWidth(useScreen?: boolean): number;
  98420. /**
  98421. * Gets the current render height
  98422. * @param useScreen defines if screen size must be used (or the current render target if any)
  98423. * @returns a number defining the current render height
  98424. */
  98425. getRenderHeight(useScreen?: boolean): number;
  98426. /**
  98427. * Can be used to override the current requestAnimationFrame requester.
  98428. * @hidden
  98429. */
  98430. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  98431. /**
  98432. * Register and execute a render loop. The engine can have more than one render function
  98433. * @param renderFunction defines the function to continuously execute
  98434. */
  98435. runRenderLoop(renderFunction: () => void): void;
  98436. /**
  98437. * Clear the current render buffer or the current render target (if any is set up)
  98438. * @param color defines the color to use
  98439. * @param backBuffer defines if the back buffer must be cleared
  98440. * @param depth defines if the depth buffer must be cleared
  98441. * @param stencil defines if the stencil buffer must be cleared
  98442. */
  98443. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98444. private _viewportCached;
  98445. /** @hidden */
  98446. _viewport(x: number, y: number, width: number, height: number): void;
  98447. /**
  98448. * Set the WebGL's viewport
  98449. * @param viewport defines the viewport element to be used
  98450. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  98451. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  98452. */
  98453. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  98454. /**
  98455. * Begin a new frame
  98456. */
  98457. beginFrame(): void;
  98458. /**
  98459. * Enf the current frame
  98460. */
  98461. endFrame(): void;
  98462. /**
  98463. * Resize the view according to the canvas' size
  98464. */
  98465. resize(): void;
  98466. /**
  98467. * Force a specific size of the canvas
  98468. * @param width defines the new canvas' width
  98469. * @param height defines the new canvas' height
  98470. */
  98471. setSize(width: number, height: number): void;
  98472. /**
  98473. * Binds the frame buffer to the specified texture.
  98474. * @param texture The texture to render to or null for the default canvas
  98475. * @param faceIndex The face of the texture to render to in case of cube texture
  98476. * @param requiredWidth The width of the target to render to
  98477. * @param requiredHeight The height of the target to render to
  98478. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  98479. * @param depthStencilTexture The depth stencil texture to use to render
  98480. * @param lodLevel defines le lod level to bind to the frame buffer
  98481. */
  98482. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  98483. /** @hidden */
  98484. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  98485. /**
  98486. * Unbind the current render target texture from the webGL context
  98487. * @param texture defines the render target texture to unbind
  98488. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  98489. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  98490. */
  98491. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98492. /**
  98493. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  98494. */
  98495. flushFramebuffer(): void;
  98496. /**
  98497. * Unbind the current render target and bind the default framebuffer
  98498. */
  98499. restoreDefaultFramebuffer(): void;
  98500. /** @hidden */
  98501. protected _resetVertexBufferBinding(): void;
  98502. /**
  98503. * Creates a vertex buffer
  98504. * @param data the data for the vertex buffer
  98505. * @returns the new WebGL static buffer
  98506. */
  98507. createVertexBuffer(data: DataArray): DataBuffer;
  98508. private _createVertexBuffer;
  98509. /**
  98510. * Creates a dynamic vertex buffer
  98511. * @param data the data for the dynamic vertex buffer
  98512. * @returns the new WebGL dynamic buffer
  98513. */
  98514. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  98515. protected _resetIndexBufferBinding(): void;
  98516. /**
  98517. * Creates a new index buffer
  98518. * @param indices defines the content of the index buffer
  98519. * @param updatable defines if the index buffer must be updatable
  98520. * @returns a new webGL buffer
  98521. */
  98522. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  98523. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  98524. /**
  98525. * Bind a webGL buffer to the webGL context
  98526. * @param buffer defines the buffer to bind
  98527. */
  98528. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  98529. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  98530. private bindBuffer;
  98531. /**
  98532. * update the bound buffer with the given data
  98533. * @param data defines the data to update
  98534. */
  98535. updateArrayBuffer(data: Float32Array): void;
  98536. private _vertexAttribPointer;
  98537. private _bindIndexBufferWithCache;
  98538. private _bindVertexBuffersAttributes;
  98539. /**
  98540. * Records a vertex array object
  98541. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  98542. * @param vertexBuffers defines the list of vertex buffers to store
  98543. * @param indexBuffer defines the index buffer to store
  98544. * @param effect defines the effect to store
  98545. * @returns the new vertex array object
  98546. */
  98547. recordVertexArrayObject(vertexBuffers: {
  98548. [key: string]: VertexBuffer;
  98549. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  98550. /**
  98551. * Bind a specific vertex array object
  98552. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  98553. * @param vertexArrayObject defines the vertex array object to bind
  98554. * @param indexBuffer defines the index buffer to bind
  98555. */
  98556. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  98557. /**
  98558. * Bind webGl buffers directly to the webGL context
  98559. * @param vertexBuffer defines the vertex buffer to bind
  98560. * @param indexBuffer defines the index buffer to bind
  98561. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  98562. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  98563. * @param effect defines the effect associated with the vertex buffer
  98564. */
  98565. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  98566. private _unbindVertexArrayObject;
  98567. /**
  98568. * Bind a list of vertex buffers to the webGL context
  98569. * @param vertexBuffers defines the list of vertex buffers to bind
  98570. * @param indexBuffer defines the index buffer to bind
  98571. * @param effect defines the effect associated with the vertex buffers
  98572. */
  98573. bindBuffers(vertexBuffers: {
  98574. [key: string]: Nullable<VertexBuffer>;
  98575. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  98576. /**
  98577. * Unbind all instance attributes
  98578. */
  98579. unbindInstanceAttributes(): void;
  98580. /**
  98581. * Release and free the memory of a vertex array object
  98582. * @param vao defines the vertex array object to delete
  98583. */
  98584. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  98585. /** @hidden */
  98586. _releaseBuffer(buffer: DataBuffer): boolean;
  98587. protected _deleteBuffer(buffer: DataBuffer): void;
  98588. /**
  98589. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  98590. * @param instancesBuffer defines the webGL buffer to update and bind
  98591. * @param data defines the data to store in the buffer
  98592. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  98593. */
  98594. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  98595. /**
  98596. * Apply all cached states (depth, culling, stencil and alpha)
  98597. */
  98598. applyStates(): void;
  98599. /**
  98600. * Send a draw order
  98601. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98602. * @param indexStart defines the starting index
  98603. * @param indexCount defines the number of index to draw
  98604. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98605. */
  98606. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98607. /**
  98608. * Draw a list of points
  98609. * @param verticesStart defines the index of first vertex to draw
  98610. * @param verticesCount defines the count of vertices to draw
  98611. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98612. */
  98613. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98614. /**
  98615. * Draw a list of unindexed primitives
  98616. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98617. * @param verticesStart defines the index of first vertex to draw
  98618. * @param verticesCount defines the count of vertices to draw
  98619. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98620. */
  98621. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98622. /**
  98623. * Draw a list of indexed primitives
  98624. * @param fillMode defines the primitive to use
  98625. * @param indexStart defines the starting index
  98626. * @param indexCount defines the number of index to draw
  98627. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98628. */
  98629. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98630. /**
  98631. * Draw a list of unindexed primitives
  98632. * @param fillMode defines the primitive to use
  98633. * @param verticesStart defines the index of first vertex to draw
  98634. * @param verticesCount defines the count of vertices to draw
  98635. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98636. */
  98637. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98638. private _drawMode;
  98639. /** @hidden */
  98640. protected _reportDrawCall(): void;
  98641. /** @hidden */
  98642. _releaseEffect(effect: Effect): void;
  98643. /** @hidden */
  98644. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98645. /**
  98646. * Create a new effect (used to store vertex/fragment shaders)
  98647. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  98648. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  98649. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  98650. * @param samplers defines an array of string used to represent textures
  98651. * @param defines defines the string containing the defines to use to compile the shaders
  98652. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  98653. * @param onCompiled defines a function to call when the effect creation is successful
  98654. * @param onError defines a function to call when the effect creation has failed
  98655. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  98656. * @returns the new Effect
  98657. */
  98658. 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;
  98659. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  98660. private _compileShader;
  98661. private _compileRawShader;
  98662. /**
  98663. * Directly creates a webGL program
  98664. * @param pipelineContext defines the pipeline context to attach to
  98665. * @param vertexCode defines the vertex shader code to use
  98666. * @param fragmentCode defines the fragment shader code to use
  98667. * @param context defines the webGL context to use (if not set, the current one will be used)
  98668. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98669. * @returns the new webGL program
  98670. */
  98671. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98672. /**
  98673. * Creates a webGL program
  98674. * @param pipelineContext defines the pipeline context to attach to
  98675. * @param vertexCode defines the vertex shader code to use
  98676. * @param fragmentCode defines the fragment shader code to use
  98677. * @param defines defines the string containing the defines to use to compile the shaders
  98678. * @param context defines the webGL context to use (if not set, the current one will be used)
  98679. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98680. * @returns the new webGL program
  98681. */
  98682. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98683. /**
  98684. * Creates a new pipeline context
  98685. * @returns the new pipeline
  98686. */
  98687. createPipelineContext(): IPipelineContext;
  98688. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98689. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  98690. /** @hidden */
  98691. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  98692. /** @hidden */
  98693. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  98694. /** @hidden */
  98695. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  98696. /**
  98697. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  98698. * @param pipelineContext defines the pipeline context to use
  98699. * @param uniformsNames defines the list of uniform names
  98700. * @returns an array of webGL uniform locations
  98701. */
  98702. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  98703. /**
  98704. * Gets the lsit of active attributes for a given webGL program
  98705. * @param pipelineContext defines the pipeline context to use
  98706. * @param attributesNames defines the list of attribute names to get
  98707. * @returns an array of indices indicating the offset of each attribute
  98708. */
  98709. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  98710. /**
  98711. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  98712. * @param effect defines the effect to activate
  98713. */
  98714. enableEffect(effect: Nullable<Effect>): void;
  98715. /**
  98716. * Set the value of an uniform to a number (int)
  98717. * @param uniform defines the webGL uniform location where to store the value
  98718. * @param value defines the int number to store
  98719. */
  98720. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98721. /**
  98722. * Set the value of an uniform to an array of int32
  98723. * @param uniform defines the webGL uniform location where to store the value
  98724. * @param array defines the array of int32 to store
  98725. */
  98726. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98727. /**
  98728. * Set the value of an uniform to an array of int32 (stored as vec2)
  98729. * @param uniform defines the webGL uniform location where to store the value
  98730. * @param array defines the array of int32 to store
  98731. */
  98732. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98733. /**
  98734. * Set the value of an uniform to an array of int32 (stored as vec3)
  98735. * @param uniform defines the webGL uniform location where to store the value
  98736. * @param array defines the array of int32 to store
  98737. */
  98738. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98739. /**
  98740. * Set the value of an uniform to an array of int32 (stored as vec4)
  98741. * @param uniform defines the webGL uniform location where to store the value
  98742. * @param array defines the array of int32 to store
  98743. */
  98744. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98745. /**
  98746. * Set the value of an uniform to an array of number
  98747. * @param uniform defines the webGL uniform location where to store the value
  98748. * @param array defines the array of number to store
  98749. */
  98750. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98751. /**
  98752. * Set the value of an uniform to an array of number (stored as vec2)
  98753. * @param uniform defines the webGL uniform location where to store the value
  98754. * @param array defines the array of number to store
  98755. */
  98756. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98757. /**
  98758. * Set the value of an uniform to an array of number (stored as vec3)
  98759. * @param uniform defines the webGL uniform location where to store the value
  98760. * @param array defines the array of number to store
  98761. */
  98762. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98763. /**
  98764. * Set the value of an uniform to an array of number (stored as vec4)
  98765. * @param uniform defines the webGL uniform location where to store the value
  98766. * @param array defines the array of number to store
  98767. */
  98768. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98769. /**
  98770. * Set the value of an uniform to an array of float32 (stored as matrices)
  98771. * @param uniform defines the webGL uniform location where to store the value
  98772. * @param matrices defines the array of float32 to store
  98773. */
  98774. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  98775. /**
  98776. * Set the value of an uniform to a matrix (3x3)
  98777. * @param uniform defines the webGL uniform location where to store the value
  98778. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  98779. */
  98780. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98781. /**
  98782. * Set the value of an uniform to a matrix (2x2)
  98783. * @param uniform defines the webGL uniform location where to store the value
  98784. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  98785. */
  98786. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98787. /**
  98788. * Set the value of an uniform to a number (float)
  98789. * @param uniform defines the webGL uniform location where to store the value
  98790. * @param value defines the float number to store
  98791. */
  98792. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98793. /**
  98794. * Set the value of an uniform to a vec2
  98795. * @param uniform defines the webGL uniform location where to store the value
  98796. * @param x defines the 1st component of the value
  98797. * @param y defines the 2nd component of the value
  98798. */
  98799. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  98800. /**
  98801. * Set the value of an uniform to a vec3
  98802. * @param uniform defines the webGL uniform location where to store the value
  98803. * @param x defines the 1st component of the value
  98804. * @param y defines the 2nd component of the value
  98805. * @param z defines the 3rd component of the value
  98806. */
  98807. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  98808. /**
  98809. * Set the value of an uniform to a vec4
  98810. * @param uniform defines the webGL uniform location where to store the value
  98811. * @param x defines the 1st component of the value
  98812. * @param y defines the 2nd component of the value
  98813. * @param z defines the 3rd component of the value
  98814. * @param w defines the 4th component of the value
  98815. */
  98816. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  98817. /**
  98818. * Gets the depth culling state manager
  98819. */
  98820. readonly depthCullingState: DepthCullingState;
  98821. /**
  98822. * Gets the alpha state manager
  98823. */
  98824. readonly alphaState: AlphaState;
  98825. /**
  98826. * Gets the stencil state manager
  98827. */
  98828. readonly stencilState: StencilState;
  98829. /**
  98830. * Clears the list of texture accessible through engine.
  98831. * This can help preventing texture load conflict due to name collision.
  98832. */
  98833. clearInternalTexturesCache(): void;
  98834. /**
  98835. * Force the entire cache to be cleared
  98836. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98837. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98838. */
  98839. wipeCaches(bruteForce?: boolean): void;
  98840. /** @hidden */
  98841. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98842. min: number;
  98843. mag: number;
  98844. };
  98845. /** @hidden */
  98846. _createTexture(): WebGLTexture;
  98847. /**
  98848. * Usually called from Texture.ts.
  98849. * Passed information to create a WebGLTexture
  98850. * @param urlArg defines a value which contains one of the following:
  98851. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98852. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98853. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98854. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98855. * @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)
  98856. * @param scene needed for loading to the correct scene
  98857. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98858. * @param onLoad optional callback to be called upon successful completion
  98859. * @param onError optional callback to be called upon failure
  98860. * @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
  98861. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98862. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98863. * @param forcedExtension defines the extension to use to pick the right loader
  98864. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98865. * @param mimeType defines an optional mime type
  98866. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98867. */
  98868. 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;
  98869. /**
  98870. * @hidden
  98871. */
  98872. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98873. /**
  98874. * Creates a raw texture
  98875. * @param data defines the data to store in the texture
  98876. * @param width defines the width of the texture
  98877. * @param height defines the height of the texture
  98878. * @param format defines the format of the data
  98879. * @param generateMipMaps defines if the engine should generate the mip levels
  98880. * @param invertY defines if data must be stored with Y axis inverted
  98881. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98882. * @param compression defines the compression used (null by default)
  98883. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98884. * @returns the raw texture inside an InternalTexture
  98885. */
  98886. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98887. /**
  98888. * Creates a new raw cube texture
  98889. * @param data defines the array of data to use to create each face
  98890. * @param size defines the size of the textures
  98891. * @param format defines the format of the data
  98892. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98893. * @param generateMipMaps defines if the engine should generate the mip levels
  98894. * @param invertY defines if data must be stored with Y axis inverted
  98895. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98896. * @param compression defines the compression used (null by default)
  98897. * @returns the cube texture as an InternalTexture
  98898. */
  98899. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98900. /**
  98901. * Creates a new raw 3D texture
  98902. * @param data defines the data used to create the texture
  98903. * @param width defines the width of the texture
  98904. * @param height defines the height of the texture
  98905. * @param depth defines the depth of the texture
  98906. * @param format defines the format of the texture
  98907. * @param generateMipMaps defines if the engine must generate mip levels
  98908. * @param invertY defines if data must be stored with Y axis inverted
  98909. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98910. * @param compression defines the compressed used (can be null)
  98911. * @param textureType defines the compressed used (can be null)
  98912. * @returns a new raw 3D texture (stored in an InternalTexture)
  98913. */
  98914. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98915. /**
  98916. * Creates a new raw 2D array texture
  98917. * @param data defines the data used to create the texture
  98918. * @param width defines the width of the texture
  98919. * @param height defines the height of the texture
  98920. * @param depth defines the number of layers of the texture
  98921. * @param format defines the format of the texture
  98922. * @param generateMipMaps defines if the engine must generate mip levels
  98923. * @param invertY defines if data must be stored with Y axis inverted
  98924. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98925. * @param compression defines the compressed used (can be null)
  98926. * @param textureType defines the compressed used (can be null)
  98927. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98928. */
  98929. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98930. private _unpackFlipYCached;
  98931. /**
  98932. * In case you are sharing the context with other applications, it might
  98933. * be interested to not cache the unpack flip y state to ensure a consistent
  98934. * value would be set.
  98935. */
  98936. enableUnpackFlipYCached: boolean;
  98937. /** @hidden */
  98938. _unpackFlipY(value: boolean): void;
  98939. /** @hidden */
  98940. _getUnpackAlignement(): number;
  98941. /**
  98942. * Update the sampling mode of a given texture
  98943. * @param samplingMode defines the required sampling mode
  98944. * @param texture defines the texture to update
  98945. */
  98946. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98947. /** @hidden */
  98948. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98949. width: number;
  98950. height: number;
  98951. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98952. /** @hidden */
  98953. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98954. /** @hidden */
  98955. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98956. /** @hidden */
  98957. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98958. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98959. private _prepareWebGLTexture;
  98960. /** @hidden */
  98961. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98962. /** @hidden */
  98963. _releaseFramebufferObjects(texture: InternalTexture): void;
  98964. /** @hidden */
  98965. _releaseTexture(texture: InternalTexture): void;
  98966. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98967. protected _setProgram(program: WebGLProgram): void;
  98968. protected _boundUniforms: {
  98969. [key: number]: WebGLUniformLocation;
  98970. };
  98971. /**
  98972. * Binds an effect to the webGL context
  98973. * @param effect defines the effect to bind
  98974. */
  98975. bindSamplers(effect: Effect): void;
  98976. private _activateCurrentTexture;
  98977. /** @hidden */
  98978. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98979. /** @hidden */
  98980. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98981. /**
  98982. * Unbind all textures from the webGL context
  98983. */
  98984. unbindAllTextures(): void;
  98985. /**
  98986. * Sets a texture to the according uniform.
  98987. * @param channel The texture channel
  98988. * @param uniform The uniform to set
  98989. * @param texture The texture to apply
  98990. */
  98991. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98992. private _bindSamplerUniformToChannel;
  98993. private _getTextureWrapMode;
  98994. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98995. /**
  98996. * Sets an array of texture to the webGL context
  98997. * @param channel defines the channel where the texture array must be set
  98998. * @param uniform defines the associated uniform location
  98999. * @param textures defines the array of textures to bind
  99000. */
  99001. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  99002. /** @hidden */
  99003. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  99004. private _setTextureParameterFloat;
  99005. private _setTextureParameterInteger;
  99006. /**
  99007. * Unbind all vertex attributes from the webGL context
  99008. */
  99009. unbindAllAttributes(): void;
  99010. /**
  99011. * 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
  99012. */
  99013. releaseEffects(): void;
  99014. /**
  99015. * Dispose and release all associated resources
  99016. */
  99017. dispose(): void;
  99018. /**
  99019. * Attach a new callback raised when context lost event is fired
  99020. * @param callback defines the callback to call
  99021. */
  99022. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  99023. /**
  99024. * Attach a new callback raised when context restored event is fired
  99025. * @param callback defines the callback to call
  99026. */
  99027. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  99028. /**
  99029. * Get the current error code of the webGL context
  99030. * @returns the error code
  99031. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  99032. */
  99033. getError(): number;
  99034. private _canRenderToFloatFramebuffer;
  99035. private _canRenderToHalfFloatFramebuffer;
  99036. private _canRenderToFramebuffer;
  99037. /** @hidden */
  99038. _getWebGLTextureType(type: number): number;
  99039. /** @hidden */
  99040. _getInternalFormat(format: number): number;
  99041. /** @hidden */
  99042. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  99043. /** @hidden */
  99044. _getRGBAMultiSampleBufferFormat(type: number): number;
  99045. /** @hidden */
  99046. _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;
  99047. /**
  99048. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  99049. * @returns true if the engine can be created
  99050. * @ignorenaming
  99051. */
  99052. static isSupported(): boolean;
  99053. /**
  99054. * Find the next highest power of two.
  99055. * @param x Number to start search from.
  99056. * @return Next highest power of two.
  99057. */
  99058. static CeilingPOT(x: number): number;
  99059. /**
  99060. * Find the next lowest power of two.
  99061. * @param x Number to start search from.
  99062. * @return Next lowest power of two.
  99063. */
  99064. static FloorPOT(x: number): number;
  99065. /**
  99066. * Find the nearest power of two.
  99067. * @param x Number to start search from.
  99068. * @return Next nearest power of two.
  99069. */
  99070. static NearestPOT(x: number): number;
  99071. /**
  99072. * Get the closest exponent of two
  99073. * @param value defines the value to approximate
  99074. * @param max defines the maximum value to return
  99075. * @param mode defines how to define the closest value
  99076. * @returns closest exponent of two of the given value
  99077. */
  99078. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  99079. /**
  99080. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  99081. * @param func - the function to be called
  99082. * @param requester - the object that will request the next frame. Falls back to window.
  99083. * @returns frame number
  99084. */
  99085. static QueueNewFrame(func: () => void, requester?: any): number;
  99086. /**
  99087. * Gets host document
  99088. * @returns the host document object
  99089. */
  99090. getHostDocument(): Document;
  99091. }
  99092. }
  99093. declare module BABYLON {
  99094. /**
  99095. * Class representing spherical harmonics coefficients to the 3rd degree
  99096. */
  99097. export class SphericalHarmonics {
  99098. /**
  99099. * Defines whether or not the harmonics have been prescaled for rendering.
  99100. */
  99101. preScaled: boolean;
  99102. /**
  99103. * The l0,0 coefficients of the spherical harmonics
  99104. */
  99105. l00: Vector3;
  99106. /**
  99107. * The l1,-1 coefficients of the spherical harmonics
  99108. */
  99109. l1_1: Vector3;
  99110. /**
  99111. * The l1,0 coefficients of the spherical harmonics
  99112. */
  99113. l10: Vector3;
  99114. /**
  99115. * The l1,1 coefficients of the spherical harmonics
  99116. */
  99117. l11: Vector3;
  99118. /**
  99119. * The l2,-2 coefficients of the spherical harmonics
  99120. */
  99121. l2_2: Vector3;
  99122. /**
  99123. * The l2,-1 coefficients of the spherical harmonics
  99124. */
  99125. l2_1: Vector3;
  99126. /**
  99127. * The l2,0 coefficients of the spherical harmonics
  99128. */
  99129. l20: Vector3;
  99130. /**
  99131. * The l2,1 coefficients of the spherical harmonics
  99132. */
  99133. l21: Vector3;
  99134. /**
  99135. * The l2,2 coefficients of the spherical harmonics
  99136. */
  99137. l22: Vector3;
  99138. /**
  99139. * Adds a light to the spherical harmonics
  99140. * @param direction the direction of the light
  99141. * @param color the color of the light
  99142. * @param deltaSolidAngle the delta solid angle of the light
  99143. */
  99144. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  99145. /**
  99146. * Scales the spherical harmonics by the given amount
  99147. * @param scale the amount to scale
  99148. */
  99149. scaleInPlace(scale: number): void;
  99150. /**
  99151. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  99152. *
  99153. * ```
  99154. * E_lm = A_l * L_lm
  99155. * ```
  99156. *
  99157. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  99158. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  99159. * the scaling factors are given in equation 9.
  99160. */
  99161. convertIncidentRadianceToIrradiance(): void;
  99162. /**
  99163. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  99164. *
  99165. * ```
  99166. * L = (1/pi) * E * rho
  99167. * ```
  99168. *
  99169. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  99170. */
  99171. convertIrradianceToLambertianRadiance(): void;
  99172. /**
  99173. * Integrates the reconstruction coefficients directly in to the SH preventing further
  99174. * required operations at run time.
  99175. *
  99176. * This is simply done by scaling back the SH with Ylm constants parameter.
  99177. * The trigonometric part being applied by the shader at run time.
  99178. */
  99179. preScaleForRendering(): void;
  99180. /**
  99181. * Constructs a spherical harmonics from an array.
  99182. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  99183. * @returns the spherical harmonics
  99184. */
  99185. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  99186. /**
  99187. * Gets the spherical harmonics from polynomial
  99188. * @param polynomial the spherical polynomial
  99189. * @returns the spherical harmonics
  99190. */
  99191. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  99192. }
  99193. /**
  99194. * Class representing spherical polynomial coefficients to the 3rd degree
  99195. */
  99196. export class SphericalPolynomial {
  99197. private _harmonics;
  99198. /**
  99199. * The spherical harmonics used to create the polynomials.
  99200. */
  99201. readonly preScaledHarmonics: SphericalHarmonics;
  99202. /**
  99203. * The x coefficients of the spherical polynomial
  99204. */
  99205. x: Vector3;
  99206. /**
  99207. * The y coefficients of the spherical polynomial
  99208. */
  99209. y: Vector3;
  99210. /**
  99211. * The z coefficients of the spherical polynomial
  99212. */
  99213. z: Vector3;
  99214. /**
  99215. * The xx coefficients of the spherical polynomial
  99216. */
  99217. xx: Vector3;
  99218. /**
  99219. * The yy coefficients of the spherical polynomial
  99220. */
  99221. yy: Vector3;
  99222. /**
  99223. * The zz coefficients of the spherical polynomial
  99224. */
  99225. zz: Vector3;
  99226. /**
  99227. * The xy coefficients of the spherical polynomial
  99228. */
  99229. xy: Vector3;
  99230. /**
  99231. * The yz coefficients of the spherical polynomial
  99232. */
  99233. yz: Vector3;
  99234. /**
  99235. * The zx coefficients of the spherical polynomial
  99236. */
  99237. zx: Vector3;
  99238. /**
  99239. * Adds an ambient color to the spherical polynomial
  99240. * @param color the color to add
  99241. */
  99242. addAmbient(color: Color3): void;
  99243. /**
  99244. * Scales the spherical polynomial by the given amount
  99245. * @param scale the amount to scale
  99246. */
  99247. scaleInPlace(scale: number): void;
  99248. /**
  99249. * Gets the spherical polynomial from harmonics
  99250. * @param harmonics the spherical harmonics
  99251. * @returns the spherical polynomial
  99252. */
  99253. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  99254. /**
  99255. * Constructs a spherical polynomial from an array.
  99256. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  99257. * @returns the spherical polynomial
  99258. */
  99259. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  99260. }
  99261. }
  99262. declare module BABYLON {
  99263. /**
  99264. * Defines the source of the internal texture
  99265. */
  99266. export enum InternalTextureSource {
  99267. /**
  99268. * The source of the texture data is unknown
  99269. */
  99270. Unknown = 0,
  99271. /**
  99272. * Texture data comes from an URL
  99273. */
  99274. Url = 1,
  99275. /**
  99276. * Texture data is only used for temporary storage
  99277. */
  99278. Temp = 2,
  99279. /**
  99280. * Texture data comes from raw data (ArrayBuffer)
  99281. */
  99282. Raw = 3,
  99283. /**
  99284. * Texture content is dynamic (video or dynamic texture)
  99285. */
  99286. Dynamic = 4,
  99287. /**
  99288. * Texture content is generated by rendering to it
  99289. */
  99290. RenderTarget = 5,
  99291. /**
  99292. * Texture content is part of a multi render target process
  99293. */
  99294. MultiRenderTarget = 6,
  99295. /**
  99296. * Texture data comes from a cube data file
  99297. */
  99298. Cube = 7,
  99299. /**
  99300. * Texture data comes from a raw cube data
  99301. */
  99302. CubeRaw = 8,
  99303. /**
  99304. * Texture data come from a prefiltered cube data file
  99305. */
  99306. CubePrefiltered = 9,
  99307. /**
  99308. * Texture content is raw 3D data
  99309. */
  99310. Raw3D = 10,
  99311. /**
  99312. * Texture content is raw 2D array data
  99313. */
  99314. Raw2DArray = 11,
  99315. /**
  99316. * Texture content is a depth texture
  99317. */
  99318. Depth = 12,
  99319. /**
  99320. * Texture data comes from a raw cube data encoded with RGBD
  99321. */
  99322. CubeRawRGBD = 13
  99323. }
  99324. /**
  99325. * Class used to store data associated with WebGL texture data for the engine
  99326. * This class should not be used directly
  99327. */
  99328. export class InternalTexture {
  99329. /** @hidden */
  99330. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  99331. /**
  99332. * Defines if the texture is ready
  99333. */
  99334. isReady: boolean;
  99335. /**
  99336. * Defines if the texture is a cube texture
  99337. */
  99338. isCube: boolean;
  99339. /**
  99340. * Defines if the texture contains 3D data
  99341. */
  99342. is3D: boolean;
  99343. /**
  99344. * Defines if the texture contains 2D array data
  99345. */
  99346. is2DArray: boolean;
  99347. /**
  99348. * Defines if the texture contains multiview data
  99349. */
  99350. isMultiview: boolean;
  99351. /**
  99352. * Gets the URL used to load this texture
  99353. */
  99354. url: string;
  99355. /**
  99356. * Gets the sampling mode of the texture
  99357. */
  99358. samplingMode: number;
  99359. /**
  99360. * Gets a boolean indicating if the texture needs mipmaps generation
  99361. */
  99362. generateMipMaps: boolean;
  99363. /**
  99364. * Gets the number of samples used by the texture (WebGL2+ only)
  99365. */
  99366. samples: number;
  99367. /**
  99368. * Gets the type of the texture (int, float...)
  99369. */
  99370. type: number;
  99371. /**
  99372. * Gets the format of the texture (RGB, RGBA...)
  99373. */
  99374. format: number;
  99375. /**
  99376. * Observable called when the texture is loaded
  99377. */
  99378. onLoadedObservable: Observable<InternalTexture>;
  99379. /**
  99380. * Gets the width of the texture
  99381. */
  99382. width: number;
  99383. /**
  99384. * Gets the height of the texture
  99385. */
  99386. height: number;
  99387. /**
  99388. * Gets the depth of the texture
  99389. */
  99390. depth: number;
  99391. /**
  99392. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  99393. */
  99394. baseWidth: number;
  99395. /**
  99396. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  99397. */
  99398. baseHeight: number;
  99399. /**
  99400. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  99401. */
  99402. baseDepth: number;
  99403. /**
  99404. * Gets a boolean indicating if the texture is inverted on Y axis
  99405. */
  99406. invertY: boolean;
  99407. /** @hidden */
  99408. _invertVScale: boolean;
  99409. /** @hidden */
  99410. _associatedChannel: number;
  99411. /** @hidden */
  99412. _source: InternalTextureSource;
  99413. /** @hidden */
  99414. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  99415. /** @hidden */
  99416. _bufferView: Nullable<ArrayBufferView>;
  99417. /** @hidden */
  99418. _bufferViewArray: Nullable<ArrayBufferView[]>;
  99419. /** @hidden */
  99420. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  99421. /** @hidden */
  99422. _size: number;
  99423. /** @hidden */
  99424. _extension: string;
  99425. /** @hidden */
  99426. _files: Nullable<string[]>;
  99427. /** @hidden */
  99428. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99429. /** @hidden */
  99430. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  99431. /** @hidden */
  99432. _framebuffer: Nullable<WebGLFramebuffer>;
  99433. /** @hidden */
  99434. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  99435. /** @hidden */
  99436. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  99437. /** @hidden */
  99438. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  99439. /** @hidden */
  99440. _attachments: Nullable<number[]>;
  99441. /** @hidden */
  99442. _cachedCoordinatesMode: Nullable<number>;
  99443. /** @hidden */
  99444. _cachedWrapU: Nullable<number>;
  99445. /** @hidden */
  99446. _cachedWrapV: Nullable<number>;
  99447. /** @hidden */
  99448. _cachedWrapR: Nullable<number>;
  99449. /** @hidden */
  99450. _cachedAnisotropicFilteringLevel: Nullable<number>;
  99451. /** @hidden */
  99452. _isDisabled: boolean;
  99453. /** @hidden */
  99454. _compression: Nullable<string>;
  99455. /** @hidden */
  99456. _generateStencilBuffer: boolean;
  99457. /** @hidden */
  99458. _generateDepthBuffer: boolean;
  99459. /** @hidden */
  99460. _comparisonFunction: number;
  99461. /** @hidden */
  99462. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  99463. /** @hidden */
  99464. _lodGenerationScale: number;
  99465. /** @hidden */
  99466. _lodGenerationOffset: number;
  99467. /** @hidden */
  99468. _colorTextureArray: Nullable<WebGLTexture>;
  99469. /** @hidden */
  99470. _depthStencilTextureArray: Nullable<WebGLTexture>;
  99471. /** @hidden */
  99472. _lodTextureHigh: Nullable<BaseTexture>;
  99473. /** @hidden */
  99474. _lodTextureMid: Nullable<BaseTexture>;
  99475. /** @hidden */
  99476. _lodTextureLow: Nullable<BaseTexture>;
  99477. /** @hidden */
  99478. _isRGBD: boolean;
  99479. /** @hidden */
  99480. _linearSpecularLOD: boolean;
  99481. /** @hidden */
  99482. _irradianceTexture: Nullable<BaseTexture>;
  99483. /** @hidden */
  99484. _webGLTexture: Nullable<WebGLTexture>;
  99485. /** @hidden */
  99486. _references: number;
  99487. private _engine;
  99488. /**
  99489. * Gets the Engine the texture belongs to.
  99490. * @returns The babylon engine
  99491. */
  99492. getEngine(): ThinEngine;
  99493. /**
  99494. * Gets the data source type of the texture
  99495. */
  99496. readonly source: InternalTextureSource;
  99497. /**
  99498. * Creates a new InternalTexture
  99499. * @param engine defines the engine to use
  99500. * @param source defines the type of data that will be used
  99501. * @param delayAllocation if the texture allocation should be delayed (default: false)
  99502. */
  99503. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  99504. /**
  99505. * Increments the number of references (ie. the number of Texture that point to it)
  99506. */
  99507. incrementReferences(): void;
  99508. /**
  99509. * Change the size of the texture (not the size of the content)
  99510. * @param width defines the new width
  99511. * @param height defines the new height
  99512. * @param depth defines the new depth (1 by default)
  99513. */
  99514. updateSize(width: int, height: int, depth?: int): void;
  99515. /** @hidden */
  99516. _rebuild(): void;
  99517. /** @hidden */
  99518. _swapAndDie(target: InternalTexture): void;
  99519. /**
  99520. * Dispose the current allocated resources
  99521. */
  99522. dispose(): void;
  99523. }
  99524. }
  99525. declare module BABYLON {
  99526. /**
  99527. * Class used to work with sound analyzer using fast fourier transform (FFT)
  99528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99529. */
  99530. export class Analyser {
  99531. /**
  99532. * Gets or sets the smoothing
  99533. * @ignorenaming
  99534. */
  99535. SMOOTHING: number;
  99536. /**
  99537. * Gets or sets the FFT table size
  99538. * @ignorenaming
  99539. */
  99540. FFT_SIZE: number;
  99541. /**
  99542. * Gets or sets the bar graph amplitude
  99543. * @ignorenaming
  99544. */
  99545. BARGRAPHAMPLITUDE: number;
  99546. /**
  99547. * Gets or sets the position of the debug canvas
  99548. * @ignorenaming
  99549. */
  99550. DEBUGCANVASPOS: {
  99551. x: number;
  99552. y: number;
  99553. };
  99554. /**
  99555. * Gets or sets the debug canvas size
  99556. * @ignorenaming
  99557. */
  99558. DEBUGCANVASSIZE: {
  99559. width: number;
  99560. height: number;
  99561. };
  99562. private _byteFreqs;
  99563. private _byteTime;
  99564. private _floatFreqs;
  99565. private _webAudioAnalyser;
  99566. private _debugCanvas;
  99567. private _debugCanvasContext;
  99568. private _scene;
  99569. private _registerFunc;
  99570. private _audioEngine;
  99571. /**
  99572. * Creates a new analyser
  99573. * @param scene defines hosting scene
  99574. */
  99575. constructor(scene: Scene);
  99576. /**
  99577. * Get the number of data values you will have to play with for the visualization
  99578. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  99579. * @returns a number
  99580. */
  99581. getFrequencyBinCount(): number;
  99582. /**
  99583. * Gets the current frequency data as a byte array
  99584. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99585. * @returns a Uint8Array
  99586. */
  99587. getByteFrequencyData(): Uint8Array;
  99588. /**
  99589. * Gets the current waveform as a byte array
  99590. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  99591. * @returns a Uint8Array
  99592. */
  99593. getByteTimeDomainData(): Uint8Array;
  99594. /**
  99595. * Gets the current frequency data as a float array
  99596. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99597. * @returns a Float32Array
  99598. */
  99599. getFloatFrequencyData(): Float32Array;
  99600. /**
  99601. * Renders the debug canvas
  99602. */
  99603. drawDebugCanvas(): void;
  99604. /**
  99605. * Stops rendering the debug canvas and removes it
  99606. */
  99607. stopDebugCanvas(): void;
  99608. /**
  99609. * Connects two audio nodes
  99610. * @param inputAudioNode defines first node to connect
  99611. * @param outputAudioNode defines second node to connect
  99612. */
  99613. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  99614. /**
  99615. * Releases all associated resources
  99616. */
  99617. dispose(): void;
  99618. }
  99619. }
  99620. declare module BABYLON {
  99621. /**
  99622. * This represents an audio engine and it is responsible
  99623. * to play, synchronize and analyse sounds throughout the application.
  99624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99625. */
  99626. export interface IAudioEngine extends IDisposable {
  99627. /**
  99628. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99629. */
  99630. readonly canUseWebAudio: boolean;
  99631. /**
  99632. * Gets the current AudioContext if available.
  99633. */
  99634. readonly audioContext: Nullable<AudioContext>;
  99635. /**
  99636. * The master gain node defines the global audio volume of your audio engine.
  99637. */
  99638. readonly masterGain: GainNode;
  99639. /**
  99640. * Gets whether or not mp3 are supported by your browser.
  99641. */
  99642. readonly isMP3supported: boolean;
  99643. /**
  99644. * Gets whether or not ogg are supported by your browser.
  99645. */
  99646. readonly isOGGsupported: boolean;
  99647. /**
  99648. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99649. * @ignoreNaming
  99650. */
  99651. WarnedWebAudioUnsupported: boolean;
  99652. /**
  99653. * Defines if the audio engine relies on a custom unlocked button.
  99654. * In this case, the embedded button will not be displayed.
  99655. */
  99656. useCustomUnlockedButton: boolean;
  99657. /**
  99658. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  99659. */
  99660. readonly unlocked: boolean;
  99661. /**
  99662. * Event raised when audio has been unlocked on the browser.
  99663. */
  99664. onAudioUnlockedObservable: Observable<AudioEngine>;
  99665. /**
  99666. * Event raised when audio has been locked on the browser.
  99667. */
  99668. onAudioLockedObservable: Observable<AudioEngine>;
  99669. /**
  99670. * Flags the audio engine in Locked state.
  99671. * This happens due to new browser policies preventing audio to autoplay.
  99672. */
  99673. lock(): void;
  99674. /**
  99675. * Unlocks the audio engine once a user action has been done on the dom.
  99676. * This is helpful to resume play once browser policies have been satisfied.
  99677. */
  99678. unlock(): void;
  99679. }
  99680. /**
  99681. * This represents the default audio engine used in babylon.
  99682. * It is responsible to play, synchronize and analyse sounds throughout the application.
  99683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99684. */
  99685. export class AudioEngine implements IAudioEngine {
  99686. private _audioContext;
  99687. private _audioContextInitialized;
  99688. private _muteButton;
  99689. private _hostElement;
  99690. /**
  99691. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99692. */
  99693. canUseWebAudio: boolean;
  99694. /**
  99695. * The master gain node defines the global audio volume of your audio engine.
  99696. */
  99697. masterGain: GainNode;
  99698. /**
  99699. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99700. * @ignoreNaming
  99701. */
  99702. WarnedWebAudioUnsupported: boolean;
  99703. /**
  99704. * Gets whether or not mp3 are supported by your browser.
  99705. */
  99706. isMP3supported: boolean;
  99707. /**
  99708. * Gets whether or not ogg are supported by your browser.
  99709. */
  99710. isOGGsupported: boolean;
  99711. /**
  99712. * Gets whether audio has been unlocked on the device.
  99713. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  99714. * a user interaction has happened.
  99715. */
  99716. unlocked: boolean;
  99717. /**
  99718. * Defines if the audio engine relies on a custom unlocked button.
  99719. * In this case, the embedded button will not be displayed.
  99720. */
  99721. useCustomUnlockedButton: boolean;
  99722. /**
  99723. * Event raised when audio has been unlocked on the browser.
  99724. */
  99725. onAudioUnlockedObservable: Observable<AudioEngine>;
  99726. /**
  99727. * Event raised when audio has been locked on the browser.
  99728. */
  99729. onAudioLockedObservable: Observable<AudioEngine>;
  99730. /**
  99731. * Gets the current AudioContext if available.
  99732. */
  99733. readonly audioContext: Nullable<AudioContext>;
  99734. private _connectedAnalyser;
  99735. /**
  99736. * Instantiates a new audio engine.
  99737. *
  99738. * There should be only one per page as some browsers restrict the number
  99739. * of audio contexts you can create.
  99740. * @param hostElement defines the host element where to display the mute icon if necessary
  99741. */
  99742. constructor(hostElement?: Nullable<HTMLElement>);
  99743. /**
  99744. * Flags the audio engine in Locked state.
  99745. * This happens due to new browser policies preventing audio to autoplay.
  99746. */
  99747. lock(): void;
  99748. /**
  99749. * Unlocks the audio engine once a user action has been done on the dom.
  99750. * This is helpful to resume play once browser policies have been satisfied.
  99751. */
  99752. unlock(): void;
  99753. private _resumeAudioContext;
  99754. private _initializeAudioContext;
  99755. private _tryToRun;
  99756. private _triggerRunningState;
  99757. private _triggerSuspendedState;
  99758. private _displayMuteButton;
  99759. private _moveButtonToTopLeft;
  99760. private _onResize;
  99761. private _hideMuteButton;
  99762. /**
  99763. * Destroy and release the resources associated with the audio ccontext.
  99764. */
  99765. dispose(): void;
  99766. /**
  99767. * Gets the global volume sets on the master gain.
  99768. * @returns the global volume if set or -1 otherwise
  99769. */
  99770. getGlobalVolume(): number;
  99771. /**
  99772. * Sets the global volume of your experience (sets on the master gain).
  99773. * @param newVolume Defines the new global volume of the application
  99774. */
  99775. setGlobalVolume(newVolume: number): void;
  99776. /**
  99777. * Connect the audio engine to an audio analyser allowing some amazing
  99778. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99780. * @param analyser The analyser to connect to the engine
  99781. */
  99782. connectToAnalyser(analyser: Analyser): void;
  99783. }
  99784. }
  99785. declare module BABYLON {
  99786. /**
  99787. * Interface used to present a loading screen while loading a scene
  99788. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99789. */
  99790. export interface ILoadingScreen {
  99791. /**
  99792. * Function called to display the loading screen
  99793. */
  99794. displayLoadingUI: () => void;
  99795. /**
  99796. * Function called to hide the loading screen
  99797. */
  99798. hideLoadingUI: () => void;
  99799. /**
  99800. * Gets or sets the color to use for the background
  99801. */
  99802. loadingUIBackgroundColor: string;
  99803. /**
  99804. * Gets or sets the text to display while loading
  99805. */
  99806. loadingUIText: string;
  99807. }
  99808. /**
  99809. * Class used for the default loading screen
  99810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99811. */
  99812. export class DefaultLoadingScreen implements ILoadingScreen {
  99813. private _renderingCanvas;
  99814. private _loadingText;
  99815. private _loadingDivBackgroundColor;
  99816. private _loadingDiv;
  99817. private _loadingTextDiv;
  99818. /** Gets or sets the logo url to use for the default loading screen */
  99819. static DefaultLogoUrl: string;
  99820. /** Gets or sets the spinner url to use for the default loading screen */
  99821. static DefaultSpinnerUrl: string;
  99822. /**
  99823. * Creates a new default loading screen
  99824. * @param _renderingCanvas defines the canvas used to render the scene
  99825. * @param _loadingText defines the default text to display
  99826. * @param _loadingDivBackgroundColor defines the default background color
  99827. */
  99828. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  99829. /**
  99830. * Function called to display the loading screen
  99831. */
  99832. displayLoadingUI(): void;
  99833. /**
  99834. * Function called to hide the loading screen
  99835. */
  99836. hideLoadingUI(): void;
  99837. /**
  99838. * Gets or sets the text to display while loading
  99839. */
  99840. loadingUIText: string;
  99841. /**
  99842. * Gets or sets the color to use for the background
  99843. */
  99844. loadingUIBackgroundColor: string;
  99845. private _resizeLoadingUI;
  99846. }
  99847. }
  99848. declare module BABYLON {
  99849. /**
  99850. * Interface for any object that can request an animation frame
  99851. */
  99852. export interface ICustomAnimationFrameRequester {
  99853. /**
  99854. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99855. */
  99856. renderFunction?: Function;
  99857. /**
  99858. * Called to request the next frame to render to
  99859. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99860. */
  99861. requestAnimationFrame: Function;
  99862. /**
  99863. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99864. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99865. */
  99866. requestID?: number;
  99867. }
  99868. }
  99869. declare module BABYLON {
  99870. /**
  99871. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99872. */
  99873. export class PerformanceMonitor {
  99874. private _enabled;
  99875. private _rollingFrameTime;
  99876. private _lastFrameTimeMs;
  99877. /**
  99878. * constructor
  99879. * @param frameSampleSize The number of samples required to saturate the sliding window
  99880. */
  99881. constructor(frameSampleSize?: number);
  99882. /**
  99883. * Samples current frame
  99884. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99885. */
  99886. sampleFrame(timeMs?: number): void;
  99887. /**
  99888. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99889. */
  99890. readonly averageFrameTime: number;
  99891. /**
  99892. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99893. */
  99894. readonly averageFrameTimeVariance: number;
  99895. /**
  99896. * Returns the frame time of the most recent frame
  99897. */
  99898. readonly instantaneousFrameTime: number;
  99899. /**
  99900. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99901. */
  99902. readonly averageFPS: number;
  99903. /**
  99904. * Returns the average framerate in frames per second using the most recent frame time
  99905. */
  99906. readonly instantaneousFPS: number;
  99907. /**
  99908. * Returns true if enough samples have been taken to completely fill the sliding window
  99909. */
  99910. readonly isSaturated: boolean;
  99911. /**
  99912. * Enables contributions to the sliding window sample set
  99913. */
  99914. enable(): void;
  99915. /**
  99916. * Disables contributions to the sliding window sample set
  99917. * Samples will not be interpolated over the disabled period
  99918. */
  99919. disable(): void;
  99920. /**
  99921. * Returns true if sampling is enabled
  99922. */
  99923. readonly isEnabled: boolean;
  99924. /**
  99925. * Resets performance monitor
  99926. */
  99927. reset(): void;
  99928. }
  99929. /**
  99930. * RollingAverage
  99931. *
  99932. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99933. */
  99934. export class RollingAverage {
  99935. /**
  99936. * Current average
  99937. */
  99938. average: number;
  99939. /**
  99940. * Current variance
  99941. */
  99942. variance: number;
  99943. protected _samples: Array<number>;
  99944. protected _sampleCount: number;
  99945. protected _pos: number;
  99946. protected _m2: number;
  99947. /**
  99948. * constructor
  99949. * @param length The number of samples required to saturate the sliding window
  99950. */
  99951. constructor(length: number);
  99952. /**
  99953. * Adds a sample to the sample set
  99954. * @param v The sample value
  99955. */
  99956. add(v: number): void;
  99957. /**
  99958. * Returns previously added values or null if outside of history or outside the sliding window domain
  99959. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99960. * @return Value previously recorded with add() or null if outside of range
  99961. */
  99962. history(i: number): number;
  99963. /**
  99964. * Returns true if enough samples have been taken to completely fill the sliding window
  99965. * @return true if sample-set saturated
  99966. */
  99967. isSaturated(): boolean;
  99968. /**
  99969. * Resets the rolling average (equivalent to 0 samples taken so far)
  99970. */
  99971. reset(): void;
  99972. /**
  99973. * Wraps a value around the sample range boundaries
  99974. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99975. * @return Wrapped position in sample range
  99976. */
  99977. protected _wrapPosition(i: number): number;
  99978. }
  99979. }
  99980. declare module BABYLON {
  99981. /**
  99982. * This class is used to track a performance counter which is number based.
  99983. * The user has access to many properties which give statistics of different nature.
  99984. *
  99985. * The implementer can track two kinds of Performance Counter: time and count.
  99986. * 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.
  99987. * 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.
  99988. */
  99989. export class PerfCounter {
  99990. /**
  99991. * Gets or sets a global boolean to turn on and off all the counters
  99992. */
  99993. static Enabled: boolean;
  99994. /**
  99995. * Returns the smallest value ever
  99996. */
  99997. readonly min: number;
  99998. /**
  99999. * Returns the biggest value ever
  100000. */
  100001. readonly max: number;
  100002. /**
  100003. * Returns the average value since the performance counter is running
  100004. */
  100005. readonly average: number;
  100006. /**
  100007. * Returns the average value of the last second the counter was monitored
  100008. */
  100009. readonly lastSecAverage: number;
  100010. /**
  100011. * Returns the current value
  100012. */
  100013. readonly current: number;
  100014. /**
  100015. * Gets the accumulated total
  100016. */
  100017. readonly total: number;
  100018. /**
  100019. * Gets the total value count
  100020. */
  100021. readonly count: number;
  100022. /**
  100023. * Creates a new counter
  100024. */
  100025. constructor();
  100026. /**
  100027. * Call this method to start monitoring a new frame.
  100028. * 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.
  100029. */
  100030. fetchNewFrame(): void;
  100031. /**
  100032. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  100033. * @param newCount the count value to add to the monitored count
  100034. * @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.
  100035. */
  100036. addCount(newCount: number, fetchResult: boolean): void;
  100037. /**
  100038. * Start monitoring this performance counter
  100039. */
  100040. beginMonitoring(): void;
  100041. /**
  100042. * Compute the time lapsed since the previous beginMonitoring() call.
  100043. * @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
  100044. */
  100045. endMonitoring(newFrame?: boolean): void;
  100046. private _fetchResult;
  100047. private _startMonitoringTime;
  100048. private _min;
  100049. private _max;
  100050. private _average;
  100051. private _current;
  100052. private _totalValueCount;
  100053. private _totalAccumulated;
  100054. private _lastSecAverage;
  100055. private _lastSecAccumulated;
  100056. private _lastSecTime;
  100057. private _lastSecValueCount;
  100058. }
  100059. }
  100060. declare module BABYLON {
  100061. /**
  100062. * Defines the interface used by display changed events
  100063. */
  100064. export interface IDisplayChangedEventArgs {
  100065. /** Gets the vrDisplay object (if any) */
  100066. vrDisplay: Nullable<any>;
  100067. /** Gets a boolean indicating if webVR is supported */
  100068. vrSupported: boolean;
  100069. }
  100070. /**
  100071. * Defines the interface used by objects containing a viewport (like a camera)
  100072. */
  100073. interface IViewportOwnerLike {
  100074. /**
  100075. * Gets or sets the viewport
  100076. */
  100077. viewport: IViewportLike;
  100078. }
  100079. /**
  100080. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  100081. */
  100082. export class Engine extends ThinEngine {
  100083. /** Defines that alpha blending is disabled */
  100084. static readonly ALPHA_DISABLE: number;
  100085. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  100086. static readonly ALPHA_ADD: number;
  100087. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  100088. static readonly ALPHA_COMBINE: number;
  100089. /** Defines that alpha blending to DEST - SRC * DEST */
  100090. static readonly ALPHA_SUBTRACT: number;
  100091. /** Defines that alpha blending to SRC * DEST */
  100092. static readonly ALPHA_MULTIPLY: number;
  100093. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  100094. static readonly ALPHA_MAXIMIZED: number;
  100095. /** Defines that alpha blending to SRC + DEST */
  100096. static readonly ALPHA_ONEONE: number;
  100097. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  100098. static readonly ALPHA_PREMULTIPLIED: number;
  100099. /**
  100100. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  100101. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  100102. */
  100103. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  100104. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  100105. static readonly ALPHA_INTERPOLATE: number;
  100106. /**
  100107. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  100108. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  100109. */
  100110. static readonly ALPHA_SCREENMODE: number;
  100111. /** Defines that the ressource is not delayed*/
  100112. static readonly DELAYLOADSTATE_NONE: number;
  100113. /** Defines that the ressource was successfully delay loaded */
  100114. static readonly DELAYLOADSTATE_LOADED: number;
  100115. /** Defines that the ressource is currently delay loading */
  100116. static readonly DELAYLOADSTATE_LOADING: number;
  100117. /** Defines that the ressource is delayed and has not started loading */
  100118. static readonly DELAYLOADSTATE_NOTLOADED: number;
  100119. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  100120. static readonly NEVER: number;
  100121. /** 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 */
  100122. static readonly ALWAYS: number;
  100123. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  100124. static readonly LESS: number;
  100125. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  100126. static readonly EQUAL: number;
  100127. /** 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 */
  100128. static readonly LEQUAL: number;
  100129. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  100130. static readonly GREATER: number;
  100131. /** 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 */
  100132. static readonly GEQUAL: number;
  100133. /** 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 */
  100134. static readonly NOTEQUAL: number;
  100135. /** Passed to stencilOperation to specify that stencil value must be kept */
  100136. static readonly KEEP: number;
  100137. /** Passed to stencilOperation to specify that stencil value must be replaced */
  100138. static readonly REPLACE: number;
  100139. /** Passed to stencilOperation to specify that stencil value must be incremented */
  100140. static readonly INCR: number;
  100141. /** Passed to stencilOperation to specify that stencil value must be decremented */
  100142. static readonly DECR: number;
  100143. /** Passed to stencilOperation to specify that stencil value must be inverted */
  100144. static readonly INVERT: number;
  100145. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  100146. static readonly INCR_WRAP: number;
  100147. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  100148. static readonly DECR_WRAP: number;
  100149. /** Texture is not repeating outside of 0..1 UVs */
  100150. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  100151. /** Texture is repeating outside of 0..1 UVs */
  100152. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  100153. /** Texture is repeating and mirrored */
  100154. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  100155. /** ALPHA */
  100156. static readonly TEXTUREFORMAT_ALPHA: number;
  100157. /** LUMINANCE */
  100158. static readonly TEXTUREFORMAT_LUMINANCE: number;
  100159. /** LUMINANCE_ALPHA */
  100160. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  100161. /** RGB */
  100162. static readonly TEXTUREFORMAT_RGB: number;
  100163. /** RGBA */
  100164. static readonly TEXTUREFORMAT_RGBA: number;
  100165. /** RED */
  100166. static readonly TEXTUREFORMAT_RED: number;
  100167. /** RED (2nd reference) */
  100168. static readonly TEXTUREFORMAT_R: number;
  100169. /** RG */
  100170. static readonly TEXTUREFORMAT_RG: number;
  100171. /** RED_INTEGER */
  100172. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  100173. /** RED_INTEGER (2nd reference) */
  100174. static readonly TEXTUREFORMAT_R_INTEGER: number;
  100175. /** RG_INTEGER */
  100176. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  100177. /** RGB_INTEGER */
  100178. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  100179. /** RGBA_INTEGER */
  100180. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  100181. /** UNSIGNED_BYTE */
  100182. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  100183. /** UNSIGNED_BYTE (2nd reference) */
  100184. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  100185. /** FLOAT */
  100186. static readonly TEXTURETYPE_FLOAT: number;
  100187. /** HALF_FLOAT */
  100188. static readonly TEXTURETYPE_HALF_FLOAT: number;
  100189. /** BYTE */
  100190. static readonly TEXTURETYPE_BYTE: number;
  100191. /** SHORT */
  100192. static readonly TEXTURETYPE_SHORT: number;
  100193. /** UNSIGNED_SHORT */
  100194. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  100195. /** INT */
  100196. static readonly TEXTURETYPE_INT: number;
  100197. /** UNSIGNED_INT */
  100198. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  100199. /** UNSIGNED_SHORT_4_4_4_4 */
  100200. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  100201. /** UNSIGNED_SHORT_5_5_5_1 */
  100202. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  100203. /** UNSIGNED_SHORT_5_6_5 */
  100204. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  100205. /** UNSIGNED_INT_2_10_10_10_REV */
  100206. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  100207. /** UNSIGNED_INT_24_8 */
  100208. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  100209. /** UNSIGNED_INT_10F_11F_11F_REV */
  100210. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  100211. /** UNSIGNED_INT_5_9_9_9_REV */
  100212. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  100213. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  100214. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  100215. /** nearest is mag = nearest and min = nearest and mip = linear */
  100216. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  100217. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100218. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  100219. /** Trilinear is mag = linear and min = linear and mip = linear */
  100220. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  100221. /** nearest is mag = nearest and min = nearest and mip = linear */
  100222. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  100223. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100224. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  100225. /** Trilinear is mag = linear and min = linear and mip = linear */
  100226. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  100227. /** mag = nearest and min = nearest and mip = nearest */
  100228. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  100229. /** mag = nearest and min = linear and mip = nearest */
  100230. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  100231. /** mag = nearest and min = linear and mip = linear */
  100232. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  100233. /** mag = nearest and min = linear and mip = none */
  100234. static readonly TEXTURE_NEAREST_LINEAR: number;
  100235. /** mag = nearest and min = nearest and mip = none */
  100236. static readonly TEXTURE_NEAREST_NEAREST: number;
  100237. /** mag = linear and min = nearest and mip = nearest */
  100238. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  100239. /** mag = linear and min = nearest and mip = linear */
  100240. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  100241. /** mag = linear and min = linear and mip = none */
  100242. static readonly TEXTURE_LINEAR_LINEAR: number;
  100243. /** mag = linear and min = nearest and mip = none */
  100244. static readonly TEXTURE_LINEAR_NEAREST: number;
  100245. /** Explicit coordinates mode */
  100246. static readonly TEXTURE_EXPLICIT_MODE: number;
  100247. /** Spherical coordinates mode */
  100248. static readonly TEXTURE_SPHERICAL_MODE: number;
  100249. /** Planar coordinates mode */
  100250. static readonly TEXTURE_PLANAR_MODE: number;
  100251. /** Cubic coordinates mode */
  100252. static readonly TEXTURE_CUBIC_MODE: number;
  100253. /** Projection coordinates mode */
  100254. static readonly TEXTURE_PROJECTION_MODE: number;
  100255. /** Skybox coordinates mode */
  100256. static readonly TEXTURE_SKYBOX_MODE: number;
  100257. /** Inverse Cubic coordinates mode */
  100258. static readonly TEXTURE_INVCUBIC_MODE: number;
  100259. /** Equirectangular coordinates mode */
  100260. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  100261. /** Equirectangular Fixed coordinates mode */
  100262. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  100263. /** Equirectangular Fixed Mirrored coordinates mode */
  100264. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100265. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  100266. static readonly SCALEMODE_FLOOR: number;
  100267. /** Defines that texture rescaling will look for the nearest power of 2 size */
  100268. static readonly SCALEMODE_NEAREST: number;
  100269. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  100270. static readonly SCALEMODE_CEILING: number;
  100271. /**
  100272. * Returns the current npm package of the sdk
  100273. */
  100274. static readonly NpmPackage: string;
  100275. /**
  100276. * Returns the current version of the framework
  100277. */
  100278. static readonly Version: string;
  100279. /** Gets the list of created engines */
  100280. static readonly Instances: Engine[];
  100281. /**
  100282. * Gets the latest created engine
  100283. */
  100284. static readonly LastCreatedEngine: Nullable<Engine>;
  100285. /**
  100286. * Gets the latest created scene
  100287. */
  100288. static readonly LastCreatedScene: Nullable<Scene>;
  100289. /**
  100290. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  100291. * @param flag defines which part of the materials must be marked as dirty
  100292. * @param predicate defines a predicate used to filter which materials should be affected
  100293. */
  100294. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100295. /**
  100296. * Method called to create the default loading screen.
  100297. * This can be overriden in your own app.
  100298. * @param canvas The rendering canvas element
  100299. * @returns The loading screen
  100300. */
  100301. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  100302. /**
  100303. * Method called to create the default rescale post process on each engine.
  100304. */
  100305. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  100306. /**
  100307. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  100308. **/
  100309. enableOfflineSupport: boolean;
  100310. /**
  100311. * 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)
  100312. **/
  100313. disableManifestCheck: boolean;
  100314. /**
  100315. * Gets the list of created scenes
  100316. */
  100317. scenes: Scene[];
  100318. /**
  100319. * Event raised when a new scene is created
  100320. */
  100321. onNewSceneAddedObservable: Observable<Scene>;
  100322. /**
  100323. * Gets the list of created postprocesses
  100324. */
  100325. postProcesses: PostProcess[];
  100326. /**
  100327. * Gets a boolean indicating if the pointer is currently locked
  100328. */
  100329. isPointerLock: boolean;
  100330. /**
  100331. * Observable event triggered each time the rendering canvas is resized
  100332. */
  100333. onResizeObservable: Observable<Engine>;
  100334. /**
  100335. * Observable event triggered each time the canvas loses focus
  100336. */
  100337. onCanvasBlurObservable: Observable<Engine>;
  100338. /**
  100339. * Observable event triggered each time the canvas gains focus
  100340. */
  100341. onCanvasFocusObservable: Observable<Engine>;
  100342. /**
  100343. * Observable event triggered each time the canvas receives pointerout event
  100344. */
  100345. onCanvasPointerOutObservable: Observable<PointerEvent>;
  100346. /**
  100347. * Observable raised when the engine begins a new frame
  100348. */
  100349. onBeginFrameObservable: Observable<Engine>;
  100350. /**
  100351. * If set, will be used to request the next animation frame for the render loop
  100352. */
  100353. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  100354. /**
  100355. * Observable raised when the engine ends the current frame
  100356. */
  100357. onEndFrameObservable: Observable<Engine>;
  100358. /**
  100359. * Observable raised when the engine is about to compile a shader
  100360. */
  100361. onBeforeShaderCompilationObservable: Observable<Engine>;
  100362. /**
  100363. * Observable raised when the engine has jsut compiled a shader
  100364. */
  100365. onAfterShaderCompilationObservable: Observable<Engine>;
  100366. /**
  100367. * Gets the audio engine
  100368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100369. * @ignorenaming
  100370. */
  100371. static audioEngine: IAudioEngine;
  100372. /**
  100373. * Default AudioEngine factory responsible of creating the Audio Engine.
  100374. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  100375. */
  100376. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  100377. /**
  100378. * Default offline support factory responsible of creating a tool used to store data locally.
  100379. * By default, this will create a Database object if the workload has been embedded.
  100380. */
  100381. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  100382. private _loadingScreen;
  100383. private _pointerLockRequested;
  100384. private _dummyFramebuffer;
  100385. private _rescalePostProcess;
  100386. /** @hidden */
  100387. protected _alphaMode: number;
  100388. /** @hidden */
  100389. protected _alphaEquation: number;
  100390. private _deterministicLockstep;
  100391. private _lockstepMaxSteps;
  100392. private _timeStep;
  100393. protected readonly _supportsHardwareTextureRescaling: boolean;
  100394. private _fps;
  100395. private _deltaTime;
  100396. /** @hidden */
  100397. _drawCalls: PerfCounter;
  100398. /**
  100399. * Turn this value on if you want to pause FPS computation when in background
  100400. */
  100401. disablePerformanceMonitorInBackground: boolean;
  100402. private _performanceMonitor;
  100403. /**
  100404. * Gets the performance monitor attached to this engine
  100405. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  100406. */
  100407. readonly performanceMonitor: PerformanceMonitor;
  100408. private _onFocus;
  100409. private _onBlur;
  100410. private _onCanvasPointerOut;
  100411. private _onCanvasBlur;
  100412. private _onCanvasFocus;
  100413. private _onFullscreenChange;
  100414. private _onPointerLockChange;
  100415. /**
  100416. * Gets the HTML element used to attach event listeners
  100417. * @returns a HTML element
  100418. */
  100419. getInputElement(): Nullable<HTMLElement>;
  100420. /**
  100421. * Creates a new engine
  100422. * @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
  100423. * @param antialias defines enable antialiasing (default: false)
  100424. * @param options defines further options to be sent to the getContext() function
  100425. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  100426. */
  100427. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  100428. /**
  100429. * Gets current aspect ratio
  100430. * @param viewportOwner defines the camera to use to get the aspect ratio
  100431. * @param useScreen defines if screen size must be used (or the current render target if any)
  100432. * @returns a number defining the aspect ratio
  100433. */
  100434. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  100435. /**
  100436. * Gets current screen aspect ratio
  100437. * @returns a number defining the aspect ratio
  100438. */
  100439. getScreenAspectRatio(): number;
  100440. /**
  100441. * Gets the client rect of the HTML canvas attached with the current webGL context
  100442. * @returns a client rectanglee
  100443. */
  100444. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  100445. /**
  100446. * Gets the client rect of the HTML element used for events
  100447. * @returns a client rectanglee
  100448. */
  100449. getInputElementClientRect(): Nullable<ClientRect>;
  100450. /**
  100451. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  100452. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100453. * @returns true if engine is in deterministic lock step mode
  100454. */
  100455. isDeterministicLockStep(): boolean;
  100456. /**
  100457. * Gets the max steps when engine is running in deterministic lock step
  100458. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100459. * @returns the max steps
  100460. */
  100461. getLockstepMaxSteps(): number;
  100462. /**
  100463. * Returns the time in ms between steps when using deterministic lock step.
  100464. * @returns time step in (ms)
  100465. */
  100466. getTimeStep(): number;
  100467. /**
  100468. * Force the mipmap generation for the given render target texture
  100469. * @param texture defines the render target texture to use
  100470. */
  100471. generateMipMapsForCubemap(texture: InternalTexture): void;
  100472. /** States */
  100473. /**
  100474. * Set various states to the webGL context
  100475. * @param culling defines backface culling state
  100476. * @param zOffset defines the value to apply to zOffset (0 by default)
  100477. * @param force defines if states must be applied even if cache is up to date
  100478. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  100479. */
  100480. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100481. /**
  100482. * Set the z offset to apply to current rendering
  100483. * @param value defines the offset to apply
  100484. */
  100485. setZOffset(value: number): void;
  100486. /**
  100487. * Gets the current value of the zOffset
  100488. * @returns the current zOffset state
  100489. */
  100490. getZOffset(): number;
  100491. /**
  100492. * Enable or disable depth buffering
  100493. * @param enable defines the state to set
  100494. */
  100495. setDepthBuffer(enable: boolean): void;
  100496. /**
  100497. * Gets a boolean indicating if depth writing is enabled
  100498. * @returns the current depth writing state
  100499. */
  100500. getDepthWrite(): boolean;
  100501. /**
  100502. * Enable or disable depth writing
  100503. * @param enable defines the state to set
  100504. */
  100505. setDepthWrite(enable: boolean): void;
  100506. /**
  100507. * Enable or disable color writing
  100508. * @param enable defines the state to set
  100509. */
  100510. setColorWrite(enable: boolean): void;
  100511. /**
  100512. * Gets a boolean indicating if color writing is enabled
  100513. * @returns the current color writing state
  100514. */
  100515. getColorWrite(): boolean;
  100516. /**
  100517. * Sets alpha constants used by some alpha blending modes
  100518. * @param r defines the red component
  100519. * @param g defines the green component
  100520. * @param b defines the blue component
  100521. * @param a defines the alpha component
  100522. */
  100523. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  100524. /**
  100525. * Sets the current alpha mode
  100526. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  100527. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  100528. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100529. */
  100530. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100531. /**
  100532. * Gets the current alpha mode
  100533. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100534. * @returns the current alpha mode
  100535. */
  100536. getAlphaMode(): number;
  100537. /**
  100538. * Sets the current alpha equation
  100539. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  100540. */
  100541. setAlphaEquation(equation: number): void;
  100542. /**
  100543. * Gets the current alpha equation.
  100544. * @returns the current alpha equation
  100545. */
  100546. getAlphaEquation(): number;
  100547. /**
  100548. * Gets a boolean indicating if stencil buffer is enabled
  100549. * @returns the current stencil buffer state
  100550. */
  100551. getStencilBuffer(): boolean;
  100552. /**
  100553. * Enable or disable the stencil buffer
  100554. * @param enable defines if the stencil buffer must be enabled or disabled
  100555. */
  100556. setStencilBuffer(enable: boolean): void;
  100557. /**
  100558. * Gets the current stencil mask
  100559. * @returns a number defining the new stencil mask to use
  100560. */
  100561. getStencilMask(): number;
  100562. /**
  100563. * Sets the current stencil mask
  100564. * @param mask defines the new stencil mask to use
  100565. */
  100566. setStencilMask(mask: number): void;
  100567. /**
  100568. * Gets the current stencil function
  100569. * @returns a number defining the stencil function to use
  100570. */
  100571. getStencilFunction(): number;
  100572. /**
  100573. * Gets the current stencil reference value
  100574. * @returns a number defining the stencil reference value to use
  100575. */
  100576. getStencilFunctionReference(): number;
  100577. /**
  100578. * Gets the current stencil mask
  100579. * @returns a number defining the stencil mask to use
  100580. */
  100581. getStencilFunctionMask(): number;
  100582. /**
  100583. * Sets the current stencil function
  100584. * @param stencilFunc defines the new stencil function to use
  100585. */
  100586. setStencilFunction(stencilFunc: number): void;
  100587. /**
  100588. * Sets the current stencil reference
  100589. * @param reference defines the new stencil reference to use
  100590. */
  100591. setStencilFunctionReference(reference: number): void;
  100592. /**
  100593. * Sets the current stencil mask
  100594. * @param mask defines the new stencil mask to use
  100595. */
  100596. setStencilFunctionMask(mask: number): void;
  100597. /**
  100598. * Gets the current stencil operation when stencil fails
  100599. * @returns a number defining stencil operation to use when stencil fails
  100600. */
  100601. getStencilOperationFail(): number;
  100602. /**
  100603. * Gets the current stencil operation when depth fails
  100604. * @returns a number defining stencil operation to use when depth fails
  100605. */
  100606. getStencilOperationDepthFail(): number;
  100607. /**
  100608. * Gets the current stencil operation when stencil passes
  100609. * @returns a number defining stencil operation to use when stencil passes
  100610. */
  100611. getStencilOperationPass(): number;
  100612. /**
  100613. * Sets the stencil operation to use when stencil fails
  100614. * @param operation defines the stencil operation to use when stencil fails
  100615. */
  100616. setStencilOperationFail(operation: number): void;
  100617. /**
  100618. * Sets the stencil operation to use when depth fails
  100619. * @param operation defines the stencil operation to use when depth fails
  100620. */
  100621. setStencilOperationDepthFail(operation: number): void;
  100622. /**
  100623. * Sets the stencil operation to use when stencil passes
  100624. * @param operation defines the stencil operation to use when stencil passes
  100625. */
  100626. setStencilOperationPass(operation: number): void;
  100627. /**
  100628. * Sets a boolean indicating if the dithering state is enabled or disabled
  100629. * @param value defines the dithering state
  100630. */
  100631. setDitheringState(value: boolean): void;
  100632. /**
  100633. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  100634. * @param value defines the rasterizer state
  100635. */
  100636. setRasterizerState(value: boolean): void;
  100637. /**
  100638. * Gets the current depth function
  100639. * @returns a number defining the depth function
  100640. */
  100641. getDepthFunction(): Nullable<number>;
  100642. /**
  100643. * Sets the current depth function
  100644. * @param depthFunc defines the function to use
  100645. */
  100646. setDepthFunction(depthFunc: number): void;
  100647. /**
  100648. * Sets the current depth function to GREATER
  100649. */
  100650. setDepthFunctionToGreater(): void;
  100651. /**
  100652. * Sets the current depth function to GEQUAL
  100653. */
  100654. setDepthFunctionToGreaterOrEqual(): void;
  100655. /**
  100656. * Sets the current depth function to LESS
  100657. */
  100658. setDepthFunctionToLess(): void;
  100659. /**
  100660. * Sets the current depth function to LEQUAL
  100661. */
  100662. setDepthFunctionToLessOrEqual(): void;
  100663. private _cachedStencilBuffer;
  100664. private _cachedStencilFunction;
  100665. private _cachedStencilMask;
  100666. private _cachedStencilOperationPass;
  100667. private _cachedStencilOperationFail;
  100668. private _cachedStencilOperationDepthFail;
  100669. private _cachedStencilReference;
  100670. /**
  100671. * Caches the the state of the stencil buffer
  100672. */
  100673. cacheStencilState(): void;
  100674. /**
  100675. * Restores the state of the stencil buffer
  100676. */
  100677. restoreStencilState(): void;
  100678. /**
  100679. * Directly set the WebGL Viewport
  100680. * @param x defines the x coordinate of the viewport (in screen space)
  100681. * @param y defines the y coordinate of the viewport (in screen space)
  100682. * @param width defines the width of the viewport (in screen space)
  100683. * @param height defines the height of the viewport (in screen space)
  100684. * @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
  100685. */
  100686. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  100687. /**
  100688. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  100689. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100690. * @param y defines the y-coordinate of the corner of the clear rectangle
  100691. * @param width defines the width of the clear rectangle
  100692. * @param height defines the height of the clear rectangle
  100693. * @param clearColor defines the clear color
  100694. */
  100695. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  100696. /**
  100697. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  100698. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100699. * @param y defines the y-coordinate of the corner of the clear rectangle
  100700. * @param width defines the width of the clear rectangle
  100701. * @param height defines the height of the clear rectangle
  100702. */
  100703. enableScissor(x: number, y: number, width: number, height: number): void;
  100704. /**
  100705. * Disable previously set scissor test rectangle
  100706. */
  100707. disableScissor(): void;
  100708. protected _reportDrawCall(): void;
  100709. /**
  100710. * Initializes a webVR display and starts listening to display change events
  100711. * The onVRDisplayChangedObservable will be notified upon these changes
  100712. * @returns The onVRDisplayChangedObservable
  100713. */
  100714. initWebVR(): Observable<IDisplayChangedEventArgs>;
  100715. /** @hidden */
  100716. _prepareVRComponent(): void;
  100717. /** @hidden */
  100718. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  100719. /** @hidden */
  100720. _submitVRFrame(): void;
  100721. /**
  100722. * Call this function to leave webVR mode
  100723. * Will do nothing if webVR is not supported or if there is no webVR device
  100724. * @see http://doc.babylonjs.com/how_to/webvr_camera
  100725. */
  100726. disableVR(): void;
  100727. /**
  100728. * Gets a boolean indicating that the system is in VR mode and is presenting
  100729. * @returns true if VR mode is engaged
  100730. */
  100731. isVRPresenting(): boolean;
  100732. /** @hidden */
  100733. _requestVRFrame(): void;
  100734. /** @hidden */
  100735. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100736. /**
  100737. * Gets the source code of the vertex shader associated with a specific webGL program
  100738. * @param program defines the program to use
  100739. * @returns a string containing the source code of the vertex shader associated with the program
  100740. */
  100741. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  100742. /**
  100743. * Gets the source code of the fragment shader associated with a specific webGL program
  100744. * @param program defines the program to use
  100745. * @returns a string containing the source code of the fragment shader associated with the program
  100746. */
  100747. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  100748. /**
  100749. * Reads pixels from the current frame buffer. Please note that this function can be slow
  100750. * @param x defines the x coordinate of the rectangle where pixels must be read
  100751. * @param y defines the y coordinate of the rectangle where pixels must be read
  100752. * @param width defines the width of the rectangle where pixels must be read
  100753. * @param height defines the height of the rectangle where pixels must be read
  100754. * @returns a Uint8Array containing RGBA colors
  100755. */
  100756. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  100757. /**
  100758. * Sets a depth stencil texture from a render target to the according uniform.
  100759. * @param channel The texture channel
  100760. * @param uniform The uniform to set
  100761. * @param texture The render target texture containing the depth stencil texture to apply
  100762. */
  100763. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  100764. /**
  100765. * Sets a texture to the webGL context from a postprocess
  100766. * @param channel defines the channel to use
  100767. * @param postProcess defines the source postprocess
  100768. */
  100769. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  100770. /**
  100771. * Binds the output of the passed in post process to the texture channel specified
  100772. * @param channel The channel the texture should be bound to
  100773. * @param postProcess The post process which's output should be bound
  100774. */
  100775. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  100776. /** @hidden */
  100777. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  100778. protected _rebuildBuffers(): void;
  100779. /** @hidden */
  100780. _renderFrame(): void;
  100781. _renderLoop(): void;
  100782. /** @hidden */
  100783. _renderViews(): boolean;
  100784. /**
  100785. * Toggle full screen mode
  100786. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100787. */
  100788. switchFullscreen(requestPointerLock: boolean): void;
  100789. /**
  100790. * Enters full screen mode
  100791. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100792. */
  100793. enterFullscreen(requestPointerLock: boolean): void;
  100794. /**
  100795. * Exits full screen mode
  100796. */
  100797. exitFullscreen(): void;
  100798. /**
  100799. * Enters Pointerlock mode
  100800. */
  100801. enterPointerlock(): void;
  100802. /**
  100803. * Exits Pointerlock mode
  100804. */
  100805. exitPointerlock(): void;
  100806. /**
  100807. * Begin a new frame
  100808. */
  100809. beginFrame(): void;
  100810. /**
  100811. * Enf the current frame
  100812. */
  100813. endFrame(): void;
  100814. resize(): void;
  100815. /**
  100816. * Set the compressed texture format to use, based on the formats you have, and the formats
  100817. * supported by the hardware / browser.
  100818. *
  100819. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  100820. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  100821. * to API arguments needed to compressed textures. This puts the burden on the container
  100822. * generator to house the arcane code for determining these for current & future formats.
  100823. *
  100824. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  100825. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  100826. *
  100827. * Note: The result of this call is not taken into account when a texture is base64.
  100828. *
  100829. * @param formatsAvailable defines the list of those format families you have created
  100830. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  100831. *
  100832. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  100833. * @returns The extension selected.
  100834. */
  100835. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100836. /**
  100837. * Force a specific size of the canvas
  100838. * @param width defines the new canvas' width
  100839. * @param height defines the new canvas' height
  100840. */
  100841. setSize(width: number, height: number): void;
  100842. /**
  100843. * Updates a dynamic vertex buffer.
  100844. * @param vertexBuffer the vertex buffer to update
  100845. * @param data the data used to update the vertex buffer
  100846. * @param byteOffset the byte offset of the data
  100847. * @param byteLength the byte length of the data
  100848. */
  100849. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100850. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100851. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100852. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100853. _releaseTexture(texture: InternalTexture): void;
  100854. /**
  100855. * @hidden
  100856. * Rescales a texture
  100857. * @param source input texutre
  100858. * @param destination destination texture
  100859. * @param scene scene to use to render the resize
  100860. * @param internalFormat format to use when resizing
  100861. * @param onComplete callback to be called when resize has completed
  100862. */
  100863. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100864. /**
  100865. * Gets the current framerate
  100866. * @returns a number representing the framerate
  100867. */
  100868. getFps(): number;
  100869. /**
  100870. * Gets the time spent between current and previous frame
  100871. * @returns a number representing the delta time in ms
  100872. */
  100873. getDeltaTime(): number;
  100874. private _measureFps;
  100875. /** @hidden */
  100876. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100877. /**
  100878. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100879. * @param renderTarget The render target to set the frame buffer for
  100880. */
  100881. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100882. /**
  100883. * Update a dynamic index buffer
  100884. * @param indexBuffer defines the target index buffer
  100885. * @param indices defines the data to update
  100886. * @param offset defines the offset in the target index buffer where update should start
  100887. */
  100888. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100889. /**
  100890. * Updates the sample count of a render target texture
  100891. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100892. * @param texture defines the texture to update
  100893. * @param samples defines the sample count to set
  100894. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100895. */
  100896. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100897. /**
  100898. * Updates a depth texture Comparison Mode and Function.
  100899. * If the comparison Function is equal to 0, the mode will be set to none.
  100900. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100901. * @param texture The texture to set the comparison function for
  100902. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100903. */
  100904. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100905. /**
  100906. * Creates a webGL buffer to use with instanciation
  100907. * @param capacity defines the size of the buffer
  100908. * @returns the webGL buffer
  100909. */
  100910. createInstancesBuffer(capacity: number): DataBuffer;
  100911. /**
  100912. * Delete a webGL buffer used with instanciation
  100913. * @param buffer defines the webGL buffer to delete
  100914. */
  100915. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100916. /** @hidden */
  100917. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100918. dispose(): void;
  100919. private _disableTouchAction;
  100920. /**
  100921. * Display the loading screen
  100922. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100923. */
  100924. displayLoadingUI(): void;
  100925. /**
  100926. * Hide the loading screen
  100927. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100928. */
  100929. hideLoadingUI(): void;
  100930. /**
  100931. * Gets the current loading screen object
  100932. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100933. */
  100934. /**
  100935. * Sets the current loading screen object
  100936. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100937. */
  100938. loadingScreen: ILoadingScreen;
  100939. /**
  100940. * Sets the current loading screen text
  100941. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100942. */
  100943. loadingUIText: string;
  100944. /**
  100945. * Sets the current loading screen background color
  100946. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100947. */
  100948. loadingUIBackgroundColor: string;
  100949. /** Pointerlock and fullscreen */
  100950. /**
  100951. * Ask the browser to promote the current element to pointerlock mode
  100952. * @param element defines the DOM element to promote
  100953. */
  100954. static _RequestPointerlock(element: HTMLElement): void;
  100955. /**
  100956. * Asks the browser to exit pointerlock mode
  100957. */
  100958. static _ExitPointerlock(): void;
  100959. /**
  100960. * Ask the browser to promote the current element to fullscreen rendering mode
  100961. * @param element defines the DOM element to promote
  100962. */
  100963. static _RequestFullscreen(element: HTMLElement): void;
  100964. /**
  100965. * Asks the browser to exit fullscreen mode
  100966. */
  100967. static _ExitFullscreen(): void;
  100968. }
  100969. }
  100970. declare module BABYLON {
  100971. /**
  100972. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100973. * during the life time of the application.
  100974. */
  100975. export class EngineStore {
  100976. /** Gets the list of created engines */
  100977. static Instances: Engine[];
  100978. /** @hidden */
  100979. static _LastCreatedScene: Nullable<Scene>;
  100980. /**
  100981. * Gets the latest created engine
  100982. */
  100983. static readonly LastCreatedEngine: Nullable<Engine>;
  100984. /**
  100985. * Gets the latest created scene
  100986. */
  100987. static readonly LastCreatedScene: Nullable<Scene>;
  100988. /**
  100989. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100990. * @ignorenaming
  100991. */
  100992. static UseFallbackTexture: boolean;
  100993. /**
  100994. * Texture content used if a texture cannot loaded
  100995. * @ignorenaming
  100996. */
  100997. static FallbackTexture: string;
  100998. }
  100999. }
  101000. declare module BABYLON {
  101001. /**
  101002. * Helper class that provides a small promise polyfill
  101003. */
  101004. export class PromisePolyfill {
  101005. /**
  101006. * Static function used to check if the polyfill is required
  101007. * If this is the case then the function will inject the polyfill to window.Promise
  101008. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  101009. */
  101010. static Apply(force?: boolean): void;
  101011. }
  101012. }
  101013. declare module BABYLON {
  101014. /**
  101015. * Interface for screenshot methods with describe argument called `size` as object with options
  101016. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  101017. */
  101018. export interface IScreenshotSize {
  101019. /**
  101020. * number in pixels for canvas height
  101021. */
  101022. height?: number;
  101023. /**
  101024. * multiplier allowing render at a higher or lower resolution
  101025. * If value is defined then height and width will be ignored and taken from camera
  101026. */
  101027. precision?: number;
  101028. /**
  101029. * number in pixels for canvas width
  101030. */
  101031. width?: number;
  101032. }
  101033. }
  101034. declare module BABYLON {
  101035. interface IColor4Like {
  101036. r: float;
  101037. g: float;
  101038. b: float;
  101039. a: float;
  101040. }
  101041. /**
  101042. * Class containing a set of static utilities functions
  101043. */
  101044. export class Tools {
  101045. /**
  101046. * Gets or sets the base URL to use to load assets
  101047. */
  101048. static BaseUrl: string;
  101049. /**
  101050. * Enable/Disable Custom HTTP Request Headers globally.
  101051. * default = false
  101052. * @see CustomRequestHeaders
  101053. */
  101054. static UseCustomRequestHeaders: boolean;
  101055. /**
  101056. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  101057. * i.e. when loading files, where the server/service expects an Authorization header
  101058. */
  101059. static CustomRequestHeaders: {
  101060. [key: string]: string;
  101061. };
  101062. /**
  101063. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  101064. */
  101065. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  101066. /**
  101067. * Default behaviour for cors in the application.
  101068. * It can be a string if the expected behavior is identical in the entire app.
  101069. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  101070. */
  101071. static CorsBehavior: string | ((url: string | string[]) => string);
  101072. /**
  101073. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  101074. * @ignorenaming
  101075. */
  101076. static UseFallbackTexture: boolean;
  101077. /**
  101078. * Use this object to register external classes like custom textures or material
  101079. * to allow the laoders to instantiate them
  101080. */
  101081. static RegisteredExternalClasses: {
  101082. [key: string]: Object;
  101083. };
  101084. /**
  101085. * Texture content used if a texture cannot loaded
  101086. * @ignorenaming
  101087. */
  101088. static fallbackTexture: string;
  101089. /**
  101090. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  101091. * @param u defines the coordinate on X axis
  101092. * @param v defines the coordinate on Y axis
  101093. * @param width defines the width of the source data
  101094. * @param height defines the height of the source data
  101095. * @param pixels defines the source byte array
  101096. * @param color defines the output color
  101097. */
  101098. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  101099. /**
  101100. * Interpolates between a and b via alpha
  101101. * @param a The lower value (returned when alpha = 0)
  101102. * @param b The upper value (returned when alpha = 1)
  101103. * @param alpha The interpolation-factor
  101104. * @return The mixed value
  101105. */
  101106. static Mix(a: number, b: number, alpha: number): number;
  101107. /**
  101108. * Tries to instantiate a new object from a given class name
  101109. * @param className defines the class name to instantiate
  101110. * @returns the new object or null if the system was not able to do the instantiation
  101111. */
  101112. static Instantiate(className: string): any;
  101113. /**
  101114. * Provides a slice function that will work even on IE
  101115. * @param data defines the array to slice
  101116. * @param start defines the start of the data (optional)
  101117. * @param end defines the end of the data (optional)
  101118. * @returns the new sliced array
  101119. */
  101120. static Slice<T>(data: T, start?: number, end?: number): T;
  101121. /**
  101122. * Polyfill for setImmediate
  101123. * @param action defines the action to execute after the current execution block
  101124. */
  101125. static SetImmediate(action: () => void): void;
  101126. /**
  101127. * Function indicating if a number is an exponent of 2
  101128. * @param value defines the value to test
  101129. * @returns true if the value is an exponent of 2
  101130. */
  101131. static IsExponentOfTwo(value: number): boolean;
  101132. private static _tmpFloatArray;
  101133. /**
  101134. * Returns the nearest 32-bit single precision float representation of a Number
  101135. * @param value A Number. If the parameter is of a different type, it will get converted
  101136. * to a number or to NaN if it cannot be converted
  101137. * @returns number
  101138. */
  101139. static FloatRound(value: number): number;
  101140. /**
  101141. * Extracts the filename from a path
  101142. * @param path defines the path to use
  101143. * @returns the filename
  101144. */
  101145. static GetFilename(path: string): string;
  101146. /**
  101147. * Extracts the "folder" part of a path (everything before the filename).
  101148. * @param uri The URI to extract the info from
  101149. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  101150. * @returns The "folder" part of the path
  101151. */
  101152. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  101153. /**
  101154. * Extracts text content from a DOM element hierarchy
  101155. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  101156. */
  101157. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  101158. /**
  101159. * Convert an angle in radians to degrees
  101160. * @param angle defines the angle to convert
  101161. * @returns the angle in degrees
  101162. */
  101163. static ToDegrees(angle: number): number;
  101164. /**
  101165. * Convert an angle in degrees to radians
  101166. * @param angle defines the angle to convert
  101167. * @returns the angle in radians
  101168. */
  101169. static ToRadians(angle: number): number;
  101170. /**
  101171. * Returns an array if obj is not an array
  101172. * @param obj defines the object to evaluate as an array
  101173. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  101174. * @returns either obj directly if obj is an array or a new array containing obj
  101175. */
  101176. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  101177. /**
  101178. * Gets the pointer prefix to use
  101179. * @returns "pointer" if touch is enabled. Else returns "mouse"
  101180. */
  101181. static GetPointerPrefix(): string;
  101182. /**
  101183. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  101184. * @param url define the url we are trying
  101185. * @param element define the dom element where to configure the cors policy
  101186. */
  101187. static SetCorsBehavior(url: string | string[], element: {
  101188. crossOrigin: string | null;
  101189. }): void;
  101190. /**
  101191. * Removes unwanted characters from an url
  101192. * @param url defines the url to clean
  101193. * @returns the cleaned url
  101194. */
  101195. static CleanUrl(url: string): string;
  101196. /**
  101197. * Gets or sets a function used to pre-process url before using them to load assets
  101198. */
  101199. static PreprocessUrl: (url: string) => string;
  101200. /**
  101201. * Loads an image as an HTMLImageElement.
  101202. * @param input url string, ArrayBuffer, or Blob to load
  101203. * @param onLoad callback called when the image successfully loads
  101204. * @param onError callback called when the image fails to load
  101205. * @param offlineProvider offline provider for caching
  101206. * @param mimeType optional mime type
  101207. * @returns the HTMLImageElement of the loaded image
  101208. */
  101209. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  101210. /**
  101211. * Loads a file from a url
  101212. * @param url url string, ArrayBuffer, or Blob to load
  101213. * @param onSuccess callback called when the file successfully loads
  101214. * @param onProgress callback called while file is loading (if the server supports this mode)
  101215. * @param offlineProvider defines the offline provider for caching
  101216. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  101217. * @param onError callback called when the file fails to load
  101218. * @returns a file request object
  101219. */
  101220. 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;
  101221. /**
  101222. * Loads a file from a url
  101223. * @param url the file url to load
  101224. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  101225. */
  101226. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  101227. /**
  101228. * Load a script (identified by an url). When the url returns, the
  101229. * content of this file is added into a new script element, attached to the DOM (body element)
  101230. * @param scriptUrl defines the url of the script to laod
  101231. * @param onSuccess defines the callback called when the script is loaded
  101232. * @param onError defines the callback to call if an error occurs
  101233. * @param scriptId defines the id of the script element
  101234. */
  101235. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  101236. /**
  101237. * Load an asynchronous script (identified by an url). When the url returns, the
  101238. * content of this file is added into a new script element, attached to the DOM (body element)
  101239. * @param scriptUrl defines the url of the script to laod
  101240. * @param scriptId defines the id of the script element
  101241. * @returns a promise request object
  101242. */
  101243. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  101244. /**
  101245. * Loads a file from a blob
  101246. * @param fileToLoad defines the blob to use
  101247. * @param callback defines the callback to call when data is loaded
  101248. * @param progressCallback defines the callback to call during loading process
  101249. * @returns a file request object
  101250. */
  101251. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  101252. /**
  101253. * Reads a file from a File object
  101254. * @param file defines the file to load
  101255. * @param onSuccess defines the callback to call when data is loaded
  101256. * @param onProgress defines the callback to call during loading process
  101257. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  101258. * @param onError defines the callback to call when an error occurs
  101259. * @returns a file request object
  101260. */
  101261. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  101262. /**
  101263. * Creates a data url from a given string content
  101264. * @param content defines the content to convert
  101265. * @returns the new data url link
  101266. */
  101267. static FileAsURL(content: string): string;
  101268. /**
  101269. * Format the given number to a specific decimal format
  101270. * @param value defines the number to format
  101271. * @param decimals defines the number of decimals to use
  101272. * @returns the formatted string
  101273. */
  101274. static Format(value: number, decimals?: number): string;
  101275. /**
  101276. * Tries to copy an object by duplicating every property
  101277. * @param source defines the source object
  101278. * @param destination defines the target object
  101279. * @param doNotCopyList defines a list of properties to avoid
  101280. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  101281. */
  101282. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  101283. /**
  101284. * Gets a boolean indicating if the given object has no own property
  101285. * @param obj defines the object to test
  101286. * @returns true if object has no own property
  101287. */
  101288. static IsEmpty(obj: any): boolean;
  101289. /**
  101290. * Function used to register events at window level
  101291. * @param windowElement defines the Window object to use
  101292. * @param events defines the events to register
  101293. */
  101294. static RegisterTopRootEvents(windowElement: Window, events: {
  101295. name: string;
  101296. handler: Nullable<(e: FocusEvent) => any>;
  101297. }[]): void;
  101298. /**
  101299. * Function used to unregister events from window level
  101300. * @param windowElement defines the Window object to use
  101301. * @param events defines the events to unregister
  101302. */
  101303. static UnregisterTopRootEvents(windowElement: Window, events: {
  101304. name: string;
  101305. handler: Nullable<(e: FocusEvent) => any>;
  101306. }[]): void;
  101307. /**
  101308. * @ignore
  101309. */
  101310. static _ScreenshotCanvas: HTMLCanvasElement;
  101311. /**
  101312. * Dumps the current bound framebuffer
  101313. * @param width defines the rendering width
  101314. * @param height defines the rendering height
  101315. * @param engine defines the hosting engine
  101316. * @param successCallback defines the callback triggered once the data are available
  101317. * @param mimeType defines the mime type of the result
  101318. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  101319. */
  101320. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  101321. /**
  101322. * Converts the canvas data to blob.
  101323. * This acts as a polyfill for browsers not supporting the to blob function.
  101324. * @param canvas Defines the canvas to extract the data from
  101325. * @param successCallback Defines the callback triggered once the data are available
  101326. * @param mimeType Defines the mime type of the result
  101327. */
  101328. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  101329. /**
  101330. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  101331. * @param successCallback defines the callback triggered once the data are available
  101332. * @param mimeType defines the mime type of the result
  101333. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  101334. */
  101335. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  101336. /**
  101337. * Downloads a blob in the browser
  101338. * @param blob defines the blob to download
  101339. * @param fileName defines the name of the downloaded file
  101340. */
  101341. static Download(blob: Blob, fileName: string): void;
  101342. /**
  101343. * Captures a screenshot of the current rendering
  101344. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101345. * @param engine defines the rendering engine
  101346. * @param camera defines the source camera
  101347. * @param size This parameter can be set to a single number or to an object with the
  101348. * following (optional) properties: precision, width, height. If a single number is passed,
  101349. * it will be used for both width and height. If an object is passed, the screenshot size
  101350. * will be derived from the parameters. The precision property is a multiplier allowing
  101351. * rendering at a higher or lower resolution
  101352. * @param successCallback defines the callback receives a single parameter which contains the
  101353. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101354. * src parameter of an <img> to display it
  101355. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  101356. * Check your browser for supported MIME types
  101357. */
  101358. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  101359. /**
  101360. * Captures a screenshot of the current rendering
  101361. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101362. * @param engine defines the rendering engine
  101363. * @param camera defines the source camera
  101364. * @param size This parameter can be set to a single number or to an object with the
  101365. * following (optional) properties: precision, width, height. If a single number is passed,
  101366. * it will be used for both width and height. If an object is passed, the screenshot size
  101367. * will be derived from the parameters. The precision property is a multiplier allowing
  101368. * rendering at a higher or lower resolution
  101369. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  101370. * Check your browser for supported MIME types
  101371. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  101372. * to the src parameter of an <img> to display it
  101373. */
  101374. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  101375. /**
  101376. * Generates an image screenshot from the specified camera.
  101377. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101378. * @param engine The engine to use for rendering
  101379. * @param camera The camera to use for rendering
  101380. * @param size This parameter can be set to a single number or to an object with the
  101381. * following (optional) properties: precision, width, height. If a single number is passed,
  101382. * it will be used for both width and height. If an object is passed, the screenshot size
  101383. * will be derived from the parameters. The precision property is a multiplier allowing
  101384. * rendering at a higher or lower resolution
  101385. * @param successCallback The callback receives a single parameter which contains the
  101386. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101387. * src parameter of an <img> to display it
  101388. * @param mimeType The MIME type of the screenshot image (default: image/png).
  101389. * Check your browser for supported MIME types
  101390. * @param samples Texture samples (default: 1)
  101391. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  101392. * @param fileName A name for for the downloaded file.
  101393. */
  101394. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  101395. /**
  101396. * Generates an image screenshot from the specified camera.
  101397. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101398. * @param engine The engine to use for rendering
  101399. * @param camera The camera to use for rendering
  101400. * @param size This parameter can be set to a single number or to an object with the
  101401. * following (optional) properties: precision, width, height. If a single number is passed,
  101402. * it will be used for both width and height. If an object is passed, the screenshot size
  101403. * will be derived from the parameters. The precision property is a multiplier allowing
  101404. * rendering at a higher or lower resolution
  101405. * @param mimeType The MIME type of the screenshot image (default: image/png).
  101406. * Check your browser for supported MIME types
  101407. * @param samples Texture samples (default: 1)
  101408. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  101409. * @param fileName A name for for the downloaded file.
  101410. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  101411. * to the src parameter of an <img> to display it
  101412. */
  101413. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  101414. /**
  101415. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101416. * Be aware Math.random() could cause collisions, but:
  101417. * "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"
  101418. * @returns a pseudo random id
  101419. */
  101420. static RandomId(): string;
  101421. /**
  101422. * Test if the given uri is a base64 string
  101423. * @param uri The uri to test
  101424. * @return True if the uri is a base64 string or false otherwise
  101425. */
  101426. static IsBase64(uri: string): boolean;
  101427. /**
  101428. * Decode the given base64 uri.
  101429. * @param uri The uri to decode
  101430. * @return The decoded base64 data.
  101431. */
  101432. static DecodeBase64(uri: string): ArrayBuffer;
  101433. /**
  101434. * Gets the absolute url.
  101435. * @param url the input url
  101436. * @return the absolute url
  101437. */
  101438. static GetAbsoluteUrl(url: string): string;
  101439. /**
  101440. * No log
  101441. */
  101442. static readonly NoneLogLevel: number;
  101443. /**
  101444. * Only message logs
  101445. */
  101446. static readonly MessageLogLevel: number;
  101447. /**
  101448. * Only warning logs
  101449. */
  101450. static readonly WarningLogLevel: number;
  101451. /**
  101452. * Only error logs
  101453. */
  101454. static readonly ErrorLogLevel: number;
  101455. /**
  101456. * All logs
  101457. */
  101458. static readonly AllLogLevel: number;
  101459. /**
  101460. * Gets a value indicating the number of loading errors
  101461. * @ignorenaming
  101462. */
  101463. static readonly errorsCount: number;
  101464. /**
  101465. * Callback called when a new log is added
  101466. */
  101467. static OnNewCacheEntry: (entry: string) => void;
  101468. /**
  101469. * Log a message to the console
  101470. * @param message defines the message to log
  101471. */
  101472. static Log(message: string): void;
  101473. /**
  101474. * Write a warning message to the console
  101475. * @param message defines the message to log
  101476. */
  101477. static Warn(message: string): void;
  101478. /**
  101479. * Write an error message to the console
  101480. * @param message defines the message to log
  101481. */
  101482. static Error(message: string): void;
  101483. /**
  101484. * Gets current log cache (list of logs)
  101485. */
  101486. static readonly LogCache: string;
  101487. /**
  101488. * Clears the log cache
  101489. */
  101490. static ClearLogCache(): void;
  101491. /**
  101492. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  101493. */
  101494. static LogLevels: number;
  101495. /**
  101496. * Checks if the window object exists
  101497. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  101498. */
  101499. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  101500. /**
  101501. * No performance log
  101502. */
  101503. static readonly PerformanceNoneLogLevel: number;
  101504. /**
  101505. * Use user marks to log performance
  101506. */
  101507. static readonly PerformanceUserMarkLogLevel: number;
  101508. /**
  101509. * Log performance to the console
  101510. */
  101511. static readonly PerformanceConsoleLogLevel: number;
  101512. private static _performance;
  101513. /**
  101514. * Sets the current performance log level
  101515. */
  101516. static PerformanceLogLevel: number;
  101517. private static _StartPerformanceCounterDisabled;
  101518. private static _EndPerformanceCounterDisabled;
  101519. private static _StartUserMark;
  101520. private static _EndUserMark;
  101521. private static _StartPerformanceConsole;
  101522. private static _EndPerformanceConsole;
  101523. /**
  101524. * Starts a performance counter
  101525. */
  101526. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  101527. /**
  101528. * Ends a specific performance coutner
  101529. */
  101530. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  101531. /**
  101532. * Gets either window.performance.now() if supported or Date.now() else
  101533. */
  101534. static readonly Now: number;
  101535. /**
  101536. * This method will return the name of the class used to create the instance of the given object.
  101537. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  101538. * @param object the object to get the class name from
  101539. * @param isType defines if the object is actually a type
  101540. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  101541. */
  101542. static GetClassName(object: any, isType?: boolean): string;
  101543. /**
  101544. * Gets the first element of an array satisfying a given predicate
  101545. * @param array defines the array to browse
  101546. * @param predicate defines the predicate to use
  101547. * @returns null if not found or the element
  101548. */
  101549. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  101550. /**
  101551. * This method will return the name of the full name of the class, including its owning module (if any).
  101552. * 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).
  101553. * @param object the object to get the class name from
  101554. * @param isType defines if the object is actually a type
  101555. * @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.
  101556. * @ignorenaming
  101557. */
  101558. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  101559. /**
  101560. * Returns a promise that resolves after the given amount of time.
  101561. * @param delay Number of milliseconds to delay
  101562. * @returns Promise that resolves after the given amount of time
  101563. */
  101564. static DelayAsync(delay: number): Promise<void>;
  101565. }
  101566. /**
  101567. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  101568. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  101569. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  101570. * @param name The name of the class, case should be preserved
  101571. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  101572. */
  101573. export function className(name: string, module?: string): (target: Object) => void;
  101574. /**
  101575. * An implementation of a loop for asynchronous functions.
  101576. */
  101577. export class AsyncLoop {
  101578. /**
  101579. * Defines the number of iterations for the loop
  101580. */
  101581. iterations: number;
  101582. /**
  101583. * Defines the current index of the loop.
  101584. */
  101585. index: number;
  101586. private _done;
  101587. private _fn;
  101588. private _successCallback;
  101589. /**
  101590. * Constructor.
  101591. * @param iterations the number of iterations.
  101592. * @param func the function to run each iteration
  101593. * @param successCallback the callback that will be called upon succesful execution
  101594. * @param offset starting offset.
  101595. */
  101596. constructor(
  101597. /**
  101598. * Defines the number of iterations for the loop
  101599. */
  101600. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  101601. /**
  101602. * Execute the next iteration. Must be called after the last iteration was finished.
  101603. */
  101604. executeNext(): void;
  101605. /**
  101606. * Break the loop and run the success callback.
  101607. */
  101608. breakLoop(): void;
  101609. /**
  101610. * Create and run an async loop.
  101611. * @param iterations the number of iterations.
  101612. * @param fn the function to run each iteration
  101613. * @param successCallback the callback that will be called upon succesful execution
  101614. * @param offset starting offset.
  101615. * @returns the created async loop object
  101616. */
  101617. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  101618. /**
  101619. * A for-loop that will run a given number of iterations synchronous and the rest async.
  101620. * @param iterations total number of iterations
  101621. * @param syncedIterations number of synchronous iterations in each async iteration.
  101622. * @param fn the function to call each iteration.
  101623. * @param callback a success call back that will be called when iterating stops.
  101624. * @param breakFunction a break condition (optional)
  101625. * @param timeout timeout settings for the setTimeout function. default - 0.
  101626. * @returns the created async loop object
  101627. */
  101628. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  101629. }
  101630. }
  101631. declare module BABYLON {
  101632. /**
  101633. * This class implement a typical dictionary using a string as key and the generic type T as value.
  101634. * The underlying implementation relies on an associative array to ensure the best performances.
  101635. * The value can be anything including 'null' but except 'undefined'
  101636. */
  101637. export class StringDictionary<T> {
  101638. /**
  101639. * This will clear this dictionary and copy the content from the 'source' one.
  101640. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  101641. * @param source the dictionary to take the content from and copy to this dictionary
  101642. */
  101643. copyFrom(source: StringDictionary<T>): void;
  101644. /**
  101645. * Get a value based from its key
  101646. * @param key the given key to get the matching value from
  101647. * @return the value if found, otherwise undefined is returned
  101648. */
  101649. get(key: string): T | undefined;
  101650. /**
  101651. * Get a value from its key or add it if it doesn't exist.
  101652. * This method will ensure you that a given key/data will be present in the dictionary.
  101653. * @param key the given key to get the matching value from
  101654. * @param factory the factory that will create the value if the key is not present in the dictionary.
  101655. * The factory will only be invoked if there's no data for the given key.
  101656. * @return the value corresponding to the key.
  101657. */
  101658. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  101659. /**
  101660. * Get a value from its key if present in the dictionary otherwise add it
  101661. * @param key the key to get the value from
  101662. * @param val if there's no such key/value pair in the dictionary add it with this value
  101663. * @return the value corresponding to the key
  101664. */
  101665. getOrAdd(key: string, val: T): T;
  101666. /**
  101667. * Check if there's a given key in the dictionary
  101668. * @param key the key to check for
  101669. * @return true if the key is present, false otherwise
  101670. */
  101671. contains(key: string): boolean;
  101672. /**
  101673. * Add a new key and its corresponding value
  101674. * @param key the key to add
  101675. * @param value the value corresponding to the key
  101676. * @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
  101677. */
  101678. add(key: string, value: T): boolean;
  101679. /**
  101680. * Update a specific value associated to a key
  101681. * @param key defines the key to use
  101682. * @param value defines the value to store
  101683. * @returns true if the value was updated (or false if the key was not found)
  101684. */
  101685. set(key: string, value: T): boolean;
  101686. /**
  101687. * Get the element of the given key and remove it from the dictionary
  101688. * @param key defines the key to search
  101689. * @returns the value associated with the key or null if not found
  101690. */
  101691. getAndRemove(key: string): Nullable<T>;
  101692. /**
  101693. * Remove a key/value from the dictionary.
  101694. * @param key the key to remove
  101695. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  101696. */
  101697. remove(key: string): boolean;
  101698. /**
  101699. * Clear the whole content of the dictionary
  101700. */
  101701. clear(): void;
  101702. /**
  101703. * Gets the current count
  101704. */
  101705. readonly count: number;
  101706. /**
  101707. * Execute a callback on each key/val of the dictionary.
  101708. * Note that you can remove any element in this dictionary in the callback implementation
  101709. * @param callback the callback to execute on a given key/value pair
  101710. */
  101711. forEach(callback: (key: string, val: T) => void): void;
  101712. /**
  101713. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  101714. * If the callback returns null or undefined the method will iterate to the next key/value pair
  101715. * Note that you can remove any element in this dictionary in the callback implementation
  101716. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  101717. * @returns the first item
  101718. */
  101719. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  101720. private _count;
  101721. private _data;
  101722. }
  101723. }
  101724. declare module BABYLON {
  101725. /** @hidden */
  101726. export interface ICollisionCoordinator {
  101727. createCollider(): Collider;
  101728. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101729. init(scene: Scene): void;
  101730. }
  101731. /** @hidden */
  101732. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  101733. private _scene;
  101734. private _scaledPosition;
  101735. private _scaledVelocity;
  101736. private _finalPosition;
  101737. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101738. createCollider(): Collider;
  101739. init(scene: Scene): void;
  101740. private _collideWithWorld;
  101741. }
  101742. }
  101743. declare module BABYLON {
  101744. /**
  101745. * Class used to manage all inputs for the scene.
  101746. */
  101747. export class InputManager {
  101748. /** The distance in pixel that you have to move to prevent some events */
  101749. static DragMovementThreshold: number;
  101750. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  101751. static LongPressDelay: number;
  101752. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  101753. static DoubleClickDelay: number;
  101754. /** If you need to check double click without raising a single click at first click, enable this flag */
  101755. static ExclusiveDoubleClickMode: boolean;
  101756. private _wheelEventName;
  101757. private _onPointerMove;
  101758. private _onPointerDown;
  101759. private _onPointerUp;
  101760. private _initClickEvent;
  101761. private _initActionManager;
  101762. private _delayedSimpleClick;
  101763. private _delayedSimpleClickTimeout;
  101764. private _previousDelayedSimpleClickTimeout;
  101765. private _meshPickProceed;
  101766. private _previousButtonPressed;
  101767. private _currentPickResult;
  101768. private _previousPickResult;
  101769. private _totalPointersPressed;
  101770. private _doubleClickOccured;
  101771. private _pointerOverMesh;
  101772. private _pickedDownMesh;
  101773. private _pickedUpMesh;
  101774. private _pointerX;
  101775. private _pointerY;
  101776. private _unTranslatedPointerX;
  101777. private _unTranslatedPointerY;
  101778. private _startingPointerPosition;
  101779. private _previousStartingPointerPosition;
  101780. private _startingPointerTime;
  101781. private _previousStartingPointerTime;
  101782. private _pointerCaptures;
  101783. private _onKeyDown;
  101784. private _onKeyUp;
  101785. private _onCanvasFocusObserver;
  101786. private _onCanvasBlurObserver;
  101787. private _scene;
  101788. /**
  101789. * Creates a new InputManager
  101790. * @param scene defines the hosting scene
  101791. */
  101792. constructor(scene: Scene);
  101793. /**
  101794. * Gets the mesh that is currently under the pointer
  101795. */
  101796. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101797. /**
  101798. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  101799. */
  101800. readonly unTranslatedPointer: Vector2;
  101801. /**
  101802. * Gets or sets the current on-screen X position of the pointer
  101803. */
  101804. pointerX: number;
  101805. /**
  101806. * Gets or sets the current on-screen Y position of the pointer
  101807. */
  101808. pointerY: number;
  101809. private _updatePointerPosition;
  101810. private _processPointerMove;
  101811. private _setRayOnPointerInfo;
  101812. private _checkPrePointerObservable;
  101813. /**
  101814. * Use this method to simulate a pointer move on a mesh
  101815. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101816. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101817. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101818. */
  101819. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101820. /**
  101821. * Use this method to simulate a pointer down on a mesh
  101822. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101823. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101824. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101825. */
  101826. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101827. private _processPointerDown;
  101828. /** @hidden */
  101829. _isPointerSwiping(): boolean;
  101830. /**
  101831. * Use this method to simulate a pointer up on a mesh
  101832. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101833. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101834. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101835. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101836. */
  101837. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101838. private _processPointerUp;
  101839. /**
  101840. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101841. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101842. * @returns true if the pointer was captured
  101843. */
  101844. isPointerCaptured(pointerId?: number): boolean;
  101845. /**
  101846. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101847. * @param attachUp defines if you want to attach events to pointerup
  101848. * @param attachDown defines if you want to attach events to pointerdown
  101849. * @param attachMove defines if you want to attach events to pointermove
  101850. */
  101851. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101852. /**
  101853. * Detaches all event handlers
  101854. */
  101855. detachControl(): void;
  101856. /**
  101857. * Force the value of meshUnderPointer
  101858. * @param mesh defines the mesh to use
  101859. */
  101860. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101861. /**
  101862. * Gets the mesh under the pointer
  101863. * @returns a Mesh or null if no mesh is under the pointer
  101864. */
  101865. getPointerOverMesh(): Nullable<AbstractMesh>;
  101866. }
  101867. }
  101868. declare module BABYLON {
  101869. /**
  101870. * Helper class used to generate session unique ID
  101871. */
  101872. export class UniqueIdGenerator {
  101873. private static _UniqueIdCounter;
  101874. /**
  101875. * Gets an unique (relatively to the current scene) Id
  101876. */
  101877. static readonly UniqueId: number;
  101878. }
  101879. }
  101880. declare module BABYLON {
  101881. /**
  101882. * This class defines the direct association between an animation and a target
  101883. */
  101884. export class TargetedAnimation {
  101885. /**
  101886. * Animation to perform
  101887. */
  101888. animation: Animation;
  101889. /**
  101890. * Target to animate
  101891. */
  101892. target: any;
  101893. /**
  101894. * Serialize the object
  101895. * @returns the JSON object representing the current entity
  101896. */
  101897. serialize(): any;
  101898. }
  101899. /**
  101900. * Use this class to create coordinated animations on multiple targets
  101901. */
  101902. export class AnimationGroup implements IDisposable {
  101903. /** The name of the animation group */
  101904. name: string;
  101905. private _scene;
  101906. private _targetedAnimations;
  101907. private _animatables;
  101908. private _from;
  101909. private _to;
  101910. private _isStarted;
  101911. private _isPaused;
  101912. private _speedRatio;
  101913. private _loopAnimation;
  101914. /**
  101915. * Gets or sets the unique id of the node
  101916. */
  101917. uniqueId: number;
  101918. /**
  101919. * This observable will notify when one animation have ended
  101920. */
  101921. onAnimationEndObservable: Observable<TargetedAnimation>;
  101922. /**
  101923. * Observer raised when one animation loops
  101924. */
  101925. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101926. /**
  101927. * Observer raised when all animations have looped
  101928. */
  101929. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101930. /**
  101931. * This observable will notify when all animations have ended.
  101932. */
  101933. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101934. /**
  101935. * This observable will notify when all animations have paused.
  101936. */
  101937. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101938. /**
  101939. * This observable will notify when all animations are playing.
  101940. */
  101941. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101942. /**
  101943. * Gets the first frame
  101944. */
  101945. readonly from: number;
  101946. /**
  101947. * Gets the last frame
  101948. */
  101949. readonly to: number;
  101950. /**
  101951. * Define if the animations are started
  101952. */
  101953. readonly isStarted: boolean;
  101954. /**
  101955. * Gets a value indicating that the current group is playing
  101956. */
  101957. readonly isPlaying: boolean;
  101958. /**
  101959. * Gets or sets the speed ratio to use for all animations
  101960. */
  101961. /**
  101962. * Gets or sets the speed ratio to use for all animations
  101963. */
  101964. speedRatio: number;
  101965. /**
  101966. * Gets or sets if all animations should loop or not
  101967. */
  101968. loopAnimation: boolean;
  101969. /**
  101970. * Gets the targeted animations for this animation group
  101971. */
  101972. readonly targetedAnimations: Array<TargetedAnimation>;
  101973. /**
  101974. * returning the list of animatables controlled by this animation group.
  101975. */
  101976. readonly animatables: Array<Animatable>;
  101977. /**
  101978. * Instantiates a new Animation Group.
  101979. * This helps managing several animations at once.
  101980. * @see http://doc.babylonjs.com/how_to/group
  101981. * @param name Defines the name of the group
  101982. * @param scene Defines the scene the group belongs to
  101983. */
  101984. constructor(
  101985. /** The name of the animation group */
  101986. name: string, scene?: Nullable<Scene>);
  101987. /**
  101988. * Add an animation (with its target) in the group
  101989. * @param animation defines the animation we want to add
  101990. * @param target defines the target of the animation
  101991. * @returns the TargetedAnimation object
  101992. */
  101993. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101994. /**
  101995. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101996. * It can add constant keys at begin or end
  101997. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101998. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101999. * @returns the animation group
  102000. */
  102001. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  102002. private _animationLoopCount;
  102003. private _animationLoopFlags;
  102004. private _processLoop;
  102005. /**
  102006. * Start all animations on given targets
  102007. * @param loop defines if animations must loop
  102008. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  102009. * @param from defines the from key (optional)
  102010. * @param to defines the to key (optional)
  102011. * @returns the current animation group
  102012. */
  102013. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  102014. /**
  102015. * Pause all animations
  102016. * @returns the animation group
  102017. */
  102018. pause(): AnimationGroup;
  102019. /**
  102020. * Play all animations to initial state
  102021. * This function will start() the animations if they were not started or will restart() them if they were paused
  102022. * @param loop defines if animations must loop
  102023. * @returns the animation group
  102024. */
  102025. play(loop?: boolean): AnimationGroup;
  102026. /**
  102027. * Reset all animations to initial state
  102028. * @returns the animation group
  102029. */
  102030. reset(): AnimationGroup;
  102031. /**
  102032. * Restart animations from key 0
  102033. * @returns the animation group
  102034. */
  102035. restart(): AnimationGroup;
  102036. /**
  102037. * Stop all animations
  102038. * @returns the animation group
  102039. */
  102040. stop(): AnimationGroup;
  102041. /**
  102042. * Set animation weight for all animatables
  102043. * @param weight defines the weight to use
  102044. * @return the animationGroup
  102045. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  102046. */
  102047. setWeightForAllAnimatables(weight: number): AnimationGroup;
  102048. /**
  102049. * Synchronize and normalize all animatables with a source animatable
  102050. * @param root defines the root animatable to synchronize with
  102051. * @return the animationGroup
  102052. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  102053. */
  102054. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  102055. /**
  102056. * Goes to a specific frame in this animation group
  102057. * @param frame the frame number to go to
  102058. * @return the animationGroup
  102059. */
  102060. goToFrame(frame: number): AnimationGroup;
  102061. /**
  102062. * Dispose all associated resources
  102063. */
  102064. dispose(): void;
  102065. private _checkAnimationGroupEnded;
  102066. /**
  102067. * Clone the current animation group and returns a copy
  102068. * @param newName defines the name of the new group
  102069. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  102070. * @returns the new aniamtion group
  102071. */
  102072. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  102073. /**
  102074. * Serializes the animationGroup to an object
  102075. * @returns Serialized object
  102076. */
  102077. serialize(): any;
  102078. /**
  102079. * Returns a new AnimationGroup object parsed from the source provided.
  102080. * @param parsedAnimationGroup defines the source
  102081. * @param scene defines the scene that will receive the animationGroup
  102082. * @returns a new AnimationGroup
  102083. */
  102084. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  102085. /**
  102086. * Returns the string "AnimationGroup"
  102087. * @returns "AnimationGroup"
  102088. */
  102089. getClassName(): string;
  102090. /**
  102091. * Creates a detailled string about the object
  102092. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  102093. * @returns a string representing the object
  102094. */
  102095. toString(fullDetails?: boolean): string;
  102096. }
  102097. }
  102098. declare module BABYLON {
  102099. /**
  102100. * Define an interface for all classes that will hold resources
  102101. */
  102102. export interface IDisposable {
  102103. /**
  102104. * Releases all held resources
  102105. */
  102106. dispose(): void;
  102107. }
  102108. /** Interface defining initialization parameters for Scene class */
  102109. export interface SceneOptions {
  102110. /**
  102111. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  102112. * It will improve performance when the number of geometries becomes important.
  102113. */
  102114. useGeometryUniqueIdsMap?: boolean;
  102115. /**
  102116. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  102117. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  102118. */
  102119. useMaterialMeshMap?: boolean;
  102120. /**
  102121. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  102122. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  102123. */
  102124. useClonedMeshhMap?: boolean;
  102125. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  102126. virtual?: boolean;
  102127. }
  102128. /**
  102129. * Represents a scene to be rendered by the engine.
  102130. * @see http://doc.babylonjs.com/features/scene
  102131. */
  102132. export class Scene extends AbstractScene implements IAnimatable {
  102133. /** The fog is deactivated */
  102134. static readonly FOGMODE_NONE: number;
  102135. /** The fog density is following an exponential function */
  102136. static readonly FOGMODE_EXP: number;
  102137. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  102138. static readonly FOGMODE_EXP2: number;
  102139. /** The fog density is following a linear function. */
  102140. static readonly FOGMODE_LINEAR: number;
  102141. /**
  102142. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  102143. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102144. */
  102145. static MinDeltaTime: number;
  102146. /**
  102147. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  102148. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102149. */
  102150. static MaxDeltaTime: number;
  102151. /**
  102152. * Factory used to create the default material.
  102153. * @param name The name of the material to create
  102154. * @param scene The scene to create the material for
  102155. * @returns The default material
  102156. */
  102157. static DefaultMaterialFactory(scene: Scene): Material;
  102158. /**
  102159. * Factory used to create the a collision coordinator.
  102160. * @returns The collision coordinator
  102161. */
  102162. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  102163. /** @hidden */
  102164. _inputManager: InputManager;
  102165. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  102166. cameraToUseForPointers: Nullable<Camera>;
  102167. /** @hidden */
  102168. readonly _isScene: boolean;
  102169. /**
  102170. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  102171. */
  102172. autoClear: boolean;
  102173. /**
  102174. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  102175. */
  102176. autoClearDepthAndStencil: boolean;
  102177. /**
  102178. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  102179. */
  102180. clearColor: Color4;
  102181. /**
  102182. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  102183. */
  102184. ambientColor: Color3;
  102185. /**
  102186. * This is use to store the default BRDF lookup for PBR materials in your scene.
  102187. * It should only be one of the following (if not the default embedded one):
  102188. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  102189. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  102190. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  102191. * The material properties need to be setup according to the type of texture in use.
  102192. */
  102193. environmentBRDFTexture: BaseTexture;
  102194. /** @hidden */
  102195. protected _environmentTexture: Nullable<BaseTexture>;
  102196. /**
  102197. * Texture used in all pbr material as the reflection texture.
  102198. * As in the majority of the scene they are the same (exception for multi room and so on),
  102199. * this is easier to reference from here than from all the materials.
  102200. */
  102201. /**
  102202. * Texture used in all pbr material as the reflection texture.
  102203. * As in the majority of the scene they are the same (exception for multi room and so on),
  102204. * this is easier to set here than in all the materials.
  102205. */
  102206. environmentTexture: Nullable<BaseTexture>;
  102207. /** @hidden */
  102208. protected _environmentIntensity: number;
  102209. /**
  102210. * Intensity of the environment in all pbr material.
  102211. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  102212. * As in the majority of the scene they are the same (exception for multi room and so on),
  102213. * this is easier to reference from here than from all the materials.
  102214. */
  102215. /**
  102216. * Intensity of the environment in all pbr material.
  102217. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  102218. * As in the majority of the scene they are the same (exception for multi room and so on),
  102219. * this is easier to set here than in all the materials.
  102220. */
  102221. environmentIntensity: number;
  102222. /** @hidden */
  102223. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102224. /**
  102225. * Default image processing configuration used either in the rendering
  102226. * Forward main pass or through the imageProcessingPostProcess if present.
  102227. * As in the majority of the scene they are the same (exception for multi camera),
  102228. * this is easier to reference from here than from all the materials and post process.
  102229. *
  102230. * No setter as we it is a shared configuration, you can set the values instead.
  102231. */
  102232. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  102233. private _forceWireframe;
  102234. /**
  102235. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  102236. */
  102237. forceWireframe: boolean;
  102238. private _forcePointsCloud;
  102239. /**
  102240. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  102241. */
  102242. forcePointsCloud: boolean;
  102243. /**
  102244. * Gets or sets the active clipplane 1
  102245. */
  102246. clipPlane: Nullable<Plane>;
  102247. /**
  102248. * Gets or sets the active clipplane 2
  102249. */
  102250. clipPlane2: Nullable<Plane>;
  102251. /**
  102252. * Gets or sets the active clipplane 3
  102253. */
  102254. clipPlane3: Nullable<Plane>;
  102255. /**
  102256. * Gets or sets the active clipplane 4
  102257. */
  102258. clipPlane4: Nullable<Plane>;
  102259. /**
  102260. * Gets or sets a boolean indicating if animations are enabled
  102261. */
  102262. animationsEnabled: boolean;
  102263. private _animationPropertiesOverride;
  102264. /**
  102265. * Gets or sets the animation properties override
  102266. */
  102267. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  102268. /**
  102269. * Gets or sets a boolean indicating if a constant deltatime has to be used
  102270. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  102271. */
  102272. useConstantAnimationDeltaTime: boolean;
  102273. /**
  102274. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  102275. * Please note that it requires to run a ray cast through the scene on every frame
  102276. */
  102277. constantlyUpdateMeshUnderPointer: boolean;
  102278. /**
  102279. * Defines the HTML cursor to use when hovering over interactive elements
  102280. */
  102281. hoverCursor: string;
  102282. /**
  102283. * Defines the HTML default cursor to use (empty by default)
  102284. */
  102285. defaultCursor: string;
  102286. /**
  102287. * Defines wether cursors are handled by the scene.
  102288. */
  102289. doNotHandleCursors: boolean;
  102290. /**
  102291. * This is used to call preventDefault() on pointer down
  102292. * in order to block unwanted artifacts like system double clicks
  102293. */
  102294. preventDefaultOnPointerDown: boolean;
  102295. /**
  102296. * This is used to call preventDefault() on pointer up
  102297. * in order to block unwanted artifacts like system double clicks
  102298. */
  102299. preventDefaultOnPointerUp: boolean;
  102300. /**
  102301. * Gets or sets user defined metadata
  102302. */
  102303. metadata: any;
  102304. /**
  102305. * For internal use only. Please do not use.
  102306. */
  102307. reservedDataStore: any;
  102308. /**
  102309. * Gets the name of the plugin used to load this scene (null by default)
  102310. */
  102311. loadingPluginName: string;
  102312. /**
  102313. * Use this array to add regular expressions used to disable offline support for specific urls
  102314. */
  102315. disableOfflineSupportExceptionRules: RegExp[];
  102316. /**
  102317. * An event triggered when the scene is disposed.
  102318. */
  102319. onDisposeObservable: Observable<Scene>;
  102320. private _onDisposeObserver;
  102321. /** Sets a function to be executed when this scene is disposed. */
  102322. onDispose: () => void;
  102323. /**
  102324. * An event triggered before rendering the scene (right after animations and physics)
  102325. */
  102326. onBeforeRenderObservable: Observable<Scene>;
  102327. private _onBeforeRenderObserver;
  102328. /** Sets a function to be executed before rendering this scene */
  102329. beforeRender: Nullable<() => void>;
  102330. /**
  102331. * An event triggered after rendering the scene
  102332. */
  102333. onAfterRenderObservable: Observable<Scene>;
  102334. /**
  102335. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  102336. */
  102337. onAfterRenderCameraObservable: Observable<Camera>;
  102338. private _onAfterRenderObserver;
  102339. /** Sets a function to be executed after rendering this scene */
  102340. afterRender: Nullable<() => void>;
  102341. /**
  102342. * An event triggered before animating the scene
  102343. */
  102344. onBeforeAnimationsObservable: Observable<Scene>;
  102345. /**
  102346. * An event triggered after animations processing
  102347. */
  102348. onAfterAnimationsObservable: Observable<Scene>;
  102349. /**
  102350. * An event triggered before draw calls are ready to be sent
  102351. */
  102352. onBeforeDrawPhaseObservable: Observable<Scene>;
  102353. /**
  102354. * An event triggered after draw calls have been sent
  102355. */
  102356. onAfterDrawPhaseObservable: Observable<Scene>;
  102357. /**
  102358. * An event triggered when the scene is ready
  102359. */
  102360. onReadyObservable: Observable<Scene>;
  102361. /**
  102362. * An event triggered before rendering a camera
  102363. */
  102364. onBeforeCameraRenderObservable: Observable<Camera>;
  102365. private _onBeforeCameraRenderObserver;
  102366. /** Sets a function to be executed before rendering a camera*/
  102367. beforeCameraRender: () => void;
  102368. /**
  102369. * An event triggered after rendering a camera
  102370. */
  102371. onAfterCameraRenderObservable: Observable<Camera>;
  102372. private _onAfterCameraRenderObserver;
  102373. /** Sets a function to be executed after rendering a camera*/
  102374. afterCameraRender: () => void;
  102375. /**
  102376. * An event triggered when active meshes evaluation is about to start
  102377. */
  102378. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  102379. /**
  102380. * An event triggered when active meshes evaluation is done
  102381. */
  102382. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  102383. /**
  102384. * An event triggered when particles rendering is about to start
  102385. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  102386. */
  102387. onBeforeParticlesRenderingObservable: Observable<Scene>;
  102388. /**
  102389. * An event triggered when particles rendering is done
  102390. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  102391. */
  102392. onAfterParticlesRenderingObservable: Observable<Scene>;
  102393. /**
  102394. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  102395. */
  102396. onDataLoadedObservable: Observable<Scene>;
  102397. /**
  102398. * An event triggered when a camera is created
  102399. */
  102400. onNewCameraAddedObservable: Observable<Camera>;
  102401. /**
  102402. * An event triggered when a camera is removed
  102403. */
  102404. onCameraRemovedObservable: Observable<Camera>;
  102405. /**
  102406. * An event triggered when a light is created
  102407. */
  102408. onNewLightAddedObservable: Observable<Light>;
  102409. /**
  102410. * An event triggered when a light is removed
  102411. */
  102412. onLightRemovedObservable: Observable<Light>;
  102413. /**
  102414. * An event triggered when a geometry is created
  102415. */
  102416. onNewGeometryAddedObservable: Observable<Geometry>;
  102417. /**
  102418. * An event triggered when a geometry is removed
  102419. */
  102420. onGeometryRemovedObservable: Observable<Geometry>;
  102421. /**
  102422. * An event triggered when a transform node is created
  102423. */
  102424. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  102425. /**
  102426. * An event triggered when a transform node is removed
  102427. */
  102428. onTransformNodeRemovedObservable: Observable<TransformNode>;
  102429. /**
  102430. * An event triggered when a mesh is created
  102431. */
  102432. onNewMeshAddedObservable: Observable<AbstractMesh>;
  102433. /**
  102434. * An event triggered when a mesh is removed
  102435. */
  102436. onMeshRemovedObservable: Observable<AbstractMesh>;
  102437. /**
  102438. * An event triggered when a skeleton is created
  102439. */
  102440. onNewSkeletonAddedObservable: Observable<Skeleton>;
  102441. /**
  102442. * An event triggered when a skeleton is removed
  102443. */
  102444. onSkeletonRemovedObservable: Observable<Skeleton>;
  102445. /**
  102446. * An event triggered when a material is created
  102447. */
  102448. onNewMaterialAddedObservable: Observable<Material>;
  102449. /**
  102450. * An event triggered when a material is removed
  102451. */
  102452. onMaterialRemovedObservable: Observable<Material>;
  102453. /**
  102454. * An event triggered when a texture is created
  102455. */
  102456. onNewTextureAddedObservable: Observable<BaseTexture>;
  102457. /**
  102458. * An event triggered when a texture is removed
  102459. */
  102460. onTextureRemovedObservable: Observable<BaseTexture>;
  102461. /**
  102462. * An event triggered when render targets are about to be rendered
  102463. * Can happen multiple times per frame.
  102464. */
  102465. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  102466. /**
  102467. * An event triggered when render targets were rendered.
  102468. * Can happen multiple times per frame.
  102469. */
  102470. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  102471. /**
  102472. * An event triggered before calculating deterministic simulation step
  102473. */
  102474. onBeforeStepObservable: Observable<Scene>;
  102475. /**
  102476. * An event triggered after calculating deterministic simulation step
  102477. */
  102478. onAfterStepObservable: Observable<Scene>;
  102479. /**
  102480. * An event triggered when the activeCamera property is updated
  102481. */
  102482. onActiveCameraChanged: Observable<Scene>;
  102483. /**
  102484. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  102485. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  102486. * 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)
  102487. */
  102488. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  102489. /**
  102490. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  102491. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  102492. * 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)
  102493. */
  102494. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  102495. /**
  102496. * This Observable will when a mesh has been imported into the scene.
  102497. */
  102498. onMeshImportedObservable: Observable<AbstractMesh>;
  102499. /**
  102500. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  102501. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  102502. */
  102503. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  102504. /** @hidden */
  102505. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  102506. /**
  102507. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  102508. */
  102509. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  102510. /**
  102511. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  102512. */
  102513. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  102514. /**
  102515. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  102516. */
  102517. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  102518. /** Callback called when a pointer move is detected */
  102519. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  102520. /** Callback called when a pointer down is detected */
  102521. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  102522. /** Callback called when a pointer up is detected */
  102523. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  102524. /** Callback called when a pointer pick is detected */
  102525. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  102526. /**
  102527. * 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).
  102528. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  102529. */
  102530. onPrePointerObservable: Observable<PointerInfoPre>;
  102531. /**
  102532. * Observable event triggered each time an input event is received from the rendering canvas
  102533. */
  102534. onPointerObservable: Observable<PointerInfo>;
  102535. /**
  102536. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  102537. */
  102538. readonly unTranslatedPointer: Vector2;
  102539. /**
  102540. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  102541. */
  102542. static DragMovementThreshold: number;
  102543. /**
  102544. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  102545. */
  102546. static LongPressDelay: number;
  102547. /**
  102548. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  102549. */
  102550. static DoubleClickDelay: number;
  102551. /** If you need to check double click without raising a single click at first click, enable this flag */
  102552. static ExclusiveDoubleClickMode: boolean;
  102553. /** @hidden */
  102554. _mirroredCameraPosition: Nullable<Vector3>;
  102555. /**
  102556. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  102557. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  102558. */
  102559. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  102560. /**
  102561. * Observable event triggered each time an keyboard event is received from the hosting window
  102562. */
  102563. onKeyboardObservable: Observable<KeyboardInfo>;
  102564. private _useRightHandedSystem;
  102565. /**
  102566. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  102567. */
  102568. useRightHandedSystem: boolean;
  102569. private _timeAccumulator;
  102570. private _currentStepId;
  102571. private _currentInternalStep;
  102572. /**
  102573. * Sets the step Id used by deterministic lock step
  102574. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102575. * @param newStepId defines the step Id
  102576. */
  102577. setStepId(newStepId: number): void;
  102578. /**
  102579. * Gets the step Id used by deterministic lock step
  102580. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102581. * @returns the step Id
  102582. */
  102583. getStepId(): number;
  102584. /**
  102585. * Gets the internal step used by deterministic lock step
  102586. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102587. * @returns the internal step
  102588. */
  102589. getInternalStep(): number;
  102590. private _fogEnabled;
  102591. /**
  102592. * Gets or sets a boolean indicating if fog is enabled on this scene
  102593. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102594. * (Default is true)
  102595. */
  102596. fogEnabled: boolean;
  102597. private _fogMode;
  102598. /**
  102599. * Gets or sets the fog mode to use
  102600. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102601. * | mode | value |
  102602. * | --- | --- |
  102603. * | FOGMODE_NONE | 0 |
  102604. * | FOGMODE_EXP | 1 |
  102605. * | FOGMODE_EXP2 | 2 |
  102606. * | FOGMODE_LINEAR | 3 |
  102607. */
  102608. fogMode: number;
  102609. /**
  102610. * Gets or sets the fog color to use
  102611. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102612. * (Default is Color3(0.2, 0.2, 0.3))
  102613. */
  102614. fogColor: Color3;
  102615. /**
  102616. * Gets or sets the fog density to use
  102617. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102618. * (Default is 0.1)
  102619. */
  102620. fogDensity: number;
  102621. /**
  102622. * Gets or sets the fog start distance to use
  102623. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102624. * (Default is 0)
  102625. */
  102626. fogStart: number;
  102627. /**
  102628. * Gets or sets the fog end distance to use
  102629. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102630. * (Default is 1000)
  102631. */
  102632. fogEnd: number;
  102633. private _shadowsEnabled;
  102634. /**
  102635. * Gets or sets a boolean indicating if shadows are enabled on this scene
  102636. */
  102637. shadowsEnabled: boolean;
  102638. private _lightsEnabled;
  102639. /**
  102640. * Gets or sets a boolean indicating if lights are enabled on this scene
  102641. */
  102642. lightsEnabled: boolean;
  102643. /** All of the active cameras added to this scene. */
  102644. activeCameras: Camera[];
  102645. /** @hidden */
  102646. _activeCamera: Nullable<Camera>;
  102647. /** Gets or sets the current active camera */
  102648. activeCamera: Nullable<Camera>;
  102649. private _defaultMaterial;
  102650. /** The default material used on meshes when no material is affected */
  102651. /** The default material used on meshes when no material is affected */
  102652. defaultMaterial: Material;
  102653. private _texturesEnabled;
  102654. /**
  102655. * Gets or sets a boolean indicating if textures are enabled on this scene
  102656. */
  102657. texturesEnabled: boolean;
  102658. /**
  102659. * Gets or sets a boolean indicating if particles are enabled on this scene
  102660. */
  102661. particlesEnabled: boolean;
  102662. /**
  102663. * Gets or sets a boolean indicating if sprites are enabled on this scene
  102664. */
  102665. spritesEnabled: boolean;
  102666. private _skeletonsEnabled;
  102667. /**
  102668. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  102669. */
  102670. skeletonsEnabled: boolean;
  102671. /**
  102672. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  102673. */
  102674. lensFlaresEnabled: boolean;
  102675. /**
  102676. * Gets or sets a boolean indicating if collisions are enabled on this scene
  102677. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102678. */
  102679. collisionsEnabled: boolean;
  102680. private _collisionCoordinator;
  102681. /** @hidden */
  102682. readonly collisionCoordinator: ICollisionCoordinator;
  102683. /**
  102684. * Defines the gravity applied to this scene (used only for collisions)
  102685. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102686. */
  102687. gravity: Vector3;
  102688. /**
  102689. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  102690. */
  102691. postProcessesEnabled: boolean;
  102692. /**
  102693. * The list of postprocesses added to the scene
  102694. */
  102695. postProcesses: PostProcess[];
  102696. /**
  102697. * Gets the current postprocess manager
  102698. */
  102699. postProcessManager: PostProcessManager;
  102700. /**
  102701. * Gets or sets a boolean indicating if render targets are enabled on this scene
  102702. */
  102703. renderTargetsEnabled: boolean;
  102704. /**
  102705. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  102706. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  102707. */
  102708. dumpNextRenderTargets: boolean;
  102709. /**
  102710. * The list of user defined render targets added to the scene
  102711. */
  102712. customRenderTargets: RenderTargetTexture[];
  102713. /**
  102714. * Defines if texture loading must be delayed
  102715. * If true, textures will only be loaded when they need to be rendered
  102716. */
  102717. useDelayedTextureLoading: boolean;
  102718. /**
  102719. * Gets the list of meshes imported to the scene through SceneLoader
  102720. */
  102721. importedMeshesFiles: String[];
  102722. /**
  102723. * Gets or sets a boolean indicating if probes are enabled on this scene
  102724. */
  102725. probesEnabled: boolean;
  102726. /**
  102727. * Gets or sets the current offline provider to use to store scene data
  102728. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  102729. */
  102730. offlineProvider: IOfflineProvider;
  102731. /**
  102732. * Gets or sets the action manager associated with the scene
  102733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102734. */
  102735. actionManager: AbstractActionManager;
  102736. private _meshesForIntersections;
  102737. /**
  102738. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  102739. */
  102740. proceduralTexturesEnabled: boolean;
  102741. private _engine;
  102742. private _totalVertices;
  102743. /** @hidden */
  102744. _activeIndices: PerfCounter;
  102745. /** @hidden */
  102746. _activeParticles: PerfCounter;
  102747. /** @hidden */
  102748. _activeBones: PerfCounter;
  102749. private _animationRatio;
  102750. /** @hidden */
  102751. _animationTimeLast: number;
  102752. /** @hidden */
  102753. _animationTime: number;
  102754. /**
  102755. * Gets or sets a general scale for animation speed
  102756. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  102757. */
  102758. animationTimeScale: number;
  102759. /** @hidden */
  102760. _cachedMaterial: Nullable<Material>;
  102761. /** @hidden */
  102762. _cachedEffect: Nullable<Effect>;
  102763. /** @hidden */
  102764. _cachedVisibility: Nullable<number>;
  102765. private _renderId;
  102766. private _frameId;
  102767. private _executeWhenReadyTimeoutId;
  102768. private _intermediateRendering;
  102769. private _viewUpdateFlag;
  102770. private _projectionUpdateFlag;
  102771. /** @hidden */
  102772. _toBeDisposed: Nullable<IDisposable>[];
  102773. private _activeRequests;
  102774. /** @hidden */
  102775. _pendingData: any[];
  102776. private _isDisposed;
  102777. /**
  102778. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  102779. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  102780. */
  102781. dispatchAllSubMeshesOfActiveMeshes: boolean;
  102782. private _activeMeshes;
  102783. private _processedMaterials;
  102784. private _renderTargets;
  102785. /** @hidden */
  102786. _activeParticleSystems: SmartArray<IParticleSystem>;
  102787. private _activeSkeletons;
  102788. private _softwareSkinnedMeshes;
  102789. private _renderingManager;
  102790. /** @hidden */
  102791. _activeAnimatables: Animatable[];
  102792. private _transformMatrix;
  102793. private _sceneUbo;
  102794. /** @hidden */
  102795. _viewMatrix: Matrix;
  102796. private _projectionMatrix;
  102797. /** @hidden */
  102798. _forcedViewPosition: Nullable<Vector3>;
  102799. /** @hidden */
  102800. _frustumPlanes: Plane[];
  102801. /**
  102802. * Gets the list of frustum planes (built from the active camera)
  102803. */
  102804. readonly frustumPlanes: Plane[];
  102805. /**
  102806. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  102807. * This is useful if there are more lights that the maximum simulteanous authorized
  102808. */
  102809. requireLightSorting: boolean;
  102810. /** @hidden */
  102811. readonly useMaterialMeshMap: boolean;
  102812. /** @hidden */
  102813. readonly useClonedMeshhMap: boolean;
  102814. private _externalData;
  102815. private _uid;
  102816. /**
  102817. * @hidden
  102818. * Backing store of defined scene components.
  102819. */
  102820. _components: ISceneComponent[];
  102821. /**
  102822. * @hidden
  102823. * Backing store of defined scene components.
  102824. */
  102825. _serializableComponents: ISceneSerializableComponent[];
  102826. /**
  102827. * List of components to register on the next registration step.
  102828. */
  102829. private _transientComponents;
  102830. /**
  102831. * Registers the transient components if needed.
  102832. */
  102833. private _registerTransientComponents;
  102834. /**
  102835. * @hidden
  102836. * Add a component to the scene.
  102837. * Note that the ccomponent could be registered on th next frame if this is called after
  102838. * the register component stage.
  102839. * @param component Defines the component to add to the scene
  102840. */
  102841. _addComponent(component: ISceneComponent): void;
  102842. /**
  102843. * @hidden
  102844. * Gets a component from the scene.
  102845. * @param name defines the name of the component to retrieve
  102846. * @returns the component or null if not present
  102847. */
  102848. _getComponent(name: string): Nullable<ISceneComponent>;
  102849. /**
  102850. * @hidden
  102851. * Defines the actions happening before camera updates.
  102852. */
  102853. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102854. /**
  102855. * @hidden
  102856. * Defines the actions happening before clear the canvas.
  102857. */
  102858. _beforeClearStage: Stage<SimpleStageAction>;
  102859. /**
  102860. * @hidden
  102861. * Defines the actions when collecting render targets for the frame.
  102862. */
  102863. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102864. /**
  102865. * @hidden
  102866. * Defines the actions happening for one camera in the frame.
  102867. */
  102868. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102869. /**
  102870. * @hidden
  102871. * Defines the actions happening during the per mesh ready checks.
  102872. */
  102873. _isReadyForMeshStage: Stage<MeshStageAction>;
  102874. /**
  102875. * @hidden
  102876. * Defines the actions happening before evaluate active mesh checks.
  102877. */
  102878. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102879. /**
  102880. * @hidden
  102881. * Defines the actions happening during the evaluate sub mesh checks.
  102882. */
  102883. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102884. /**
  102885. * @hidden
  102886. * Defines the actions happening during the active mesh stage.
  102887. */
  102888. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102889. /**
  102890. * @hidden
  102891. * Defines the actions happening during the per camera render target step.
  102892. */
  102893. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102894. /**
  102895. * @hidden
  102896. * Defines the actions happening just before the active camera is drawing.
  102897. */
  102898. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102899. /**
  102900. * @hidden
  102901. * Defines the actions happening just before a render target is drawing.
  102902. */
  102903. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102904. /**
  102905. * @hidden
  102906. * Defines the actions happening just before a rendering group is drawing.
  102907. */
  102908. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102909. /**
  102910. * @hidden
  102911. * Defines the actions happening just before a mesh is drawing.
  102912. */
  102913. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102914. /**
  102915. * @hidden
  102916. * Defines the actions happening just after a mesh has been drawn.
  102917. */
  102918. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102919. /**
  102920. * @hidden
  102921. * Defines the actions happening just after a rendering group has been drawn.
  102922. */
  102923. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102924. /**
  102925. * @hidden
  102926. * Defines the actions happening just after the active camera has been drawn.
  102927. */
  102928. _afterCameraDrawStage: Stage<CameraStageAction>;
  102929. /**
  102930. * @hidden
  102931. * Defines the actions happening just after a render target has been drawn.
  102932. */
  102933. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102934. /**
  102935. * @hidden
  102936. * Defines the actions happening just after rendering all cameras and computing intersections.
  102937. */
  102938. _afterRenderStage: Stage<SimpleStageAction>;
  102939. /**
  102940. * @hidden
  102941. * Defines the actions happening when a pointer move event happens.
  102942. */
  102943. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102944. /**
  102945. * @hidden
  102946. * Defines the actions happening when a pointer down event happens.
  102947. */
  102948. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102949. /**
  102950. * @hidden
  102951. * Defines the actions happening when a pointer up event happens.
  102952. */
  102953. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102954. /**
  102955. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102956. */
  102957. private geometriesByUniqueId;
  102958. /**
  102959. * Creates a new Scene
  102960. * @param engine defines the engine to use to render this scene
  102961. * @param options defines the scene options
  102962. */
  102963. constructor(engine: Engine, options?: SceneOptions);
  102964. /**
  102965. * Gets a string idenfifying the name of the class
  102966. * @returns "Scene" string
  102967. */
  102968. getClassName(): string;
  102969. private _defaultMeshCandidates;
  102970. /**
  102971. * @hidden
  102972. */
  102973. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102974. private _defaultSubMeshCandidates;
  102975. /**
  102976. * @hidden
  102977. */
  102978. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102979. /**
  102980. * Sets the default candidate providers for the scene.
  102981. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102982. * and getCollidingSubMeshCandidates to their default function
  102983. */
  102984. setDefaultCandidateProviders(): void;
  102985. /**
  102986. * Gets the mesh that is currently under the pointer
  102987. */
  102988. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102989. /**
  102990. * Gets or sets the current on-screen X position of the pointer
  102991. */
  102992. pointerX: number;
  102993. /**
  102994. * Gets or sets the current on-screen Y position of the pointer
  102995. */
  102996. pointerY: number;
  102997. /**
  102998. * Gets the cached material (ie. the latest rendered one)
  102999. * @returns the cached material
  103000. */
  103001. getCachedMaterial(): Nullable<Material>;
  103002. /**
  103003. * Gets the cached effect (ie. the latest rendered one)
  103004. * @returns the cached effect
  103005. */
  103006. getCachedEffect(): Nullable<Effect>;
  103007. /**
  103008. * Gets the cached visibility state (ie. the latest rendered one)
  103009. * @returns the cached visibility state
  103010. */
  103011. getCachedVisibility(): Nullable<number>;
  103012. /**
  103013. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  103014. * @param material defines the current material
  103015. * @param effect defines the current effect
  103016. * @param visibility defines the current visibility state
  103017. * @returns true if one parameter is not cached
  103018. */
  103019. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  103020. /**
  103021. * Gets the engine associated with the scene
  103022. * @returns an Engine
  103023. */
  103024. getEngine(): Engine;
  103025. /**
  103026. * Gets the total number of vertices rendered per frame
  103027. * @returns the total number of vertices rendered per frame
  103028. */
  103029. getTotalVertices(): number;
  103030. /**
  103031. * Gets the performance counter for total vertices
  103032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  103033. */
  103034. readonly totalVerticesPerfCounter: PerfCounter;
  103035. /**
  103036. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  103037. * @returns the total number of active indices rendered per frame
  103038. */
  103039. getActiveIndices(): number;
  103040. /**
  103041. * Gets the performance counter for active indices
  103042. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  103043. */
  103044. readonly totalActiveIndicesPerfCounter: PerfCounter;
  103045. /**
  103046. * Gets the total number of active particles rendered per frame
  103047. * @returns the total number of active particles rendered per frame
  103048. */
  103049. getActiveParticles(): number;
  103050. /**
  103051. * Gets the performance counter for active particles
  103052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  103053. */
  103054. readonly activeParticlesPerfCounter: PerfCounter;
  103055. /**
  103056. * Gets the total number of active bones rendered per frame
  103057. * @returns the total number of active bones rendered per frame
  103058. */
  103059. getActiveBones(): number;
  103060. /**
  103061. * Gets the performance counter for active bones
  103062. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  103063. */
  103064. readonly activeBonesPerfCounter: PerfCounter;
  103065. /**
  103066. * Gets the array of active meshes
  103067. * @returns an array of AbstractMesh
  103068. */
  103069. getActiveMeshes(): SmartArray<AbstractMesh>;
  103070. /**
  103071. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  103072. * @returns a number
  103073. */
  103074. getAnimationRatio(): number;
  103075. /**
  103076. * Gets an unique Id for the current render phase
  103077. * @returns a number
  103078. */
  103079. getRenderId(): number;
  103080. /**
  103081. * Gets an unique Id for the current frame
  103082. * @returns a number
  103083. */
  103084. getFrameId(): number;
  103085. /** Call this function if you want to manually increment the render Id*/
  103086. incrementRenderId(): void;
  103087. private _createUbo;
  103088. /**
  103089. * Use this method to simulate a pointer move on a mesh
  103090. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103091. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103092. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103093. * @returns the current scene
  103094. */
  103095. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  103096. /**
  103097. * Use this method to simulate a pointer down on a mesh
  103098. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103099. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103100. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103101. * @returns the current scene
  103102. */
  103103. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  103104. /**
  103105. * Use this method to simulate a pointer up on a mesh
  103106. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103107. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103108. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103109. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  103110. * @returns the current scene
  103111. */
  103112. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  103113. /**
  103114. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  103115. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  103116. * @returns true if the pointer was captured
  103117. */
  103118. isPointerCaptured(pointerId?: number): boolean;
  103119. /**
  103120. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  103121. * @param attachUp defines if you want to attach events to pointerup
  103122. * @param attachDown defines if you want to attach events to pointerdown
  103123. * @param attachMove defines if you want to attach events to pointermove
  103124. */
  103125. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  103126. /** Detaches all event handlers*/
  103127. detachControl(): void;
  103128. /**
  103129. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  103130. * Delay loaded resources are not taking in account
  103131. * @return true if all required resources are ready
  103132. */
  103133. isReady(): boolean;
  103134. /** Resets all cached information relative to material (including effect and visibility) */
  103135. resetCachedMaterial(): void;
  103136. /**
  103137. * Registers a function to be called before every frame render
  103138. * @param func defines the function to register
  103139. */
  103140. registerBeforeRender(func: () => void): void;
  103141. /**
  103142. * Unregisters a function called before every frame render
  103143. * @param func defines the function to unregister
  103144. */
  103145. unregisterBeforeRender(func: () => void): void;
  103146. /**
  103147. * Registers a function to be called after every frame render
  103148. * @param func defines the function to register
  103149. */
  103150. registerAfterRender(func: () => void): void;
  103151. /**
  103152. * Unregisters a function called after every frame render
  103153. * @param func defines the function to unregister
  103154. */
  103155. unregisterAfterRender(func: () => void): void;
  103156. private _executeOnceBeforeRender;
  103157. /**
  103158. * The provided function will run before render once and will be disposed afterwards.
  103159. * A timeout delay can be provided so that the function will be executed in N ms.
  103160. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  103161. * @param func The function to be executed.
  103162. * @param timeout optional delay in ms
  103163. */
  103164. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  103165. /** @hidden */
  103166. _addPendingData(data: any): void;
  103167. /** @hidden */
  103168. _removePendingData(data: any): void;
  103169. /**
  103170. * Returns the number of items waiting to be loaded
  103171. * @returns the number of items waiting to be loaded
  103172. */
  103173. getWaitingItemsCount(): number;
  103174. /**
  103175. * Returns a boolean indicating if the scene is still loading data
  103176. */
  103177. readonly isLoading: boolean;
  103178. /**
  103179. * Registers a function to be executed when the scene is ready
  103180. * @param {Function} func - the function to be executed
  103181. */
  103182. executeWhenReady(func: () => void): void;
  103183. /**
  103184. * Returns a promise that resolves when the scene is ready
  103185. * @returns A promise that resolves when the scene is ready
  103186. */
  103187. whenReadyAsync(): Promise<void>;
  103188. /** @hidden */
  103189. _checkIsReady(): void;
  103190. /**
  103191. * Gets all animatable attached to the scene
  103192. */
  103193. readonly animatables: Animatable[];
  103194. /**
  103195. * Resets the last animation time frame.
  103196. * Useful to override when animations start running when loading a scene for the first time.
  103197. */
  103198. resetLastAnimationTimeFrame(): void;
  103199. /**
  103200. * Gets the current view matrix
  103201. * @returns a Matrix
  103202. */
  103203. getViewMatrix(): Matrix;
  103204. /**
  103205. * Gets the current projection matrix
  103206. * @returns a Matrix
  103207. */
  103208. getProjectionMatrix(): Matrix;
  103209. /**
  103210. * Gets the current transform matrix
  103211. * @returns a Matrix made of View * Projection
  103212. */
  103213. getTransformMatrix(): Matrix;
  103214. /**
  103215. * Sets the current transform matrix
  103216. * @param viewL defines the View matrix to use
  103217. * @param projectionL defines the Projection matrix to use
  103218. * @param viewR defines the right View matrix to use (if provided)
  103219. * @param projectionR defines the right Projection matrix to use (if provided)
  103220. */
  103221. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  103222. /**
  103223. * Gets the uniform buffer used to store scene data
  103224. * @returns a UniformBuffer
  103225. */
  103226. getSceneUniformBuffer(): UniformBuffer;
  103227. /**
  103228. * Gets an unique (relatively to the current scene) Id
  103229. * @returns an unique number for the scene
  103230. */
  103231. getUniqueId(): number;
  103232. /**
  103233. * Add a mesh to the list of scene's meshes
  103234. * @param newMesh defines the mesh to add
  103235. * @param recursive if all child meshes should also be added to the scene
  103236. */
  103237. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  103238. /**
  103239. * Remove a mesh for the list of scene's meshes
  103240. * @param toRemove defines the mesh to remove
  103241. * @param recursive if all child meshes should also be removed from the scene
  103242. * @returns the index where the mesh was in the mesh list
  103243. */
  103244. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  103245. /**
  103246. * Add a transform node to the list of scene's transform nodes
  103247. * @param newTransformNode defines the transform node to add
  103248. */
  103249. addTransformNode(newTransformNode: TransformNode): void;
  103250. /**
  103251. * Remove a transform node for the list of scene's transform nodes
  103252. * @param toRemove defines the transform node to remove
  103253. * @returns the index where the transform node was in the transform node list
  103254. */
  103255. removeTransformNode(toRemove: TransformNode): number;
  103256. /**
  103257. * Remove a skeleton for the list of scene's skeletons
  103258. * @param toRemove defines the skeleton to remove
  103259. * @returns the index where the skeleton was in the skeleton list
  103260. */
  103261. removeSkeleton(toRemove: Skeleton): number;
  103262. /**
  103263. * Remove a morph target for the list of scene's morph targets
  103264. * @param toRemove defines the morph target to remove
  103265. * @returns the index where the morph target was in the morph target list
  103266. */
  103267. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  103268. /**
  103269. * Remove a light for the list of scene's lights
  103270. * @param toRemove defines the light to remove
  103271. * @returns the index where the light was in the light list
  103272. */
  103273. removeLight(toRemove: Light): number;
  103274. /**
  103275. * Remove a camera for the list of scene's cameras
  103276. * @param toRemove defines the camera to remove
  103277. * @returns the index where the camera was in the camera list
  103278. */
  103279. removeCamera(toRemove: Camera): number;
  103280. /**
  103281. * Remove a particle system for the list of scene's particle systems
  103282. * @param toRemove defines the particle system to remove
  103283. * @returns the index where the particle system was in the particle system list
  103284. */
  103285. removeParticleSystem(toRemove: IParticleSystem): number;
  103286. /**
  103287. * Remove a animation for the list of scene's animations
  103288. * @param toRemove defines the animation to remove
  103289. * @returns the index where the animation was in the animation list
  103290. */
  103291. removeAnimation(toRemove: Animation): number;
  103292. /**
  103293. * Will stop the animation of the given target
  103294. * @param target - the target
  103295. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  103296. * @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)
  103297. */
  103298. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  103299. /**
  103300. * Removes the given animation group from this scene.
  103301. * @param toRemove The animation group to remove
  103302. * @returns The index of the removed animation group
  103303. */
  103304. removeAnimationGroup(toRemove: AnimationGroup): number;
  103305. /**
  103306. * Removes the given multi-material from this scene.
  103307. * @param toRemove The multi-material to remove
  103308. * @returns The index of the removed multi-material
  103309. */
  103310. removeMultiMaterial(toRemove: MultiMaterial): number;
  103311. /**
  103312. * Removes the given material from this scene.
  103313. * @param toRemove The material to remove
  103314. * @returns The index of the removed material
  103315. */
  103316. removeMaterial(toRemove: Material): number;
  103317. /**
  103318. * Removes the given action manager from this scene.
  103319. * @param toRemove The action manager to remove
  103320. * @returns The index of the removed action manager
  103321. */
  103322. removeActionManager(toRemove: AbstractActionManager): number;
  103323. /**
  103324. * Removes the given texture from this scene.
  103325. * @param toRemove The texture to remove
  103326. * @returns The index of the removed texture
  103327. */
  103328. removeTexture(toRemove: BaseTexture): number;
  103329. /**
  103330. * Adds the given light to this scene
  103331. * @param newLight The light to add
  103332. */
  103333. addLight(newLight: Light): void;
  103334. /**
  103335. * Sorts the list list based on light priorities
  103336. */
  103337. sortLightsByPriority(): void;
  103338. /**
  103339. * Adds the given camera to this scene
  103340. * @param newCamera The camera to add
  103341. */
  103342. addCamera(newCamera: Camera): void;
  103343. /**
  103344. * Adds the given skeleton to this scene
  103345. * @param newSkeleton The skeleton to add
  103346. */
  103347. addSkeleton(newSkeleton: Skeleton): void;
  103348. /**
  103349. * Adds the given particle system to this scene
  103350. * @param newParticleSystem The particle system to add
  103351. */
  103352. addParticleSystem(newParticleSystem: IParticleSystem): void;
  103353. /**
  103354. * Adds the given animation to this scene
  103355. * @param newAnimation The animation to add
  103356. */
  103357. addAnimation(newAnimation: Animation): void;
  103358. /**
  103359. * Adds the given animation group to this scene.
  103360. * @param newAnimationGroup The animation group to add
  103361. */
  103362. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  103363. /**
  103364. * Adds the given multi-material to this scene
  103365. * @param newMultiMaterial The multi-material to add
  103366. */
  103367. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  103368. /**
  103369. * Adds the given material to this scene
  103370. * @param newMaterial The material to add
  103371. */
  103372. addMaterial(newMaterial: Material): void;
  103373. /**
  103374. * Adds the given morph target to this scene
  103375. * @param newMorphTargetManager The morph target to add
  103376. */
  103377. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  103378. /**
  103379. * Adds the given geometry to this scene
  103380. * @param newGeometry The geometry to add
  103381. */
  103382. addGeometry(newGeometry: Geometry): void;
  103383. /**
  103384. * Adds the given action manager to this scene
  103385. * @param newActionManager The action manager to add
  103386. */
  103387. addActionManager(newActionManager: AbstractActionManager): void;
  103388. /**
  103389. * Adds the given texture to this scene.
  103390. * @param newTexture The texture to add
  103391. */
  103392. addTexture(newTexture: BaseTexture): void;
  103393. /**
  103394. * Switch active camera
  103395. * @param newCamera defines the new active camera
  103396. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  103397. */
  103398. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  103399. /**
  103400. * sets the active camera of the scene using its ID
  103401. * @param id defines the camera's ID
  103402. * @return the new active camera or null if none found.
  103403. */
  103404. setActiveCameraByID(id: string): Nullable<Camera>;
  103405. /**
  103406. * sets the active camera of the scene using its name
  103407. * @param name defines the camera's name
  103408. * @returns the new active camera or null if none found.
  103409. */
  103410. setActiveCameraByName(name: string): Nullable<Camera>;
  103411. /**
  103412. * get an animation group using its name
  103413. * @param name defines the material's name
  103414. * @return the animation group or null if none found.
  103415. */
  103416. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  103417. /**
  103418. * Get a material using its unique id
  103419. * @param uniqueId defines the material's unique id
  103420. * @return the material or null if none found.
  103421. */
  103422. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  103423. /**
  103424. * get a material using its id
  103425. * @param id defines the material's ID
  103426. * @return the material or null if none found.
  103427. */
  103428. getMaterialByID(id: string): Nullable<Material>;
  103429. /**
  103430. * Gets a the last added material using a given id
  103431. * @param id defines the material's ID
  103432. * @return the last material with the given id or null if none found.
  103433. */
  103434. getLastMaterialByID(id: string): Nullable<Material>;
  103435. /**
  103436. * Gets a material using its name
  103437. * @param name defines the material's name
  103438. * @return the material or null if none found.
  103439. */
  103440. getMaterialByName(name: string): Nullable<Material>;
  103441. /**
  103442. * Get a texture using its unique id
  103443. * @param uniqueId defines the texture's unique id
  103444. * @return the texture or null if none found.
  103445. */
  103446. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  103447. /**
  103448. * Gets a camera using its id
  103449. * @param id defines the id to look for
  103450. * @returns the camera or null if not found
  103451. */
  103452. getCameraByID(id: string): Nullable<Camera>;
  103453. /**
  103454. * Gets a camera using its unique id
  103455. * @param uniqueId defines the unique id to look for
  103456. * @returns the camera or null if not found
  103457. */
  103458. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  103459. /**
  103460. * Gets a camera using its name
  103461. * @param name defines the camera's name
  103462. * @return the camera or null if none found.
  103463. */
  103464. getCameraByName(name: string): Nullable<Camera>;
  103465. /**
  103466. * Gets a bone using its id
  103467. * @param id defines the bone's id
  103468. * @return the bone or null if not found
  103469. */
  103470. getBoneByID(id: string): Nullable<Bone>;
  103471. /**
  103472. * Gets a bone using its id
  103473. * @param name defines the bone's name
  103474. * @return the bone or null if not found
  103475. */
  103476. getBoneByName(name: string): Nullable<Bone>;
  103477. /**
  103478. * Gets a light node using its name
  103479. * @param name defines the the light's name
  103480. * @return the light or null if none found.
  103481. */
  103482. getLightByName(name: string): Nullable<Light>;
  103483. /**
  103484. * Gets a light node using its id
  103485. * @param id defines the light's id
  103486. * @return the light or null if none found.
  103487. */
  103488. getLightByID(id: string): Nullable<Light>;
  103489. /**
  103490. * Gets a light node using its scene-generated unique ID
  103491. * @param uniqueId defines the light's unique id
  103492. * @return the light or null if none found.
  103493. */
  103494. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  103495. /**
  103496. * Gets a particle system by id
  103497. * @param id defines the particle system id
  103498. * @return the corresponding system or null if none found
  103499. */
  103500. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  103501. /**
  103502. * Gets a geometry using its ID
  103503. * @param id defines the geometry's id
  103504. * @return the geometry or null if none found.
  103505. */
  103506. getGeometryByID(id: string): Nullable<Geometry>;
  103507. private _getGeometryByUniqueID;
  103508. /**
  103509. * Add a new geometry to this scene
  103510. * @param geometry defines the geometry to be added to the scene.
  103511. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  103512. * @return a boolean defining if the geometry was added or not
  103513. */
  103514. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  103515. /**
  103516. * Removes an existing geometry
  103517. * @param geometry defines the geometry to be removed from the scene
  103518. * @return a boolean defining if the geometry was removed or not
  103519. */
  103520. removeGeometry(geometry: Geometry): boolean;
  103521. /**
  103522. * Gets the list of geometries attached to the scene
  103523. * @returns an array of Geometry
  103524. */
  103525. getGeometries(): Geometry[];
  103526. /**
  103527. * Gets the first added mesh found of a given ID
  103528. * @param id defines the id to search for
  103529. * @return the mesh found or null if not found at all
  103530. */
  103531. getMeshByID(id: string): Nullable<AbstractMesh>;
  103532. /**
  103533. * Gets a list of meshes using their id
  103534. * @param id defines the id to search for
  103535. * @returns a list of meshes
  103536. */
  103537. getMeshesByID(id: string): Array<AbstractMesh>;
  103538. /**
  103539. * Gets the first added transform node found of a given ID
  103540. * @param id defines the id to search for
  103541. * @return the found transform node or null if not found at all.
  103542. */
  103543. getTransformNodeByID(id: string): Nullable<TransformNode>;
  103544. /**
  103545. * Gets a transform node with its auto-generated unique id
  103546. * @param uniqueId efines the unique id to search for
  103547. * @return the found transform node or null if not found at all.
  103548. */
  103549. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  103550. /**
  103551. * Gets a list of transform nodes using their id
  103552. * @param id defines the id to search for
  103553. * @returns a list of transform nodes
  103554. */
  103555. getTransformNodesByID(id: string): Array<TransformNode>;
  103556. /**
  103557. * Gets a mesh with its auto-generated unique id
  103558. * @param uniqueId defines the unique id to search for
  103559. * @return the found mesh or null if not found at all.
  103560. */
  103561. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  103562. /**
  103563. * Gets a the last added mesh using a given id
  103564. * @param id defines the id to search for
  103565. * @return the found mesh or null if not found at all.
  103566. */
  103567. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  103568. /**
  103569. * Gets a the last added node (Mesh, Camera, Light) using a given id
  103570. * @param id defines the id to search for
  103571. * @return the found node or null if not found at all
  103572. */
  103573. getLastEntryByID(id: string): Nullable<Node>;
  103574. /**
  103575. * Gets a node (Mesh, Camera, Light) using a given id
  103576. * @param id defines the id to search for
  103577. * @return the found node or null if not found at all
  103578. */
  103579. getNodeByID(id: string): Nullable<Node>;
  103580. /**
  103581. * Gets a node (Mesh, Camera, Light) using a given name
  103582. * @param name defines the name to search for
  103583. * @return the found node or null if not found at all.
  103584. */
  103585. getNodeByName(name: string): Nullable<Node>;
  103586. /**
  103587. * Gets a mesh using a given name
  103588. * @param name defines the name to search for
  103589. * @return the found mesh or null if not found at all.
  103590. */
  103591. getMeshByName(name: string): Nullable<AbstractMesh>;
  103592. /**
  103593. * Gets a transform node using a given name
  103594. * @param name defines the name to search for
  103595. * @return the found transform node or null if not found at all.
  103596. */
  103597. getTransformNodeByName(name: string): Nullable<TransformNode>;
  103598. /**
  103599. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  103600. * @param id defines the id to search for
  103601. * @return the found skeleton or null if not found at all.
  103602. */
  103603. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  103604. /**
  103605. * Gets a skeleton using a given auto generated unique id
  103606. * @param uniqueId defines the unique id to search for
  103607. * @return the found skeleton or null if not found at all.
  103608. */
  103609. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  103610. /**
  103611. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  103612. * @param id defines the id to search for
  103613. * @return the found skeleton or null if not found at all.
  103614. */
  103615. getSkeletonById(id: string): Nullable<Skeleton>;
  103616. /**
  103617. * Gets a skeleton using a given name
  103618. * @param name defines the name to search for
  103619. * @return the found skeleton or null if not found at all.
  103620. */
  103621. getSkeletonByName(name: string): Nullable<Skeleton>;
  103622. /**
  103623. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  103624. * @param id defines the id to search for
  103625. * @return the found morph target manager or null if not found at all.
  103626. */
  103627. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  103628. /**
  103629. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  103630. * @param id defines the id to search for
  103631. * @return the found morph target or null if not found at all.
  103632. */
  103633. getMorphTargetById(id: string): Nullable<MorphTarget>;
  103634. /**
  103635. * Gets a boolean indicating if the given mesh is active
  103636. * @param mesh defines the mesh to look for
  103637. * @returns true if the mesh is in the active list
  103638. */
  103639. isActiveMesh(mesh: AbstractMesh): boolean;
  103640. /**
  103641. * Return a unique id as a string which can serve as an identifier for the scene
  103642. */
  103643. readonly uid: string;
  103644. /**
  103645. * Add an externaly attached data from its key.
  103646. * This method call will fail and return false, if such key already exists.
  103647. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  103648. * @param key the unique key that identifies the data
  103649. * @param data the data object to associate to the key for this Engine instance
  103650. * @return true if no such key were already present and the data was added successfully, false otherwise
  103651. */
  103652. addExternalData<T>(key: string, data: T): boolean;
  103653. /**
  103654. * Get an externaly attached data from its key
  103655. * @param key the unique key that identifies the data
  103656. * @return the associated data, if present (can be null), or undefined if not present
  103657. */
  103658. getExternalData<T>(key: string): Nullable<T>;
  103659. /**
  103660. * Get an externaly attached data from its key, create it using a factory if it's not already present
  103661. * @param key the unique key that identifies the data
  103662. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  103663. * @return the associated data, can be null if the factory returned null.
  103664. */
  103665. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  103666. /**
  103667. * Remove an externaly attached data from the Engine instance
  103668. * @param key the unique key that identifies the data
  103669. * @return true if the data was successfully removed, false if it doesn't exist
  103670. */
  103671. removeExternalData(key: string): boolean;
  103672. private _evaluateSubMesh;
  103673. /**
  103674. * Clear the processed materials smart array preventing retention point in material dispose.
  103675. */
  103676. freeProcessedMaterials(): void;
  103677. private _preventFreeActiveMeshesAndRenderingGroups;
  103678. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  103679. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  103680. * when disposing several meshes in a row or a hierarchy of meshes.
  103681. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  103682. */
  103683. blockfreeActiveMeshesAndRenderingGroups: boolean;
  103684. /**
  103685. * Clear the active meshes smart array preventing retention point in mesh dispose.
  103686. */
  103687. freeActiveMeshes(): void;
  103688. /**
  103689. * Clear the info related to rendering groups preventing retention points during dispose.
  103690. */
  103691. freeRenderingGroups(): void;
  103692. /** @hidden */
  103693. _isInIntermediateRendering(): boolean;
  103694. /**
  103695. * Lambda returning the list of potentially active meshes.
  103696. */
  103697. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  103698. /**
  103699. * Lambda returning the list of potentially active sub meshes.
  103700. */
  103701. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  103702. /**
  103703. * Lambda returning the list of potentially intersecting sub meshes.
  103704. */
  103705. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  103706. /**
  103707. * Lambda returning the list of potentially colliding sub meshes.
  103708. */
  103709. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  103710. private _activeMeshesFrozen;
  103711. private _skipEvaluateActiveMeshesCompletely;
  103712. /**
  103713. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  103714. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  103715. * @returns the current scene
  103716. */
  103717. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  103718. /**
  103719. * Use this function to restart evaluating active meshes on every frame
  103720. * @returns the current scene
  103721. */
  103722. unfreezeActiveMeshes(): Scene;
  103723. private _evaluateActiveMeshes;
  103724. private _activeMesh;
  103725. /**
  103726. * Update the transform matrix to update from the current active camera
  103727. * @param force defines a boolean used to force the update even if cache is up to date
  103728. */
  103729. updateTransformMatrix(force?: boolean): void;
  103730. private _bindFrameBuffer;
  103731. /** @hidden */
  103732. _allowPostProcessClearColor: boolean;
  103733. /** @hidden */
  103734. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  103735. private _processSubCameras;
  103736. private _checkIntersections;
  103737. /** @hidden */
  103738. _advancePhysicsEngineStep(step: number): void;
  103739. /**
  103740. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  103741. */
  103742. getDeterministicFrameTime: () => number;
  103743. /** @hidden */
  103744. _animate(): void;
  103745. /** Execute all animations (for a frame) */
  103746. animate(): void;
  103747. /**
  103748. * Render the scene
  103749. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  103750. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  103751. */
  103752. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  103753. /**
  103754. * Freeze all materials
  103755. * A frozen material will not be updatable but should be faster to render
  103756. */
  103757. freezeMaterials(): void;
  103758. /**
  103759. * Unfreeze all materials
  103760. * A frozen material will not be updatable but should be faster to render
  103761. */
  103762. unfreezeMaterials(): void;
  103763. /**
  103764. * Releases all held ressources
  103765. */
  103766. dispose(): void;
  103767. /**
  103768. * Gets if the scene is already disposed
  103769. */
  103770. readonly isDisposed: boolean;
  103771. /**
  103772. * Call this function to reduce memory footprint of the scene.
  103773. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  103774. */
  103775. clearCachedVertexData(): void;
  103776. /**
  103777. * This function will remove the local cached buffer data from texture.
  103778. * It will save memory but will prevent the texture from being rebuilt
  103779. */
  103780. cleanCachedTextureBuffer(): void;
  103781. /**
  103782. * Get the world extend vectors with an optional filter
  103783. *
  103784. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  103785. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  103786. */
  103787. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  103788. min: Vector3;
  103789. max: Vector3;
  103790. };
  103791. /**
  103792. * Creates a ray that can be used to pick in the scene
  103793. * @param x defines the x coordinate of the origin (on-screen)
  103794. * @param y defines the y coordinate of the origin (on-screen)
  103795. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103796. * @param camera defines the camera to use for the picking
  103797. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103798. * @returns a Ray
  103799. */
  103800. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  103801. /**
  103802. * Creates a ray that can be used to pick in the scene
  103803. * @param x defines the x coordinate of the origin (on-screen)
  103804. * @param y defines the y coordinate of the origin (on-screen)
  103805. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103806. * @param result defines the ray where to store the picking ray
  103807. * @param camera defines the camera to use for the picking
  103808. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103809. * @returns the current scene
  103810. */
  103811. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  103812. /**
  103813. * Creates a ray that can be used to pick in the scene
  103814. * @param x defines the x coordinate of the origin (on-screen)
  103815. * @param y defines the y coordinate of the origin (on-screen)
  103816. * @param camera defines the camera to use for the picking
  103817. * @returns a Ray
  103818. */
  103819. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  103820. /**
  103821. * Creates a ray that can be used to pick in the scene
  103822. * @param x defines the x coordinate of the origin (on-screen)
  103823. * @param y defines the y coordinate of the origin (on-screen)
  103824. * @param result defines the ray where to store the picking ray
  103825. * @param camera defines the camera to use for the picking
  103826. * @returns the current scene
  103827. */
  103828. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  103829. /** Launch a ray to try to pick a mesh in the scene
  103830. * @param x position on screen
  103831. * @param y position on screen
  103832. * @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
  103833. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  103834. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103835. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103836. * @returns a PickingInfo
  103837. */
  103838. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103839. /** Use the given ray to pick a mesh in the scene
  103840. * @param ray The ray to use to pick meshes
  103841. * @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
  103842. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103843. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103844. * @returns a PickingInfo
  103845. */
  103846. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103847. /**
  103848. * Launch a ray to try to pick a mesh in the scene
  103849. * @param x X position on screen
  103850. * @param y Y position on screen
  103851. * @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
  103852. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103854. * @returns an array of PickingInfo
  103855. */
  103856. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103857. /**
  103858. * Launch a ray to try to pick a mesh in the scene
  103859. * @param ray Ray to use
  103860. * @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
  103861. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103862. * @returns an array of PickingInfo
  103863. */
  103864. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103865. /**
  103866. * Force the value of meshUnderPointer
  103867. * @param mesh defines the mesh to use
  103868. */
  103869. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103870. /**
  103871. * Gets the mesh under the pointer
  103872. * @returns a Mesh or null if no mesh is under the pointer
  103873. */
  103874. getPointerOverMesh(): Nullable<AbstractMesh>;
  103875. /** @hidden */
  103876. _rebuildGeometries(): void;
  103877. /** @hidden */
  103878. _rebuildTextures(): void;
  103879. private _getByTags;
  103880. /**
  103881. * Get a list of meshes by tags
  103882. * @param tagsQuery defines the tags query to use
  103883. * @param forEach defines a predicate used to filter results
  103884. * @returns an array of Mesh
  103885. */
  103886. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103887. /**
  103888. * Get a list of cameras by tags
  103889. * @param tagsQuery defines the tags query to use
  103890. * @param forEach defines a predicate used to filter results
  103891. * @returns an array of Camera
  103892. */
  103893. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103894. /**
  103895. * Get a list of lights by tags
  103896. * @param tagsQuery defines the tags query to use
  103897. * @param forEach defines a predicate used to filter results
  103898. * @returns an array of Light
  103899. */
  103900. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103901. /**
  103902. * Get a list of materials by tags
  103903. * @param tagsQuery defines the tags query to use
  103904. * @param forEach defines a predicate used to filter results
  103905. * @returns an array of Material
  103906. */
  103907. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103908. /**
  103909. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103910. * This allowed control for front to back rendering or reversly depending of the special needs.
  103911. *
  103912. * @param renderingGroupId The rendering group id corresponding to its index
  103913. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103914. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103915. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103916. */
  103917. 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;
  103918. /**
  103919. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103920. *
  103921. * @param renderingGroupId The rendering group id corresponding to its index
  103922. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103923. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103924. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103925. */
  103926. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103927. /**
  103928. * Gets the current auto clear configuration for one rendering group of the rendering
  103929. * manager.
  103930. * @param index the rendering group index to get the information for
  103931. * @returns The auto clear setup for the requested rendering group
  103932. */
  103933. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103934. private _blockMaterialDirtyMechanism;
  103935. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103936. blockMaterialDirtyMechanism: boolean;
  103937. /**
  103938. * Will flag all materials as dirty to trigger new shader compilation
  103939. * @param flag defines the flag used to specify which material part must be marked as dirty
  103940. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103941. */
  103942. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103943. /** @hidden */
  103944. _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;
  103945. /** @hidden */
  103946. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103947. /** @hidden */
  103948. _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;
  103949. /** @hidden */
  103950. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103951. /** @hidden */
  103952. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103953. /** @hidden */
  103954. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103955. }
  103956. }
  103957. declare module BABYLON {
  103958. /**
  103959. * Set of assets to keep when moving a scene into an asset container.
  103960. */
  103961. export class KeepAssets extends AbstractScene {
  103962. }
  103963. /**
  103964. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103965. */
  103966. export class InstantiatedEntries {
  103967. /**
  103968. * List of new root nodes (eg. nodes with no parent)
  103969. */
  103970. rootNodes: TransformNode[];
  103971. /**
  103972. * List of new skeletons
  103973. */
  103974. skeletons: Skeleton[];
  103975. /**
  103976. * List of new animation groups
  103977. */
  103978. animationGroups: AnimationGroup[];
  103979. }
  103980. /**
  103981. * Container with a set of assets that can be added or removed from a scene.
  103982. */
  103983. export class AssetContainer extends AbstractScene {
  103984. /**
  103985. * The scene the AssetContainer belongs to.
  103986. */
  103987. scene: Scene;
  103988. /**
  103989. * Instantiates an AssetContainer.
  103990. * @param scene The scene the AssetContainer belongs to.
  103991. */
  103992. constructor(scene: Scene);
  103993. /**
  103994. * Instantiate or clone all meshes and add the new ones to the scene.
  103995. * Skeletons and animation groups will all be cloned
  103996. * @param nameFunction defines an optional function used to get new names for clones
  103997. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103998. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103999. */
  104000. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  104001. /**
  104002. * Adds all the assets from the container to the scene.
  104003. */
  104004. addAllToScene(): void;
  104005. /**
  104006. * Removes all the assets in the container from the scene
  104007. */
  104008. removeAllFromScene(): void;
  104009. /**
  104010. * Disposes all the assets in the container
  104011. */
  104012. dispose(): void;
  104013. private _moveAssets;
  104014. /**
  104015. * Removes all the assets contained in the scene and adds them to the container.
  104016. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  104017. */
  104018. moveAllFromScene(keepAssets?: KeepAssets): void;
  104019. /**
  104020. * 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.
  104021. * @returns the root mesh
  104022. */
  104023. createRootMesh(): Mesh;
  104024. }
  104025. }
  104026. declare module BABYLON {
  104027. /**
  104028. * Defines how the parser contract is defined.
  104029. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  104030. */
  104031. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  104032. /**
  104033. * Defines how the individual parser contract is defined.
  104034. * These parser can parse an individual asset
  104035. */
  104036. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  104037. /**
  104038. * Base class of the scene acting as a container for the different elements composing a scene.
  104039. * This class is dynamically extended by the different components of the scene increasing
  104040. * flexibility and reducing coupling
  104041. */
  104042. export abstract class AbstractScene {
  104043. /**
  104044. * Stores the list of available parsers in the application.
  104045. */
  104046. private static _BabylonFileParsers;
  104047. /**
  104048. * Stores the list of available individual parsers in the application.
  104049. */
  104050. private static _IndividualBabylonFileParsers;
  104051. /**
  104052. * Adds a parser in the list of available ones
  104053. * @param name Defines the name of the parser
  104054. * @param parser Defines the parser to add
  104055. */
  104056. static AddParser(name: string, parser: BabylonFileParser): void;
  104057. /**
  104058. * Gets a general parser from the list of avaialble ones
  104059. * @param name Defines the name of the parser
  104060. * @returns the requested parser or null
  104061. */
  104062. static GetParser(name: string): Nullable<BabylonFileParser>;
  104063. /**
  104064. * Adds n individual parser in the list of available ones
  104065. * @param name Defines the name of the parser
  104066. * @param parser Defines the parser to add
  104067. */
  104068. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  104069. /**
  104070. * Gets an individual parser from the list of avaialble ones
  104071. * @param name Defines the name of the parser
  104072. * @returns the requested parser or null
  104073. */
  104074. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  104075. /**
  104076. * Parser json data and populate both a scene and its associated container object
  104077. * @param jsonData Defines the data to parse
  104078. * @param scene Defines the scene to parse the data for
  104079. * @param container Defines the container attached to the parsing sequence
  104080. * @param rootUrl Defines the root url of the data
  104081. */
  104082. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  104083. /**
  104084. * Gets the list of root nodes (ie. nodes with no parent)
  104085. */
  104086. rootNodes: Node[];
  104087. /** All of the cameras added to this scene
  104088. * @see http://doc.babylonjs.com/babylon101/cameras
  104089. */
  104090. cameras: Camera[];
  104091. /**
  104092. * All of the lights added to this scene
  104093. * @see http://doc.babylonjs.com/babylon101/lights
  104094. */
  104095. lights: Light[];
  104096. /**
  104097. * All of the (abstract) meshes added to this scene
  104098. */
  104099. meshes: AbstractMesh[];
  104100. /**
  104101. * The list of skeletons added to the scene
  104102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  104103. */
  104104. skeletons: Skeleton[];
  104105. /**
  104106. * All of the particle systems added to this scene
  104107. * @see http://doc.babylonjs.com/babylon101/particles
  104108. */
  104109. particleSystems: IParticleSystem[];
  104110. /**
  104111. * Gets a list of Animations associated with the scene
  104112. */
  104113. animations: Animation[];
  104114. /**
  104115. * All of the animation groups added to this scene
  104116. * @see http://doc.babylonjs.com/how_to/group
  104117. */
  104118. animationGroups: AnimationGroup[];
  104119. /**
  104120. * All of the multi-materials added to this scene
  104121. * @see http://doc.babylonjs.com/how_to/multi_materials
  104122. */
  104123. multiMaterials: MultiMaterial[];
  104124. /**
  104125. * All of the materials added to this scene
  104126. * In the context of a Scene, it is not supposed to be modified manually.
  104127. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  104128. * Note also that the order of the Material within the array is not significant and might change.
  104129. * @see http://doc.babylonjs.com/babylon101/materials
  104130. */
  104131. materials: Material[];
  104132. /**
  104133. * The list of morph target managers added to the scene
  104134. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  104135. */
  104136. morphTargetManagers: MorphTargetManager[];
  104137. /**
  104138. * The list of geometries used in the scene.
  104139. */
  104140. geometries: Geometry[];
  104141. /**
  104142. * All of the tranform nodes added to this scene
  104143. * In the context of a Scene, it is not supposed to be modified manually.
  104144. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  104145. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  104146. * @see http://doc.babylonjs.com/how_to/transformnode
  104147. */
  104148. transformNodes: TransformNode[];
  104149. /**
  104150. * ActionManagers available on the scene.
  104151. */
  104152. actionManagers: AbstractActionManager[];
  104153. /**
  104154. * Textures to keep.
  104155. */
  104156. textures: BaseTexture[];
  104157. /**
  104158. * Environment texture for the scene
  104159. */
  104160. environmentTexture: Nullable<BaseTexture>;
  104161. }
  104162. }
  104163. declare module BABYLON {
  104164. /**
  104165. * Interface used to define options for Sound class
  104166. */
  104167. export interface ISoundOptions {
  104168. /**
  104169. * Does the sound autoplay once loaded.
  104170. */
  104171. autoplay?: boolean;
  104172. /**
  104173. * Does the sound loop after it finishes playing once.
  104174. */
  104175. loop?: boolean;
  104176. /**
  104177. * Sound's volume
  104178. */
  104179. volume?: number;
  104180. /**
  104181. * Is it a spatial sound?
  104182. */
  104183. spatialSound?: boolean;
  104184. /**
  104185. * Maximum distance to hear that sound
  104186. */
  104187. maxDistance?: number;
  104188. /**
  104189. * Uses user defined attenuation function
  104190. */
  104191. useCustomAttenuation?: boolean;
  104192. /**
  104193. * Define the roll off factor of spatial sounds.
  104194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104195. */
  104196. rolloffFactor?: number;
  104197. /**
  104198. * Define the reference distance the sound should be heard perfectly.
  104199. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104200. */
  104201. refDistance?: number;
  104202. /**
  104203. * Define the distance attenuation model the sound will follow.
  104204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104205. */
  104206. distanceModel?: string;
  104207. /**
  104208. * Defines the playback speed (1 by default)
  104209. */
  104210. playbackRate?: number;
  104211. /**
  104212. * Defines if the sound is from a streaming source
  104213. */
  104214. streaming?: boolean;
  104215. /**
  104216. * Defines an optional length (in seconds) inside the sound file
  104217. */
  104218. length?: number;
  104219. /**
  104220. * Defines an optional offset (in seconds) inside the sound file
  104221. */
  104222. offset?: number;
  104223. /**
  104224. * If true, URLs will not be required to state the audio file codec to use.
  104225. */
  104226. skipCodecCheck?: boolean;
  104227. }
  104228. /**
  104229. * Defines a sound that can be played in the application.
  104230. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  104231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104232. */
  104233. export class Sound {
  104234. /**
  104235. * The name of the sound in the scene.
  104236. */
  104237. name: string;
  104238. /**
  104239. * Does the sound autoplay once loaded.
  104240. */
  104241. autoplay: boolean;
  104242. /**
  104243. * Does the sound loop after it finishes playing once.
  104244. */
  104245. loop: boolean;
  104246. /**
  104247. * Does the sound use a custom attenuation curve to simulate the falloff
  104248. * happening when the source gets further away from the camera.
  104249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  104250. */
  104251. useCustomAttenuation: boolean;
  104252. /**
  104253. * The sound track id this sound belongs to.
  104254. */
  104255. soundTrackId: number;
  104256. /**
  104257. * Is this sound currently played.
  104258. */
  104259. isPlaying: boolean;
  104260. /**
  104261. * Is this sound currently paused.
  104262. */
  104263. isPaused: boolean;
  104264. /**
  104265. * Does this sound enables spatial sound.
  104266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104267. */
  104268. spatialSound: boolean;
  104269. /**
  104270. * Define the reference distance the sound should be heard perfectly.
  104271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104272. */
  104273. refDistance: number;
  104274. /**
  104275. * Define the roll off factor of spatial sounds.
  104276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104277. */
  104278. rolloffFactor: number;
  104279. /**
  104280. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  104281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104282. */
  104283. maxDistance: number;
  104284. /**
  104285. * Define the distance attenuation model the sound will follow.
  104286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104287. */
  104288. distanceModel: string;
  104289. /**
  104290. * @hidden
  104291. * Back Compat
  104292. **/
  104293. onended: () => any;
  104294. /**
  104295. * Observable event when the current playing sound finishes.
  104296. */
  104297. onEndedObservable: Observable<Sound>;
  104298. private _panningModel;
  104299. private _playbackRate;
  104300. private _streaming;
  104301. private _startTime;
  104302. private _startOffset;
  104303. private _position;
  104304. /** @hidden */
  104305. _positionInEmitterSpace: boolean;
  104306. private _localDirection;
  104307. private _volume;
  104308. private _isReadyToPlay;
  104309. private _isDirectional;
  104310. private _readyToPlayCallback;
  104311. private _audioBuffer;
  104312. private _soundSource;
  104313. private _streamingSource;
  104314. private _soundPanner;
  104315. private _soundGain;
  104316. private _inputAudioNode;
  104317. private _outputAudioNode;
  104318. private _coneInnerAngle;
  104319. private _coneOuterAngle;
  104320. private _coneOuterGain;
  104321. private _scene;
  104322. private _connectedTransformNode;
  104323. private _customAttenuationFunction;
  104324. private _registerFunc;
  104325. private _isOutputConnected;
  104326. private _htmlAudioElement;
  104327. private _urlType;
  104328. private _length?;
  104329. private _offset?;
  104330. /** @hidden */
  104331. static _SceneComponentInitialization: (scene: Scene) => void;
  104332. /**
  104333. * Create a sound and attach it to a scene
  104334. * @param name Name of your sound
  104335. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  104336. * @param scene defines the scene the sound belongs to
  104337. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  104338. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  104339. */
  104340. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  104341. /**
  104342. * Release the sound and its associated resources
  104343. */
  104344. dispose(): void;
  104345. /**
  104346. * Gets if the sounds is ready to be played or not.
  104347. * @returns true if ready, otherwise false
  104348. */
  104349. isReady(): boolean;
  104350. private _soundLoaded;
  104351. /**
  104352. * Sets the data of the sound from an audiobuffer
  104353. * @param audioBuffer The audioBuffer containing the data
  104354. */
  104355. setAudioBuffer(audioBuffer: AudioBuffer): void;
  104356. /**
  104357. * Updates the current sounds options such as maxdistance, loop...
  104358. * @param options A JSON object containing values named as the object properties
  104359. */
  104360. updateOptions(options: ISoundOptions): void;
  104361. private _createSpatialParameters;
  104362. private _updateSpatialParameters;
  104363. /**
  104364. * Switch the panning model to HRTF:
  104365. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  104366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104367. */
  104368. switchPanningModelToHRTF(): void;
  104369. /**
  104370. * Switch the panning model to Equal Power:
  104371. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  104372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104373. */
  104374. switchPanningModelToEqualPower(): void;
  104375. private _switchPanningModel;
  104376. /**
  104377. * Connect this sound to a sound track audio node like gain...
  104378. * @param soundTrackAudioNode the sound track audio node to connect to
  104379. */
  104380. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  104381. /**
  104382. * Transform this sound into a directional source
  104383. * @param coneInnerAngle Size of the inner cone in degree
  104384. * @param coneOuterAngle Size of the outer cone in degree
  104385. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  104386. */
  104387. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  104388. /**
  104389. * Gets or sets the inner angle for the directional cone.
  104390. */
  104391. /**
  104392. * Gets or sets the inner angle for the directional cone.
  104393. */
  104394. directionalConeInnerAngle: number;
  104395. /**
  104396. * Gets or sets the outer angle for the directional cone.
  104397. */
  104398. /**
  104399. * Gets or sets the outer angle for the directional cone.
  104400. */
  104401. directionalConeOuterAngle: number;
  104402. /**
  104403. * Sets the position of the emitter if spatial sound is enabled
  104404. * @param newPosition Defines the new posisiton
  104405. */
  104406. setPosition(newPosition: Vector3): void;
  104407. /**
  104408. * Sets the local direction of the emitter if spatial sound is enabled
  104409. * @param newLocalDirection Defines the new local direction
  104410. */
  104411. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  104412. private _updateDirection;
  104413. /** @hidden */
  104414. updateDistanceFromListener(): void;
  104415. /**
  104416. * Sets a new custom attenuation function for the sound.
  104417. * @param callback Defines the function used for the attenuation
  104418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  104419. */
  104420. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  104421. /**
  104422. * Play the sound
  104423. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  104424. * @param offset (optional) Start the sound at a specific time in seconds
  104425. * @param length (optional) Sound duration (in seconds)
  104426. */
  104427. play(time?: number, offset?: number, length?: number): void;
  104428. private _onended;
  104429. /**
  104430. * Stop the sound
  104431. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  104432. */
  104433. stop(time?: number): void;
  104434. /**
  104435. * Put the sound in pause
  104436. */
  104437. pause(): void;
  104438. /**
  104439. * Sets a dedicated volume for this sounds
  104440. * @param newVolume Define the new volume of the sound
  104441. * @param time Define time for gradual change to new volume
  104442. */
  104443. setVolume(newVolume: number, time?: number): void;
  104444. /**
  104445. * Set the sound play back rate
  104446. * @param newPlaybackRate Define the playback rate the sound should be played at
  104447. */
  104448. setPlaybackRate(newPlaybackRate: number): void;
  104449. /**
  104450. * Gets the volume of the sound.
  104451. * @returns the volume of the sound
  104452. */
  104453. getVolume(): number;
  104454. /**
  104455. * Attach the sound to a dedicated mesh
  104456. * @param transformNode The transform node to connect the sound with
  104457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  104458. */
  104459. attachToMesh(transformNode: TransformNode): void;
  104460. /**
  104461. * Detach the sound from the previously attached mesh
  104462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  104463. */
  104464. detachFromMesh(): void;
  104465. private _onRegisterAfterWorldMatrixUpdate;
  104466. /**
  104467. * Clone the current sound in the scene.
  104468. * @returns the new sound clone
  104469. */
  104470. clone(): Nullable<Sound>;
  104471. /**
  104472. * Gets the current underlying audio buffer containing the data
  104473. * @returns the audio buffer
  104474. */
  104475. getAudioBuffer(): Nullable<AudioBuffer>;
  104476. /**
  104477. * Serializes the Sound in a JSON representation
  104478. * @returns the JSON representation of the sound
  104479. */
  104480. serialize(): any;
  104481. /**
  104482. * Parse a JSON representation of a sound to innstantiate in a given scene
  104483. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  104484. * @param scene Define the scene the new parsed sound should be created in
  104485. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  104486. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  104487. * @returns the newly parsed sound
  104488. */
  104489. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  104490. }
  104491. }
  104492. declare module BABYLON {
  104493. /**
  104494. * This defines an action helpful to play a defined sound on a triggered action.
  104495. */
  104496. export class PlaySoundAction extends Action {
  104497. private _sound;
  104498. /**
  104499. * Instantiate the action
  104500. * @param triggerOptions defines the trigger options
  104501. * @param sound defines the sound to play
  104502. * @param condition defines the trigger related conditions
  104503. */
  104504. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  104505. /** @hidden */
  104506. _prepare(): void;
  104507. /**
  104508. * Execute the action and play the sound.
  104509. */
  104510. execute(): void;
  104511. /**
  104512. * Serializes the actions and its related information.
  104513. * @param parent defines the object to serialize in
  104514. * @returns the serialized object
  104515. */
  104516. serialize(parent: any): any;
  104517. }
  104518. /**
  104519. * This defines an action helpful to stop a defined sound on a triggered action.
  104520. */
  104521. export class StopSoundAction extends Action {
  104522. private _sound;
  104523. /**
  104524. * Instantiate the action
  104525. * @param triggerOptions defines the trigger options
  104526. * @param sound defines the sound to stop
  104527. * @param condition defines the trigger related conditions
  104528. */
  104529. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  104530. /** @hidden */
  104531. _prepare(): void;
  104532. /**
  104533. * Execute the action and stop the sound.
  104534. */
  104535. execute(): void;
  104536. /**
  104537. * Serializes the actions and its related information.
  104538. * @param parent defines the object to serialize in
  104539. * @returns the serialized object
  104540. */
  104541. serialize(parent: any): any;
  104542. }
  104543. }
  104544. declare module BABYLON {
  104545. /**
  104546. * This defines an action responsible to change the value of a property
  104547. * by interpolating between its current value and the newly set one once triggered.
  104548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104549. */
  104550. export class InterpolateValueAction extends Action {
  104551. /**
  104552. * Defines the path of the property where the value should be interpolated
  104553. */
  104554. propertyPath: string;
  104555. /**
  104556. * Defines the target value at the end of the interpolation.
  104557. */
  104558. value: any;
  104559. /**
  104560. * Defines the time it will take for the property to interpolate to the value.
  104561. */
  104562. duration: number;
  104563. /**
  104564. * Defines if the other scene animations should be stopped when the action has been triggered
  104565. */
  104566. stopOtherAnimations?: boolean;
  104567. /**
  104568. * Defines a callback raised once the interpolation animation has been done.
  104569. */
  104570. onInterpolationDone?: () => void;
  104571. /**
  104572. * Observable triggered once the interpolation animation has been done.
  104573. */
  104574. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  104575. private _target;
  104576. private _effectiveTarget;
  104577. private _property;
  104578. /**
  104579. * Instantiate the action
  104580. * @param triggerOptions defines the trigger options
  104581. * @param target defines the object containing the value to interpolate
  104582. * @param propertyPath defines the path to the property in the target object
  104583. * @param value defines the target value at the end of the interpolation
  104584. * @param duration deines the time it will take for the property to interpolate to the value.
  104585. * @param condition defines the trigger related conditions
  104586. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  104587. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  104588. */
  104589. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  104590. /** @hidden */
  104591. _prepare(): void;
  104592. /**
  104593. * Execute the action starts the value interpolation.
  104594. */
  104595. execute(): void;
  104596. /**
  104597. * Serializes the actions and its related information.
  104598. * @param parent defines the object to serialize in
  104599. * @returns the serialized object
  104600. */
  104601. serialize(parent: any): any;
  104602. }
  104603. }
  104604. declare module BABYLON {
  104605. /**
  104606. * Options allowed during the creation of a sound track.
  104607. */
  104608. export interface ISoundTrackOptions {
  104609. /**
  104610. * The volume the sound track should take during creation
  104611. */
  104612. volume?: number;
  104613. /**
  104614. * Define if the sound track is the main sound track of the scene
  104615. */
  104616. mainTrack?: boolean;
  104617. }
  104618. /**
  104619. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  104620. * It will be also used in a future release to apply effects on a specific track.
  104621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104622. */
  104623. export class SoundTrack {
  104624. /**
  104625. * The unique identifier of the sound track in the scene.
  104626. */
  104627. id: number;
  104628. /**
  104629. * The list of sounds included in the sound track.
  104630. */
  104631. soundCollection: Array<Sound>;
  104632. private _outputAudioNode;
  104633. private _scene;
  104634. private _connectedAnalyser;
  104635. private _options;
  104636. private _isInitialized;
  104637. /**
  104638. * Creates a new sound track.
  104639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104640. * @param scene Define the scene the sound track belongs to
  104641. * @param options
  104642. */
  104643. constructor(scene: Scene, options?: ISoundTrackOptions);
  104644. private _initializeSoundTrackAudioGraph;
  104645. /**
  104646. * Release the sound track and its associated resources
  104647. */
  104648. dispose(): void;
  104649. /**
  104650. * Adds a sound to this sound track
  104651. * @param sound define the cound to add
  104652. * @ignoreNaming
  104653. */
  104654. AddSound(sound: Sound): void;
  104655. /**
  104656. * Removes a sound to this sound track
  104657. * @param sound define the cound to remove
  104658. * @ignoreNaming
  104659. */
  104660. RemoveSound(sound: Sound): void;
  104661. /**
  104662. * Set a global volume for the full sound track.
  104663. * @param newVolume Define the new volume of the sound track
  104664. */
  104665. setVolume(newVolume: number): void;
  104666. /**
  104667. * Switch the panning model to HRTF:
  104668. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  104669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104670. */
  104671. switchPanningModelToHRTF(): void;
  104672. /**
  104673. * Switch the panning model to Equal Power:
  104674. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  104675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104676. */
  104677. switchPanningModelToEqualPower(): void;
  104678. /**
  104679. * Connect the sound track to an audio analyser allowing some amazing
  104680. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  104681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  104682. * @param analyser The analyser to connect to the engine
  104683. */
  104684. connectToAnalyser(analyser: Analyser): void;
  104685. }
  104686. }
  104687. declare module BABYLON {
  104688. interface AbstractScene {
  104689. /**
  104690. * The list of sounds used in the scene.
  104691. */
  104692. sounds: Nullable<Array<Sound>>;
  104693. }
  104694. interface Scene {
  104695. /**
  104696. * @hidden
  104697. * Backing field
  104698. */
  104699. _mainSoundTrack: SoundTrack;
  104700. /**
  104701. * The main sound track played by the scene.
  104702. * It cotains your primary collection of sounds.
  104703. */
  104704. mainSoundTrack: SoundTrack;
  104705. /**
  104706. * The list of sound tracks added to the scene
  104707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104708. */
  104709. soundTracks: Nullable<Array<SoundTrack>>;
  104710. /**
  104711. * Gets a sound using a given name
  104712. * @param name defines the name to search for
  104713. * @return the found sound or null if not found at all.
  104714. */
  104715. getSoundByName(name: string): Nullable<Sound>;
  104716. /**
  104717. * Gets or sets if audio support is enabled
  104718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104719. */
  104720. audioEnabled: boolean;
  104721. /**
  104722. * Gets or sets if audio will be output to headphones
  104723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104724. */
  104725. headphone: boolean;
  104726. /**
  104727. * Gets or sets custom audio listener position provider
  104728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104729. */
  104730. audioListenerPositionProvider: Nullable<() => Vector3>;
  104731. /**
  104732. * Gets or sets a refresh rate when using 3D audio positioning
  104733. */
  104734. audioPositioningRefreshRate: number;
  104735. }
  104736. /**
  104737. * Defines the sound scene component responsible to manage any sounds
  104738. * in a given scene.
  104739. */
  104740. export class AudioSceneComponent implements ISceneSerializableComponent {
  104741. /**
  104742. * The component name helpfull to identify the component in the list of scene components.
  104743. */
  104744. readonly name: string;
  104745. /**
  104746. * The scene the component belongs to.
  104747. */
  104748. scene: Scene;
  104749. private _audioEnabled;
  104750. /**
  104751. * Gets whether audio is enabled or not.
  104752. * Please use related enable/disable method to switch state.
  104753. */
  104754. readonly audioEnabled: boolean;
  104755. private _headphone;
  104756. /**
  104757. * Gets whether audio is outputing to headphone or not.
  104758. * Please use the according Switch methods to change output.
  104759. */
  104760. readonly headphone: boolean;
  104761. /**
  104762. * Gets or sets a refresh rate when using 3D audio positioning
  104763. */
  104764. audioPositioningRefreshRate: number;
  104765. private _audioListenerPositionProvider;
  104766. /**
  104767. * Gets the current audio listener position provider
  104768. */
  104769. /**
  104770. * Sets a custom listener position for all sounds in the scene
  104771. * By default, this is the position of the first active camera
  104772. */
  104773. audioListenerPositionProvider: Nullable<() => Vector3>;
  104774. /**
  104775. * Creates a new instance of the component for the given scene
  104776. * @param scene Defines the scene to register the component in
  104777. */
  104778. constructor(scene: Scene);
  104779. /**
  104780. * Registers the component in a given scene
  104781. */
  104782. register(): void;
  104783. /**
  104784. * Rebuilds the elements related to this component in case of
  104785. * context lost for instance.
  104786. */
  104787. rebuild(): void;
  104788. /**
  104789. * Serializes the component data to the specified json object
  104790. * @param serializationObject The object to serialize to
  104791. */
  104792. serialize(serializationObject: any): void;
  104793. /**
  104794. * Adds all the elements from the container to the scene
  104795. * @param container the container holding the elements
  104796. */
  104797. addFromContainer(container: AbstractScene): void;
  104798. /**
  104799. * Removes all the elements in the container from the scene
  104800. * @param container contains the elements to remove
  104801. * @param dispose if the removed element should be disposed (default: false)
  104802. */
  104803. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104804. /**
  104805. * Disposes the component and the associated ressources.
  104806. */
  104807. dispose(): void;
  104808. /**
  104809. * Disables audio in the associated scene.
  104810. */
  104811. disableAudio(): void;
  104812. /**
  104813. * Enables audio in the associated scene.
  104814. */
  104815. enableAudio(): void;
  104816. /**
  104817. * Switch audio to headphone output.
  104818. */
  104819. switchAudioModeForHeadphones(): void;
  104820. /**
  104821. * Switch audio to normal speakers.
  104822. */
  104823. switchAudioModeForNormalSpeakers(): void;
  104824. private _cachedCameraDirection;
  104825. private _cachedCameraPosition;
  104826. private _lastCheck;
  104827. private _afterRender;
  104828. }
  104829. }
  104830. declare module BABYLON {
  104831. /**
  104832. * Wraps one or more Sound objects and selects one with random weight for playback.
  104833. */
  104834. export class WeightedSound {
  104835. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104836. loop: boolean;
  104837. private _coneInnerAngle;
  104838. private _coneOuterAngle;
  104839. private _volume;
  104840. /** A Sound is currently playing. */
  104841. isPlaying: boolean;
  104842. /** A Sound is currently paused. */
  104843. isPaused: boolean;
  104844. private _sounds;
  104845. private _weights;
  104846. private _currentIndex?;
  104847. /**
  104848. * Creates a new WeightedSound from the list of sounds given.
  104849. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104850. * @param sounds Array of Sounds that will be selected from.
  104851. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104852. */
  104853. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104854. /**
  104855. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104856. */
  104857. /**
  104858. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104859. */
  104860. directionalConeInnerAngle: number;
  104861. /**
  104862. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104863. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104864. */
  104865. /**
  104866. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104867. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104868. */
  104869. directionalConeOuterAngle: number;
  104870. /**
  104871. * Playback volume.
  104872. */
  104873. /**
  104874. * Playback volume.
  104875. */
  104876. volume: number;
  104877. private _onended;
  104878. /**
  104879. * Suspend playback
  104880. */
  104881. pause(): void;
  104882. /**
  104883. * Stop playback
  104884. */
  104885. stop(): void;
  104886. /**
  104887. * Start playback.
  104888. * @param startOffset Position the clip head at a specific time in seconds.
  104889. */
  104890. play(startOffset?: number): void;
  104891. }
  104892. }
  104893. declare module BABYLON {
  104894. /**
  104895. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104896. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104897. */
  104898. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104899. /**
  104900. * Gets the name of the behavior.
  104901. */
  104902. readonly name: string;
  104903. /**
  104904. * The easing function used by animations
  104905. */
  104906. static EasingFunction: BackEase;
  104907. /**
  104908. * The easing mode used by animations
  104909. */
  104910. static EasingMode: number;
  104911. /**
  104912. * The duration of the animation, in milliseconds
  104913. */
  104914. transitionDuration: number;
  104915. /**
  104916. * Length of the distance animated by the transition when lower radius is reached
  104917. */
  104918. lowerRadiusTransitionRange: number;
  104919. /**
  104920. * Length of the distance animated by the transition when upper radius is reached
  104921. */
  104922. upperRadiusTransitionRange: number;
  104923. private _autoTransitionRange;
  104924. /**
  104925. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104926. */
  104927. /**
  104928. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104929. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104930. */
  104931. autoTransitionRange: boolean;
  104932. private _attachedCamera;
  104933. private _onAfterCheckInputsObserver;
  104934. private _onMeshTargetChangedObserver;
  104935. /**
  104936. * Initializes the behavior.
  104937. */
  104938. init(): void;
  104939. /**
  104940. * Attaches the behavior to its arc rotate camera.
  104941. * @param camera Defines the camera to attach the behavior to
  104942. */
  104943. attach(camera: ArcRotateCamera): void;
  104944. /**
  104945. * Detaches the behavior from its current arc rotate camera.
  104946. */
  104947. detach(): void;
  104948. private _radiusIsAnimating;
  104949. private _radiusBounceTransition;
  104950. private _animatables;
  104951. private _cachedWheelPrecision;
  104952. /**
  104953. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104954. * @param radiusLimit The limit to check against.
  104955. * @return Bool to indicate if at limit.
  104956. */
  104957. private _isRadiusAtLimit;
  104958. /**
  104959. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104960. * @param radiusDelta The delta by which to animate to. Can be negative.
  104961. */
  104962. private _applyBoundRadiusAnimation;
  104963. /**
  104964. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104965. */
  104966. protected _clearAnimationLocks(): void;
  104967. /**
  104968. * Stops and removes all animations that have been applied to the camera
  104969. */
  104970. stopAllAnimations(): void;
  104971. }
  104972. }
  104973. declare module BABYLON {
  104974. /**
  104975. * 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.
  104976. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104977. */
  104978. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104979. /**
  104980. * Gets the name of the behavior.
  104981. */
  104982. readonly name: string;
  104983. private _mode;
  104984. private _radiusScale;
  104985. private _positionScale;
  104986. private _defaultElevation;
  104987. private _elevationReturnTime;
  104988. private _elevationReturnWaitTime;
  104989. private _zoomStopsAnimation;
  104990. private _framingTime;
  104991. /**
  104992. * The easing function used by animations
  104993. */
  104994. static EasingFunction: ExponentialEase;
  104995. /**
  104996. * The easing mode used by animations
  104997. */
  104998. static EasingMode: number;
  104999. /**
  105000. * Sets the current mode used by the behavior
  105001. */
  105002. /**
  105003. * Gets current mode used by the behavior.
  105004. */
  105005. mode: number;
  105006. /**
  105007. * Sets the scale applied to the radius (1 by default)
  105008. */
  105009. /**
  105010. * Gets the scale applied to the radius
  105011. */
  105012. radiusScale: number;
  105013. /**
  105014. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  105015. */
  105016. /**
  105017. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  105018. */
  105019. positionScale: number;
  105020. /**
  105021. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  105022. * behaviour is triggered, in radians.
  105023. */
  105024. /**
  105025. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  105026. * behaviour is triggered, in radians.
  105027. */
  105028. defaultElevation: number;
  105029. /**
  105030. * Sets the time (in milliseconds) taken to return to the default beta position.
  105031. * Negative value indicates camera should not return to default.
  105032. */
  105033. /**
  105034. * Gets the time (in milliseconds) taken to return to the default beta position.
  105035. * Negative value indicates camera should not return to default.
  105036. */
  105037. elevationReturnTime: number;
  105038. /**
  105039. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  105040. */
  105041. /**
  105042. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  105043. */
  105044. elevationReturnWaitTime: number;
  105045. /**
  105046. * Sets the flag that indicates if user zooming should stop animation.
  105047. */
  105048. /**
  105049. * Gets the flag that indicates if user zooming should stop animation.
  105050. */
  105051. zoomStopsAnimation: boolean;
  105052. /**
  105053. * Sets the transition time when framing the mesh, in milliseconds
  105054. */
  105055. /**
  105056. * Gets the transition time when framing the mesh, in milliseconds
  105057. */
  105058. framingTime: number;
  105059. /**
  105060. * Define if the behavior should automatically change the configured
  105061. * camera limits and sensibilities.
  105062. */
  105063. autoCorrectCameraLimitsAndSensibility: boolean;
  105064. private _onPrePointerObservableObserver;
  105065. private _onAfterCheckInputsObserver;
  105066. private _onMeshTargetChangedObserver;
  105067. private _attachedCamera;
  105068. private _isPointerDown;
  105069. private _lastInteractionTime;
  105070. /**
  105071. * Initializes the behavior.
  105072. */
  105073. init(): void;
  105074. /**
  105075. * Attaches the behavior to its arc rotate camera.
  105076. * @param camera Defines the camera to attach the behavior to
  105077. */
  105078. attach(camera: ArcRotateCamera): void;
  105079. /**
  105080. * Detaches the behavior from its current arc rotate camera.
  105081. */
  105082. detach(): void;
  105083. private _animatables;
  105084. private _betaIsAnimating;
  105085. private _betaTransition;
  105086. private _radiusTransition;
  105087. private _vectorTransition;
  105088. /**
  105089. * Targets the given mesh and updates zoom level accordingly.
  105090. * @param mesh The mesh to target.
  105091. * @param radius Optional. If a cached radius position already exists, overrides default.
  105092. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  105093. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  105094. * @param onAnimationEnd Callback triggered at the end of the framing animation
  105095. */
  105096. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  105097. /**
  105098. * Targets the given mesh with its children and updates zoom level accordingly.
  105099. * @param mesh The mesh to target.
  105100. * @param radius Optional. If a cached radius position already exists, overrides default.
  105101. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  105102. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  105103. * @param onAnimationEnd Callback triggered at the end of the framing animation
  105104. */
  105105. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  105106. /**
  105107. * Targets the given meshes with their children and updates zoom level accordingly.
  105108. * @param meshes The mesh to target.
  105109. * @param radius Optional. If a cached radius position already exists, overrides default.
  105110. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  105111. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  105112. * @param onAnimationEnd Callback triggered at the end of the framing animation
  105113. */
  105114. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  105115. /**
  105116. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  105117. * @param minimumWorld Determines the smaller position of the bounding box extend
  105118. * @param maximumWorld Determines the bigger position of the bounding box extend
  105119. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  105120. * @param onAnimationEnd Callback triggered at the end of the framing animation
  105121. */
  105122. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  105123. /**
  105124. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  105125. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  105126. * frustum width.
  105127. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  105128. * to fully enclose the mesh in the viewing frustum.
  105129. */
  105130. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  105131. /**
  105132. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  105133. * is automatically returned to its default position (expected to be above ground plane).
  105134. */
  105135. private _maintainCameraAboveGround;
  105136. /**
  105137. * Returns the frustum slope based on the canvas ratio and camera FOV
  105138. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  105139. */
  105140. private _getFrustumSlope;
  105141. /**
  105142. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  105143. */
  105144. private _clearAnimationLocks;
  105145. /**
  105146. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105147. */
  105148. private _applyUserInteraction;
  105149. /**
  105150. * Stops and removes all animations that have been applied to the camera
  105151. */
  105152. stopAllAnimations(): void;
  105153. /**
  105154. * Gets a value indicating if the user is moving the camera
  105155. */
  105156. readonly isUserIsMoving: boolean;
  105157. /**
  105158. * The camera can move all the way towards the mesh.
  105159. */
  105160. static IgnoreBoundsSizeMode: number;
  105161. /**
  105162. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  105163. */
  105164. static FitFrustumSidesMode: number;
  105165. }
  105166. }
  105167. declare module BABYLON {
  105168. /**
  105169. * Base class for Camera Pointer Inputs.
  105170. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  105171. * for example usage.
  105172. */
  105173. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  105174. /**
  105175. * Defines the camera the input is attached to.
  105176. */
  105177. abstract camera: Camera;
  105178. /**
  105179. * Whether keyboard modifier keys are pressed at time of last mouse event.
  105180. */
  105181. protected _altKey: boolean;
  105182. protected _ctrlKey: boolean;
  105183. protected _metaKey: boolean;
  105184. protected _shiftKey: boolean;
  105185. /**
  105186. * Which mouse buttons were pressed at time of last mouse event.
  105187. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  105188. */
  105189. protected _buttonsPressed: number;
  105190. /**
  105191. * Defines the buttons associated with the input to handle camera move.
  105192. */
  105193. buttons: number[];
  105194. /**
  105195. * Attach the input controls to a specific dom element to get the input from.
  105196. * @param element Defines the element the controls should be listened from
  105197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105198. */
  105199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105200. /**
  105201. * Detach the current controls from the specified dom element.
  105202. * @param element Defines the element to stop listening the inputs from
  105203. */
  105204. detachControl(element: Nullable<HTMLElement>): void;
  105205. /**
  105206. * Gets the class name of the current input.
  105207. * @returns the class name
  105208. */
  105209. getClassName(): string;
  105210. /**
  105211. * Get the friendly name associated with the input class.
  105212. * @returns the input friendly name
  105213. */
  105214. getSimpleName(): string;
  105215. /**
  105216. * Called on pointer POINTERDOUBLETAP event.
  105217. * Override this method to provide functionality on POINTERDOUBLETAP event.
  105218. */
  105219. protected onDoubleTap(type: string): void;
  105220. /**
  105221. * Called on pointer POINTERMOVE event if only a single touch is active.
  105222. * Override this method to provide functionality.
  105223. */
  105224. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105225. /**
  105226. * Called on pointer POINTERMOVE event if multiple touches are active.
  105227. * Override this method to provide functionality.
  105228. */
  105229. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105230. /**
  105231. * Called on JS contextmenu event.
  105232. * Override this method to provide functionality.
  105233. */
  105234. protected onContextMenu(evt: PointerEvent): void;
  105235. /**
  105236. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  105237. * press.
  105238. * Override this method to provide functionality.
  105239. */
  105240. protected onButtonDown(evt: PointerEvent): void;
  105241. /**
  105242. * Called each time a new POINTERUP event occurs. Ie, for each button
  105243. * release.
  105244. * Override this method to provide functionality.
  105245. */
  105246. protected onButtonUp(evt: PointerEvent): void;
  105247. /**
  105248. * Called when window becomes inactive.
  105249. * Override this method to provide functionality.
  105250. */
  105251. protected onLostFocus(): void;
  105252. private _pointerInput;
  105253. private _observer;
  105254. private _onLostFocus;
  105255. private pointA;
  105256. private pointB;
  105257. }
  105258. }
  105259. declare module BABYLON {
  105260. /**
  105261. * Manage the pointers inputs to control an arc rotate camera.
  105262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105263. */
  105264. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  105265. /**
  105266. * Defines the camera the input is attached to.
  105267. */
  105268. camera: ArcRotateCamera;
  105269. /**
  105270. * Gets the class name of the current input.
  105271. * @returns the class name
  105272. */
  105273. getClassName(): string;
  105274. /**
  105275. * Defines the buttons associated with the input to handle camera move.
  105276. */
  105277. buttons: number[];
  105278. /**
  105279. * Defines the pointer angular sensibility along the X axis or how fast is
  105280. * the camera rotating.
  105281. */
  105282. angularSensibilityX: number;
  105283. /**
  105284. * Defines the pointer angular sensibility along the Y axis or how fast is
  105285. * the camera rotating.
  105286. */
  105287. angularSensibilityY: number;
  105288. /**
  105289. * Defines the pointer pinch precision or how fast is the camera zooming.
  105290. */
  105291. pinchPrecision: number;
  105292. /**
  105293. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  105294. * from 0.
  105295. * It defines the percentage of current camera.radius to use as delta when
  105296. * pinch zoom is used.
  105297. */
  105298. pinchDeltaPercentage: number;
  105299. /**
  105300. * Defines the pointer panning sensibility or how fast is the camera moving.
  105301. */
  105302. panningSensibility: number;
  105303. /**
  105304. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  105305. */
  105306. multiTouchPanning: boolean;
  105307. /**
  105308. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  105309. * zoom (pinch) through multitouch.
  105310. */
  105311. multiTouchPanAndZoom: boolean;
  105312. /**
  105313. * Revers pinch action direction.
  105314. */
  105315. pinchInwards: boolean;
  105316. private _isPanClick;
  105317. private _twoFingerActivityCount;
  105318. private _isPinching;
  105319. /**
  105320. * Called on pointer POINTERMOVE event if only a single touch is active.
  105321. */
  105322. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105323. /**
  105324. * Called on pointer POINTERDOUBLETAP event.
  105325. */
  105326. protected onDoubleTap(type: string): void;
  105327. /**
  105328. * Called on pointer POINTERMOVE event if multiple touches are active.
  105329. */
  105330. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105331. /**
  105332. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  105333. * press.
  105334. */
  105335. protected onButtonDown(evt: PointerEvent): void;
  105336. /**
  105337. * Called each time a new POINTERUP event occurs. Ie, for each button
  105338. * release.
  105339. */
  105340. protected onButtonUp(evt: PointerEvent): void;
  105341. /**
  105342. * Called when window becomes inactive.
  105343. */
  105344. protected onLostFocus(): void;
  105345. }
  105346. }
  105347. declare module BABYLON {
  105348. /**
  105349. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  105350. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105351. */
  105352. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  105353. /**
  105354. * Defines the camera the input is attached to.
  105355. */
  105356. camera: ArcRotateCamera;
  105357. /**
  105358. * Defines the list of key codes associated with the up action (increase alpha)
  105359. */
  105360. keysUp: number[];
  105361. /**
  105362. * Defines the list of key codes associated with the down action (decrease alpha)
  105363. */
  105364. keysDown: number[];
  105365. /**
  105366. * Defines the list of key codes associated with the left action (increase beta)
  105367. */
  105368. keysLeft: number[];
  105369. /**
  105370. * Defines the list of key codes associated with the right action (decrease beta)
  105371. */
  105372. keysRight: number[];
  105373. /**
  105374. * Defines the list of key codes associated with the reset action.
  105375. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  105376. */
  105377. keysReset: number[];
  105378. /**
  105379. * Defines the panning sensibility of the inputs.
  105380. * (How fast is the camera paning)
  105381. */
  105382. panningSensibility: number;
  105383. /**
  105384. * Defines the zooming sensibility of the inputs.
  105385. * (How fast is the camera zooming)
  105386. */
  105387. zoomingSensibility: number;
  105388. /**
  105389. * Defines wether maintaining the alt key down switch the movement mode from
  105390. * orientation to zoom.
  105391. */
  105392. useAltToZoom: boolean;
  105393. /**
  105394. * Rotation speed of the camera
  105395. */
  105396. angularSpeed: number;
  105397. private _keys;
  105398. private _ctrlPressed;
  105399. private _altPressed;
  105400. private _onCanvasBlurObserver;
  105401. private _onKeyboardObserver;
  105402. private _engine;
  105403. private _scene;
  105404. /**
  105405. * Attach the input controls to a specific dom element to get the input from.
  105406. * @param element Defines the element the controls should be listened from
  105407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105408. */
  105409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105410. /**
  105411. * Detach the current controls from the specified dom element.
  105412. * @param element Defines the element to stop listening the inputs from
  105413. */
  105414. detachControl(element: Nullable<HTMLElement>): void;
  105415. /**
  105416. * Update the current camera state depending on the inputs that have been used this frame.
  105417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105418. */
  105419. checkInputs(): void;
  105420. /**
  105421. * Gets the class name of the current intput.
  105422. * @returns the class name
  105423. */
  105424. getClassName(): string;
  105425. /**
  105426. * Get the friendly name associated with the input class.
  105427. * @returns the input friendly name
  105428. */
  105429. getSimpleName(): string;
  105430. }
  105431. }
  105432. declare module BABYLON {
  105433. /**
  105434. * Manage the mouse wheel inputs to control an arc rotate camera.
  105435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105436. */
  105437. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  105438. /**
  105439. * Defines the camera the input is attached to.
  105440. */
  105441. camera: ArcRotateCamera;
  105442. /**
  105443. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105444. */
  105445. wheelPrecision: number;
  105446. /**
  105447. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105448. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105449. */
  105450. wheelDeltaPercentage: number;
  105451. private _wheel;
  105452. private _observer;
  105453. private computeDeltaFromMouseWheelLegacyEvent;
  105454. /**
  105455. * Attach the input controls to a specific dom element to get the input from.
  105456. * @param element Defines the element the controls should be listened from
  105457. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105458. */
  105459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105460. /**
  105461. * Detach the current controls from the specified dom element.
  105462. * @param element Defines the element to stop listening the inputs from
  105463. */
  105464. detachControl(element: Nullable<HTMLElement>): void;
  105465. /**
  105466. * Gets the class name of the current intput.
  105467. * @returns the class name
  105468. */
  105469. getClassName(): string;
  105470. /**
  105471. * Get the friendly name associated with the input class.
  105472. * @returns the input friendly name
  105473. */
  105474. getSimpleName(): string;
  105475. }
  105476. }
  105477. declare module BABYLON {
  105478. /**
  105479. * Default Inputs manager for the ArcRotateCamera.
  105480. * It groups all the default supported inputs for ease of use.
  105481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105482. */
  105483. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  105484. /**
  105485. * Instantiates a new ArcRotateCameraInputsManager.
  105486. * @param camera Defines the camera the inputs belong to
  105487. */
  105488. constructor(camera: ArcRotateCamera);
  105489. /**
  105490. * Add mouse wheel input support to the input manager.
  105491. * @returns the current input manager
  105492. */
  105493. addMouseWheel(): ArcRotateCameraInputsManager;
  105494. /**
  105495. * Add pointers input support to the input manager.
  105496. * @returns the current input manager
  105497. */
  105498. addPointers(): ArcRotateCameraInputsManager;
  105499. /**
  105500. * Add keyboard input support to the input manager.
  105501. * @returns the current input manager
  105502. */
  105503. addKeyboard(): ArcRotateCameraInputsManager;
  105504. }
  105505. }
  105506. declare module BABYLON {
  105507. /**
  105508. * This represents an orbital type of camera.
  105509. *
  105510. * 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.
  105511. * 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.
  105512. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  105513. */
  105514. export class ArcRotateCamera extends TargetCamera {
  105515. /**
  105516. * Defines the rotation angle of the camera along the longitudinal axis.
  105517. */
  105518. alpha: number;
  105519. /**
  105520. * Defines the rotation angle of the camera along the latitudinal axis.
  105521. */
  105522. beta: number;
  105523. /**
  105524. * Defines the radius of the camera from it s target point.
  105525. */
  105526. radius: number;
  105527. protected _target: Vector3;
  105528. protected _targetHost: Nullable<AbstractMesh>;
  105529. /**
  105530. * Defines the target point of the camera.
  105531. * The camera looks towards it form the radius distance.
  105532. */
  105533. target: Vector3;
  105534. /**
  105535. * Define the current local position of the camera in the scene
  105536. */
  105537. position: Vector3;
  105538. protected _upVector: Vector3;
  105539. protected _upToYMatrix: Matrix;
  105540. protected _YToUpMatrix: Matrix;
  105541. /**
  105542. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  105543. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  105544. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  105545. */
  105546. upVector: Vector3;
  105547. /**
  105548. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  105549. */
  105550. setMatUp(): void;
  105551. /**
  105552. * Current inertia value on the longitudinal axis.
  105553. * The bigger this number the longer it will take for the camera to stop.
  105554. */
  105555. inertialAlphaOffset: number;
  105556. /**
  105557. * Current inertia value on the latitudinal axis.
  105558. * The bigger this number the longer it will take for the camera to stop.
  105559. */
  105560. inertialBetaOffset: number;
  105561. /**
  105562. * Current inertia value on the radius axis.
  105563. * The bigger this number the longer it will take for the camera to stop.
  105564. */
  105565. inertialRadiusOffset: number;
  105566. /**
  105567. * Minimum allowed angle on the longitudinal axis.
  105568. * This can help limiting how the Camera is able to move in the scene.
  105569. */
  105570. lowerAlphaLimit: Nullable<number>;
  105571. /**
  105572. * Maximum allowed angle on the longitudinal axis.
  105573. * This can help limiting how the Camera is able to move in the scene.
  105574. */
  105575. upperAlphaLimit: Nullable<number>;
  105576. /**
  105577. * Minimum allowed angle on the latitudinal axis.
  105578. * This can help limiting how the Camera is able to move in the scene.
  105579. */
  105580. lowerBetaLimit: number;
  105581. /**
  105582. * Maximum allowed angle on the latitudinal axis.
  105583. * This can help limiting how the Camera is able to move in the scene.
  105584. */
  105585. upperBetaLimit: number;
  105586. /**
  105587. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  105588. * This can help limiting how the Camera is able to move in the scene.
  105589. */
  105590. lowerRadiusLimit: Nullable<number>;
  105591. /**
  105592. * Maximum allowed distance of the camera to the target (The camera can not get further).
  105593. * This can help limiting how the Camera is able to move in the scene.
  105594. */
  105595. upperRadiusLimit: Nullable<number>;
  105596. /**
  105597. * Defines the current inertia value used during panning of the camera along the X axis.
  105598. */
  105599. inertialPanningX: number;
  105600. /**
  105601. * Defines the current inertia value used during panning of the camera along the Y axis.
  105602. */
  105603. inertialPanningY: number;
  105604. /**
  105605. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  105606. * Basically if your fingers moves away from more than this distance you will be considered
  105607. * in pinch mode.
  105608. */
  105609. pinchToPanMaxDistance: number;
  105610. /**
  105611. * Defines the maximum distance the camera can pan.
  105612. * This could help keeping the cammera always in your scene.
  105613. */
  105614. panningDistanceLimit: Nullable<number>;
  105615. /**
  105616. * Defines the target of the camera before paning.
  105617. */
  105618. panningOriginTarget: Vector3;
  105619. /**
  105620. * Defines the value of the inertia used during panning.
  105621. * 0 would mean stop inertia and one would mean no decelleration at all.
  105622. */
  105623. panningInertia: number;
  105624. /**
  105625. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  105626. */
  105627. angularSensibilityX: number;
  105628. /**
  105629. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  105630. */
  105631. angularSensibilityY: number;
  105632. /**
  105633. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  105634. */
  105635. pinchPrecision: number;
  105636. /**
  105637. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  105638. * It will be used instead of pinchDeltaPrecision if different from 0.
  105639. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105640. */
  105641. pinchDeltaPercentage: number;
  105642. /**
  105643. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  105644. */
  105645. panningSensibility: number;
  105646. /**
  105647. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  105648. */
  105649. keysUp: number[];
  105650. /**
  105651. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  105652. */
  105653. keysDown: number[];
  105654. /**
  105655. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  105656. */
  105657. keysLeft: number[];
  105658. /**
  105659. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  105660. */
  105661. keysRight: number[];
  105662. /**
  105663. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105664. */
  105665. wheelPrecision: number;
  105666. /**
  105667. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  105668. * It will be used instead of pinchDeltaPrecision if different from 0.
  105669. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105670. */
  105671. wheelDeltaPercentage: number;
  105672. /**
  105673. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  105674. */
  105675. zoomOnFactor: number;
  105676. /**
  105677. * Defines a screen offset for the camera position.
  105678. */
  105679. targetScreenOffset: Vector2;
  105680. /**
  105681. * Allows the camera to be completely reversed.
  105682. * If false the camera can not arrive upside down.
  105683. */
  105684. allowUpsideDown: boolean;
  105685. /**
  105686. * Define if double tap/click is used to restore the previously saved state of the camera.
  105687. */
  105688. useInputToRestoreState: boolean;
  105689. /** @hidden */
  105690. _viewMatrix: Matrix;
  105691. /** @hidden */
  105692. _useCtrlForPanning: boolean;
  105693. /** @hidden */
  105694. _panningMouseButton: number;
  105695. /**
  105696. * Defines the input associated to the camera.
  105697. */
  105698. inputs: ArcRotateCameraInputsManager;
  105699. /** @hidden */
  105700. _reset: () => void;
  105701. /**
  105702. * Defines the allowed panning axis.
  105703. */
  105704. panningAxis: Vector3;
  105705. protected _localDirection: Vector3;
  105706. protected _transformedDirection: Vector3;
  105707. private _bouncingBehavior;
  105708. /**
  105709. * Gets the bouncing behavior of the camera if it has been enabled.
  105710. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105711. */
  105712. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  105713. /**
  105714. * Defines if the bouncing behavior of the camera is enabled on the camera.
  105715. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105716. */
  105717. useBouncingBehavior: boolean;
  105718. private _framingBehavior;
  105719. /**
  105720. * Gets the framing behavior of the camera if it has been enabled.
  105721. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105722. */
  105723. readonly framingBehavior: Nullable<FramingBehavior>;
  105724. /**
  105725. * Defines if the framing behavior of the camera is enabled on the camera.
  105726. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105727. */
  105728. useFramingBehavior: boolean;
  105729. private _autoRotationBehavior;
  105730. /**
  105731. * Gets the auto rotation behavior of the camera if it has been enabled.
  105732. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105733. */
  105734. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  105735. /**
  105736. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  105737. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105738. */
  105739. useAutoRotationBehavior: boolean;
  105740. /**
  105741. * Observable triggered when the mesh target has been changed on the camera.
  105742. */
  105743. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  105744. /**
  105745. * Event raised when the camera is colliding with a mesh.
  105746. */
  105747. onCollide: (collidedMesh: AbstractMesh) => void;
  105748. /**
  105749. * Defines whether the camera should check collision with the objects oh the scene.
  105750. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  105751. */
  105752. checkCollisions: boolean;
  105753. /**
  105754. * Defines the collision radius of the camera.
  105755. * This simulates a sphere around the camera.
  105756. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105757. */
  105758. collisionRadius: Vector3;
  105759. protected _collider: Collider;
  105760. protected _previousPosition: Vector3;
  105761. protected _collisionVelocity: Vector3;
  105762. protected _newPosition: Vector3;
  105763. protected _previousAlpha: number;
  105764. protected _previousBeta: number;
  105765. protected _previousRadius: number;
  105766. protected _collisionTriggered: boolean;
  105767. protected _targetBoundingCenter: Nullable<Vector3>;
  105768. private _computationVector;
  105769. /**
  105770. * Instantiates a new ArcRotateCamera in a given scene
  105771. * @param name Defines the name of the camera
  105772. * @param alpha Defines the camera rotation along the logitudinal axis
  105773. * @param beta Defines the camera rotation along the latitudinal axis
  105774. * @param radius Defines the camera distance from its target
  105775. * @param target Defines the camera target
  105776. * @param scene Defines the scene the camera belongs to
  105777. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  105778. */
  105779. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105780. /** @hidden */
  105781. _initCache(): void;
  105782. /** @hidden */
  105783. _updateCache(ignoreParentClass?: boolean): void;
  105784. protected _getTargetPosition(): Vector3;
  105785. private _storedAlpha;
  105786. private _storedBeta;
  105787. private _storedRadius;
  105788. private _storedTarget;
  105789. private _storedTargetScreenOffset;
  105790. /**
  105791. * Stores the current state of the camera (alpha, beta, radius and target)
  105792. * @returns the camera itself
  105793. */
  105794. storeState(): Camera;
  105795. /**
  105796. * @hidden
  105797. * Restored camera state. You must call storeState() first
  105798. */
  105799. _restoreStateValues(): boolean;
  105800. /** @hidden */
  105801. _isSynchronizedViewMatrix(): boolean;
  105802. /**
  105803. * Attached controls to the current camera.
  105804. * @param element Defines the element the controls should be listened from
  105805. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105806. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  105807. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  105808. */
  105809. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  105810. /**
  105811. * Detach the current controls from the camera.
  105812. * The camera will stop reacting to inputs.
  105813. * @param element Defines the element to stop listening the inputs from
  105814. */
  105815. detachControl(element: HTMLElement): void;
  105816. /** @hidden */
  105817. _checkInputs(): void;
  105818. protected _checkLimits(): void;
  105819. /**
  105820. * Rebuilds angles (alpha, beta) and radius from the give position and target
  105821. */
  105822. rebuildAnglesAndRadius(): void;
  105823. /**
  105824. * Use a position to define the current camera related information like alpha, beta and radius
  105825. * @param position Defines the position to set the camera at
  105826. */
  105827. setPosition(position: Vector3): void;
  105828. /**
  105829. * Defines the target the camera should look at.
  105830. * This will automatically adapt alpha beta and radius to fit within the new target.
  105831. * @param target Defines the new target as a Vector or a mesh
  105832. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  105833. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  105834. */
  105835. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105836. /** @hidden */
  105837. _getViewMatrix(): Matrix;
  105838. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105839. /**
  105840. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105841. * @param meshes Defines the mesh to zoom on
  105842. * @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)
  105843. */
  105844. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105845. /**
  105846. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105847. * The target will be changed but the radius
  105848. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105849. * @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)
  105850. */
  105851. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105852. min: Vector3;
  105853. max: Vector3;
  105854. distance: number;
  105855. }, doNotUpdateMaxZ?: boolean): void;
  105856. /**
  105857. * @override
  105858. * Override Camera.createRigCamera
  105859. */
  105860. createRigCamera(name: string, cameraIndex: number): Camera;
  105861. /**
  105862. * @hidden
  105863. * @override
  105864. * Override Camera._updateRigCameras
  105865. */
  105866. _updateRigCameras(): void;
  105867. /**
  105868. * Destroy the camera and release the current resources hold by it.
  105869. */
  105870. dispose(): void;
  105871. /**
  105872. * Gets the current object class name.
  105873. * @return the class name
  105874. */
  105875. getClassName(): string;
  105876. }
  105877. }
  105878. declare module BABYLON {
  105879. /**
  105880. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105881. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105882. */
  105883. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105884. /**
  105885. * Gets the name of the behavior.
  105886. */
  105887. readonly name: string;
  105888. private _zoomStopsAnimation;
  105889. private _idleRotationSpeed;
  105890. private _idleRotationWaitTime;
  105891. private _idleRotationSpinupTime;
  105892. /**
  105893. * Sets the flag that indicates if user zooming should stop animation.
  105894. */
  105895. /**
  105896. * Gets the flag that indicates if user zooming should stop animation.
  105897. */
  105898. zoomStopsAnimation: boolean;
  105899. /**
  105900. * Sets the default speed at which the camera rotates around the model.
  105901. */
  105902. /**
  105903. * Gets the default speed at which the camera rotates around the model.
  105904. */
  105905. idleRotationSpeed: number;
  105906. /**
  105907. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105908. */
  105909. /**
  105910. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105911. */
  105912. idleRotationWaitTime: number;
  105913. /**
  105914. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105915. */
  105916. /**
  105917. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105918. */
  105919. idleRotationSpinupTime: number;
  105920. /**
  105921. * Gets a value indicating if the camera is currently rotating because of this behavior
  105922. */
  105923. readonly rotationInProgress: boolean;
  105924. private _onPrePointerObservableObserver;
  105925. private _onAfterCheckInputsObserver;
  105926. private _attachedCamera;
  105927. private _isPointerDown;
  105928. private _lastFrameTime;
  105929. private _lastInteractionTime;
  105930. private _cameraRotationSpeed;
  105931. /**
  105932. * Initializes the behavior.
  105933. */
  105934. init(): void;
  105935. /**
  105936. * Attaches the behavior to its arc rotate camera.
  105937. * @param camera Defines the camera to attach the behavior to
  105938. */
  105939. attach(camera: ArcRotateCamera): void;
  105940. /**
  105941. * Detaches the behavior from its current arc rotate camera.
  105942. */
  105943. detach(): void;
  105944. /**
  105945. * Returns true if user is scrolling.
  105946. * @return true if user is scrolling.
  105947. */
  105948. private _userIsZooming;
  105949. private _lastFrameRadius;
  105950. private _shouldAnimationStopForInteraction;
  105951. /**
  105952. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105953. */
  105954. private _applyUserInteraction;
  105955. private _userIsMoving;
  105956. }
  105957. }
  105958. declare module BABYLON {
  105959. /**
  105960. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105961. */
  105962. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105963. private ui;
  105964. /**
  105965. * The name of the behavior
  105966. */
  105967. name: string;
  105968. /**
  105969. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105970. */
  105971. distanceAwayFromFace: number;
  105972. /**
  105973. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105974. */
  105975. distanceAwayFromBottomOfFace: number;
  105976. private _faceVectors;
  105977. private _target;
  105978. private _scene;
  105979. private _onRenderObserver;
  105980. private _tmpMatrix;
  105981. private _tmpVector;
  105982. /**
  105983. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105984. * @param ui The transform node that should be attched to the mesh
  105985. */
  105986. constructor(ui: TransformNode);
  105987. /**
  105988. * Initializes the behavior
  105989. */
  105990. init(): void;
  105991. private _closestFace;
  105992. private _zeroVector;
  105993. private _lookAtTmpMatrix;
  105994. private _lookAtToRef;
  105995. /**
  105996. * Attaches the AttachToBoxBehavior to the passed in mesh
  105997. * @param target The mesh that the specified node will be attached to
  105998. */
  105999. attach(target: Mesh): void;
  106000. /**
  106001. * Detaches the behavior from the mesh
  106002. */
  106003. detach(): void;
  106004. }
  106005. }
  106006. declare module BABYLON {
  106007. /**
  106008. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  106009. */
  106010. export class FadeInOutBehavior implements Behavior<Mesh> {
  106011. /**
  106012. * Time in milliseconds to delay before fading in (Default: 0)
  106013. */
  106014. delay: number;
  106015. /**
  106016. * Time in milliseconds for the mesh to fade in (Default: 300)
  106017. */
  106018. fadeInTime: number;
  106019. private _millisecondsPerFrame;
  106020. private _hovered;
  106021. private _hoverValue;
  106022. private _ownerNode;
  106023. /**
  106024. * Instatiates the FadeInOutBehavior
  106025. */
  106026. constructor();
  106027. /**
  106028. * The name of the behavior
  106029. */
  106030. readonly name: string;
  106031. /**
  106032. * Initializes the behavior
  106033. */
  106034. init(): void;
  106035. /**
  106036. * Attaches the fade behavior on the passed in mesh
  106037. * @param ownerNode The mesh that will be faded in/out once attached
  106038. */
  106039. attach(ownerNode: Mesh): void;
  106040. /**
  106041. * Detaches the behavior from the mesh
  106042. */
  106043. detach(): void;
  106044. /**
  106045. * Triggers the mesh to begin fading in or out
  106046. * @param value if the object should fade in or out (true to fade in)
  106047. */
  106048. fadeIn(value: boolean): void;
  106049. private _update;
  106050. private _setAllVisibility;
  106051. }
  106052. }
  106053. declare module BABYLON {
  106054. /**
  106055. * Class containing a set of static utilities functions for managing Pivots
  106056. * @hidden
  106057. */
  106058. export class PivotTools {
  106059. private static _PivotCached;
  106060. private static _OldPivotPoint;
  106061. private static _PivotTranslation;
  106062. private static _PivotTmpVector;
  106063. /** @hidden */
  106064. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  106065. /** @hidden */
  106066. static _RestorePivotPoint(mesh: AbstractMesh): void;
  106067. }
  106068. }
  106069. declare module BABYLON {
  106070. /**
  106071. * Class containing static functions to help procedurally build meshes
  106072. */
  106073. export class PlaneBuilder {
  106074. /**
  106075. * Creates a plane mesh
  106076. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  106077. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  106078. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  106079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106082. * @param name defines the name of the mesh
  106083. * @param options defines the options used to create the mesh
  106084. * @param scene defines the hosting scene
  106085. * @returns the plane mesh
  106086. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  106087. */
  106088. static CreatePlane(name: string, options: {
  106089. size?: number;
  106090. width?: number;
  106091. height?: number;
  106092. sideOrientation?: number;
  106093. frontUVs?: Vector4;
  106094. backUVs?: Vector4;
  106095. updatable?: boolean;
  106096. sourcePlane?: Plane;
  106097. }, scene?: Nullable<Scene>): Mesh;
  106098. }
  106099. }
  106100. declare module BABYLON {
  106101. /**
  106102. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  106103. */
  106104. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  106105. private static _AnyMouseID;
  106106. /**
  106107. * Abstract mesh the behavior is set on
  106108. */
  106109. attachedNode: AbstractMesh;
  106110. private _dragPlane;
  106111. private _scene;
  106112. private _pointerObserver;
  106113. private _beforeRenderObserver;
  106114. private static _planeScene;
  106115. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  106116. /**
  106117. * 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)
  106118. */
  106119. maxDragAngle: number;
  106120. /**
  106121. * @hidden
  106122. */
  106123. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  106124. /**
  106125. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  106126. */
  106127. currentDraggingPointerID: number;
  106128. /**
  106129. * The last position where the pointer hit the drag plane in world space
  106130. */
  106131. lastDragPosition: Vector3;
  106132. /**
  106133. * If the behavior is currently in a dragging state
  106134. */
  106135. dragging: boolean;
  106136. /**
  106137. * 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)
  106138. */
  106139. dragDeltaRatio: number;
  106140. /**
  106141. * If the drag plane orientation should be updated during the dragging (Default: true)
  106142. */
  106143. updateDragPlane: boolean;
  106144. private _debugMode;
  106145. private _moving;
  106146. /**
  106147. * Fires each time the attached mesh is dragged with the pointer
  106148. * * delta between last drag position and current drag position in world space
  106149. * * dragDistance along the drag axis
  106150. * * dragPlaneNormal normal of the current drag plane used during the drag
  106151. * * dragPlanePoint in world space where the drag intersects the drag plane
  106152. */
  106153. onDragObservable: Observable<{
  106154. delta: Vector3;
  106155. dragPlanePoint: Vector3;
  106156. dragPlaneNormal: Vector3;
  106157. dragDistance: number;
  106158. pointerId: number;
  106159. }>;
  106160. /**
  106161. * Fires each time a drag begins (eg. mouse down on mesh)
  106162. */
  106163. onDragStartObservable: Observable<{
  106164. dragPlanePoint: Vector3;
  106165. pointerId: number;
  106166. }>;
  106167. /**
  106168. * Fires each time a drag ends (eg. mouse release after drag)
  106169. */
  106170. onDragEndObservable: Observable<{
  106171. dragPlanePoint: Vector3;
  106172. pointerId: number;
  106173. }>;
  106174. /**
  106175. * If the attached mesh should be moved when dragged
  106176. */
  106177. moveAttached: boolean;
  106178. /**
  106179. * If the drag behavior will react to drag events (Default: true)
  106180. */
  106181. enabled: boolean;
  106182. /**
  106183. * If pointer events should start and release the drag (Default: true)
  106184. */
  106185. startAndReleaseDragOnPointerEvents: boolean;
  106186. /**
  106187. * If camera controls should be detached during the drag
  106188. */
  106189. detachCameraControls: boolean;
  106190. /**
  106191. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  106192. */
  106193. useObjectOrienationForDragging: boolean;
  106194. private _options;
  106195. /**
  106196. * Creates a pointer drag behavior that can be attached to a mesh
  106197. * @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)
  106198. */
  106199. constructor(options?: {
  106200. dragAxis?: Vector3;
  106201. dragPlaneNormal?: Vector3;
  106202. });
  106203. /**
  106204. * Predicate to determine if it is valid to move the object to a new position when it is moved
  106205. */
  106206. validateDrag: (targetPosition: Vector3) => boolean;
  106207. /**
  106208. * The name of the behavior
  106209. */
  106210. readonly name: string;
  106211. /**
  106212. * Initializes the behavior
  106213. */
  106214. init(): void;
  106215. private _tmpVector;
  106216. private _alternatePickedPoint;
  106217. private _worldDragAxis;
  106218. private _targetPosition;
  106219. private _attachedElement;
  106220. /**
  106221. * Attaches the drag behavior the passed in mesh
  106222. * @param ownerNode The mesh that will be dragged around once attached
  106223. * @param predicate Predicate to use for pick filtering
  106224. */
  106225. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  106226. /**
  106227. * Force relase the drag action by code.
  106228. */
  106229. releaseDrag(): void;
  106230. private _startDragRay;
  106231. private _lastPointerRay;
  106232. /**
  106233. * Simulates the start of a pointer drag event on the behavior
  106234. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  106235. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  106236. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  106237. */
  106238. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  106239. private _startDrag;
  106240. private _dragDelta;
  106241. private _moveDrag;
  106242. private _pickWithRayOnDragPlane;
  106243. private _pointA;
  106244. private _pointB;
  106245. private _pointC;
  106246. private _lineA;
  106247. private _lineB;
  106248. private _localAxis;
  106249. private _lookAt;
  106250. private _updateDragPlanePosition;
  106251. /**
  106252. * Detaches the behavior from the mesh
  106253. */
  106254. detach(): void;
  106255. }
  106256. }
  106257. declare module BABYLON {
  106258. /**
  106259. * A behavior that when attached to a mesh will allow the mesh to be scaled
  106260. */
  106261. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  106262. private _dragBehaviorA;
  106263. private _dragBehaviorB;
  106264. private _startDistance;
  106265. private _initialScale;
  106266. private _targetScale;
  106267. private _ownerNode;
  106268. private _sceneRenderObserver;
  106269. /**
  106270. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  106271. */
  106272. constructor();
  106273. /**
  106274. * The name of the behavior
  106275. */
  106276. readonly name: string;
  106277. /**
  106278. * Initializes the behavior
  106279. */
  106280. init(): void;
  106281. private _getCurrentDistance;
  106282. /**
  106283. * Attaches the scale behavior the passed in mesh
  106284. * @param ownerNode The mesh that will be scaled around once attached
  106285. */
  106286. attach(ownerNode: Mesh): void;
  106287. /**
  106288. * Detaches the behavior from the mesh
  106289. */
  106290. detach(): void;
  106291. }
  106292. }
  106293. declare module BABYLON {
  106294. /**
  106295. * 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
  106296. */
  106297. export class SixDofDragBehavior implements Behavior<Mesh> {
  106298. private static _virtualScene;
  106299. private _ownerNode;
  106300. private _sceneRenderObserver;
  106301. private _scene;
  106302. private _targetPosition;
  106303. private _virtualOriginMesh;
  106304. private _virtualDragMesh;
  106305. private _pointerObserver;
  106306. private _moving;
  106307. private _startingOrientation;
  106308. /**
  106309. * 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)
  106310. */
  106311. private zDragFactor;
  106312. /**
  106313. * If the object should rotate to face the drag origin
  106314. */
  106315. rotateDraggedObject: boolean;
  106316. /**
  106317. * If the behavior is currently in a dragging state
  106318. */
  106319. dragging: boolean;
  106320. /**
  106321. * 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)
  106322. */
  106323. dragDeltaRatio: number;
  106324. /**
  106325. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  106326. */
  106327. currentDraggingPointerID: number;
  106328. /**
  106329. * If camera controls should be detached during the drag
  106330. */
  106331. detachCameraControls: boolean;
  106332. /**
  106333. * Fires each time a drag starts
  106334. */
  106335. onDragStartObservable: Observable<{}>;
  106336. /**
  106337. * Fires each time a drag ends (eg. mouse release after drag)
  106338. */
  106339. onDragEndObservable: Observable<{}>;
  106340. /**
  106341. * 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
  106342. */
  106343. constructor();
  106344. /**
  106345. * The name of the behavior
  106346. */
  106347. readonly name: string;
  106348. /**
  106349. * Initializes the behavior
  106350. */
  106351. init(): void;
  106352. /**
  106353. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  106354. */
  106355. private readonly _pointerCamera;
  106356. /**
  106357. * Attaches the scale behavior the passed in mesh
  106358. * @param ownerNode The mesh that will be scaled around once attached
  106359. */
  106360. attach(ownerNode: Mesh): void;
  106361. /**
  106362. * Detaches the behavior from the mesh
  106363. */
  106364. detach(): void;
  106365. }
  106366. }
  106367. declare module BABYLON {
  106368. /**
  106369. * Class used to apply inverse kinematics to bones
  106370. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  106371. */
  106372. export class BoneIKController {
  106373. private static _tmpVecs;
  106374. private static _tmpQuat;
  106375. private static _tmpMats;
  106376. /**
  106377. * Gets or sets the target mesh
  106378. */
  106379. targetMesh: AbstractMesh;
  106380. /** Gets or sets the mesh used as pole */
  106381. poleTargetMesh: AbstractMesh;
  106382. /**
  106383. * Gets or sets the bone used as pole
  106384. */
  106385. poleTargetBone: Nullable<Bone>;
  106386. /**
  106387. * Gets or sets the target position
  106388. */
  106389. targetPosition: Vector3;
  106390. /**
  106391. * Gets or sets the pole target position
  106392. */
  106393. poleTargetPosition: Vector3;
  106394. /**
  106395. * Gets or sets the pole target local offset
  106396. */
  106397. poleTargetLocalOffset: Vector3;
  106398. /**
  106399. * Gets or sets the pole angle
  106400. */
  106401. poleAngle: number;
  106402. /**
  106403. * Gets or sets the mesh associated with the controller
  106404. */
  106405. mesh: AbstractMesh;
  106406. /**
  106407. * 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)
  106408. */
  106409. slerpAmount: number;
  106410. private _bone1Quat;
  106411. private _bone1Mat;
  106412. private _bone2Ang;
  106413. private _bone1;
  106414. private _bone2;
  106415. private _bone1Length;
  106416. private _bone2Length;
  106417. private _maxAngle;
  106418. private _maxReach;
  106419. private _rightHandedSystem;
  106420. private _bendAxis;
  106421. private _slerping;
  106422. private _adjustRoll;
  106423. /**
  106424. * Gets or sets maximum allowed angle
  106425. */
  106426. maxAngle: number;
  106427. /**
  106428. * Creates a new BoneIKController
  106429. * @param mesh defines the mesh to control
  106430. * @param bone defines the bone to control
  106431. * @param options defines options to set up the controller
  106432. */
  106433. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  106434. targetMesh?: AbstractMesh;
  106435. poleTargetMesh?: AbstractMesh;
  106436. poleTargetBone?: Bone;
  106437. poleTargetLocalOffset?: Vector3;
  106438. poleAngle?: number;
  106439. bendAxis?: Vector3;
  106440. maxAngle?: number;
  106441. slerpAmount?: number;
  106442. });
  106443. private _setMaxAngle;
  106444. /**
  106445. * Force the controller to update the bones
  106446. */
  106447. update(): void;
  106448. }
  106449. }
  106450. declare module BABYLON {
  106451. /**
  106452. * Class used to make a bone look toward a point in space
  106453. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  106454. */
  106455. export class BoneLookController {
  106456. private static _tmpVecs;
  106457. private static _tmpQuat;
  106458. private static _tmpMats;
  106459. /**
  106460. * The target Vector3 that the bone will look at
  106461. */
  106462. target: Vector3;
  106463. /**
  106464. * The mesh that the bone is attached to
  106465. */
  106466. mesh: AbstractMesh;
  106467. /**
  106468. * The bone that will be looking to the target
  106469. */
  106470. bone: Bone;
  106471. /**
  106472. * The up axis of the coordinate system that is used when the bone is rotated
  106473. */
  106474. upAxis: Vector3;
  106475. /**
  106476. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  106477. */
  106478. upAxisSpace: Space;
  106479. /**
  106480. * Used to make an adjustment to the yaw of the bone
  106481. */
  106482. adjustYaw: number;
  106483. /**
  106484. * Used to make an adjustment to the pitch of the bone
  106485. */
  106486. adjustPitch: number;
  106487. /**
  106488. * Used to make an adjustment to the roll of the bone
  106489. */
  106490. adjustRoll: number;
  106491. /**
  106492. * 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)
  106493. */
  106494. slerpAmount: number;
  106495. private _minYaw;
  106496. private _maxYaw;
  106497. private _minPitch;
  106498. private _maxPitch;
  106499. private _minYawSin;
  106500. private _minYawCos;
  106501. private _maxYawSin;
  106502. private _maxYawCos;
  106503. private _midYawConstraint;
  106504. private _minPitchTan;
  106505. private _maxPitchTan;
  106506. private _boneQuat;
  106507. private _slerping;
  106508. private _transformYawPitch;
  106509. private _transformYawPitchInv;
  106510. private _firstFrameSkipped;
  106511. private _yawRange;
  106512. private _fowardAxis;
  106513. /**
  106514. * Gets or sets the minimum yaw angle that the bone can look to
  106515. */
  106516. minYaw: number;
  106517. /**
  106518. * Gets or sets the maximum yaw angle that the bone can look to
  106519. */
  106520. maxYaw: number;
  106521. /**
  106522. * Gets or sets the minimum pitch angle that the bone can look to
  106523. */
  106524. minPitch: number;
  106525. /**
  106526. * Gets or sets the maximum pitch angle that the bone can look to
  106527. */
  106528. maxPitch: number;
  106529. /**
  106530. * Create a BoneLookController
  106531. * @param mesh the mesh that the bone belongs to
  106532. * @param bone the bone that will be looking to the target
  106533. * @param target the target Vector3 to look at
  106534. * @param options optional settings:
  106535. * * maxYaw: the maximum angle the bone will yaw to
  106536. * * minYaw: the minimum angle the bone will yaw to
  106537. * * maxPitch: the maximum angle the bone will pitch to
  106538. * * minPitch: the minimum angle the bone will yaw to
  106539. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  106540. * * upAxis: the up axis of the coordinate system
  106541. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  106542. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  106543. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  106544. * * adjustYaw: used to make an adjustment to the yaw of the bone
  106545. * * adjustPitch: used to make an adjustment to the pitch of the bone
  106546. * * adjustRoll: used to make an adjustment to the roll of the bone
  106547. **/
  106548. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  106549. maxYaw?: number;
  106550. minYaw?: number;
  106551. maxPitch?: number;
  106552. minPitch?: number;
  106553. slerpAmount?: number;
  106554. upAxis?: Vector3;
  106555. upAxisSpace?: Space;
  106556. yawAxis?: Vector3;
  106557. pitchAxis?: Vector3;
  106558. adjustYaw?: number;
  106559. adjustPitch?: number;
  106560. adjustRoll?: number;
  106561. });
  106562. /**
  106563. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  106564. */
  106565. update(): void;
  106566. private _getAngleDiff;
  106567. private _getAngleBetween;
  106568. private _isAngleBetween;
  106569. }
  106570. }
  106571. declare module BABYLON {
  106572. /**
  106573. * Manage the gamepad inputs to control an arc rotate camera.
  106574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106575. */
  106576. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  106577. /**
  106578. * Defines the camera the input is attached to.
  106579. */
  106580. camera: ArcRotateCamera;
  106581. /**
  106582. * Defines the gamepad the input is gathering event from.
  106583. */
  106584. gamepad: Nullable<Gamepad>;
  106585. /**
  106586. * Defines the gamepad rotation sensiblity.
  106587. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106588. */
  106589. gamepadRotationSensibility: number;
  106590. /**
  106591. * Defines the gamepad move sensiblity.
  106592. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106593. */
  106594. gamepadMoveSensibility: number;
  106595. private _yAxisScale;
  106596. /**
  106597. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106598. */
  106599. invertYAxis: boolean;
  106600. private _onGamepadConnectedObserver;
  106601. private _onGamepadDisconnectedObserver;
  106602. /**
  106603. * Attach the input controls to a specific dom element to get the input from.
  106604. * @param element Defines the element the controls should be listened from
  106605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106606. */
  106607. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106608. /**
  106609. * Detach the current controls from the specified dom element.
  106610. * @param element Defines the element to stop listening the inputs from
  106611. */
  106612. detachControl(element: Nullable<HTMLElement>): void;
  106613. /**
  106614. * Update the current camera state depending on the inputs that have been used this frame.
  106615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106616. */
  106617. checkInputs(): void;
  106618. /**
  106619. * Gets the class name of the current intput.
  106620. * @returns the class name
  106621. */
  106622. getClassName(): string;
  106623. /**
  106624. * Get the friendly name associated with the input class.
  106625. * @returns the input friendly name
  106626. */
  106627. getSimpleName(): string;
  106628. }
  106629. }
  106630. declare module BABYLON {
  106631. interface ArcRotateCameraInputsManager {
  106632. /**
  106633. * Add orientation input support to the input manager.
  106634. * @returns the current input manager
  106635. */
  106636. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  106637. }
  106638. /**
  106639. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  106640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106641. */
  106642. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  106643. /**
  106644. * Defines the camera the input is attached to.
  106645. */
  106646. camera: ArcRotateCamera;
  106647. /**
  106648. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  106649. */
  106650. alphaCorrection: number;
  106651. /**
  106652. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  106653. */
  106654. gammaCorrection: number;
  106655. private _alpha;
  106656. private _gamma;
  106657. private _dirty;
  106658. private _deviceOrientationHandler;
  106659. /**
  106660. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  106661. */
  106662. constructor();
  106663. /**
  106664. * Attach the input controls to a specific dom element to get the input from.
  106665. * @param element Defines the element the controls should be listened from
  106666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106667. */
  106668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106669. /** @hidden */
  106670. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  106671. /**
  106672. * Update the current camera state depending on the inputs that have been used this frame.
  106673. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106674. */
  106675. checkInputs(): void;
  106676. /**
  106677. * Detach the current controls from the specified dom element.
  106678. * @param element Defines the element to stop listening the inputs from
  106679. */
  106680. detachControl(element: Nullable<HTMLElement>): void;
  106681. /**
  106682. * Gets the class name of the current intput.
  106683. * @returns the class name
  106684. */
  106685. getClassName(): string;
  106686. /**
  106687. * Get the friendly name associated with the input class.
  106688. * @returns the input friendly name
  106689. */
  106690. getSimpleName(): string;
  106691. }
  106692. }
  106693. declare module BABYLON {
  106694. /**
  106695. * Listen to mouse events to control the camera.
  106696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106697. */
  106698. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  106699. /**
  106700. * Defines the camera the input is attached to.
  106701. */
  106702. camera: FlyCamera;
  106703. /**
  106704. * Defines if touch is enabled. (Default is true.)
  106705. */
  106706. touchEnabled: boolean;
  106707. /**
  106708. * Defines the buttons associated with the input to handle camera rotation.
  106709. */
  106710. buttons: number[];
  106711. /**
  106712. * Assign buttons for Yaw control.
  106713. */
  106714. buttonsYaw: number[];
  106715. /**
  106716. * Assign buttons for Pitch control.
  106717. */
  106718. buttonsPitch: number[];
  106719. /**
  106720. * Assign buttons for Roll control.
  106721. */
  106722. buttonsRoll: number[];
  106723. /**
  106724. * Detect if any button is being pressed while mouse is moved.
  106725. * -1 = Mouse locked.
  106726. * 0 = Left button.
  106727. * 1 = Middle Button.
  106728. * 2 = Right Button.
  106729. */
  106730. activeButton: number;
  106731. /**
  106732. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  106733. * Higher values reduce its sensitivity.
  106734. */
  106735. angularSensibility: number;
  106736. private _mousemoveCallback;
  106737. private _observer;
  106738. private _rollObserver;
  106739. private previousPosition;
  106740. private noPreventDefault;
  106741. private element;
  106742. /**
  106743. * Listen to mouse events to control the camera.
  106744. * @param touchEnabled Define if touch is enabled. (Default is true.)
  106745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106746. */
  106747. constructor(touchEnabled?: boolean);
  106748. /**
  106749. * Attach the mouse control to the HTML DOM element.
  106750. * @param element Defines the element that listens to the input events.
  106751. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  106752. */
  106753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106754. /**
  106755. * Detach the current controls from the specified dom element.
  106756. * @param element Defines the element to stop listening the inputs from
  106757. */
  106758. detachControl(element: Nullable<HTMLElement>): void;
  106759. /**
  106760. * Gets the class name of the current input.
  106761. * @returns the class name.
  106762. */
  106763. getClassName(): string;
  106764. /**
  106765. * Get the friendly name associated with the input class.
  106766. * @returns the input's friendly name.
  106767. */
  106768. getSimpleName(): string;
  106769. private _pointerInput;
  106770. private _onMouseMove;
  106771. /**
  106772. * Rotate camera by mouse offset.
  106773. */
  106774. private rotateCamera;
  106775. }
  106776. }
  106777. declare module BABYLON {
  106778. /**
  106779. * Default Inputs manager for the FlyCamera.
  106780. * It groups all the default supported inputs for ease of use.
  106781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106782. */
  106783. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  106784. /**
  106785. * Instantiates a new FlyCameraInputsManager.
  106786. * @param camera Defines the camera the inputs belong to.
  106787. */
  106788. constructor(camera: FlyCamera);
  106789. /**
  106790. * Add keyboard input support to the input manager.
  106791. * @returns the new FlyCameraKeyboardMoveInput().
  106792. */
  106793. addKeyboard(): FlyCameraInputsManager;
  106794. /**
  106795. * Add mouse input support to the input manager.
  106796. * @param touchEnabled Enable touch screen support.
  106797. * @returns the new FlyCameraMouseInput().
  106798. */
  106799. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  106800. }
  106801. }
  106802. declare module BABYLON {
  106803. /**
  106804. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106805. * such as in a 3D Space Shooter or a Flight Simulator.
  106806. */
  106807. export class FlyCamera extends TargetCamera {
  106808. /**
  106809. * Define the collision ellipsoid of the camera.
  106810. * This is helpful for simulating a camera body, like a player's body.
  106811. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106812. */
  106813. ellipsoid: Vector3;
  106814. /**
  106815. * Define an offset for the position of the ellipsoid around the camera.
  106816. * This can be helpful if the camera is attached away from the player's body center,
  106817. * such as at its head.
  106818. */
  106819. ellipsoidOffset: Vector3;
  106820. /**
  106821. * Enable or disable collisions of the camera with the rest of the scene objects.
  106822. */
  106823. checkCollisions: boolean;
  106824. /**
  106825. * Enable or disable gravity on the camera.
  106826. */
  106827. applyGravity: boolean;
  106828. /**
  106829. * Define the current direction the camera is moving to.
  106830. */
  106831. cameraDirection: Vector3;
  106832. /**
  106833. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  106834. * This overrides and empties cameraRotation.
  106835. */
  106836. rotationQuaternion: Quaternion;
  106837. /**
  106838. * Track Roll to maintain the wanted Rolling when looking around.
  106839. */
  106840. _trackRoll: number;
  106841. /**
  106842. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106843. */
  106844. rollCorrect: number;
  106845. /**
  106846. * Mimic a banked turn, Rolling the camera when Yawing.
  106847. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106848. */
  106849. bankedTurn: boolean;
  106850. /**
  106851. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106852. */
  106853. bankedTurnLimit: number;
  106854. /**
  106855. * Value of 0 disables the banked Roll.
  106856. * Value of 1 is equal to the Yaw angle in radians.
  106857. */
  106858. bankedTurnMultiplier: number;
  106859. /**
  106860. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106861. */
  106862. inputs: FlyCameraInputsManager;
  106863. /**
  106864. * Gets the input sensibility for mouse input.
  106865. * Higher values reduce sensitivity.
  106866. */
  106867. /**
  106868. * Sets the input sensibility for a mouse input.
  106869. * Higher values reduce sensitivity.
  106870. */
  106871. angularSensibility: number;
  106872. /**
  106873. * Get the keys for camera movement forward.
  106874. */
  106875. /**
  106876. * Set the keys for camera movement forward.
  106877. */
  106878. keysForward: number[];
  106879. /**
  106880. * Get the keys for camera movement backward.
  106881. */
  106882. keysBackward: number[];
  106883. /**
  106884. * Get the keys for camera movement up.
  106885. */
  106886. /**
  106887. * Set the keys for camera movement up.
  106888. */
  106889. keysUp: number[];
  106890. /**
  106891. * Get the keys for camera movement down.
  106892. */
  106893. /**
  106894. * Set the keys for camera movement down.
  106895. */
  106896. keysDown: number[];
  106897. /**
  106898. * Get the keys for camera movement left.
  106899. */
  106900. /**
  106901. * Set the keys for camera movement left.
  106902. */
  106903. keysLeft: number[];
  106904. /**
  106905. * Set the keys for camera movement right.
  106906. */
  106907. /**
  106908. * Set the keys for camera movement right.
  106909. */
  106910. keysRight: number[];
  106911. /**
  106912. * Event raised when the camera collides with a mesh in the scene.
  106913. */
  106914. onCollide: (collidedMesh: AbstractMesh) => void;
  106915. private _collider;
  106916. private _needMoveForGravity;
  106917. private _oldPosition;
  106918. private _diffPosition;
  106919. private _newPosition;
  106920. /** @hidden */
  106921. _localDirection: Vector3;
  106922. /** @hidden */
  106923. _transformedDirection: Vector3;
  106924. /**
  106925. * Instantiates a FlyCamera.
  106926. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106927. * such as in a 3D Space Shooter or a Flight Simulator.
  106928. * @param name Define the name of the camera in the scene.
  106929. * @param position Define the starting position of the camera in the scene.
  106930. * @param scene Define the scene the camera belongs to.
  106931. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106932. */
  106933. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106934. /**
  106935. * Attach a control to the HTML DOM element.
  106936. * @param element Defines the element that listens to the input events.
  106937. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106938. */
  106939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106940. /**
  106941. * Detach a control from the HTML DOM element.
  106942. * The camera will stop reacting to that input.
  106943. * @param element Defines the element that listens to the input events.
  106944. */
  106945. detachControl(element: HTMLElement): void;
  106946. private _collisionMask;
  106947. /**
  106948. * Get the mask that the camera ignores in collision events.
  106949. */
  106950. /**
  106951. * Set the mask that the camera ignores in collision events.
  106952. */
  106953. collisionMask: number;
  106954. /** @hidden */
  106955. _collideWithWorld(displacement: Vector3): void;
  106956. /** @hidden */
  106957. private _onCollisionPositionChange;
  106958. /** @hidden */
  106959. _checkInputs(): void;
  106960. /** @hidden */
  106961. _decideIfNeedsToMove(): boolean;
  106962. /** @hidden */
  106963. _updatePosition(): void;
  106964. /**
  106965. * Restore the Roll to its target value at the rate specified.
  106966. * @param rate - Higher means slower restoring.
  106967. * @hidden
  106968. */
  106969. restoreRoll(rate: number): void;
  106970. /**
  106971. * Destroy the camera and release the current resources held by it.
  106972. */
  106973. dispose(): void;
  106974. /**
  106975. * Get the current object class name.
  106976. * @returns the class name.
  106977. */
  106978. getClassName(): string;
  106979. }
  106980. }
  106981. declare module BABYLON {
  106982. /**
  106983. * Listen to keyboard events to control the camera.
  106984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106985. */
  106986. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106987. /**
  106988. * Defines the camera the input is attached to.
  106989. */
  106990. camera: FlyCamera;
  106991. /**
  106992. * The list of keyboard keys used to control the forward move of the camera.
  106993. */
  106994. keysForward: number[];
  106995. /**
  106996. * The list of keyboard keys used to control the backward move of the camera.
  106997. */
  106998. keysBackward: number[];
  106999. /**
  107000. * The list of keyboard keys used to control the forward move of the camera.
  107001. */
  107002. keysUp: number[];
  107003. /**
  107004. * The list of keyboard keys used to control the backward move of the camera.
  107005. */
  107006. keysDown: number[];
  107007. /**
  107008. * The list of keyboard keys used to control the right strafe move of the camera.
  107009. */
  107010. keysRight: number[];
  107011. /**
  107012. * The list of keyboard keys used to control the left strafe move of the camera.
  107013. */
  107014. keysLeft: number[];
  107015. private _keys;
  107016. private _onCanvasBlurObserver;
  107017. private _onKeyboardObserver;
  107018. private _engine;
  107019. private _scene;
  107020. /**
  107021. * Attach the input controls to a specific dom element to get the input from.
  107022. * @param element Defines the element the controls should be listened from
  107023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107024. */
  107025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107026. /**
  107027. * Detach the current controls from the specified dom element.
  107028. * @param element Defines the element to stop listening the inputs from
  107029. */
  107030. detachControl(element: Nullable<HTMLElement>): void;
  107031. /**
  107032. * Gets the class name of the current intput.
  107033. * @returns the class name
  107034. */
  107035. getClassName(): string;
  107036. /** @hidden */
  107037. _onLostFocus(e: FocusEvent): void;
  107038. /**
  107039. * Get the friendly name associated with the input class.
  107040. * @returns the input friendly name
  107041. */
  107042. getSimpleName(): string;
  107043. /**
  107044. * Update the current camera state depending on the inputs that have been used this frame.
  107045. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107046. */
  107047. checkInputs(): void;
  107048. }
  107049. }
  107050. declare module BABYLON {
  107051. /**
  107052. * Manage the mouse wheel inputs to control a follow camera.
  107053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107054. */
  107055. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  107056. /**
  107057. * Defines the camera the input is attached to.
  107058. */
  107059. camera: FollowCamera;
  107060. /**
  107061. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  107062. */
  107063. axisControlRadius: boolean;
  107064. /**
  107065. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  107066. */
  107067. axisControlHeight: boolean;
  107068. /**
  107069. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  107070. */
  107071. axisControlRotation: boolean;
  107072. /**
  107073. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  107074. * relation to mouseWheel events.
  107075. */
  107076. wheelPrecision: number;
  107077. /**
  107078. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  107079. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  107080. */
  107081. wheelDeltaPercentage: number;
  107082. private _wheel;
  107083. private _observer;
  107084. /**
  107085. * Attach the input controls to a specific dom element to get the input from.
  107086. * @param element Defines the element the controls should be listened from
  107087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107088. */
  107089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107090. /**
  107091. * Detach the current controls from the specified dom element.
  107092. * @param element Defines the element to stop listening the inputs from
  107093. */
  107094. detachControl(element: Nullable<HTMLElement>): void;
  107095. /**
  107096. * Gets the class name of the current intput.
  107097. * @returns the class name
  107098. */
  107099. getClassName(): string;
  107100. /**
  107101. * Get the friendly name associated with the input class.
  107102. * @returns the input friendly name
  107103. */
  107104. getSimpleName(): string;
  107105. }
  107106. }
  107107. declare module BABYLON {
  107108. /**
  107109. * Manage the pointers inputs to control an follow camera.
  107110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107111. */
  107112. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  107113. /**
  107114. * Defines the camera the input is attached to.
  107115. */
  107116. camera: FollowCamera;
  107117. /**
  107118. * Gets the class name of the current input.
  107119. * @returns the class name
  107120. */
  107121. getClassName(): string;
  107122. /**
  107123. * Defines the pointer angular sensibility along the X axis or how fast is
  107124. * the camera rotating.
  107125. * A negative number will reverse the axis direction.
  107126. */
  107127. angularSensibilityX: number;
  107128. /**
  107129. * Defines the pointer angular sensibility along the Y axis or how fast is
  107130. * the camera rotating.
  107131. * A negative number will reverse the axis direction.
  107132. */
  107133. angularSensibilityY: number;
  107134. /**
  107135. * Defines the pointer pinch precision or how fast is the camera zooming.
  107136. * A negative number will reverse the axis direction.
  107137. */
  107138. pinchPrecision: number;
  107139. /**
  107140. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  107141. * from 0.
  107142. * It defines the percentage of current camera.radius to use as delta when
  107143. * pinch zoom is used.
  107144. */
  107145. pinchDeltaPercentage: number;
  107146. /**
  107147. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  107148. */
  107149. axisXControlRadius: boolean;
  107150. /**
  107151. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  107152. */
  107153. axisXControlHeight: boolean;
  107154. /**
  107155. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  107156. */
  107157. axisXControlRotation: boolean;
  107158. /**
  107159. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  107160. */
  107161. axisYControlRadius: boolean;
  107162. /**
  107163. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  107164. */
  107165. axisYControlHeight: boolean;
  107166. /**
  107167. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  107168. */
  107169. axisYControlRotation: boolean;
  107170. /**
  107171. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  107172. */
  107173. axisPinchControlRadius: boolean;
  107174. /**
  107175. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  107176. */
  107177. axisPinchControlHeight: boolean;
  107178. /**
  107179. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  107180. */
  107181. axisPinchControlRotation: boolean;
  107182. /**
  107183. * Log error messages if basic misconfiguration has occurred.
  107184. */
  107185. warningEnable: boolean;
  107186. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  107187. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  107188. private _warningCounter;
  107189. private _warning;
  107190. }
  107191. }
  107192. declare module BABYLON {
  107193. /**
  107194. * Default Inputs manager for the FollowCamera.
  107195. * It groups all the default supported inputs for ease of use.
  107196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107197. */
  107198. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  107199. /**
  107200. * Instantiates a new FollowCameraInputsManager.
  107201. * @param camera Defines the camera the inputs belong to
  107202. */
  107203. constructor(camera: FollowCamera);
  107204. /**
  107205. * Add keyboard input support to the input manager.
  107206. * @returns the current input manager
  107207. */
  107208. addKeyboard(): FollowCameraInputsManager;
  107209. /**
  107210. * Add mouse wheel input support to the input manager.
  107211. * @returns the current input manager
  107212. */
  107213. addMouseWheel(): FollowCameraInputsManager;
  107214. /**
  107215. * Add pointers input support to the input manager.
  107216. * @returns the current input manager
  107217. */
  107218. addPointers(): FollowCameraInputsManager;
  107219. /**
  107220. * Add orientation input support to the input manager.
  107221. * @returns the current input manager
  107222. */
  107223. addVRDeviceOrientation(): FollowCameraInputsManager;
  107224. }
  107225. }
  107226. declare module BABYLON {
  107227. /**
  107228. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  107229. * an arc rotate version arcFollowCamera are available.
  107230. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  107231. */
  107232. export class FollowCamera extends TargetCamera {
  107233. /**
  107234. * Distance the follow camera should follow an object at
  107235. */
  107236. radius: number;
  107237. /**
  107238. * Minimum allowed distance of the camera to the axis of rotation
  107239. * (The camera can not get closer).
  107240. * This can help limiting how the Camera is able to move in the scene.
  107241. */
  107242. lowerRadiusLimit: Nullable<number>;
  107243. /**
  107244. * Maximum allowed distance of the camera to the axis of rotation
  107245. * (The camera can not get further).
  107246. * This can help limiting how the Camera is able to move in the scene.
  107247. */
  107248. upperRadiusLimit: Nullable<number>;
  107249. /**
  107250. * Define a rotation offset between the camera and the object it follows
  107251. */
  107252. rotationOffset: number;
  107253. /**
  107254. * Minimum allowed angle to camera position relative to target object.
  107255. * This can help limiting how the Camera is able to move in the scene.
  107256. */
  107257. lowerRotationOffsetLimit: Nullable<number>;
  107258. /**
  107259. * Maximum allowed angle to camera position relative to target object.
  107260. * This can help limiting how the Camera is able to move in the scene.
  107261. */
  107262. upperRotationOffsetLimit: Nullable<number>;
  107263. /**
  107264. * Define a height offset between the camera and the object it follows.
  107265. * It can help following an object from the top (like a car chaing a plane)
  107266. */
  107267. heightOffset: number;
  107268. /**
  107269. * Minimum allowed height of camera position relative to target object.
  107270. * This can help limiting how the Camera is able to move in the scene.
  107271. */
  107272. lowerHeightOffsetLimit: Nullable<number>;
  107273. /**
  107274. * Maximum allowed height of camera position relative to target object.
  107275. * This can help limiting how the Camera is able to move in the scene.
  107276. */
  107277. upperHeightOffsetLimit: Nullable<number>;
  107278. /**
  107279. * Define how fast the camera can accelerate to follow it s target.
  107280. */
  107281. cameraAcceleration: number;
  107282. /**
  107283. * Define the speed limit of the camera following an object.
  107284. */
  107285. maxCameraSpeed: number;
  107286. /**
  107287. * Define the target of the camera.
  107288. */
  107289. lockedTarget: Nullable<AbstractMesh>;
  107290. /**
  107291. * Defines the input associated with the camera.
  107292. */
  107293. inputs: FollowCameraInputsManager;
  107294. /**
  107295. * Instantiates the follow camera.
  107296. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  107297. * @param name Define the name of the camera in the scene
  107298. * @param position Define the position of the camera
  107299. * @param scene Define the scene the camera belong to
  107300. * @param lockedTarget Define the target of the camera
  107301. */
  107302. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  107303. private _follow;
  107304. /**
  107305. * Attached controls to the current camera.
  107306. * @param element Defines the element the controls should be listened from
  107307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107308. */
  107309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107310. /**
  107311. * Detach the current controls from the camera.
  107312. * The camera will stop reacting to inputs.
  107313. * @param element Defines the element to stop listening the inputs from
  107314. */
  107315. detachControl(element: HTMLElement): void;
  107316. /** @hidden */
  107317. _checkInputs(): void;
  107318. private _checkLimits;
  107319. /**
  107320. * Gets the camera class name.
  107321. * @returns the class name
  107322. */
  107323. getClassName(): string;
  107324. }
  107325. /**
  107326. * Arc Rotate version of the follow camera.
  107327. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  107328. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  107329. */
  107330. export class ArcFollowCamera extends TargetCamera {
  107331. /** The longitudinal angle of the camera */
  107332. alpha: number;
  107333. /** The latitudinal angle of the camera */
  107334. beta: number;
  107335. /** The radius of the camera from its target */
  107336. radius: number;
  107337. /** Define the camera target (the messh it should follow) */
  107338. target: Nullable<AbstractMesh>;
  107339. private _cartesianCoordinates;
  107340. /**
  107341. * Instantiates a new ArcFollowCamera
  107342. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  107343. * @param name Define the name of the camera
  107344. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  107345. * @param beta Define the rotation angle of the camera around the elevation axis
  107346. * @param radius Define the radius of the camera from its target point
  107347. * @param target Define the target of the camera
  107348. * @param scene Define the scene the camera belongs to
  107349. */
  107350. constructor(name: string,
  107351. /** The longitudinal angle of the camera */
  107352. alpha: number,
  107353. /** The latitudinal angle of the camera */
  107354. beta: number,
  107355. /** The radius of the camera from its target */
  107356. radius: number,
  107357. /** Define the camera target (the messh it should follow) */
  107358. target: Nullable<AbstractMesh>, scene: Scene);
  107359. private _follow;
  107360. /** @hidden */
  107361. _checkInputs(): void;
  107362. /**
  107363. * Returns the class name of the object.
  107364. * It is mostly used internally for serialization purposes.
  107365. */
  107366. getClassName(): string;
  107367. }
  107368. }
  107369. declare module BABYLON {
  107370. /**
  107371. * Manage the keyboard inputs to control the movement of a follow camera.
  107372. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107373. */
  107374. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  107375. /**
  107376. * Defines the camera the input is attached to.
  107377. */
  107378. camera: FollowCamera;
  107379. /**
  107380. * Defines the list of key codes associated with the up action (increase heightOffset)
  107381. */
  107382. keysHeightOffsetIncr: number[];
  107383. /**
  107384. * Defines the list of key codes associated with the down action (decrease heightOffset)
  107385. */
  107386. keysHeightOffsetDecr: number[];
  107387. /**
  107388. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  107389. */
  107390. keysHeightOffsetModifierAlt: boolean;
  107391. /**
  107392. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  107393. */
  107394. keysHeightOffsetModifierCtrl: boolean;
  107395. /**
  107396. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  107397. */
  107398. keysHeightOffsetModifierShift: boolean;
  107399. /**
  107400. * Defines the list of key codes associated with the left action (increase rotationOffset)
  107401. */
  107402. keysRotationOffsetIncr: number[];
  107403. /**
  107404. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  107405. */
  107406. keysRotationOffsetDecr: number[];
  107407. /**
  107408. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  107409. */
  107410. keysRotationOffsetModifierAlt: boolean;
  107411. /**
  107412. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  107413. */
  107414. keysRotationOffsetModifierCtrl: boolean;
  107415. /**
  107416. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  107417. */
  107418. keysRotationOffsetModifierShift: boolean;
  107419. /**
  107420. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  107421. */
  107422. keysRadiusIncr: number[];
  107423. /**
  107424. * Defines the list of key codes associated with the zoom-out action (increase radius)
  107425. */
  107426. keysRadiusDecr: number[];
  107427. /**
  107428. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  107429. */
  107430. keysRadiusModifierAlt: boolean;
  107431. /**
  107432. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  107433. */
  107434. keysRadiusModifierCtrl: boolean;
  107435. /**
  107436. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  107437. */
  107438. keysRadiusModifierShift: boolean;
  107439. /**
  107440. * Defines the rate of change of heightOffset.
  107441. */
  107442. heightSensibility: number;
  107443. /**
  107444. * Defines the rate of change of rotationOffset.
  107445. */
  107446. rotationSensibility: number;
  107447. /**
  107448. * Defines the rate of change of radius.
  107449. */
  107450. radiusSensibility: number;
  107451. private _keys;
  107452. private _ctrlPressed;
  107453. private _altPressed;
  107454. private _shiftPressed;
  107455. private _onCanvasBlurObserver;
  107456. private _onKeyboardObserver;
  107457. private _engine;
  107458. private _scene;
  107459. /**
  107460. * Attach the input controls to a specific dom element to get the input from.
  107461. * @param element Defines the element the controls should be listened from
  107462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107463. */
  107464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107465. /**
  107466. * Detach the current controls from the specified dom element.
  107467. * @param element Defines the element to stop listening the inputs from
  107468. */
  107469. detachControl(element: Nullable<HTMLElement>): void;
  107470. /**
  107471. * Update the current camera state depending on the inputs that have been used this frame.
  107472. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107473. */
  107474. checkInputs(): void;
  107475. /**
  107476. * Gets the class name of the current input.
  107477. * @returns the class name
  107478. */
  107479. getClassName(): string;
  107480. /**
  107481. * Get the friendly name associated with the input class.
  107482. * @returns the input friendly name
  107483. */
  107484. getSimpleName(): string;
  107485. /**
  107486. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107487. * allow modification of the heightOffset value.
  107488. */
  107489. private _modifierHeightOffset;
  107490. /**
  107491. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107492. * allow modification of the rotationOffset value.
  107493. */
  107494. private _modifierRotationOffset;
  107495. /**
  107496. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107497. * allow modification of the radius value.
  107498. */
  107499. private _modifierRadius;
  107500. }
  107501. }
  107502. declare module BABYLON {
  107503. interface FreeCameraInputsManager {
  107504. /**
  107505. * @hidden
  107506. */
  107507. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  107508. /**
  107509. * Add orientation input support to the input manager.
  107510. * @returns the current input manager
  107511. */
  107512. addDeviceOrientation(): FreeCameraInputsManager;
  107513. }
  107514. /**
  107515. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  107516. * Screen rotation is taken into account.
  107517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107518. */
  107519. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  107520. private _camera;
  107521. private _screenOrientationAngle;
  107522. private _constantTranform;
  107523. private _screenQuaternion;
  107524. private _alpha;
  107525. private _beta;
  107526. private _gamma;
  107527. /**
  107528. * Can be used to detect if a device orientation sensor is availible on a device
  107529. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  107530. * @returns a promise that will resolve on orientation change
  107531. */
  107532. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  107533. /**
  107534. * @hidden
  107535. */
  107536. _onDeviceOrientationChangedObservable: Observable<void>;
  107537. /**
  107538. * Instantiates a new input
  107539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107540. */
  107541. constructor();
  107542. /**
  107543. * Define the camera controlled by the input.
  107544. */
  107545. camera: FreeCamera;
  107546. /**
  107547. * Attach the input controls to a specific dom element to get the input from.
  107548. * @param element Defines the element the controls should be listened from
  107549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107550. */
  107551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107552. private _orientationChanged;
  107553. private _deviceOrientation;
  107554. /**
  107555. * Detach the current controls from the specified dom element.
  107556. * @param element Defines the element to stop listening the inputs from
  107557. */
  107558. detachControl(element: Nullable<HTMLElement>): void;
  107559. /**
  107560. * Update the current camera state depending on the inputs that have been used this frame.
  107561. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107562. */
  107563. checkInputs(): void;
  107564. /**
  107565. * Gets the class name of the current intput.
  107566. * @returns the class name
  107567. */
  107568. getClassName(): string;
  107569. /**
  107570. * Get the friendly name associated with the input class.
  107571. * @returns the input friendly name
  107572. */
  107573. getSimpleName(): string;
  107574. }
  107575. }
  107576. declare module BABYLON {
  107577. /**
  107578. * Manage the gamepad inputs to control a free camera.
  107579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107580. */
  107581. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  107582. /**
  107583. * Define the camera the input is attached to.
  107584. */
  107585. camera: FreeCamera;
  107586. /**
  107587. * Define the Gamepad controlling the input
  107588. */
  107589. gamepad: Nullable<Gamepad>;
  107590. /**
  107591. * Defines the gamepad rotation sensiblity.
  107592. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107593. */
  107594. gamepadAngularSensibility: number;
  107595. /**
  107596. * Defines the gamepad move sensiblity.
  107597. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107598. */
  107599. gamepadMoveSensibility: number;
  107600. private _yAxisScale;
  107601. /**
  107602. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107603. */
  107604. invertYAxis: boolean;
  107605. private _onGamepadConnectedObserver;
  107606. private _onGamepadDisconnectedObserver;
  107607. private _cameraTransform;
  107608. private _deltaTransform;
  107609. private _vector3;
  107610. private _vector2;
  107611. /**
  107612. * Attach the input controls to a specific dom element to get the input from.
  107613. * @param element Defines the element the controls should be listened from
  107614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107615. */
  107616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107617. /**
  107618. * Detach the current controls from the specified dom element.
  107619. * @param element Defines the element to stop listening the inputs from
  107620. */
  107621. detachControl(element: Nullable<HTMLElement>): void;
  107622. /**
  107623. * Update the current camera state depending on the inputs that have been used this frame.
  107624. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107625. */
  107626. checkInputs(): void;
  107627. /**
  107628. * Gets the class name of the current intput.
  107629. * @returns the class name
  107630. */
  107631. getClassName(): string;
  107632. /**
  107633. * Get the friendly name associated with the input class.
  107634. * @returns the input friendly name
  107635. */
  107636. getSimpleName(): string;
  107637. }
  107638. }
  107639. declare module BABYLON {
  107640. /**
  107641. * Defines the potential axis of a Joystick
  107642. */
  107643. export enum JoystickAxis {
  107644. /** X axis */
  107645. X = 0,
  107646. /** Y axis */
  107647. Y = 1,
  107648. /** Z axis */
  107649. Z = 2
  107650. }
  107651. /**
  107652. * Class used to define virtual joystick (used in touch mode)
  107653. */
  107654. export class VirtualJoystick {
  107655. /**
  107656. * Gets or sets a boolean indicating that left and right values must be inverted
  107657. */
  107658. reverseLeftRight: boolean;
  107659. /**
  107660. * Gets or sets a boolean indicating that up and down values must be inverted
  107661. */
  107662. reverseUpDown: boolean;
  107663. /**
  107664. * Gets the offset value for the position (ie. the change of the position value)
  107665. */
  107666. deltaPosition: Vector3;
  107667. /**
  107668. * Gets a boolean indicating if the virtual joystick was pressed
  107669. */
  107670. pressed: boolean;
  107671. /**
  107672. * Canvas the virtual joystick will render onto, default z-index of this is 5
  107673. */
  107674. static Canvas: Nullable<HTMLCanvasElement>;
  107675. private static _globalJoystickIndex;
  107676. private static vjCanvasContext;
  107677. private static vjCanvasWidth;
  107678. private static vjCanvasHeight;
  107679. private static halfWidth;
  107680. private _action;
  107681. private _axisTargetedByLeftAndRight;
  107682. private _axisTargetedByUpAndDown;
  107683. private _joystickSensibility;
  107684. private _inversedSensibility;
  107685. private _joystickPointerID;
  107686. private _joystickColor;
  107687. private _joystickPointerPos;
  107688. private _joystickPreviousPointerPos;
  107689. private _joystickPointerStartPos;
  107690. private _deltaJoystickVector;
  107691. private _leftJoystick;
  107692. private _touches;
  107693. private _onPointerDownHandlerRef;
  107694. private _onPointerMoveHandlerRef;
  107695. private _onPointerUpHandlerRef;
  107696. private _onResize;
  107697. /**
  107698. * Creates a new virtual joystick
  107699. * @param leftJoystick defines that the joystick is for left hand (false by default)
  107700. */
  107701. constructor(leftJoystick?: boolean);
  107702. /**
  107703. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  107704. * @param newJoystickSensibility defines the new sensibility
  107705. */
  107706. setJoystickSensibility(newJoystickSensibility: number): void;
  107707. private _onPointerDown;
  107708. private _onPointerMove;
  107709. private _onPointerUp;
  107710. /**
  107711. * Change the color of the virtual joystick
  107712. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  107713. */
  107714. setJoystickColor(newColor: string): void;
  107715. /**
  107716. * Defines a callback to call when the joystick is touched
  107717. * @param action defines the callback
  107718. */
  107719. setActionOnTouch(action: () => any): void;
  107720. /**
  107721. * Defines which axis you'd like to control for left & right
  107722. * @param axis defines the axis to use
  107723. */
  107724. setAxisForLeftRight(axis: JoystickAxis): void;
  107725. /**
  107726. * Defines which axis you'd like to control for up & down
  107727. * @param axis defines the axis to use
  107728. */
  107729. setAxisForUpDown(axis: JoystickAxis): void;
  107730. private _drawVirtualJoystick;
  107731. /**
  107732. * Release internal HTML canvas
  107733. */
  107734. releaseCanvas(): void;
  107735. }
  107736. }
  107737. declare module BABYLON {
  107738. interface FreeCameraInputsManager {
  107739. /**
  107740. * Add virtual joystick input support to the input manager.
  107741. * @returns the current input manager
  107742. */
  107743. addVirtualJoystick(): FreeCameraInputsManager;
  107744. }
  107745. /**
  107746. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  107747. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107748. */
  107749. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  107750. /**
  107751. * Defines the camera the input is attached to.
  107752. */
  107753. camera: FreeCamera;
  107754. private _leftjoystick;
  107755. private _rightjoystick;
  107756. /**
  107757. * Gets the left stick of the virtual joystick.
  107758. * @returns The virtual Joystick
  107759. */
  107760. getLeftJoystick(): VirtualJoystick;
  107761. /**
  107762. * Gets the right stick of the virtual joystick.
  107763. * @returns The virtual Joystick
  107764. */
  107765. getRightJoystick(): VirtualJoystick;
  107766. /**
  107767. * Update the current camera state depending on the inputs that have been used this frame.
  107768. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107769. */
  107770. checkInputs(): void;
  107771. /**
  107772. * Attach the input controls to a specific dom element to get the input from.
  107773. * @param element Defines the element the controls should be listened from
  107774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107775. */
  107776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107777. /**
  107778. * Detach the current controls from the specified dom element.
  107779. * @param element Defines the element to stop listening the inputs from
  107780. */
  107781. detachControl(element: Nullable<HTMLElement>): void;
  107782. /**
  107783. * Gets the class name of the current intput.
  107784. * @returns the class name
  107785. */
  107786. getClassName(): string;
  107787. /**
  107788. * Get the friendly name associated with the input class.
  107789. * @returns the input friendly name
  107790. */
  107791. getSimpleName(): string;
  107792. }
  107793. }
  107794. declare module BABYLON {
  107795. /**
  107796. * This represents a FPS type of camera controlled by touch.
  107797. * This is like a universal camera minus the Gamepad controls.
  107798. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107799. */
  107800. export class TouchCamera extends FreeCamera {
  107801. /**
  107802. * Defines the touch sensibility for rotation.
  107803. * The higher the faster.
  107804. */
  107805. touchAngularSensibility: number;
  107806. /**
  107807. * Defines the touch sensibility for move.
  107808. * The higher the faster.
  107809. */
  107810. touchMoveSensibility: number;
  107811. /**
  107812. * Instantiates a new touch camera.
  107813. * This represents a FPS type of camera controlled by touch.
  107814. * This is like a universal camera minus the Gamepad controls.
  107815. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107816. * @param name Define the name of the camera in the scene
  107817. * @param position Define the start position of the camera in the scene
  107818. * @param scene Define the scene the camera belongs to
  107819. */
  107820. constructor(name: string, position: Vector3, scene: Scene);
  107821. /**
  107822. * Gets the current object class name.
  107823. * @return the class name
  107824. */
  107825. getClassName(): string;
  107826. /** @hidden */
  107827. _setupInputs(): void;
  107828. }
  107829. }
  107830. declare module BABYLON {
  107831. /**
  107832. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  107833. * being tilted forward or back and left or right.
  107834. */
  107835. export class DeviceOrientationCamera extends FreeCamera {
  107836. private _initialQuaternion;
  107837. private _quaternionCache;
  107838. private _tmpDragQuaternion;
  107839. private _disablePointerInputWhenUsingDeviceOrientation;
  107840. /**
  107841. * Creates a new device orientation camera
  107842. * @param name The name of the camera
  107843. * @param position The start position camera
  107844. * @param scene The scene the camera belongs to
  107845. */
  107846. constructor(name: string, position: Vector3, scene: Scene);
  107847. /**
  107848. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107849. */
  107850. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107851. private _dragFactor;
  107852. /**
  107853. * Enabled turning on the y axis when the orientation sensor is active
  107854. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107855. */
  107856. enableHorizontalDragging(dragFactor?: number): void;
  107857. /**
  107858. * Gets the current instance class name ("DeviceOrientationCamera").
  107859. * This helps avoiding instanceof at run time.
  107860. * @returns the class name
  107861. */
  107862. getClassName(): string;
  107863. /**
  107864. * @hidden
  107865. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107866. */
  107867. _checkInputs(): void;
  107868. /**
  107869. * Reset the camera to its default orientation on the specified axis only.
  107870. * @param axis The axis to reset
  107871. */
  107872. resetToCurrentRotation(axis?: Axis): void;
  107873. }
  107874. }
  107875. declare module BABYLON {
  107876. /**
  107877. * Defines supported buttons for XBox360 compatible gamepads
  107878. */
  107879. export enum Xbox360Button {
  107880. /** A */
  107881. A = 0,
  107882. /** B */
  107883. B = 1,
  107884. /** X */
  107885. X = 2,
  107886. /** Y */
  107887. Y = 3,
  107888. /** Start */
  107889. Start = 4,
  107890. /** Back */
  107891. Back = 5,
  107892. /** Left button */
  107893. LB = 6,
  107894. /** Right button */
  107895. RB = 7,
  107896. /** Left stick */
  107897. LeftStick = 8,
  107898. /** Right stick */
  107899. RightStick = 9
  107900. }
  107901. /** Defines values for XBox360 DPad */
  107902. export enum Xbox360Dpad {
  107903. /** Up */
  107904. Up = 0,
  107905. /** Down */
  107906. Down = 1,
  107907. /** Left */
  107908. Left = 2,
  107909. /** Right */
  107910. Right = 3
  107911. }
  107912. /**
  107913. * Defines a XBox360 gamepad
  107914. */
  107915. export class Xbox360Pad extends Gamepad {
  107916. private _leftTrigger;
  107917. private _rightTrigger;
  107918. private _onlefttriggerchanged;
  107919. private _onrighttriggerchanged;
  107920. private _onbuttondown;
  107921. private _onbuttonup;
  107922. private _ondpaddown;
  107923. private _ondpadup;
  107924. /** Observable raised when a button is pressed */
  107925. onButtonDownObservable: Observable<Xbox360Button>;
  107926. /** Observable raised when a button is released */
  107927. onButtonUpObservable: Observable<Xbox360Button>;
  107928. /** Observable raised when a pad is pressed */
  107929. onPadDownObservable: Observable<Xbox360Dpad>;
  107930. /** Observable raised when a pad is released */
  107931. onPadUpObservable: Observable<Xbox360Dpad>;
  107932. private _buttonA;
  107933. private _buttonB;
  107934. private _buttonX;
  107935. private _buttonY;
  107936. private _buttonBack;
  107937. private _buttonStart;
  107938. private _buttonLB;
  107939. private _buttonRB;
  107940. private _buttonLeftStick;
  107941. private _buttonRightStick;
  107942. private _dPadUp;
  107943. private _dPadDown;
  107944. private _dPadLeft;
  107945. private _dPadRight;
  107946. private _isXboxOnePad;
  107947. /**
  107948. * Creates a new XBox360 gamepad object
  107949. * @param id defines the id of this gamepad
  107950. * @param index defines its index
  107951. * @param gamepad defines the internal HTML gamepad object
  107952. * @param xboxOne defines if it is a XBox One gamepad
  107953. */
  107954. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107955. /**
  107956. * Defines the callback to call when left trigger is pressed
  107957. * @param callback defines the callback to use
  107958. */
  107959. onlefttriggerchanged(callback: (value: number) => void): void;
  107960. /**
  107961. * Defines the callback to call when right trigger is pressed
  107962. * @param callback defines the callback to use
  107963. */
  107964. onrighttriggerchanged(callback: (value: number) => void): void;
  107965. /**
  107966. * Gets the left trigger value
  107967. */
  107968. /**
  107969. * Sets the left trigger value
  107970. */
  107971. leftTrigger: number;
  107972. /**
  107973. * Gets the right trigger value
  107974. */
  107975. /**
  107976. * Sets the right trigger value
  107977. */
  107978. rightTrigger: number;
  107979. /**
  107980. * Defines the callback to call when a button is pressed
  107981. * @param callback defines the callback to use
  107982. */
  107983. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107984. /**
  107985. * Defines the callback to call when a button is released
  107986. * @param callback defines the callback to use
  107987. */
  107988. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107989. /**
  107990. * Defines the callback to call when a pad is pressed
  107991. * @param callback defines the callback to use
  107992. */
  107993. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107994. /**
  107995. * Defines the callback to call when a pad is released
  107996. * @param callback defines the callback to use
  107997. */
  107998. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107999. private _setButtonValue;
  108000. private _setDPadValue;
  108001. /**
  108002. * Gets the value of the `A` button
  108003. */
  108004. /**
  108005. * Sets the value of the `A` button
  108006. */
  108007. buttonA: number;
  108008. /**
  108009. * Gets the value of the `B` button
  108010. */
  108011. /**
  108012. * Sets the value of the `B` button
  108013. */
  108014. buttonB: number;
  108015. /**
  108016. * Gets the value of the `X` button
  108017. */
  108018. /**
  108019. * Sets the value of the `X` button
  108020. */
  108021. buttonX: number;
  108022. /**
  108023. * Gets the value of the `Y` button
  108024. */
  108025. /**
  108026. * Sets the value of the `Y` button
  108027. */
  108028. buttonY: number;
  108029. /**
  108030. * Gets the value of the `Start` button
  108031. */
  108032. /**
  108033. * Sets the value of the `Start` button
  108034. */
  108035. buttonStart: number;
  108036. /**
  108037. * Gets the value of the `Back` button
  108038. */
  108039. /**
  108040. * Sets the value of the `Back` button
  108041. */
  108042. buttonBack: number;
  108043. /**
  108044. * Gets the value of the `Left` button
  108045. */
  108046. /**
  108047. * Sets the value of the `Left` button
  108048. */
  108049. buttonLB: number;
  108050. /**
  108051. * Gets the value of the `Right` button
  108052. */
  108053. /**
  108054. * Sets the value of the `Right` button
  108055. */
  108056. buttonRB: number;
  108057. /**
  108058. * Gets the value of the Left joystick
  108059. */
  108060. /**
  108061. * Sets the value of the Left joystick
  108062. */
  108063. buttonLeftStick: number;
  108064. /**
  108065. * Gets the value of the Right joystick
  108066. */
  108067. /**
  108068. * Sets the value of the Right joystick
  108069. */
  108070. buttonRightStick: number;
  108071. /**
  108072. * Gets the value of D-pad up
  108073. */
  108074. /**
  108075. * Sets the value of D-pad up
  108076. */
  108077. dPadUp: number;
  108078. /**
  108079. * Gets the value of D-pad down
  108080. */
  108081. /**
  108082. * Sets the value of D-pad down
  108083. */
  108084. dPadDown: number;
  108085. /**
  108086. * Gets the value of D-pad left
  108087. */
  108088. /**
  108089. * Sets the value of D-pad left
  108090. */
  108091. dPadLeft: number;
  108092. /**
  108093. * Gets the value of D-pad right
  108094. */
  108095. /**
  108096. * Sets the value of D-pad right
  108097. */
  108098. dPadRight: number;
  108099. /**
  108100. * Force the gamepad to synchronize with device values
  108101. */
  108102. update(): void;
  108103. /**
  108104. * Disposes the gamepad
  108105. */
  108106. dispose(): void;
  108107. }
  108108. }
  108109. declare module BABYLON {
  108110. /**
  108111. * Defines supported buttons for DualShock compatible gamepads
  108112. */
  108113. export enum DualShockButton {
  108114. /** Cross */
  108115. Cross = 0,
  108116. /** Circle */
  108117. Circle = 1,
  108118. /** Square */
  108119. Square = 2,
  108120. /** Triangle */
  108121. Triangle = 3,
  108122. /** Options */
  108123. Options = 4,
  108124. /** Share */
  108125. Share = 5,
  108126. /** L1 */
  108127. L1 = 6,
  108128. /** R1 */
  108129. R1 = 7,
  108130. /** Left stick */
  108131. LeftStick = 8,
  108132. /** Right stick */
  108133. RightStick = 9
  108134. }
  108135. /** Defines values for DualShock DPad */
  108136. export enum DualShockDpad {
  108137. /** Up */
  108138. Up = 0,
  108139. /** Down */
  108140. Down = 1,
  108141. /** Left */
  108142. Left = 2,
  108143. /** Right */
  108144. Right = 3
  108145. }
  108146. /**
  108147. * Defines a DualShock gamepad
  108148. */
  108149. export class DualShockPad extends Gamepad {
  108150. private _leftTrigger;
  108151. private _rightTrigger;
  108152. private _onlefttriggerchanged;
  108153. private _onrighttriggerchanged;
  108154. private _onbuttondown;
  108155. private _onbuttonup;
  108156. private _ondpaddown;
  108157. private _ondpadup;
  108158. /** Observable raised when a button is pressed */
  108159. onButtonDownObservable: Observable<DualShockButton>;
  108160. /** Observable raised when a button is released */
  108161. onButtonUpObservable: Observable<DualShockButton>;
  108162. /** Observable raised when a pad is pressed */
  108163. onPadDownObservable: Observable<DualShockDpad>;
  108164. /** Observable raised when a pad is released */
  108165. onPadUpObservable: Observable<DualShockDpad>;
  108166. private _buttonCross;
  108167. private _buttonCircle;
  108168. private _buttonSquare;
  108169. private _buttonTriangle;
  108170. private _buttonShare;
  108171. private _buttonOptions;
  108172. private _buttonL1;
  108173. private _buttonR1;
  108174. private _buttonLeftStick;
  108175. private _buttonRightStick;
  108176. private _dPadUp;
  108177. private _dPadDown;
  108178. private _dPadLeft;
  108179. private _dPadRight;
  108180. /**
  108181. * Creates a new DualShock gamepad object
  108182. * @param id defines the id of this gamepad
  108183. * @param index defines its index
  108184. * @param gamepad defines the internal HTML gamepad object
  108185. */
  108186. constructor(id: string, index: number, gamepad: any);
  108187. /**
  108188. * Defines the callback to call when left trigger is pressed
  108189. * @param callback defines the callback to use
  108190. */
  108191. onlefttriggerchanged(callback: (value: number) => void): void;
  108192. /**
  108193. * Defines the callback to call when right trigger is pressed
  108194. * @param callback defines the callback to use
  108195. */
  108196. onrighttriggerchanged(callback: (value: number) => void): void;
  108197. /**
  108198. * Gets the left trigger value
  108199. */
  108200. /**
  108201. * Sets the left trigger value
  108202. */
  108203. leftTrigger: number;
  108204. /**
  108205. * Gets the right trigger value
  108206. */
  108207. /**
  108208. * Sets the right trigger value
  108209. */
  108210. rightTrigger: number;
  108211. /**
  108212. * Defines the callback to call when a button is pressed
  108213. * @param callback defines the callback to use
  108214. */
  108215. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  108216. /**
  108217. * Defines the callback to call when a button is released
  108218. * @param callback defines the callback to use
  108219. */
  108220. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  108221. /**
  108222. * Defines the callback to call when a pad is pressed
  108223. * @param callback defines the callback to use
  108224. */
  108225. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  108226. /**
  108227. * Defines the callback to call when a pad is released
  108228. * @param callback defines the callback to use
  108229. */
  108230. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  108231. private _setButtonValue;
  108232. private _setDPadValue;
  108233. /**
  108234. * Gets the value of the `Cross` button
  108235. */
  108236. /**
  108237. * Sets the value of the `Cross` button
  108238. */
  108239. buttonCross: number;
  108240. /**
  108241. * Gets the value of the `Circle` button
  108242. */
  108243. /**
  108244. * Sets the value of the `Circle` button
  108245. */
  108246. buttonCircle: number;
  108247. /**
  108248. * Gets the value of the `Square` button
  108249. */
  108250. /**
  108251. * Sets the value of the `Square` button
  108252. */
  108253. buttonSquare: number;
  108254. /**
  108255. * Gets the value of the `Triangle` button
  108256. */
  108257. /**
  108258. * Sets the value of the `Triangle` button
  108259. */
  108260. buttonTriangle: number;
  108261. /**
  108262. * Gets the value of the `Options` button
  108263. */
  108264. /**
  108265. * Sets the value of the `Options` button
  108266. */
  108267. buttonOptions: number;
  108268. /**
  108269. * Gets the value of the `Share` button
  108270. */
  108271. /**
  108272. * Sets the value of the `Share` button
  108273. */
  108274. buttonShare: number;
  108275. /**
  108276. * Gets the value of the `L1` button
  108277. */
  108278. /**
  108279. * Sets the value of the `L1` button
  108280. */
  108281. buttonL1: number;
  108282. /**
  108283. * Gets the value of the `R1` button
  108284. */
  108285. /**
  108286. * Sets the value of the `R1` button
  108287. */
  108288. buttonR1: number;
  108289. /**
  108290. * Gets the value of the Left joystick
  108291. */
  108292. /**
  108293. * Sets the value of the Left joystick
  108294. */
  108295. buttonLeftStick: number;
  108296. /**
  108297. * Gets the value of the Right joystick
  108298. */
  108299. /**
  108300. * Sets the value of the Right joystick
  108301. */
  108302. buttonRightStick: number;
  108303. /**
  108304. * Gets the value of D-pad up
  108305. */
  108306. /**
  108307. * Sets the value of D-pad up
  108308. */
  108309. dPadUp: number;
  108310. /**
  108311. * Gets the value of D-pad down
  108312. */
  108313. /**
  108314. * Sets the value of D-pad down
  108315. */
  108316. dPadDown: number;
  108317. /**
  108318. * Gets the value of D-pad left
  108319. */
  108320. /**
  108321. * Sets the value of D-pad left
  108322. */
  108323. dPadLeft: number;
  108324. /**
  108325. * Gets the value of D-pad right
  108326. */
  108327. /**
  108328. * Sets the value of D-pad right
  108329. */
  108330. dPadRight: number;
  108331. /**
  108332. * Force the gamepad to synchronize with device values
  108333. */
  108334. update(): void;
  108335. /**
  108336. * Disposes the gamepad
  108337. */
  108338. dispose(): void;
  108339. }
  108340. }
  108341. declare module BABYLON {
  108342. /**
  108343. * Manager for handling gamepads
  108344. */
  108345. export class GamepadManager {
  108346. private _scene?;
  108347. private _babylonGamepads;
  108348. private _oneGamepadConnected;
  108349. /** @hidden */
  108350. _isMonitoring: boolean;
  108351. private _gamepadEventSupported;
  108352. private _gamepadSupport;
  108353. /**
  108354. * observable to be triggered when the gamepad controller has been connected
  108355. */
  108356. onGamepadConnectedObservable: Observable<Gamepad>;
  108357. /**
  108358. * observable to be triggered when the gamepad controller has been disconnected
  108359. */
  108360. onGamepadDisconnectedObservable: Observable<Gamepad>;
  108361. private _onGamepadConnectedEvent;
  108362. private _onGamepadDisconnectedEvent;
  108363. /**
  108364. * Initializes the gamepad manager
  108365. * @param _scene BabylonJS scene
  108366. */
  108367. constructor(_scene?: Scene | undefined);
  108368. /**
  108369. * The gamepads in the game pad manager
  108370. */
  108371. readonly gamepads: Gamepad[];
  108372. /**
  108373. * Get the gamepad controllers based on type
  108374. * @param type The type of gamepad controller
  108375. * @returns Nullable gamepad
  108376. */
  108377. getGamepadByType(type?: number): Nullable<Gamepad>;
  108378. /**
  108379. * Disposes the gamepad manager
  108380. */
  108381. dispose(): void;
  108382. private _addNewGamepad;
  108383. private _startMonitoringGamepads;
  108384. private _stopMonitoringGamepads;
  108385. /** @hidden */
  108386. _checkGamepadsStatus(): void;
  108387. private _updateGamepadObjects;
  108388. }
  108389. }
  108390. declare module BABYLON {
  108391. interface Scene {
  108392. /** @hidden */
  108393. _gamepadManager: Nullable<GamepadManager>;
  108394. /**
  108395. * Gets the gamepad manager associated with the scene
  108396. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  108397. */
  108398. gamepadManager: GamepadManager;
  108399. }
  108400. /**
  108401. * Interface representing a free camera inputs manager
  108402. */
  108403. interface FreeCameraInputsManager {
  108404. /**
  108405. * Adds gamepad input support to the FreeCameraInputsManager.
  108406. * @returns the FreeCameraInputsManager
  108407. */
  108408. addGamepad(): FreeCameraInputsManager;
  108409. }
  108410. /**
  108411. * Interface representing an arc rotate camera inputs manager
  108412. */
  108413. interface ArcRotateCameraInputsManager {
  108414. /**
  108415. * Adds gamepad input support to the ArcRotateCamera InputManager.
  108416. * @returns the camera inputs manager
  108417. */
  108418. addGamepad(): ArcRotateCameraInputsManager;
  108419. }
  108420. /**
  108421. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  108422. */
  108423. export class GamepadSystemSceneComponent implements ISceneComponent {
  108424. /**
  108425. * The component name helpfull to identify the component in the list of scene components.
  108426. */
  108427. readonly name: string;
  108428. /**
  108429. * The scene the component belongs to.
  108430. */
  108431. scene: Scene;
  108432. /**
  108433. * Creates a new instance of the component for the given scene
  108434. * @param scene Defines the scene to register the component in
  108435. */
  108436. constructor(scene: Scene);
  108437. /**
  108438. * Registers the component in a given scene
  108439. */
  108440. register(): void;
  108441. /**
  108442. * Rebuilds the elements related to this component in case of
  108443. * context lost for instance.
  108444. */
  108445. rebuild(): void;
  108446. /**
  108447. * Disposes the component and the associated ressources
  108448. */
  108449. dispose(): void;
  108450. private _beforeCameraUpdate;
  108451. }
  108452. }
  108453. declare module BABYLON {
  108454. /**
  108455. * 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,
  108456. * which still works and will still be found in many Playgrounds.
  108457. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108458. */
  108459. export class UniversalCamera extends TouchCamera {
  108460. /**
  108461. * Defines the gamepad rotation sensiblity.
  108462. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108463. */
  108464. gamepadAngularSensibility: number;
  108465. /**
  108466. * Defines the gamepad move sensiblity.
  108467. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108468. */
  108469. gamepadMoveSensibility: number;
  108470. /**
  108471. * 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,
  108472. * which still works and will still be found in many Playgrounds.
  108473. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108474. * @param name Define the name of the camera in the scene
  108475. * @param position Define the start position of the camera in the scene
  108476. * @param scene Define the scene the camera belongs to
  108477. */
  108478. constructor(name: string, position: Vector3, scene: Scene);
  108479. /**
  108480. * Gets the current object class name.
  108481. * @return the class name
  108482. */
  108483. getClassName(): string;
  108484. }
  108485. }
  108486. declare module BABYLON {
  108487. /**
  108488. * This represents a FPS type of camera. This is only here for back compat purpose.
  108489. * Please use the UniversalCamera instead as both are identical.
  108490. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108491. */
  108492. export class GamepadCamera extends UniversalCamera {
  108493. /**
  108494. * Instantiates a new Gamepad Camera
  108495. * This represents a FPS type of camera. This is only here for back compat purpose.
  108496. * Please use the UniversalCamera instead as both are identical.
  108497. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108498. * @param name Define the name of the camera in the scene
  108499. * @param position Define the start position of the camera in the scene
  108500. * @param scene Define the scene the camera belongs to
  108501. */
  108502. constructor(name: string, position: Vector3, scene: Scene);
  108503. /**
  108504. * Gets the current object class name.
  108505. * @return the class name
  108506. */
  108507. getClassName(): string;
  108508. }
  108509. }
  108510. declare module BABYLON {
  108511. /** @hidden */
  108512. export var passPixelShader: {
  108513. name: string;
  108514. shader: string;
  108515. };
  108516. }
  108517. declare module BABYLON {
  108518. /** @hidden */
  108519. export var passCubePixelShader: {
  108520. name: string;
  108521. shader: string;
  108522. };
  108523. }
  108524. declare module BABYLON {
  108525. /**
  108526. * PassPostProcess which produces an output the same as it's input
  108527. */
  108528. export class PassPostProcess extends PostProcess {
  108529. /**
  108530. * Creates the PassPostProcess
  108531. * @param name The name of the effect.
  108532. * @param options The required width/height ratio to downsize to before computing the render pass.
  108533. * @param camera The camera to apply the render pass to.
  108534. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108535. * @param engine The engine which the post process will be applied. (default: current engine)
  108536. * @param reusable If the post process can be reused on the same frame. (default: false)
  108537. * @param textureType The type of texture to be used when performing the post processing.
  108538. * @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)
  108539. */
  108540. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108541. }
  108542. /**
  108543. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  108544. */
  108545. export class PassCubePostProcess extends PostProcess {
  108546. private _face;
  108547. /**
  108548. * Gets or sets the cube face to display.
  108549. * * 0 is +X
  108550. * * 1 is -X
  108551. * * 2 is +Y
  108552. * * 3 is -Y
  108553. * * 4 is +Z
  108554. * * 5 is -Z
  108555. */
  108556. face: number;
  108557. /**
  108558. * Creates the PassCubePostProcess
  108559. * @param name The name of the effect.
  108560. * @param options The required width/height ratio to downsize to before computing the render pass.
  108561. * @param camera The camera to apply the render pass to.
  108562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108563. * @param engine The engine which the post process will be applied. (default: current engine)
  108564. * @param reusable If the post process can be reused on the same frame. (default: false)
  108565. * @param textureType The type of texture to be used when performing the post processing.
  108566. * @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)
  108567. */
  108568. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108569. }
  108570. }
  108571. declare module BABYLON {
  108572. /** @hidden */
  108573. export var anaglyphPixelShader: {
  108574. name: string;
  108575. shader: string;
  108576. };
  108577. }
  108578. declare module BABYLON {
  108579. /**
  108580. * Postprocess used to generate anaglyphic rendering
  108581. */
  108582. export class AnaglyphPostProcess extends PostProcess {
  108583. private _passedProcess;
  108584. /**
  108585. * Creates a new AnaglyphPostProcess
  108586. * @param name defines postprocess name
  108587. * @param options defines creation options or target ratio scale
  108588. * @param rigCameras defines cameras using this postprocess
  108589. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  108590. * @param engine defines hosting engine
  108591. * @param reusable defines if the postprocess will be reused multiple times per frame
  108592. */
  108593. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  108594. }
  108595. }
  108596. declare module BABYLON {
  108597. /**
  108598. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  108599. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108600. */
  108601. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  108602. /**
  108603. * Creates a new AnaglyphArcRotateCamera
  108604. * @param name defines camera name
  108605. * @param alpha defines alpha angle (in radians)
  108606. * @param beta defines beta angle (in radians)
  108607. * @param radius defines radius
  108608. * @param target defines camera target
  108609. * @param interaxialDistance defines distance between each color axis
  108610. * @param scene defines the hosting scene
  108611. */
  108612. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  108613. /**
  108614. * Gets camera class name
  108615. * @returns AnaglyphArcRotateCamera
  108616. */
  108617. getClassName(): string;
  108618. }
  108619. }
  108620. declare module BABYLON {
  108621. /**
  108622. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  108623. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108624. */
  108625. export class AnaglyphFreeCamera extends FreeCamera {
  108626. /**
  108627. * Creates a new AnaglyphFreeCamera
  108628. * @param name defines camera name
  108629. * @param position defines initial position
  108630. * @param interaxialDistance defines distance between each color axis
  108631. * @param scene defines the hosting scene
  108632. */
  108633. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108634. /**
  108635. * Gets camera class name
  108636. * @returns AnaglyphFreeCamera
  108637. */
  108638. getClassName(): string;
  108639. }
  108640. }
  108641. declare module BABYLON {
  108642. /**
  108643. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  108644. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108645. */
  108646. export class AnaglyphGamepadCamera extends GamepadCamera {
  108647. /**
  108648. * Creates a new AnaglyphGamepadCamera
  108649. * @param name defines camera name
  108650. * @param position defines initial position
  108651. * @param interaxialDistance defines distance between each color axis
  108652. * @param scene defines the hosting scene
  108653. */
  108654. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108655. /**
  108656. * Gets camera class name
  108657. * @returns AnaglyphGamepadCamera
  108658. */
  108659. getClassName(): string;
  108660. }
  108661. }
  108662. declare module BABYLON {
  108663. /**
  108664. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  108665. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108666. */
  108667. export class AnaglyphUniversalCamera extends UniversalCamera {
  108668. /**
  108669. * Creates a new AnaglyphUniversalCamera
  108670. * @param name defines camera name
  108671. * @param position defines initial position
  108672. * @param interaxialDistance defines distance between each color axis
  108673. * @param scene defines the hosting scene
  108674. */
  108675. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108676. /**
  108677. * Gets camera class name
  108678. * @returns AnaglyphUniversalCamera
  108679. */
  108680. getClassName(): string;
  108681. }
  108682. }
  108683. declare module BABYLON {
  108684. /** @hidden */
  108685. export var stereoscopicInterlacePixelShader: {
  108686. name: string;
  108687. shader: string;
  108688. };
  108689. }
  108690. declare module BABYLON {
  108691. /**
  108692. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  108693. */
  108694. export class StereoscopicInterlacePostProcess extends PostProcess {
  108695. private _stepSize;
  108696. private _passedProcess;
  108697. /**
  108698. * Initializes a StereoscopicInterlacePostProcess
  108699. * @param name The name of the effect.
  108700. * @param rigCameras The rig cameras to be appled to the post process
  108701. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  108702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108703. * @param engine The engine which the post process will be applied. (default: current engine)
  108704. * @param reusable If the post process can be reused on the same frame. (default: false)
  108705. */
  108706. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108707. }
  108708. }
  108709. declare module BABYLON {
  108710. /**
  108711. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  108712. * @see http://doc.babylonjs.com/features/cameras
  108713. */
  108714. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  108715. /**
  108716. * Creates a new StereoscopicArcRotateCamera
  108717. * @param name defines camera name
  108718. * @param alpha defines alpha angle (in radians)
  108719. * @param beta defines beta angle (in radians)
  108720. * @param radius defines radius
  108721. * @param target defines camera target
  108722. * @param interaxialDistance defines distance between each color axis
  108723. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108724. * @param scene defines the hosting scene
  108725. */
  108726. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108727. /**
  108728. * Gets camera class name
  108729. * @returns StereoscopicArcRotateCamera
  108730. */
  108731. getClassName(): string;
  108732. }
  108733. }
  108734. declare module BABYLON {
  108735. /**
  108736. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  108737. * @see http://doc.babylonjs.com/features/cameras
  108738. */
  108739. export class StereoscopicFreeCamera extends FreeCamera {
  108740. /**
  108741. * Creates a new StereoscopicFreeCamera
  108742. * @param name defines camera name
  108743. * @param position defines initial position
  108744. * @param interaxialDistance defines distance between each color axis
  108745. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108746. * @param scene defines the hosting scene
  108747. */
  108748. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108749. /**
  108750. * Gets camera class name
  108751. * @returns StereoscopicFreeCamera
  108752. */
  108753. getClassName(): string;
  108754. }
  108755. }
  108756. declare module BABYLON {
  108757. /**
  108758. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  108759. * @see http://doc.babylonjs.com/features/cameras
  108760. */
  108761. export class StereoscopicGamepadCamera extends GamepadCamera {
  108762. /**
  108763. * Creates a new StereoscopicGamepadCamera
  108764. * @param name defines camera name
  108765. * @param position defines initial position
  108766. * @param interaxialDistance defines distance between each color axis
  108767. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108768. * @param scene defines the hosting scene
  108769. */
  108770. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108771. /**
  108772. * Gets camera class name
  108773. * @returns StereoscopicGamepadCamera
  108774. */
  108775. getClassName(): string;
  108776. }
  108777. }
  108778. declare module BABYLON {
  108779. /**
  108780. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  108781. * @see http://doc.babylonjs.com/features/cameras
  108782. */
  108783. export class StereoscopicUniversalCamera extends UniversalCamera {
  108784. /**
  108785. * Creates a new StereoscopicUniversalCamera
  108786. * @param name defines camera name
  108787. * @param position defines initial position
  108788. * @param interaxialDistance defines distance between each color axis
  108789. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108790. * @param scene defines the hosting scene
  108791. */
  108792. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108793. /**
  108794. * Gets camera class name
  108795. * @returns StereoscopicUniversalCamera
  108796. */
  108797. getClassName(): string;
  108798. }
  108799. }
  108800. declare module BABYLON {
  108801. /**
  108802. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  108803. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108804. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108805. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108806. */
  108807. export class VirtualJoysticksCamera extends FreeCamera {
  108808. /**
  108809. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  108810. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108811. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108812. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108813. * @param name Define the name of the camera in the scene
  108814. * @param position Define the start position of the camera in the scene
  108815. * @param scene Define the scene the camera belongs to
  108816. */
  108817. constructor(name: string, position: Vector3, scene: Scene);
  108818. /**
  108819. * Gets the current object class name.
  108820. * @return the class name
  108821. */
  108822. getClassName(): string;
  108823. }
  108824. }
  108825. declare module BABYLON {
  108826. /**
  108827. * This represents all the required metrics to create a VR camera.
  108828. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  108829. */
  108830. export class VRCameraMetrics {
  108831. /**
  108832. * Define the horizontal resolution off the screen.
  108833. */
  108834. hResolution: number;
  108835. /**
  108836. * Define the vertical resolution off the screen.
  108837. */
  108838. vResolution: number;
  108839. /**
  108840. * Define the horizontal screen size.
  108841. */
  108842. hScreenSize: number;
  108843. /**
  108844. * Define the vertical screen size.
  108845. */
  108846. vScreenSize: number;
  108847. /**
  108848. * Define the vertical screen center position.
  108849. */
  108850. vScreenCenter: number;
  108851. /**
  108852. * Define the distance of the eyes to the screen.
  108853. */
  108854. eyeToScreenDistance: number;
  108855. /**
  108856. * Define the distance between both lenses
  108857. */
  108858. lensSeparationDistance: number;
  108859. /**
  108860. * Define the distance between both viewer's eyes.
  108861. */
  108862. interpupillaryDistance: number;
  108863. /**
  108864. * Define the distortion factor of the VR postprocess.
  108865. * Please, touch with care.
  108866. */
  108867. distortionK: number[];
  108868. /**
  108869. * Define the chromatic aberration correction factors for the VR post process.
  108870. */
  108871. chromaAbCorrection: number[];
  108872. /**
  108873. * Define the scale factor of the post process.
  108874. * The smaller the better but the slower.
  108875. */
  108876. postProcessScaleFactor: number;
  108877. /**
  108878. * Define an offset for the lens center.
  108879. */
  108880. lensCenterOffset: number;
  108881. /**
  108882. * Define if the current vr camera should compensate the distortion of the lense or not.
  108883. */
  108884. compensateDistortion: boolean;
  108885. /**
  108886. * Defines if multiview should be enabled when rendering (Default: false)
  108887. */
  108888. multiviewEnabled: boolean;
  108889. /**
  108890. * Gets the rendering aspect ratio based on the provided resolutions.
  108891. */
  108892. readonly aspectRatio: number;
  108893. /**
  108894. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108895. */
  108896. readonly aspectRatioFov: number;
  108897. /**
  108898. * @hidden
  108899. */
  108900. readonly leftHMatrix: Matrix;
  108901. /**
  108902. * @hidden
  108903. */
  108904. readonly rightHMatrix: Matrix;
  108905. /**
  108906. * @hidden
  108907. */
  108908. readonly leftPreViewMatrix: Matrix;
  108909. /**
  108910. * @hidden
  108911. */
  108912. readonly rightPreViewMatrix: Matrix;
  108913. /**
  108914. * Get the default VRMetrics based on the most generic setup.
  108915. * @returns the default vr metrics
  108916. */
  108917. static GetDefault(): VRCameraMetrics;
  108918. }
  108919. }
  108920. declare module BABYLON {
  108921. /** @hidden */
  108922. export var vrDistortionCorrectionPixelShader: {
  108923. name: string;
  108924. shader: string;
  108925. };
  108926. }
  108927. declare module BABYLON {
  108928. /**
  108929. * VRDistortionCorrectionPostProcess used for mobile VR
  108930. */
  108931. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108932. private _isRightEye;
  108933. private _distortionFactors;
  108934. private _postProcessScaleFactor;
  108935. private _lensCenterOffset;
  108936. private _scaleIn;
  108937. private _scaleFactor;
  108938. private _lensCenter;
  108939. /**
  108940. * Initializes the VRDistortionCorrectionPostProcess
  108941. * @param name The name of the effect.
  108942. * @param camera The camera to apply the render pass to.
  108943. * @param isRightEye If this is for the right eye distortion
  108944. * @param vrMetrics All the required metrics for the VR camera
  108945. */
  108946. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108947. }
  108948. }
  108949. declare module BABYLON {
  108950. /**
  108951. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108952. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108953. */
  108954. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108955. /**
  108956. * Creates a new VRDeviceOrientationArcRotateCamera
  108957. * @param name defines camera name
  108958. * @param alpha defines the camera rotation along the logitudinal axis
  108959. * @param beta defines the camera rotation along the latitudinal axis
  108960. * @param radius defines the camera distance from its target
  108961. * @param target defines the camera target
  108962. * @param scene defines the scene the camera belongs to
  108963. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108964. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108965. */
  108966. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108967. /**
  108968. * Gets camera class name
  108969. * @returns VRDeviceOrientationArcRotateCamera
  108970. */
  108971. getClassName(): string;
  108972. }
  108973. }
  108974. declare module BABYLON {
  108975. /**
  108976. * Camera used to simulate VR rendering (based on FreeCamera)
  108977. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108978. */
  108979. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108980. /**
  108981. * Creates a new VRDeviceOrientationFreeCamera
  108982. * @param name defines camera name
  108983. * @param position defines the start position of the camera
  108984. * @param scene defines the scene the camera belongs to
  108985. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108986. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108987. */
  108988. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108989. /**
  108990. * Gets camera class name
  108991. * @returns VRDeviceOrientationFreeCamera
  108992. */
  108993. getClassName(): string;
  108994. }
  108995. }
  108996. declare module BABYLON {
  108997. /**
  108998. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108999. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  109000. */
  109001. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  109002. /**
  109003. * Creates a new VRDeviceOrientationGamepadCamera
  109004. * @param name defines camera name
  109005. * @param position defines the start position of the camera
  109006. * @param scene defines the scene the camera belongs to
  109007. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  109008. * @param vrCameraMetrics defines the vr metrics associated to the camera
  109009. */
  109010. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  109011. /**
  109012. * Gets camera class name
  109013. * @returns VRDeviceOrientationGamepadCamera
  109014. */
  109015. getClassName(): string;
  109016. }
  109017. }
  109018. declare module BABYLON {
  109019. /**
  109020. * Base class of materials working in push mode in babylon JS
  109021. * @hidden
  109022. */
  109023. export class PushMaterial extends Material {
  109024. protected _activeEffect: Effect;
  109025. protected _normalMatrix: Matrix;
  109026. /**
  109027. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  109028. * This means that the material can keep using a previous shader while a new one is being compiled.
  109029. * This is mostly used when shader parallel compilation is supported (true by default)
  109030. */
  109031. allowShaderHotSwapping: boolean;
  109032. constructor(name: string, scene: Scene);
  109033. getEffect(): Effect;
  109034. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109035. /**
  109036. * Binds the given world matrix to the active effect
  109037. *
  109038. * @param world the matrix to bind
  109039. */
  109040. bindOnlyWorldMatrix(world: Matrix): void;
  109041. /**
  109042. * Binds the given normal matrix to the active effect
  109043. *
  109044. * @param normalMatrix the matrix to bind
  109045. */
  109046. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  109047. bind(world: Matrix, mesh?: Mesh): void;
  109048. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  109049. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  109050. }
  109051. }
  109052. declare module BABYLON {
  109053. /**
  109054. * This groups all the flags used to control the materials channel.
  109055. */
  109056. export class MaterialFlags {
  109057. private static _DiffuseTextureEnabled;
  109058. /**
  109059. * Are diffuse textures enabled in the application.
  109060. */
  109061. static DiffuseTextureEnabled: boolean;
  109062. private static _AmbientTextureEnabled;
  109063. /**
  109064. * Are ambient textures enabled in the application.
  109065. */
  109066. static AmbientTextureEnabled: boolean;
  109067. private static _OpacityTextureEnabled;
  109068. /**
  109069. * Are opacity textures enabled in the application.
  109070. */
  109071. static OpacityTextureEnabled: boolean;
  109072. private static _ReflectionTextureEnabled;
  109073. /**
  109074. * Are reflection textures enabled in the application.
  109075. */
  109076. static ReflectionTextureEnabled: boolean;
  109077. private static _EmissiveTextureEnabled;
  109078. /**
  109079. * Are emissive textures enabled in the application.
  109080. */
  109081. static EmissiveTextureEnabled: boolean;
  109082. private static _SpecularTextureEnabled;
  109083. /**
  109084. * Are specular textures enabled in the application.
  109085. */
  109086. static SpecularTextureEnabled: boolean;
  109087. private static _BumpTextureEnabled;
  109088. /**
  109089. * Are bump textures enabled in the application.
  109090. */
  109091. static BumpTextureEnabled: boolean;
  109092. private static _LightmapTextureEnabled;
  109093. /**
  109094. * Are lightmap textures enabled in the application.
  109095. */
  109096. static LightmapTextureEnabled: boolean;
  109097. private static _RefractionTextureEnabled;
  109098. /**
  109099. * Are refraction textures enabled in the application.
  109100. */
  109101. static RefractionTextureEnabled: boolean;
  109102. private static _ColorGradingTextureEnabled;
  109103. /**
  109104. * Are color grading textures enabled in the application.
  109105. */
  109106. static ColorGradingTextureEnabled: boolean;
  109107. private static _FresnelEnabled;
  109108. /**
  109109. * Are fresnels enabled in the application.
  109110. */
  109111. static FresnelEnabled: boolean;
  109112. private static _ClearCoatTextureEnabled;
  109113. /**
  109114. * Are clear coat textures enabled in the application.
  109115. */
  109116. static ClearCoatTextureEnabled: boolean;
  109117. private static _ClearCoatBumpTextureEnabled;
  109118. /**
  109119. * Are clear coat bump textures enabled in the application.
  109120. */
  109121. static ClearCoatBumpTextureEnabled: boolean;
  109122. private static _ClearCoatTintTextureEnabled;
  109123. /**
  109124. * Are clear coat tint textures enabled in the application.
  109125. */
  109126. static ClearCoatTintTextureEnabled: boolean;
  109127. private static _SheenTextureEnabled;
  109128. /**
  109129. * Are sheen textures enabled in the application.
  109130. */
  109131. static SheenTextureEnabled: boolean;
  109132. private static _AnisotropicTextureEnabled;
  109133. /**
  109134. * Are anisotropic textures enabled in the application.
  109135. */
  109136. static AnisotropicTextureEnabled: boolean;
  109137. private static _ThicknessTextureEnabled;
  109138. /**
  109139. * Are thickness textures enabled in the application.
  109140. */
  109141. static ThicknessTextureEnabled: boolean;
  109142. }
  109143. }
  109144. declare module BABYLON {
  109145. /** @hidden */
  109146. export var defaultFragmentDeclaration: {
  109147. name: string;
  109148. shader: string;
  109149. };
  109150. }
  109151. declare module BABYLON {
  109152. /** @hidden */
  109153. export var defaultUboDeclaration: {
  109154. name: string;
  109155. shader: string;
  109156. };
  109157. }
  109158. declare module BABYLON {
  109159. /** @hidden */
  109160. export var lightFragmentDeclaration: {
  109161. name: string;
  109162. shader: string;
  109163. };
  109164. }
  109165. declare module BABYLON {
  109166. /** @hidden */
  109167. export var lightUboDeclaration: {
  109168. name: string;
  109169. shader: string;
  109170. };
  109171. }
  109172. declare module BABYLON {
  109173. /** @hidden */
  109174. export var lightsFragmentFunctions: {
  109175. name: string;
  109176. shader: string;
  109177. };
  109178. }
  109179. declare module BABYLON {
  109180. /** @hidden */
  109181. export var shadowsFragmentFunctions: {
  109182. name: string;
  109183. shader: string;
  109184. };
  109185. }
  109186. declare module BABYLON {
  109187. /** @hidden */
  109188. export var fresnelFunction: {
  109189. name: string;
  109190. shader: string;
  109191. };
  109192. }
  109193. declare module BABYLON {
  109194. /** @hidden */
  109195. export var reflectionFunction: {
  109196. name: string;
  109197. shader: string;
  109198. };
  109199. }
  109200. declare module BABYLON {
  109201. /** @hidden */
  109202. export var bumpFragmentFunctions: {
  109203. name: string;
  109204. shader: string;
  109205. };
  109206. }
  109207. declare module BABYLON {
  109208. /** @hidden */
  109209. export var logDepthDeclaration: {
  109210. name: string;
  109211. shader: string;
  109212. };
  109213. }
  109214. declare module BABYLON {
  109215. /** @hidden */
  109216. export var bumpFragment: {
  109217. name: string;
  109218. shader: string;
  109219. };
  109220. }
  109221. declare module BABYLON {
  109222. /** @hidden */
  109223. export var depthPrePass: {
  109224. name: string;
  109225. shader: string;
  109226. };
  109227. }
  109228. declare module BABYLON {
  109229. /** @hidden */
  109230. export var lightFragment: {
  109231. name: string;
  109232. shader: string;
  109233. };
  109234. }
  109235. declare module BABYLON {
  109236. /** @hidden */
  109237. export var logDepthFragment: {
  109238. name: string;
  109239. shader: string;
  109240. };
  109241. }
  109242. declare module BABYLON {
  109243. /** @hidden */
  109244. export var defaultPixelShader: {
  109245. name: string;
  109246. shader: string;
  109247. };
  109248. }
  109249. declare module BABYLON {
  109250. /** @hidden */
  109251. export var defaultVertexDeclaration: {
  109252. name: string;
  109253. shader: string;
  109254. };
  109255. }
  109256. declare module BABYLON {
  109257. /** @hidden */
  109258. export var bumpVertexDeclaration: {
  109259. name: string;
  109260. shader: string;
  109261. };
  109262. }
  109263. declare module BABYLON {
  109264. /** @hidden */
  109265. export var bumpVertex: {
  109266. name: string;
  109267. shader: string;
  109268. };
  109269. }
  109270. declare module BABYLON {
  109271. /** @hidden */
  109272. export var fogVertex: {
  109273. name: string;
  109274. shader: string;
  109275. };
  109276. }
  109277. declare module BABYLON {
  109278. /** @hidden */
  109279. export var shadowsVertex: {
  109280. name: string;
  109281. shader: string;
  109282. };
  109283. }
  109284. declare module BABYLON {
  109285. /** @hidden */
  109286. export var pointCloudVertex: {
  109287. name: string;
  109288. shader: string;
  109289. };
  109290. }
  109291. declare module BABYLON {
  109292. /** @hidden */
  109293. export var logDepthVertex: {
  109294. name: string;
  109295. shader: string;
  109296. };
  109297. }
  109298. declare module BABYLON {
  109299. /** @hidden */
  109300. export var defaultVertexShader: {
  109301. name: string;
  109302. shader: string;
  109303. };
  109304. }
  109305. declare module BABYLON {
  109306. /** @hidden */
  109307. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  109308. MAINUV1: boolean;
  109309. MAINUV2: boolean;
  109310. DIFFUSE: boolean;
  109311. DIFFUSEDIRECTUV: number;
  109312. AMBIENT: boolean;
  109313. AMBIENTDIRECTUV: number;
  109314. OPACITY: boolean;
  109315. OPACITYDIRECTUV: number;
  109316. OPACITYRGB: boolean;
  109317. REFLECTION: boolean;
  109318. EMISSIVE: boolean;
  109319. EMISSIVEDIRECTUV: number;
  109320. SPECULAR: boolean;
  109321. SPECULARDIRECTUV: number;
  109322. BUMP: boolean;
  109323. BUMPDIRECTUV: number;
  109324. PARALLAX: boolean;
  109325. PARALLAXOCCLUSION: boolean;
  109326. SPECULAROVERALPHA: boolean;
  109327. CLIPPLANE: boolean;
  109328. CLIPPLANE2: boolean;
  109329. CLIPPLANE3: boolean;
  109330. CLIPPLANE4: boolean;
  109331. ALPHATEST: boolean;
  109332. DEPTHPREPASS: boolean;
  109333. ALPHAFROMDIFFUSE: boolean;
  109334. POINTSIZE: boolean;
  109335. FOG: boolean;
  109336. SPECULARTERM: boolean;
  109337. DIFFUSEFRESNEL: boolean;
  109338. OPACITYFRESNEL: boolean;
  109339. REFLECTIONFRESNEL: boolean;
  109340. REFRACTIONFRESNEL: boolean;
  109341. EMISSIVEFRESNEL: boolean;
  109342. FRESNEL: boolean;
  109343. NORMAL: boolean;
  109344. UV1: boolean;
  109345. UV2: boolean;
  109346. VERTEXCOLOR: boolean;
  109347. VERTEXALPHA: boolean;
  109348. NUM_BONE_INFLUENCERS: number;
  109349. BonesPerMesh: number;
  109350. BONETEXTURE: boolean;
  109351. INSTANCES: boolean;
  109352. GLOSSINESS: boolean;
  109353. ROUGHNESS: boolean;
  109354. EMISSIVEASILLUMINATION: boolean;
  109355. LINKEMISSIVEWITHDIFFUSE: boolean;
  109356. REFLECTIONFRESNELFROMSPECULAR: boolean;
  109357. LIGHTMAP: boolean;
  109358. LIGHTMAPDIRECTUV: number;
  109359. OBJECTSPACE_NORMALMAP: boolean;
  109360. USELIGHTMAPASSHADOWMAP: boolean;
  109361. REFLECTIONMAP_3D: boolean;
  109362. REFLECTIONMAP_SPHERICAL: boolean;
  109363. REFLECTIONMAP_PLANAR: boolean;
  109364. REFLECTIONMAP_CUBIC: boolean;
  109365. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109366. REFLECTIONMAP_PROJECTION: boolean;
  109367. REFLECTIONMAP_SKYBOX: boolean;
  109368. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  109369. REFLECTIONMAP_EXPLICIT: boolean;
  109370. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109371. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109372. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109373. INVERTCUBICMAP: boolean;
  109374. LOGARITHMICDEPTH: boolean;
  109375. REFRACTION: boolean;
  109376. REFRACTIONMAP_3D: boolean;
  109377. REFLECTIONOVERALPHA: boolean;
  109378. TWOSIDEDLIGHTING: boolean;
  109379. SHADOWFLOAT: boolean;
  109380. MORPHTARGETS: boolean;
  109381. MORPHTARGETS_NORMAL: boolean;
  109382. MORPHTARGETS_TANGENT: boolean;
  109383. MORPHTARGETS_UV: boolean;
  109384. NUM_MORPH_INFLUENCERS: number;
  109385. NONUNIFORMSCALING: boolean;
  109386. PREMULTIPLYALPHA: boolean;
  109387. IMAGEPROCESSING: boolean;
  109388. VIGNETTE: boolean;
  109389. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109390. VIGNETTEBLENDMODEOPAQUE: boolean;
  109391. TONEMAPPING: boolean;
  109392. TONEMAPPING_ACES: boolean;
  109393. CONTRAST: boolean;
  109394. COLORCURVES: boolean;
  109395. COLORGRADING: boolean;
  109396. COLORGRADING3D: boolean;
  109397. SAMPLER3DGREENDEPTH: boolean;
  109398. SAMPLER3DBGRMAP: boolean;
  109399. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109400. MULTIVIEW: boolean;
  109401. /**
  109402. * If the reflection texture on this material is in linear color space
  109403. * @hidden
  109404. */
  109405. IS_REFLECTION_LINEAR: boolean;
  109406. /**
  109407. * If the refraction texture on this material is in linear color space
  109408. * @hidden
  109409. */
  109410. IS_REFRACTION_LINEAR: boolean;
  109411. EXPOSURE: boolean;
  109412. constructor();
  109413. setReflectionMode(modeToEnable: string): void;
  109414. }
  109415. /**
  109416. * This is the default material used in Babylon. It is the best trade off between quality
  109417. * and performances.
  109418. * @see http://doc.babylonjs.com/babylon101/materials
  109419. */
  109420. export class StandardMaterial extends PushMaterial {
  109421. private _diffuseTexture;
  109422. /**
  109423. * The basic texture of the material as viewed under a light.
  109424. */
  109425. diffuseTexture: Nullable<BaseTexture>;
  109426. private _ambientTexture;
  109427. /**
  109428. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109429. */
  109430. ambientTexture: Nullable<BaseTexture>;
  109431. private _opacityTexture;
  109432. /**
  109433. * Define the transparency of the material from a texture.
  109434. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109435. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109436. */
  109437. opacityTexture: Nullable<BaseTexture>;
  109438. private _reflectionTexture;
  109439. /**
  109440. * Define the texture used to display the reflection.
  109441. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109442. */
  109443. reflectionTexture: Nullable<BaseTexture>;
  109444. private _emissiveTexture;
  109445. /**
  109446. * Define texture of the material as if self lit.
  109447. * This will be mixed in the final result even in the absence of light.
  109448. */
  109449. emissiveTexture: Nullable<BaseTexture>;
  109450. private _specularTexture;
  109451. /**
  109452. * Define how the color and intensity of the highlight given by the light in the material.
  109453. */
  109454. specularTexture: Nullable<BaseTexture>;
  109455. private _bumpTexture;
  109456. /**
  109457. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109458. * 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.
  109459. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  109460. */
  109461. bumpTexture: Nullable<BaseTexture>;
  109462. private _lightmapTexture;
  109463. /**
  109464. * Complex lighting can be computationally expensive to compute at runtime.
  109465. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109466. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  109467. */
  109468. lightmapTexture: Nullable<BaseTexture>;
  109469. private _refractionTexture;
  109470. /**
  109471. * Define the texture used to display the refraction.
  109472. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109473. */
  109474. refractionTexture: Nullable<BaseTexture>;
  109475. /**
  109476. * The color of the material lit by the environmental background lighting.
  109477. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109478. */
  109479. ambientColor: Color3;
  109480. /**
  109481. * The basic color of the material as viewed under a light.
  109482. */
  109483. diffuseColor: Color3;
  109484. /**
  109485. * Define how the color and intensity of the highlight given by the light in the material.
  109486. */
  109487. specularColor: Color3;
  109488. /**
  109489. * Define the color of the material as if self lit.
  109490. * This will be mixed in the final result even in the absence of light.
  109491. */
  109492. emissiveColor: Color3;
  109493. /**
  109494. * Defines how sharp are the highlights in the material.
  109495. * The bigger the value the sharper giving a more glossy feeling to the result.
  109496. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109497. */
  109498. specularPower: number;
  109499. private _useAlphaFromDiffuseTexture;
  109500. /**
  109501. * Does the transparency come from the diffuse texture alpha channel.
  109502. */
  109503. useAlphaFromDiffuseTexture: boolean;
  109504. private _useEmissiveAsIllumination;
  109505. /**
  109506. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109507. */
  109508. useEmissiveAsIllumination: boolean;
  109509. private _linkEmissiveWithDiffuse;
  109510. /**
  109511. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109512. * the emissive level when the final color is close to one.
  109513. */
  109514. linkEmissiveWithDiffuse: boolean;
  109515. private _useSpecularOverAlpha;
  109516. /**
  109517. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109518. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109519. */
  109520. useSpecularOverAlpha: boolean;
  109521. private _useReflectionOverAlpha;
  109522. /**
  109523. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109524. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109525. */
  109526. useReflectionOverAlpha: boolean;
  109527. private _disableLighting;
  109528. /**
  109529. * Does lights from the scene impacts this material.
  109530. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109531. */
  109532. disableLighting: boolean;
  109533. private _useObjectSpaceNormalMap;
  109534. /**
  109535. * Allows using an object space normal map (instead of tangent space).
  109536. */
  109537. useObjectSpaceNormalMap: boolean;
  109538. private _useParallax;
  109539. /**
  109540. * Is parallax enabled or not.
  109541. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  109542. */
  109543. useParallax: boolean;
  109544. private _useParallaxOcclusion;
  109545. /**
  109546. * Is parallax occlusion enabled or not.
  109547. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109548. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  109549. */
  109550. useParallaxOcclusion: boolean;
  109551. /**
  109552. * 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.
  109553. */
  109554. parallaxScaleBias: number;
  109555. private _roughness;
  109556. /**
  109557. * Helps to define how blurry the reflections should appears in the material.
  109558. */
  109559. roughness: number;
  109560. /**
  109561. * In case of refraction, define the value of the index of refraction.
  109562. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109563. */
  109564. indexOfRefraction: number;
  109565. /**
  109566. * Invert the refraction texture alongside the y axis.
  109567. * It can be useful with procedural textures or probe for instance.
  109568. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109569. */
  109570. invertRefractionY: boolean;
  109571. /**
  109572. * Defines the alpha limits in alpha test mode.
  109573. */
  109574. alphaCutOff: number;
  109575. private _useLightmapAsShadowmap;
  109576. /**
  109577. * In case of light mapping, define whether the map contains light or shadow informations.
  109578. */
  109579. useLightmapAsShadowmap: boolean;
  109580. private _diffuseFresnelParameters;
  109581. /**
  109582. * Define the diffuse fresnel parameters of the material.
  109583. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109584. */
  109585. diffuseFresnelParameters: FresnelParameters;
  109586. private _opacityFresnelParameters;
  109587. /**
  109588. * Define the opacity fresnel parameters of the material.
  109589. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109590. */
  109591. opacityFresnelParameters: FresnelParameters;
  109592. private _reflectionFresnelParameters;
  109593. /**
  109594. * Define the reflection fresnel parameters of the material.
  109595. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109596. */
  109597. reflectionFresnelParameters: FresnelParameters;
  109598. private _refractionFresnelParameters;
  109599. /**
  109600. * Define the refraction fresnel parameters of the material.
  109601. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109602. */
  109603. refractionFresnelParameters: FresnelParameters;
  109604. private _emissiveFresnelParameters;
  109605. /**
  109606. * Define the emissive fresnel parameters of the material.
  109607. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109608. */
  109609. emissiveFresnelParameters: FresnelParameters;
  109610. private _useReflectionFresnelFromSpecular;
  109611. /**
  109612. * If true automatically deducts the fresnels values from the material specularity.
  109613. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109614. */
  109615. useReflectionFresnelFromSpecular: boolean;
  109616. private _useGlossinessFromSpecularMapAlpha;
  109617. /**
  109618. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109619. */
  109620. useGlossinessFromSpecularMapAlpha: boolean;
  109621. private _maxSimultaneousLights;
  109622. /**
  109623. * Defines the maximum number of lights that can be used in the material
  109624. */
  109625. maxSimultaneousLights: number;
  109626. private _invertNormalMapX;
  109627. /**
  109628. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109629. */
  109630. invertNormalMapX: boolean;
  109631. private _invertNormalMapY;
  109632. /**
  109633. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109634. */
  109635. invertNormalMapY: boolean;
  109636. private _twoSidedLighting;
  109637. /**
  109638. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109639. */
  109640. twoSidedLighting: boolean;
  109641. /**
  109642. * Default configuration related to image processing available in the standard Material.
  109643. */
  109644. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109645. /**
  109646. * Gets the image processing configuration used either in this material.
  109647. */
  109648. /**
  109649. * Sets the Default image processing configuration used either in the this material.
  109650. *
  109651. * If sets to null, the scene one is in use.
  109652. */
  109653. imageProcessingConfiguration: ImageProcessingConfiguration;
  109654. /**
  109655. * Keep track of the image processing observer to allow dispose and replace.
  109656. */
  109657. private _imageProcessingObserver;
  109658. /**
  109659. * Attaches a new image processing configuration to the Standard Material.
  109660. * @param configuration
  109661. */
  109662. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109663. /**
  109664. * Gets wether the color curves effect is enabled.
  109665. */
  109666. /**
  109667. * Sets wether the color curves effect is enabled.
  109668. */
  109669. cameraColorCurvesEnabled: boolean;
  109670. /**
  109671. * Gets wether the color grading effect is enabled.
  109672. */
  109673. /**
  109674. * Gets wether the color grading effect is enabled.
  109675. */
  109676. cameraColorGradingEnabled: boolean;
  109677. /**
  109678. * Gets wether tonemapping is enabled or not.
  109679. */
  109680. /**
  109681. * Sets wether tonemapping is enabled or not
  109682. */
  109683. cameraToneMappingEnabled: boolean;
  109684. /**
  109685. * The camera exposure used on this material.
  109686. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109687. * This corresponds to a photographic exposure.
  109688. */
  109689. /**
  109690. * The camera exposure used on this material.
  109691. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109692. * This corresponds to a photographic exposure.
  109693. */
  109694. cameraExposure: number;
  109695. /**
  109696. * Gets The camera contrast used on this material.
  109697. */
  109698. /**
  109699. * Sets The camera contrast used on this material.
  109700. */
  109701. cameraContrast: number;
  109702. /**
  109703. * Gets the Color Grading 2D Lookup Texture.
  109704. */
  109705. /**
  109706. * Sets the Color Grading 2D Lookup Texture.
  109707. */
  109708. cameraColorGradingTexture: Nullable<BaseTexture>;
  109709. /**
  109710. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109711. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109712. * 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;
  109713. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109714. */
  109715. /**
  109716. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109717. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109718. * 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;
  109719. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109720. */
  109721. cameraColorCurves: Nullable<ColorCurves>;
  109722. /**
  109723. * Custom callback helping to override the default shader used in the material.
  109724. */
  109725. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  109726. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109727. protected _worldViewProjectionMatrix: Matrix;
  109728. protected _globalAmbientColor: Color3;
  109729. protected _useLogarithmicDepth: boolean;
  109730. protected _rebuildInParallel: boolean;
  109731. /**
  109732. * Instantiates a new standard material.
  109733. * This is the default material used in Babylon. It is the best trade off between quality
  109734. * and performances.
  109735. * @see http://doc.babylonjs.com/babylon101/materials
  109736. * @param name Define the name of the material in the scene
  109737. * @param scene Define the scene the material belong to
  109738. */
  109739. constructor(name: string, scene: Scene);
  109740. /**
  109741. * Gets a boolean indicating that current material needs to register RTT
  109742. */
  109743. readonly hasRenderTargetTextures: boolean;
  109744. /**
  109745. * Gets the current class name of the material e.g. "StandardMaterial"
  109746. * Mainly use in serialization.
  109747. * @returns the class name
  109748. */
  109749. getClassName(): string;
  109750. /**
  109751. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109752. * You can try switching to logarithmic depth.
  109753. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109754. */
  109755. useLogarithmicDepth: boolean;
  109756. /**
  109757. * Specifies if the material will require alpha blending
  109758. * @returns a boolean specifying if alpha blending is needed
  109759. */
  109760. needAlphaBlending(): boolean;
  109761. /**
  109762. * Specifies if this material should be rendered in alpha test mode
  109763. * @returns a boolean specifying if an alpha test is needed.
  109764. */
  109765. needAlphaTesting(): boolean;
  109766. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109767. /**
  109768. * Get the texture used for alpha test purpose.
  109769. * @returns the diffuse texture in case of the standard material.
  109770. */
  109771. getAlphaTestTexture(): Nullable<BaseTexture>;
  109772. /**
  109773. * Get if the submesh is ready to be used and all its information available.
  109774. * Child classes can use it to update shaders
  109775. * @param mesh defines the mesh to check
  109776. * @param subMesh defines which submesh to check
  109777. * @param useInstances specifies that instances should be used
  109778. * @returns a boolean indicating that the submesh is ready or not
  109779. */
  109780. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109781. /**
  109782. * Builds the material UBO layouts.
  109783. * Used internally during the effect preparation.
  109784. */
  109785. buildUniformLayout(): void;
  109786. /**
  109787. * Unbinds the material from the mesh
  109788. */
  109789. unbind(): void;
  109790. /**
  109791. * Binds the submesh to this material by preparing the effect and shader to draw
  109792. * @param world defines the world transformation matrix
  109793. * @param mesh defines the mesh containing the submesh
  109794. * @param subMesh defines the submesh to bind the material to
  109795. */
  109796. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109797. /**
  109798. * Get the list of animatables in the material.
  109799. * @returns the list of animatables object used in the material
  109800. */
  109801. getAnimatables(): IAnimatable[];
  109802. /**
  109803. * Gets the active textures from the material
  109804. * @returns an array of textures
  109805. */
  109806. getActiveTextures(): BaseTexture[];
  109807. /**
  109808. * Specifies if the material uses a texture
  109809. * @param texture defines the texture to check against the material
  109810. * @returns a boolean specifying if the material uses the texture
  109811. */
  109812. hasTexture(texture: BaseTexture): boolean;
  109813. /**
  109814. * Disposes the material
  109815. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109816. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109817. */
  109818. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109819. /**
  109820. * Makes a duplicate of the material, and gives it a new name
  109821. * @param name defines the new name for the duplicated material
  109822. * @returns the cloned material
  109823. */
  109824. clone(name: string): StandardMaterial;
  109825. /**
  109826. * Serializes this material in a JSON representation
  109827. * @returns the serialized material object
  109828. */
  109829. serialize(): any;
  109830. /**
  109831. * Creates a standard material from parsed material data
  109832. * @param source defines the JSON representation of the material
  109833. * @param scene defines the hosting scene
  109834. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109835. * @returns a new standard material
  109836. */
  109837. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109838. /**
  109839. * Are diffuse textures enabled in the application.
  109840. */
  109841. static DiffuseTextureEnabled: boolean;
  109842. /**
  109843. * Are ambient textures enabled in the application.
  109844. */
  109845. static AmbientTextureEnabled: boolean;
  109846. /**
  109847. * Are opacity textures enabled in the application.
  109848. */
  109849. static OpacityTextureEnabled: boolean;
  109850. /**
  109851. * Are reflection textures enabled in the application.
  109852. */
  109853. static ReflectionTextureEnabled: boolean;
  109854. /**
  109855. * Are emissive textures enabled in the application.
  109856. */
  109857. static EmissiveTextureEnabled: boolean;
  109858. /**
  109859. * Are specular textures enabled in the application.
  109860. */
  109861. static SpecularTextureEnabled: boolean;
  109862. /**
  109863. * Are bump textures enabled in the application.
  109864. */
  109865. static BumpTextureEnabled: boolean;
  109866. /**
  109867. * Are lightmap textures enabled in the application.
  109868. */
  109869. static LightmapTextureEnabled: boolean;
  109870. /**
  109871. * Are refraction textures enabled in the application.
  109872. */
  109873. static RefractionTextureEnabled: boolean;
  109874. /**
  109875. * Are color grading textures enabled in the application.
  109876. */
  109877. static ColorGradingTextureEnabled: boolean;
  109878. /**
  109879. * Are fresnels enabled in the application.
  109880. */
  109881. static FresnelEnabled: boolean;
  109882. }
  109883. }
  109884. declare module BABYLON {
  109885. /** @hidden */
  109886. export var imageProcessingPixelShader: {
  109887. name: string;
  109888. shader: string;
  109889. };
  109890. }
  109891. declare module BABYLON {
  109892. /**
  109893. * ImageProcessingPostProcess
  109894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109895. */
  109896. export class ImageProcessingPostProcess extends PostProcess {
  109897. /**
  109898. * Default configuration related to image processing available in the PBR Material.
  109899. */
  109900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109901. /**
  109902. * Gets the image processing configuration used either in this material.
  109903. */
  109904. /**
  109905. * Sets the Default image processing configuration used either in the this material.
  109906. *
  109907. * If sets to null, the scene one is in use.
  109908. */
  109909. imageProcessingConfiguration: ImageProcessingConfiguration;
  109910. /**
  109911. * Keep track of the image processing observer to allow dispose and replace.
  109912. */
  109913. private _imageProcessingObserver;
  109914. /**
  109915. * Attaches a new image processing configuration to the PBR Material.
  109916. * @param configuration
  109917. */
  109918. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109919. /**
  109920. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109921. */
  109922. /**
  109923. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109924. */
  109925. colorCurves: Nullable<ColorCurves>;
  109926. /**
  109927. * Gets wether the color curves effect is enabled.
  109928. */
  109929. /**
  109930. * Sets wether the color curves effect is enabled.
  109931. */
  109932. colorCurvesEnabled: boolean;
  109933. /**
  109934. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109935. */
  109936. /**
  109937. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109938. */
  109939. colorGradingTexture: Nullable<BaseTexture>;
  109940. /**
  109941. * Gets wether the color grading effect is enabled.
  109942. */
  109943. /**
  109944. * Gets wether the color grading effect is enabled.
  109945. */
  109946. colorGradingEnabled: boolean;
  109947. /**
  109948. * Gets exposure used in the effect.
  109949. */
  109950. /**
  109951. * Sets exposure used in the effect.
  109952. */
  109953. exposure: number;
  109954. /**
  109955. * Gets wether tonemapping is enabled or not.
  109956. */
  109957. /**
  109958. * Sets wether tonemapping is enabled or not
  109959. */
  109960. toneMappingEnabled: boolean;
  109961. /**
  109962. * Gets the type of tone mapping effect.
  109963. */
  109964. /**
  109965. * Sets the type of tone mapping effect.
  109966. */
  109967. toneMappingType: number;
  109968. /**
  109969. * Gets contrast used in the effect.
  109970. */
  109971. /**
  109972. * Sets contrast used in the effect.
  109973. */
  109974. contrast: number;
  109975. /**
  109976. * Gets Vignette stretch size.
  109977. */
  109978. /**
  109979. * Sets Vignette stretch size.
  109980. */
  109981. vignetteStretch: number;
  109982. /**
  109983. * Gets Vignette centre X Offset.
  109984. */
  109985. /**
  109986. * Sets Vignette centre X Offset.
  109987. */
  109988. vignetteCentreX: number;
  109989. /**
  109990. * Gets Vignette centre Y Offset.
  109991. */
  109992. /**
  109993. * Sets Vignette centre Y Offset.
  109994. */
  109995. vignetteCentreY: number;
  109996. /**
  109997. * Gets Vignette weight or intensity of the vignette effect.
  109998. */
  109999. /**
  110000. * Sets Vignette weight or intensity of the vignette effect.
  110001. */
  110002. vignetteWeight: number;
  110003. /**
  110004. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110005. * if vignetteEnabled is set to true.
  110006. */
  110007. /**
  110008. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110009. * if vignetteEnabled is set to true.
  110010. */
  110011. vignetteColor: Color4;
  110012. /**
  110013. * Gets Camera field of view used by the Vignette effect.
  110014. */
  110015. /**
  110016. * Sets Camera field of view used by the Vignette effect.
  110017. */
  110018. vignetteCameraFov: number;
  110019. /**
  110020. * Gets the vignette blend mode allowing different kind of effect.
  110021. */
  110022. /**
  110023. * Sets the vignette blend mode allowing different kind of effect.
  110024. */
  110025. vignetteBlendMode: number;
  110026. /**
  110027. * Gets wether the vignette effect is enabled.
  110028. */
  110029. /**
  110030. * Sets wether the vignette effect is enabled.
  110031. */
  110032. vignetteEnabled: boolean;
  110033. private _fromLinearSpace;
  110034. /**
  110035. * Gets wether the input of the processing is in Gamma or Linear Space.
  110036. */
  110037. /**
  110038. * Sets wether the input of the processing is in Gamma or Linear Space.
  110039. */
  110040. fromLinearSpace: boolean;
  110041. /**
  110042. * Defines cache preventing GC.
  110043. */
  110044. private _defines;
  110045. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  110046. /**
  110047. * "ImageProcessingPostProcess"
  110048. * @returns "ImageProcessingPostProcess"
  110049. */
  110050. getClassName(): string;
  110051. protected _updateParameters(): void;
  110052. dispose(camera?: Camera): void;
  110053. }
  110054. }
  110055. declare module BABYLON {
  110056. /**
  110057. * Class containing static functions to help procedurally build meshes
  110058. */
  110059. export class GroundBuilder {
  110060. /**
  110061. * Creates a ground mesh
  110062. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110063. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110065. * @param name defines the name of the mesh
  110066. * @param options defines the options used to create the mesh
  110067. * @param scene defines the hosting scene
  110068. * @returns the ground mesh
  110069. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110070. */
  110071. static CreateGround(name: string, options: {
  110072. width?: number;
  110073. height?: number;
  110074. subdivisions?: number;
  110075. subdivisionsX?: number;
  110076. subdivisionsY?: number;
  110077. updatable?: boolean;
  110078. }, scene: any): Mesh;
  110079. /**
  110080. * Creates a tiled ground mesh
  110081. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110082. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110083. * * 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
  110084. * * 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
  110085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110086. * @param name defines the name of the mesh
  110087. * @param options defines the options used to create the mesh
  110088. * @param scene defines the hosting scene
  110089. * @returns the tiled ground mesh
  110090. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110091. */
  110092. static CreateTiledGround(name: string, options: {
  110093. xmin: number;
  110094. zmin: number;
  110095. xmax: number;
  110096. zmax: number;
  110097. subdivisions?: {
  110098. w: number;
  110099. h: number;
  110100. };
  110101. precision?: {
  110102. w: number;
  110103. h: number;
  110104. };
  110105. updatable?: boolean;
  110106. }, scene?: Nullable<Scene>): Mesh;
  110107. /**
  110108. * Creates a ground mesh from a height map
  110109. * * The parameter `url` sets the URL of the height map image resource.
  110110. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110111. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110112. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110113. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110114. * * 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.
  110115. * * 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).
  110116. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110118. * @param name defines the name of the mesh
  110119. * @param url defines the url to the height map
  110120. * @param options defines the options used to create the mesh
  110121. * @param scene defines the hosting scene
  110122. * @returns the ground mesh
  110123. * @see https://doc.babylonjs.com/babylon101/height_map
  110124. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110125. */
  110126. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110127. width?: number;
  110128. height?: number;
  110129. subdivisions?: number;
  110130. minHeight?: number;
  110131. maxHeight?: number;
  110132. colorFilter?: Color3;
  110133. alphaFilter?: number;
  110134. updatable?: boolean;
  110135. onReady?: (mesh: GroundMesh) => void;
  110136. }, scene?: Nullable<Scene>): GroundMesh;
  110137. }
  110138. }
  110139. declare module BABYLON {
  110140. /**
  110141. * Class containing static functions to help procedurally build meshes
  110142. */
  110143. export class TorusBuilder {
  110144. /**
  110145. * Creates a torus mesh
  110146. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110147. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110148. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110152. * @param name defines the name of the mesh
  110153. * @param options defines the options used to create the mesh
  110154. * @param scene defines the hosting scene
  110155. * @returns the torus mesh
  110156. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110157. */
  110158. static CreateTorus(name: string, options: {
  110159. diameter?: number;
  110160. thickness?: number;
  110161. tessellation?: number;
  110162. updatable?: boolean;
  110163. sideOrientation?: number;
  110164. frontUVs?: Vector4;
  110165. backUVs?: Vector4;
  110166. }, scene: any): Mesh;
  110167. }
  110168. }
  110169. declare module BABYLON {
  110170. /**
  110171. * Class containing static functions to help procedurally build meshes
  110172. */
  110173. export class CylinderBuilder {
  110174. /**
  110175. * Creates a cylinder or a cone mesh
  110176. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110177. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110178. * * 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.
  110179. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110180. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110181. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110182. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110183. * * 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).
  110184. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110185. * * 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).
  110186. * * 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
  110187. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110188. * * 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
  110189. * * 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.
  110190. * * If `enclose` is false, a ring surface is one element.
  110191. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110192. * * 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
  110193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110196. * @param name defines the name of the mesh
  110197. * @param options defines the options used to create the mesh
  110198. * @param scene defines the hosting scene
  110199. * @returns the cylinder mesh
  110200. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110201. */
  110202. static CreateCylinder(name: string, options: {
  110203. height?: number;
  110204. diameterTop?: number;
  110205. diameterBottom?: number;
  110206. diameter?: number;
  110207. tessellation?: number;
  110208. subdivisions?: number;
  110209. arc?: number;
  110210. faceColors?: Color4[];
  110211. faceUV?: Vector4[];
  110212. updatable?: boolean;
  110213. hasRings?: boolean;
  110214. enclose?: boolean;
  110215. cap?: number;
  110216. sideOrientation?: number;
  110217. frontUVs?: Vector4;
  110218. backUVs?: Vector4;
  110219. }, scene: any): Mesh;
  110220. }
  110221. }
  110222. declare module BABYLON {
  110223. /**
  110224. * States of the webXR experience
  110225. */
  110226. export enum WebXRState {
  110227. /**
  110228. * Transitioning to being in XR mode
  110229. */
  110230. ENTERING_XR = 0,
  110231. /**
  110232. * Transitioning to non XR mode
  110233. */
  110234. EXITING_XR = 1,
  110235. /**
  110236. * In XR mode and presenting
  110237. */
  110238. IN_XR = 2,
  110239. /**
  110240. * Not entered XR mode
  110241. */
  110242. NOT_IN_XR = 3
  110243. }
  110244. /**
  110245. * Abstraction of the XR render target
  110246. */
  110247. export interface WebXRRenderTarget extends IDisposable {
  110248. /**
  110249. * xrpresent context of the canvas which can be used to display/mirror xr content
  110250. */
  110251. canvasContext: WebGLRenderingContext;
  110252. /**
  110253. * xr layer for the canvas
  110254. */
  110255. xrLayer: Nullable<XRWebGLLayer>;
  110256. /**
  110257. * Initializes the xr layer for the session
  110258. * @param xrSession xr session
  110259. * @returns a promise that will resolve once the XR Layer has been created
  110260. */
  110261. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110262. }
  110263. }
  110264. declare module BABYLON {
  110265. /**
  110266. * COnfiguration object for WebXR output canvas
  110267. */
  110268. export class WebXRManagedOutputCanvasOptions {
  110269. /**
  110270. * Options for this XR Layer output
  110271. */
  110272. canvasOptions: XRWebGLLayerOptions;
  110273. /**
  110274. * CSS styling for a newly created canvas (if not provided)
  110275. */
  110276. newCanvasCssStyle?: string;
  110277. /**
  110278. * Get the default values of the configuration object
  110279. * @returns default values of this configuration object
  110280. */
  110281. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  110282. }
  110283. /**
  110284. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110285. */
  110286. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110287. private configuration;
  110288. private _engine;
  110289. private _canvas;
  110290. /**
  110291. * xrpresent context of the canvas which can be used to display/mirror xr content
  110292. */
  110293. canvasContext: WebGLRenderingContext;
  110294. /**
  110295. * xr layer for the canvas
  110296. */
  110297. xrLayer: Nullable<XRWebGLLayer>;
  110298. /**
  110299. * Initializes the xr layer for the session
  110300. * @param xrSession xr session
  110301. * @returns a promise that will resolve once the XR Layer has been created
  110302. */
  110303. initializeXRLayerAsync(xrSession: any): any;
  110304. /**
  110305. * Initializes the canvas to be added/removed upon entering/exiting xr
  110306. * @param engine the Babylon engine
  110307. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110308. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110309. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  110310. */
  110311. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  110312. /**
  110313. * Disposes of the object
  110314. */
  110315. dispose(): void;
  110316. private _setManagedOutputCanvas;
  110317. private _addCanvas;
  110318. private _removeCanvas;
  110319. }
  110320. }
  110321. declare module BABYLON {
  110322. /**
  110323. * Manages an XRSession to work with Babylon's engine
  110324. * @see https://doc.babylonjs.com/how_to/webxr
  110325. */
  110326. export class WebXRSessionManager implements IDisposable {
  110327. private scene;
  110328. /**
  110329. * Fires every time a new xrFrame arrives which can be used to update the camera
  110330. */
  110331. onXRFrameObservable: Observable<any>;
  110332. /**
  110333. * Fires when the xr session is ended either by the device or manually done
  110334. */
  110335. onXRSessionEnded: Observable<any>;
  110336. /**
  110337. * Underlying xr session
  110338. */
  110339. session: XRSession;
  110340. /**
  110341. * Type of reference space used when creating the session
  110342. */
  110343. referenceSpace: XRReferenceSpace;
  110344. /**
  110345. * Current XR frame
  110346. */
  110347. currentFrame: Nullable<XRFrame>;
  110348. private _xrNavigator;
  110349. private baseLayer;
  110350. private _rttProvider;
  110351. private _sessionEnded;
  110352. /**
  110353. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110354. * @param scene The scene which the session should be created for
  110355. */
  110356. constructor(scene: Scene);
  110357. /**
  110358. * Initializes the manager
  110359. * After initialization enterXR can be called to start an XR session
  110360. * @returns Promise which resolves after it is initialized
  110361. */
  110362. initializeAsync(): Promise<void>;
  110363. /**
  110364. * Initializes an xr session
  110365. * @param xrSessionMode mode to initialize
  110366. * @param optionalFeatures defines optional values to pass to the session builder
  110367. * @returns a promise which will resolve once the session has been initialized
  110368. */
  110369. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  110370. /**
  110371. * Sets the reference space on the xr session
  110372. * @param referenceSpace space to set
  110373. * @returns a promise that will resolve once the reference space has been set
  110374. */
  110375. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110376. /**
  110377. * Updates the render state of the session
  110378. * @param state state to set
  110379. * @returns a promise that resolves once the render state has been updated
  110380. */
  110381. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110382. /**
  110383. * Starts rendering to the xr layer
  110384. * @returns a promise that will resolve once rendering has started
  110385. */
  110386. startRenderingToXRAsync(): Promise<void>;
  110387. /**
  110388. * Gets the correct render target texture to be rendered this frame for this eye
  110389. * @param eye the eye for which to get the render target
  110390. * @returns the render target for the specified eye
  110391. */
  110392. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110393. /**
  110394. * Stops the xrSession and restores the renderloop
  110395. * @returns Promise which resolves after it exits XR
  110396. */
  110397. exitXRAsync(): Promise<void>;
  110398. /**
  110399. * Checks if a session would be supported for the creation options specified
  110400. * @param sessionMode session mode to check if supported eg. immersive-vr
  110401. * @returns true if supported
  110402. */
  110403. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110404. /**
  110405. * Creates a WebXRRenderTarget object for the XR session
  110406. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110407. * @param options optional options to provide when creating a new render target
  110408. * @returns a WebXR render target to which the session can render
  110409. */
  110410. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  110411. /**
  110412. * @hidden
  110413. * Converts the render layer of xrSession to a render target
  110414. * @param session session to create render target for
  110415. * @param scene scene the new render target should be created for
  110416. */
  110417. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110418. /**
  110419. * Disposes of the session manager
  110420. */
  110421. dispose(): void;
  110422. /**
  110423. * Gets a promise returning true when fullfiled if the given session mode is supported
  110424. * @param sessionMode defines the session to test
  110425. * @returns a promise
  110426. */
  110427. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110428. }
  110429. }
  110430. declare module BABYLON {
  110431. /**
  110432. * WebXR Camera which holds the views for the xrSession
  110433. * @see https://doc.babylonjs.com/how_to/webxr
  110434. */
  110435. export class WebXRCamera extends FreeCamera {
  110436. /**
  110437. * Is the camera in debug mode. Used when using an emulator
  110438. */
  110439. debugMode: boolean;
  110440. /**
  110441. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110442. * @param name the name of the camera
  110443. * @param scene the scene to add the camera to
  110444. */
  110445. constructor(name: string, scene: Scene);
  110446. private _updateNumberOfRigCameras;
  110447. /** @hidden */
  110448. _updateForDualEyeDebugging(): void;
  110449. /**
  110450. * Updates the cameras position from the current pose information of the XR session
  110451. * @param xrSessionManager the session containing pose information
  110452. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110453. */
  110454. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110455. }
  110456. }
  110457. declare module BABYLON {
  110458. /**
  110459. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110460. * @see https://doc.babylonjs.com/how_to/webxr
  110461. */
  110462. export class WebXRExperienceHelper implements IDisposable {
  110463. private scene;
  110464. /**
  110465. * 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
  110466. */
  110467. container: AbstractMesh;
  110468. /**
  110469. * Camera used to render xr content
  110470. */
  110471. camera: WebXRCamera;
  110472. /**
  110473. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110474. */
  110475. state: WebXRState;
  110476. private _setState;
  110477. private static _TmpVector;
  110478. /**
  110479. * Fires when the state of the experience helper has changed
  110480. */
  110481. onStateChangedObservable: Observable<WebXRState>;
  110482. /** Session manager used to keep track of xr session */
  110483. sessionManager: WebXRSessionManager;
  110484. private _nonVRCamera;
  110485. private _originalSceneAutoClear;
  110486. private _supported;
  110487. /**
  110488. * Creates the experience helper
  110489. * @param scene the scene to attach the experience helper to
  110490. * @returns a promise for the experience helper
  110491. */
  110492. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110493. /**
  110494. * Creates a WebXRExperienceHelper
  110495. * @param scene The scene the helper should be created in
  110496. */
  110497. private constructor();
  110498. /**
  110499. * Exits XR mode and returns the scene to its original state
  110500. * @returns promise that resolves after xr mode has exited
  110501. */
  110502. exitXRAsync(): Promise<void>;
  110503. /**
  110504. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110505. * @param sessionMode options for the XR session
  110506. * @param referenceSpaceType frame of reference of the XR session
  110507. * @param renderTarget the output canvas that will be used to enter XR mode
  110508. * @returns promise that resolves after xr mode has entered
  110509. */
  110510. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  110511. /**
  110512. * Updates the global position of the camera by moving the camera's container
  110513. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110514. * @param position The desired global position of the camera
  110515. */
  110516. setPositionOfCameraUsingContainer(position: Vector3): void;
  110517. /**
  110518. * Rotates the xr camera by rotating the camera's container around the camera's position
  110519. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110520. * @param rotation the desired quaternion rotation to apply to the camera
  110521. */
  110522. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110523. /**
  110524. * Disposes of the experience helper
  110525. */
  110526. dispose(): void;
  110527. }
  110528. }
  110529. declare module BABYLON {
  110530. /**
  110531. * Represents an XR input
  110532. */
  110533. export class WebXRController {
  110534. private scene;
  110535. /** The underlying input source for the controller */
  110536. inputSource: XRInputSource;
  110537. private parentContainer;
  110538. /**
  110539. * 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
  110540. */
  110541. grip?: AbstractMesh;
  110542. /**
  110543. * Pointer which can be used to select objects or attach a visible laser to
  110544. */
  110545. pointer: AbstractMesh;
  110546. private _gamepadMode;
  110547. /**
  110548. * If available, this is the gamepad object related to this controller.
  110549. * Using this object it is possible to get click events and trackpad changes of the
  110550. * webxr controller that is currently being used.
  110551. */
  110552. gamepadController?: WebVRController;
  110553. /**
  110554. * Event that fires when the controller is removed/disposed
  110555. */
  110556. onDisposeObservable: Observable<{}>;
  110557. private _tmpMatrix;
  110558. private _tmpQuaternion;
  110559. private _tmpVector;
  110560. /**
  110561. * Creates the controller
  110562. * @see https://doc.babylonjs.com/how_to/webxr
  110563. * @param scene the scene which the controller should be associated to
  110564. * @param inputSource the underlying input source for the controller
  110565. * @param parentContainer parent that the controller meshes should be children of
  110566. */
  110567. constructor(scene: Scene,
  110568. /** The underlying input source for the controller */
  110569. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110570. /**
  110571. * Updates the controller pose based on the given XRFrame
  110572. * @param xrFrame xr frame to update the pose with
  110573. * @param referenceSpace reference space to use
  110574. */
  110575. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110576. /**
  110577. * Gets a world space ray coming from the controller
  110578. * @param result the resulting ray
  110579. */
  110580. getWorldPointerRayToRef(result: Ray): void;
  110581. /**
  110582. * Get the scene associated with this controller
  110583. * @returns the scene object
  110584. */
  110585. getScene(): Scene;
  110586. /**
  110587. * Disposes of the object
  110588. */
  110589. dispose(): void;
  110590. }
  110591. }
  110592. declare module BABYLON {
  110593. /**
  110594. * XR input used to track XR inputs such as controllers/rays
  110595. */
  110596. export class WebXRInput implements IDisposable {
  110597. /**
  110598. * Base experience the input listens to
  110599. */
  110600. baseExperience: WebXRExperienceHelper;
  110601. /**
  110602. * XR controllers being tracked
  110603. */
  110604. controllers: Array<WebXRController>;
  110605. private _frameObserver;
  110606. private _stateObserver;
  110607. /**
  110608. * Event when a controller has been connected/added
  110609. */
  110610. onControllerAddedObservable: Observable<WebXRController>;
  110611. /**
  110612. * Event when a controller has been removed/disconnected
  110613. */
  110614. onControllerRemovedObservable: Observable<WebXRController>;
  110615. /**
  110616. * Initializes the WebXRInput
  110617. * @param baseExperience experience helper which the input should be created for
  110618. */
  110619. constructor(
  110620. /**
  110621. * Base experience the input listens to
  110622. */
  110623. baseExperience: WebXRExperienceHelper);
  110624. private _onInputSourcesChange;
  110625. private _addAndRemoveControllers;
  110626. /**
  110627. * Disposes of the object
  110628. */
  110629. dispose(): void;
  110630. }
  110631. }
  110632. declare module BABYLON {
  110633. /**
  110634. * Class used to represent data loading progression
  110635. */
  110636. export class SceneLoaderProgressEvent {
  110637. /** defines if data length to load can be evaluated */
  110638. readonly lengthComputable: boolean;
  110639. /** defines the loaded data length */
  110640. readonly loaded: number;
  110641. /** defines the data length to load */
  110642. readonly total: number;
  110643. /**
  110644. * Create a new progress event
  110645. * @param lengthComputable defines if data length to load can be evaluated
  110646. * @param loaded defines the loaded data length
  110647. * @param total defines the data length to load
  110648. */
  110649. constructor(
  110650. /** defines if data length to load can be evaluated */
  110651. lengthComputable: boolean,
  110652. /** defines the loaded data length */
  110653. loaded: number,
  110654. /** defines the data length to load */
  110655. total: number);
  110656. /**
  110657. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110658. * @param event defines the source event
  110659. * @returns a new SceneLoaderProgressEvent
  110660. */
  110661. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110662. }
  110663. /**
  110664. * Interface used by SceneLoader plugins to define supported file extensions
  110665. */
  110666. export interface ISceneLoaderPluginExtensions {
  110667. /**
  110668. * Defines the list of supported extensions
  110669. */
  110670. [extension: string]: {
  110671. isBinary: boolean;
  110672. };
  110673. }
  110674. /**
  110675. * Interface used by SceneLoader plugin factory
  110676. */
  110677. export interface ISceneLoaderPluginFactory {
  110678. /**
  110679. * Defines the name of the factory
  110680. */
  110681. name: string;
  110682. /**
  110683. * Function called to create a new plugin
  110684. * @return the new plugin
  110685. */
  110686. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110687. /**
  110688. * The callback that returns true if the data can be directly loaded.
  110689. * @param data string containing the file data
  110690. * @returns if the data can be loaded directly
  110691. */
  110692. canDirectLoad?(data: string): boolean;
  110693. }
  110694. /**
  110695. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110696. */
  110697. export interface ISceneLoaderPluginBase {
  110698. /**
  110699. * The friendly name of this plugin.
  110700. */
  110701. name: string;
  110702. /**
  110703. * The file extensions supported by this plugin.
  110704. */
  110705. extensions: string | ISceneLoaderPluginExtensions;
  110706. /**
  110707. * The callback called when loading from a url.
  110708. * @param scene scene loading this url
  110709. * @param url url to load
  110710. * @param onSuccess callback called when the file successfully loads
  110711. * @param onProgress callback called while file is loading (if the server supports this mode)
  110712. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110713. * @param onError callback called when the file fails to load
  110714. * @returns a file request object
  110715. */
  110716. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110717. /**
  110718. * The callback called when loading from a file object.
  110719. * @param scene scene loading this file
  110720. * @param file defines the file to load
  110721. * @param onSuccess defines the callback to call when data is loaded
  110722. * @param onProgress defines the callback to call during loading process
  110723. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110724. * @param onError defines the callback to call when an error occurs
  110725. * @returns a file request object
  110726. */
  110727. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110728. /**
  110729. * The callback that returns true if the data can be directly loaded.
  110730. * @param data string containing the file data
  110731. * @returns if the data can be loaded directly
  110732. */
  110733. canDirectLoad?(data: string): boolean;
  110734. /**
  110735. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110736. * @param scene scene loading this data
  110737. * @param data string containing the data
  110738. * @returns data to pass to the plugin
  110739. */
  110740. directLoad?(scene: Scene, data: string): any;
  110741. /**
  110742. * The callback that allows custom handling of the root url based on the response url.
  110743. * @param rootUrl the original root url
  110744. * @param responseURL the response url if available
  110745. * @returns the new root url
  110746. */
  110747. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110748. }
  110749. /**
  110750. * Interface used to define a SceneLoader plugin
  110751. */
  110752. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110753. /**
  110754. * Import meshes into a scene.
  110755. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110756. * @param scene The scene to import into
  110757. * @param data The data to import
  110758. * @param rootUrl The root url for scene and resources
  110759. * @param meshes The meshes array to import into
  110760. * @param particleSystems The particle systems array to import into
  110761. * @param skeletons The skeletons array to import into
  110762. * @param onError The callback when import fails
  110763. * @returns True if successful or false otherwise
  110764. */
  110765. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110766. /**
  110767. * Load into a scene.
  110768. * @param scene The scene to load into
  110769. * @param data The data to import
  110770. * @param rootUrl The root url for scene and resources
  110771. * @param onError The callback when import fails
  110772. * @returns True if successful or false otherwise
  110773. */
  110774. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110775. /**
  110776. * Load into an asset container.
  110777. * @param scene The scene to load into
  110778. * @param data The data to import
  110779. * @param rootUrl The root url for scene and resources
  110780. * @param onError The callback when import fails
  110781. * @returns The loaded asset container
  110782. */
  110783. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110784. }
  110785. /**
  110786. * Interface used to define an async SceneLoader plugin
  110787. */
  110788. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110789. /**
  110790. * Import meshes into a scene.
  110791. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110792. * @param scene The scene to import into
  110793. * @param data The data to import
  110794. * @param rootUrl The root url for scene and resources
  110795. * @param onProgress The callback when the load progresses
  110796. * @param fileName Defines the name of the file to load
  110797. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110798. */
  110799. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110800. meshes: AbstractMesh[];
  110801. particleSystems: IParticleSystem[];
  110802. skeletons: Skeleton[];
  110803. animationGroups: AnimationGroup[];
  110804. }>;
  110805. /**
  110806. * Load into a scene.
  110807. * @param scene The scene to load into
  110808. * @param data The data to import
  110809. * @param rootUrl The root url for scene and resources
  110810. * @param onProgress The callback when the load progresses
  110811. * @param fileName Defines the name of the file to load
  110812. * @returns Nothing
  110813. */
  110814. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110815. /**
  110816. * Load into an asset container.
  110817. * @param scene The scene to load into
  110818. * @param data The data to import
  110819. * @param rootUrl The root url for scene and resources
  110820. * @param onProgress The callback when the load progresses
  110821. * @param fileName Defines the name of the file to load
  110822. * @returns The loaded asset container
  110823. */
  110824. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110825. }
  110826. /**
  110827. * Class used to load scene from various file formats using registered plugins
  110828. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110829. */
  110830. export class SceneLoader {
  110831. /**
  110832. * No logging while loading
  110833. */
  110834. static readonly NO_LOGGING: number;
  110835. /**
  110836. * Minimal logging while loading
  110837. */
  110838. static readonly MINIMAL_LOGGING: number;
  110839. /**
  110840. * Summary logging while loading
  110841. */
  110842. static readonly SUMMARY_LOGGING: number;
  110843. /**
  110844. * Detailled logging while loading
  110845. */
  110846. static readonly DETAILED_LOGGING: number;
  110847. /**
  110848. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  110849. */
  110850. static ForceFullSceneLoadingForIncremental: boolean;
  110851. /**
  110852. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  110853. */
  110854. static ShowLoadingScreen: boolean;
  110855. /**
  110856. * Defines the current logging level (while loading the scene)
  110857. * @ignorenaming
  110858. */
  110859. static loggingLevel: number;
  110860. /**
  110861. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  110862. */
  110863. static CleanBoneMatrixWeights: boolean;
  110864. /**
  110865. * Event raised when a plugin is used to load a scene
  110866. */
  110867. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  110868. private static _registeredPlugins;
  110869. private static _getDefaultPlugin;
  110870. private static _getPluginForExtension;
  110871. private static _getPluginForDirectLoad;
  110872. private static _getPluginForFilename;
  110873. private static _getDirectLoad;
  110874. private static _loadData;
  110875. private static _getFileInfo;
  110876. /**
  110877. * Gets a plugin that can load the given extension
  110878. * @param extension defines the extension to load
  110879. * @returns a plugin or null if none works
  110880. */
  110881. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  110882. /**
  110883. * Gets a boolean indicating that the given extension can be loaded
  110884. * @param extension defines the extension to load
  110885. * @returns true if the extension is supported
  110886. */
  110887. static IsPluginForExtensionAvailable(extension: string): boolean;
  110888. /**
  110889. * Adds a new plugin to the list of registered plugins
  110890. * @param plugin defines the plugin to add
  110891. */
  110892. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  110893. /**
  110894. * Import meshes into a scene
  110895. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110896. * @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)
  110897. * @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)
  110898. * @param scene the instance of BABYLON.Scene to append to
  110899. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  110900. * @param onProgress a callback with a progress event for each file being loaded
  110901. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110902. * @param pluginExtension the extension used to determine the plugin
  110903. * @returns The loaded plugin
  110904. */
  110905. 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>;
  110906. /**
  110907. * Import meshes into a scene
  110908. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110909. * @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)
  110910. * @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)
  110911. * @param scene the instance of BABYLON.Scene to append to
  110912. * @param onProgress a callback with a progress event for each file being loaded
  110913. * @param pluginExtension the extension used to determine the plugin
  110914. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  110915. */
  110916. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  110917. meshes: AbstractMesh[];
  110918. particleSystems: IParticleSystem[];
  110919. skeletons: Skeleton[];
  110920. animationGroups: AnimationGroup[];
  110921. }>;
  110922. /**
  110923. * Load a scene
  110924. * @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)
  110925. * @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)
  110926. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110927. * @param onSuccess a callback with the scene when import succeeds
  110928. * @param onProgress a callback with a progress event for each file being loaded
  110929. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110930. * @param pluginExtension the extension used to determine the plugin
  110931. * @returns The loaded plugin
  110932. */
  110933. 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>;
  110934. /**
  110935. * Load a scene
  110936. * @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)
  110937. * @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)
  110938. * @param engine is the instance of BABYLON.Engine to use to create the scene
  110939. * @param onProgress a callback with a progress event for each file being loaded
  110940. * @param pluginExtension the extension used to determine the plugin
  110941. * @returns The loaded scene
  110942. */
  110943. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110944. /**
  110945. * Append a scene
  110946. * @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)
  110947. * @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)
  110948. * @param scene is the instance of BABYLON.Scene to append to
  110949. * @param onSuccess a callback with the scene when import succeeds
  110950. * @param onProgress a callback with a progress event for each file being loaded
  110951. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110952. * @param pluginExtension the extension used to determine the plugin
  110953. * @returns The loaded plugin
  110954. */
  110955. 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>;
  110956. /**
  110957. * Append a scene
  110958. * @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)
  110959. * @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)
  110960. * @param scene is the instance of BABYLON.Scene to append to
  110961. * @param onProgress a callback with a progress event for each file being loaded
  110962. * @param pluginExtension the extension used to determine the plugin
  110963. * @returns The given scene
  110964. */
  110965. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  110966. /**
  110967. * Load a scene into an asset container
  110968. * @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)
  110969. * @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)
  110970. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110971. * @param onSuccess a callback with the scene when import succeeds
  110972. * @param onProgress a callback with a progress event for each file being loaded
  110973. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110974. * @param pluginExtension the extension used to determine the plugin
  110975. * @returns The loaded plugin
  110976. */
  110977. 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>;
  110978. /**
  110979. * Load a scene into an asset container
  110980. * @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)
  110981. * @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)
  110982. * @param scene is the instance of Scene to append to
  110983. * @param onProgress a callback with a progress event for each file being loaded
  110984. * @param pluginExtension the extension used to determine the plugin
  110985. * @returns The loaded asset container
  110986. */
  110987. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110988. }
  110989. }
  110990. declare module BABYLON {
  110991. /**
  110992. * Generic Controller
  110993. */
  110994. export class GenericController extends WebVRController {
  110995. /**
  110996. * Base Url for the controller model.
  110997. */
  110998. static readonly MODEL_BASE_URL: string;
  110999. /**
  111000. * File name for the controller model.
  111001. */
  111002. static readonly MODEL_FILENAME: string;
  111003. /**
  111004. * Creates a new GenericController from a gamepad
  111005. * @param vrGamepad the gamepad that the controller should be created from
  111006. */
  111007. constructor(vrGamepad: any);
  111008. /**
  111009. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111010. * @param scene scene in which to add meshes
  111011. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111012. */
  111013. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111014. /**
  111015. * Called once for each button that changed state since the last frame
  111016. * @param buttonIdx Which button index changed
  111017. * @param state New state of the button
  111018. * @param changes Which properties on the state changed since last frame
  111019. */
  111020. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111021. }
  111022. }
  111023. declare module BABYLON {
  111024. /**
  111025. * Defines the WindowsMotionController object that the state of the windows motion controller
  111026. */
  111027. export class WindowsMotionController extends WebVRController {
  111028. /**
  111029. * The base url used to load the left and right controller models
  111030. */
  111031. static MODEL_BASE_URL: string;
  111032. /**
  111033. * The name of the left controller model file
  111034. */
  111035. static MODEL_LEFT_FILENAME: string;
  111036. /**
  111037. * The name of the right controller model file
  111038. */
  111039. static MODEL_RIGHT_FILENAME: string;
  111040. /**
  111041. * The controller name prefix for this controller type
  111042. */
  111043. static readonly GAMEPAD_ID_PREFIX: string;
  111044. /**
  111045. * The controller id pattern for this controller type
  111046. */
  111047. private static readonly GAMEPAD_ID_PATTERN;
  111048. private _loadedMeshInfo;
  111049. private readonly _mapping;
  111050. /**
  111051. * Fired when the trackpad on this controller is clicked
  111052. */
  111053. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111054. /**
  111055. * Fired when the trackpad on this controller is modified
  111056. */
  111057. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111058. /**
  111059. * The current x and y values of this controller's trackpad
  111060. */
  111061. trackpad: StickValues;
  111062. /**
  111063. * Creates a new WindowsMotionController from a gamepad
  111064. * @param vrGamepad the gamepad that the controller should be created from
  111065. */
  111066. constructor(vrGamepad: any);
  111067. /**
  111068. * Fired when the trigger on this controller is modified
  111069. */
  111070. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111071. /**
  111072. * Fired when the menu button on this controller is modified
  111073. */
  111074. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111075. /**
  111076. * Fired when the grip button on this controller is modified
  111077. */
  111078. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111079. /**
  111080. * Fired when the thumbstick button on this controller is modified
  111081. */
  111082. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111083. /**
  111084. * Fired when the touchpad button on this controller is modified
  111085. */
  111086. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111087. /**
  111088. * Fired when the touchpad values on this controller are modified
  111089. */
  111090. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  111091. private _updateTrackpad;
  111092. /**
  111093. * Called once per frame by the engine.
  111094. */
  111095. update(): void;
  111096. /**
  111097. * Called once for each button that changed state since the last frame
  111098. * @param buttonIdx Which button index changed
  111099. * @param state New state of the button
  111100. * @param changes Which properties on the state changed since last frame
  111101. */
  111102. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111103. /**
  111104. * Moves the buttons on the controller mesh based on their current state
  111105. * @param buttonName the name of the button to move
  111106. * @param buttonValue the value of the button which determines the buttons new position
  111107. */
  111108. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111109. /**
  111110. * Moves the axis on the controller mesh based on its current state
  111111. * @param axis the index of the axis
  111112. * @param axisValue the value of the axis which determines the meshes new position
  111113. * @hidden
  111114. */
  111115. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  111116. /**
  111117. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111118. * @param scene scene in which to add meshes
  111119. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111120. */
  111121. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  111122. /**
  111123. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111124. * can be transformed by button presses and axes values, based on this._mapping.
  111125. *
  111126. * @param scene scene in which the meshes exist
  111127. * @param meshes list of meshes that make up the controller model to process
  111128. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111129. */
  111130. private processModel;
  111131. private createMeshInfo;
  111132. /**
  111133. * Gets the ray of the controller in the direction the controller is pointing
  111134. * @param length the length the resulting ray should be
  111135. * @returns a ray in the direction the controller is pointing
  111136. */
  111137. getForwardRay(length?: number): Ray;
  111138. /**
  111139. * Disposes of the controller
  111140. */
  111141. dispose(): void;
  111142. }
  111143. }
  111144. declare module BABYLON {
  111145. /**
  111146. * Oculus Touch Controller
  111147. */
  111148. export class OculusTouchController extends WebVRController {
  111149. /**
  111150. * Base Url for the controller model.
  111151. */
  111152. static MODEL_BASE_URL: string;
  111153. /**
  111154. * File name for the left controller model.
  111155. */
  111156. static MODEL_LEFT_FILENAME: string;
  111157. /**
  111158. * File name for the right controller model.
  111159. */
  111160. static MODEL_RIGHT_FILENAME: string;
  111161. /**
  111162. * Base Url for the Quest controller model.
  111163. */
  111164. static QUEST_MODEL_BASE_URL: string;
  111165. /**
  111166. * @hidden
  111167. * If the controllers are running on a device that needs the updated Quest controller models
  111168. */
  111169. static _IsQuest: boolean;
  111170. /**
  111171. * Fired when the secondary trigger on this controller is modified
  111172. */
  111173. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111174. /**
  111175. * Fired when the thumb rest on this controller is modified
  111176. */
  111177. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111178. /**
  111179. * Creates a new OculusTouchController from a gamepad
  111180. * @param vrGamepad the gamepad that the controller should be created from
  111181. */
  111182. constructor(vrGamepad: any);
  111183. /**
  111184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111185. * @param scene scene in which to add meshes
  111186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111187. */
  111188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111189. /**
  111190. * Fired when the A button on this controller is modified
  111191. */
  111192. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111193. /**
  111194. * Fired when the B button on this controller is modified
  111195. */
  111196. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111197. /**
  111198. * Fired when the X button on this controller is modified
  111199. */
  111200. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111201. /**
  111202. * Fired when the Y button on this controller is modified
  111203. */
  111204. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111205. /**
  111206. * Called once for each button that changed state since the last frame
  111207. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111208. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111209. * 2) secondary trigger (same)
  111210. * 3) A (right) X (left), touch, pressed = value
  111211. * 4) B / Y
  111212. * 5) thumb rest
  111213. * @param buttonIdx Which button index changed
  111214. * @param state New state of the button
  111215. * @param changes Which properties on the state changed since last frame
  111216. */
  111217. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111218. }
  111219. }
  111220. declare module BABYLON {
  111221. /**
  111222. * Vive Controller
  111223. */
  111224. export class ViveController extends WebVRController {
  111225. /**
  111226. * Base Url for the controller model.
  111227. */
  111228. static MODEL_BASE_URL: string;
  111229. /**
  111230. * File name for the controller model.
  111231. */
  111232. static MODEL_FILENAME: string;
  111233. /**
  111234. * Creates a new ViveController from a gamepad
  111235. * @param vrGamepad the gamepad that the controller should be created from
  111236. */
  111237. constructor(vrGamepad: any);
  111238. /**
  111239. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111240. * @param scene scene in which to add meshes
  111241. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111242. */
  111243. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111244. /**
  111245. * Fired when the left button on this controller is modified
  111246. */
  111247. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111248. /**
  111249. * Fired when the right button on this controller is modified
  111250. */
  111251. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111252. /**
  111253. * Fired when the menu button on this controller is modified
  111254. */
  111255. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111256. /**
  111257. * Called once for each button that changed state since the last frame
  111258. * Vive mapping:
  111259. * 0: touchpad
  111260. * 1: trigger
  111261. * 2: left AND right buttons
  111262. * 3: menu button
  111263. * @param buttonIdx Which button index changed
  111264. * @param state New state of the button
  111265. * @param changes Which properties on the state changed since last frame
  111266. */
  111267. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111268. }
  111269. }
  111270. declare module BABYLON {
  111271. /**
  111272. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111273. */
  111274. export class WebXRControllerModelLoader {
  111275. /**
  111276. * an observable that triggers when a new model (the mesh itself) was initialized.
  111277. * To know when the mesh was loaded use the controller's own modelLoaded() method
  111278. */
  111279. onControllerModelLoaded: Observable<WebXRController>;
  111280. /**
  111281. * Creates the WebXRControllerModelLoader
  111282. * @param input xr input that creates the controllers
  111283. */
  111284. constructor(input: WebXRInput);
  111285. }
  111286. }
  111287. declare module BABYLON {
  111288. /**
  111289. * Handles pointer input automatically for the pointer of XR controllers
  111290. */
  111291. export class WebXRControllerPointerSelection {
  111292. private static _idCounter;
  111293. private _tmpRay;
  111294. /**
  111295. * Creates a WebXRControllerPointerSelection
  111296. * @param input input manager to setup pointer selection
  111297. */
  111298. constructor(input: WebXRInput);
  111299. private _convertNormalToDirectionOfRay;
  111300. private _updatePointerDistance;
  111301. }
  111302. }
  111303. declare module BABYLON {
  111304. /**
  111305. * Enables teleportation
  111306. */
  111307. export class WebXRControllerTeleportation {
  111308. private _teleportationFillColor;
  111309. private _teleportationBorderColor;
  111310. private _tmpRay;
  111311. private _tmpVector;
  111312. /**
  111313. * Creates a WebXRControllerTeleportation
  111314. * @param input input manager to add teleportation to
  111315. * @param floorMeshes floormeshes which can be teleported to
  111316. */
  111317. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  111318. }
  111319. }
  111320. declare module BABYLON {
  111321. /**
  111322. * Button which can be used to enter a different mode of XR
  111323. */
  111324. export class WebXREnterExitUIButton {
  111325. /** button element */
  111326. element: HTMLElement;
  111327. /** XR initialization options for the button */
  111328. sessionMode: XRSessionMode;
  111329. /** Reference space type */
  111330. referenceSpaceType: XRReferenceSpaceType;
  111331. /**
  111332. * Creates a WebXREnterExitUIButton
  111333. * @param element button element
  111334. * @param sessionMode XR initialization session mode
  111335. * @param referenceSpaceType the type of reference space to be used
  111336. */
  111337. constructor(
  111338. /** button element */
  111339. element: HTMLElement,
  111340. /** XR initialization options for the button */
  111341. sessionMode: XRSessionMode,
  111342. /** Reference space type */
  111343. referenceSpaceType: XRReferenceSpaceType);
  111344. /**
  111345. * Overwritable function which can be used to update the button's visuals when the state changes
  111346. * @param activeButton the current active button in the UI
  111347. */
  111348. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  111349. }
  111350. /**
  111351. * Options to create the webXR UI
  111352. */
  111353. export class WebXREnterExitUIOptions {
  111354. /**
  111355. * Context to enter xr with
  111356. */
  111357. renderTarget?: Nullable<WebXRRenderTarget>;
  111358. /**
  111359. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  111360. */
  111361. customButtons?: Array<WebXREnterExitUIButton>;
  111362. /**
  111363. * A session mode to use when creating the default button.
  111364. * Default is immersive-vr
  111365. */
  111366. sessionMode?: XRSessionMode;
  111367. /**
  111368. * A reference space type to use when creating the default button.
  111369. * Default is local-floor
  111370. */
  111371. referenceSpaceType?: XRReferenceSpaceType;
  111372. }
  111373. /**
  111374. * UI to allow the user to enter/exit XR mode
  111375. */
  111376. export class WebXREnterExitUI implements IDisposable {
  111377. private scene;
  111378. private _overlay;
  111379. private _buttons;
  111380. private _activeButton;
  111381. /**
  111382. * Fired every time the active button is changed.
  111383. *
  111384. * When xr is entered via a button that launches xr that button will be the callback parameter
  111385. *
  111386. * When exiting xr the callback parameter will be null)
  111387. */
  111388. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  111389. /**
  111390. * Creates UI to allow the user to enter/exit XR mode
  111391. * @param scene the scene to add the ui to
  111392. * @param helper the xr experience helper to enter/exit xr with
  111393. * @param options options to configure the UI
  111394. * @returns the created ui
  111395. */
  111396. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  111397. private constructor();
  111398. private _updateButtons;
  111399. /**
  111400. * Disposes of the object
  111401. */
  111402. dispose(): void;
  111403. }
  111404. }
  111405. declare module BABYLON {
  111406. /**
  111407. * Options for the default xr helper
  111408. */
  111409. export class WebXRDefaultExperienceOptions {
  111410. /**
  111411. * Floor meshes that should be used for teleporting
  111412. */
  111413. floorMeshes: Array<AbstractMesh>;
  111414. /**
  111415. * Enable or disable default UI to enter XR
  111416. */
  111417. disableDefaultUI?: boolean;
  111418. /**
  111419. * optional configuration for the output canvas
  111420. */
  111421. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  111422. }
  111423. /**
  111424. * Default experience which provides a similar setup to the previous webVRExperience
  111425. */
  111426. export class WebXRDefaultExperience {
  111427. /**
  111428. * Base experience
  111429. */
  111430. baseExperience: WebXRExperienceHelper;
  111431. /**
  111432. * Input experience extension
  111433. */
  111434. input: WebXRInput;
  111435. /**
  111436. * Loads the controller models
  111437. */
  111438. controllerModelLoader: WebXRControllerModelLoader;
  111439. /**
  111440. * Enables laser pointer and selection
  111441. */
  111442. pointerSelection: WebXRControllerPointerSelection;
  111443. /**
  111444. * Enables teleportation
  111445. */
  111446. teleportation: WebXRControllerTeleportation;
  111447. /**
  111448. * Enables ui for enetering/exiting xr
  111449. */
  111450. enterExitUI: WebXREnterExitUI;
  111451. /**
  111452. * Default target xr should render to
  111453. */
  111454. renderTarget: WebXRRenderTarget;
  111455. /**
  111456. * Creates the default xr experience
  111457. * @param scene scene
  111458. * @param options options for basic configuration
  111459. * @returns resulting WebXRDefaultExperience
  111460. */
  111461. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111462. private constructor();
  111463. /**
  111464. * DIsposes of the experience helper
  111465. */
  111466. dispose(): void;
  111467. }
  111468. }
  111469. declare module BABYLON {
  111470. /**
  111471. * Options to modify the vr teleportation behavior.
  111472. */
  111473. export interface VRTeleportationOptions {
  111474. /**
  111475. * The name of the mesh which should be used as the teleportation floor. (default: null)
  111476. */
  111477. floorMeshName?: string;
  111478. /**
  111479. * A list of meshes to be used as the teleportation floor. (default: empty)
  111480. */
  111481. floorMeshes?: Mesh[];
  111482. /**
  111483. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  111484. */
  111485. teleportationMode?: number;
  111486. /**
  111487. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  111488. */
  111489. teleportationTime?: number;
  111490. /**
  111491. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  111492. */
  111493. teleportationSpeed?: number;
  111494. }
  111495. /**
  111496. * Options to modify the vr experience helper's behavior.
  111497. */
  111498. export interface VRExperienceHelperOptions extends WebVROptions {
  111499. /**
  111500. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  111501. */
  111502. createDeviceOrientationCamera?: boolean;
  111503. /**
  111504. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  111505. */
  111506. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  111507. /**
  111508. * Uses the main button on the controller to toggle the laser casted. (default: true)
  111509. */
  111510. laserToggle?: boolean;
  111511. /**
  111512. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  111513. */
  111514. floorMeshes?: Mesh[];
  111515. /**
  111516. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  111517. */
  111518. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  111519. /**
  111520. * Defines if WebXR should be used instead of WebVR (if available)
  111521. */
  111522. useXR?: boolean;
  111523. }
  111524. /**
  111525. * Event containing information after VR has been entered
  111526. */
  111527. export class OnAfterEnteringVRObservableEvent {
  111528. /**
  111529. * If entering vr was successful
  111530. */
  111531. success: boolean;
  111532. }
  111533. /**
  111534. * Helps to quickly add VR support to an existing scene.
  111535. * See http://doc.babylonjs.com/how_to/webvr_helper
  111536. */
  111537. export class VRExperienceHelper {
  111538. /** Options to modify the vr experience helper's behavior. */
  111539. webVROptions: VRExperienceHelperOptions;
  111540. private _scene;
  111541. private _position;
  111542. private _btnVR;
  111543. private _btnVRDisplayed;
  111544. private _webVRsupported;
  111545. private _webVRready;
  111546. private _webVRrequesting;
  111547. private _webVRpresenting;
  111548. private _hasEnteredVR;
  111549. private _fullscreenVRpresenting;
  111550. private _inputElement;
  111551. private _webVRCamera;
  111552. private _vrDeviceOrientationCamera;
  111553. private _deviceOrientationCamera;
  111554. private _existingCamera;
  111555. private _onKeyDown;
  111556. private _onVrDisplayPresentChange;
  111557. private _onVRDisplayChanged;
  111558. private _onVRRequestPresentStart;
  111559. private _onVRRequestPresentComplete;
  111560. /**
  111561. * 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)
  111562. */
  111563. enableGazeEvenWhenNoPointerLock: boolean;
  111564. /**
  111565. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  111566. */
  111567. exitVROnDoubleTap: boolean;
  111568. /**
  111569. * Observable raised right before entering VR.
  111570. */
  111571. onEnteringVRObservable: Observable<VRExperienceHelper>;
  111572. /**
  111573. * Observable raised when entering VR has completed.
  111574. */
  111575. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  111576. /**
  111577. * Observable raised when exiting VR.
  111578. */
  111579. onExitingVRObservable: Observable<VRExperienceHelper>;
  111580. /**
  111581. * Observable raised when controller mesh is loaded.
  111582. */
  111583. onControllerMeshLoadedObservable: Observable<WebVRController>;
  111584. /** Return this.onEnteringVRObservable
  111585. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  111586. */
  111587. readonly onEnteringVR: Observable<VRExperienceHelper>;
  111588. /** Return this.onExitingVRObservable
  111589. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  111590. */
  111591. readonly onExitingVR: Observable<VRExperienceHelper>;
  111592. /** Return this.onControllerMeshLoadedObservable
  111593. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  111594. */
  111595. readonly onControllerMeshLoaded: Observable<WebVRController>;
  111596. private _rayLength;
  111597. private _useCustomVRButton;
  111598. private _teleportationRequested;
  111599. private _teleportActive;
  111600. private _floorMeshName;
  111601. private _floorMeshesCollection;
  111602. private _teleportationMode;
  111603. private _teleportationTime;
  111604. private _teleportationSpeed;
  111605. private _rotationAllowed;
  111606. private _teleportBackwardsVector;
  111607. private _teleportationTarget;
  111608. private _isDefaultTeleportationTarget;
  111609. private _postProcessMove;
  111610. private _teleportationFillColor;
  111611. private _teleportationBorderColor;
  111612. private _rotationAngle;
  111613. private _haloCenter;
  111614. private _cameraGazer;
  111615. private _padSensibilityUp;
  111616. private _padSensibilityDown;
  111617. private _leftController;
  111618. private _rightController;
  111619. /**
  111620. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  111621. */
  111622. onNewMeshSelected: Observable<AbstractMesh>;
  111623. /**
  111624. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  111625. * This observable will provide the mesh and the controller used to select the mesh
  111626. */
  111627. onMeshSelectedWithController: Observable<{
  111628. mesh: AbstractMesh;
  111629. controller: WebVRController;
  111630. }>;
  111631. /**
  111632. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  111633. */
  111634. onNewMeshPicked: Observable<PickingInfo>;
  111635. private _circleEase;
  111636. /**
  111637. * Observable raised before camera teleportation
  111638. */
  111639. onBeforeCameraTeleport: Observable<Vector3>;
  111640. /**
  111641. * Observable raised after camera teleportation
  111642. */
  111643. onAfterCameraTeleport: Observable<Vector3>;
  111644. /**
  111645. * Observable raised when current selected mesh gets unselected
  111646. */
  111647. onSelectedMeshUnselected: Observable<AbstractMesh>;
  111648. private _raySelectionPredicate;
  111649. /**
  111650. * To be optionaly changed by user to define custom ray selection
  111651. */
  111652. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  111653. /**
  111654. * To be optionaly changed by user to define custom selection logic (after ray selection)
  111655. */
  111656. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  111657. /**
  111658. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  111659. */
  111660. teleportationEnabled: boolean;
  111661. private _defaultHeight;
  111662. private _teleportationInitialized;
  111663. private _interactionsEnabled;
  111664. private _interactionsRequested;
  111665. private _displayGaze;
  111666. private _displayLaserPointer;
  111667. /**
  111668. * The mesh used to display where the user is going to teleport.
  111669. */
  111670. /**
  111671. * Sets the mesh to be used to display where the user is going to teleport.
  111672. */
  111673. teleportationTarget: Mesh;
  111674. /**
  111675. * 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
  111676. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  111677. * See http://doc.babylonjs.com/resources/baking_transformations
  111678. */
  111679. gazeTrackerMesh: Mesh;
  111680. /**
  111681. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  111682. */
  111683. updateGazeTrackerScale: boolean;
  111684. /**
  111685. * If the gaze trackers color should be updated when selecting meshes
  111686. */
  111687. updateGazeTrackerColor: boolean;
  111688. /**
  111689. * If the controller laser color should be updated when selecting meshes
  111690. */
  111691. updateControllerLaserColor: boolean;
  111692. /**
  111693. * The gaze tracking mesh corresponding to the left controller
  111694. */
  111695. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  111696. /**
  111697. * The gaze tracking mesh corresponding to the right controller
  111698. */
  111699. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  111700. /**
  111701. * If the ray of the gaze should be displayed.
  111702. */
  111703. /**
  111704. * Sets if the ray of the gaze should be displayed.
  111705. */
  111706. displayGaze: boolean;
  111707. /**
  111708. * If the ray of the LaserPointer should be displayed.
  111709. */
  111710. /**
  111711. * Sets if the ray of the LaserPointer should be displayed.
  111712. */
  111713. displayLaserPointer: boolean;
  111714. /**
  111715. * The deviceOrientationCamera used as the camera when not in VR.
  111716. */
  111717. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  111718. /**
  111719. * Based on the current WebVR support, returns the current VR camera used.
  111720. */
  111721. readonly currentVRCamera: Nullable<Camera>;
  111722. /**
  111723. * The webVRCamera which is used when in VR.
  111724. */
  111725. readonly webVRCamera: WebVRFreeCamera;
  111726. /**
  111727. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  111728. */
  111729. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  111730. /**
  111731. * The html button that is used to trigger entering into VR.
  111732. */
  111733. readonly vrButton: Nullable<HTMLButtonElement>;
  111734. private readonly _teleportationRequestInitiated;
  111735. /**
  111736. * Defines wether or not Pointer lock should be requested when switching to
  111737. * full screen.
  111738. */
  111739. requestPointerLockOnFullScreen: boolean;
  111740. /**
  111741. * If asking to force XR, this will be populated with the default xr experience
  111742. */
  111743. xr: WebXRDefaultExperience;
  111744. /**
  111745. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  111746. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  111747. */
  111748. xrTestDone: boolean;
  111749. /**
  111750. * Instantiates a VRExperienceHelper.
  111751. * Helps to quickly add VR support to an existing scene.
  111752. * @param scene The scene the VRExperienceHelper belongs to.
  111753. * @param webVROptions Options to modify the vr experience helper's behavior.
  111754. */
  111755. constructor(scene: Scene,
  111756. /** Options to modify the vr experience helper's behavior. */
  111757. webVROptions?: VRExperienceHelperOptions);
  111758. private completeVRInit;
  111759. private _onDefaultMeshLoaded;
  111760. private _onResize;
  111761. private _onFullscreenChange;
  111762. /**
  111763. * Gets a value indicating if we are currently in VR mode.
  111764. */
  111765. readonly isInVRMode: boolean;
  111766. private onVrDisplayPresentChange;
  111767. private onVRDisplayChanged;
  111768. private moveButtonToBottomRight;
  111769. private displayVRButton;
  111770. private updateButtonVisibility;
  111771. private _cachedAngularSensibility;
  111772. /**
  111773. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  111774. * Otherwise, will use the fullscreen API.
  111775. */
  111776. enterVR(): void;
  111777. /**
  111778. * Attempt to exit VR, or fullscreen.
  111779. */
  111780. exitVR(): void;
  111781. /**
  111782. * The position of the vr experience helper.
  111783. */
  111784. /**
  111785. * Sets the position of the vr experience helper.
  111786. */
  111787. position: Vector3;
  111788. /**
  111789. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  111790. */
  111791. enableInteractions(): void;
  111792. private readonly _noControllerIsActive;
  111793. private beforeRender;
  111794. private _isTeleportationFloor;
  111795. /**
  111796. * Adds a floor mesh to be used for teleportation.
  111797. * @param floorMesh the mesh to be used for teleportation.
  111798. */
  111799. addFloorMesh(floorMesh: Mesh): void;
  111800. /**
  111801. * Removes a floor mesh from being used for teleportation.
  111802. * @param floorMesh the mesh to be removed.
  111803. */
  111804. removeFloorMesh(floorMesh: Mesh): void;
  111805. /**
  111806. * Enables interactions and teleportation using the VR controllers and gaze.
  111807. * @param vrTeleportationOptions options to modify teleportation behavior.
  111808. */
  111809. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  111810. private _onNewGamepadConnected;
  111811. private _tryEnableInteractionOnController;
  111812. private _onNewGamepadDisconnected;
  111813. private _enableInteractionOnController;
  111814. private _checkTeleportWithRay;
  111815. private _checkRotate;
  111816. private _checkTeleportBackwards;
  111817. private _enableTeleportationOnController;
  111818. private _createTeleportationCircles;
  111819. private _displayTeleportationTarget;
  111820. private _hideTeleportationTarget;
  111821. private _rotateCamera;
  111822. private _moveTeleportationSelectorTo;
  111823. private _workingVector;
  111824. private _workingQuaternion;
  111825. private _workingMatrix;
  111826. /**
  111827. * Time Constant Teleportation Mode
  111828. */
  111829. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  111830. /**
  111831. * Speed Constant Teleportation Mode
  111832. */
  111833. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  111834. /**
  111835. * Teleports the users feet to the desired location
  111836. * @param location The location where the user's feet should be placed
  111837. */
  111838. teleportCamera(location: Vector3): void;
  111839. private _convertNormalToDirectionOfRay;
  111840. private _castRayAndSelectObject;
  111841. private _notifySelectedMeshUnselected;
  111842. /**
  111843. * Sets the color of the laser ray from the vr controllers.
  111844. * @param color new color for the ray.
  111845. */
  111846. changeLaserColor(color: Color3): void;
  111847. /**
  111848. * Sets the color of the ray from the vr headsets gaze.
  111849. * @param color new color for the ray.
  111850. */
  111851. changeGazeColor(color: Color3): void;
  111852. /**
  111853. * Exits VR and disposes of the vr experience helper
  111854. */
  111855. dispose(): void;
  111856. /**
  111857. * Gets the name of the VRExperienceHelper class
  111858. * @returns "VRExperienceHelper"
  111859. */
  111860. getClassName(): string;
  111861. }
  111862. }
  111863. declare module BABYLON {
  111864. /**
  111865. * Contains an array of blocks representing the octree
  111866. */
  111867. export interface IOctreeContainer<T> {
  111868. /**
  111869. * Blocks within the octree
  111870. */
  111871. blocks: Array<OctreeBlock<T>>;
  111872. }
  111873. /**
  111874. * Class used to store a cell in an octree
  111875. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111876. */
  111877. export class OctreeBlock<T> {
  111878. /**
  111879. * Gets the content of the current block
  111880. */
  111881. entries: T[];
  111882. /**
  111883. * Gets the list of block children
  111884. */
  111885. blocks: Array<OctreeBlock<T>>;
  111886. private _depth;
  111887. private _maxDepth;
  111888. private _capacity;
  111889. private _minPoint;
  111890. private _maxPoint;
  111891. private _boundingVectors;
  111892. private _creationFunc;
  111893. /**
  111894. * Creates a new block
  111895. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  111896. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  111897. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111898. * @param depth defines the current depth of this block in the octree
  111899. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  111900. * @param creationFunc defines a callback to call when an element is added to the block
  111901. */
  111902. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  111903. /**
  111904. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111905. */
  111906. readonly capacity: number;
  111907. /**
  111908. * Gets the minimum vector (in world space) of the block's bounding box
  111909. */
  111910. readonly minPoint: Vector3;
  111911. /**
  111912. * Gets the maximum vector (in world space) of the block's bounding box
  111913. */
  111914. readonly maxPoint: Vector3;
  111915. /**
  111916. * Add a new element to this block
  111917. * @param entry defines the element to add
  111918. */
  111919. addEntry(entry: T): void;
  111920. /**
  111921. * Remove an element from this block
  111922. * @param entry defines the element to remove
  111923. */
  111924. removeEntry(entry: T): void;
  111925. /**
  111926. * Add an array of elements to this block
  111927. * @param entries defines the array of elements to add
  111928. */
  111929. addEntries(entries: T[]): void;
  111930. /**
  111931. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  111932. * @param frustumPlanes defines the frustum planes to test
  111933. * @param selection defines the array to store current content if selection is positive
  111934. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111935. */
  111936. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111937. /**
  111938. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  111939. * @param sphereCenter defines the bounding sphere center
  111940. * @param sphereRadius defines the bounding sphere radius
  111941. * @param selection defines the array to store current content if selection is positive
  111942. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111943. */
  111944. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111945. /**
  111946. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  111947. * @param ray defines the ray to test with
  111948. * @param selection defines the array to store current content if selection is positive
  111949. */
  111950. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  111951. /**
  111952. * Subdivide the content into child blocks (this block will then be empty)
  111953. */
  111954. createInnerBlocks(): void;
  111955. /**
  111956. * @hidden
  111957. */
  111958. 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;
  111959. }
  111960. }
  111961. declare module BABYLON {
  111962. /**
  111963. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  111964. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111965. */
  111966. export class Octree<T> {
  111967. /** 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.) */
  111968. maxDepth: number;
  111969. /**
  111970. * Blocks within the octree containing objects
  111971. */
  111972. blocks: Array<OctreeBlock<T>>;
  111973. /**
  111974. * Content stored in the octree
  111975. */
  111976. dynamicContent: T[];
  111977. private _maxBlockCapacity;
  111978. private _selectionContent;
  111979. private _creationFunc;
  111980. /**
  111981. * Creates a octree
  111982. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111983. * @param creationFunc function to be used to instatiate the octree
  111984. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111985. * @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.)
  111986. */
  111987. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111988. /** 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.) */
  111989. maxDepth?: number);
  111990. /**
  111991. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111992. * @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);
  111993. * @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);
  111994. * @param entries meshes to be added to the octree blocks
  111995. */
  111996. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111997. /**
  111998. * Adds a mesh to the octree
  111999. * @param entry Mesh to add to the octree
  112000. */
  112001. addMesh(entry: T): void;
  112002. /**
  112003. * Remove an element from the octree
  112004. * @param entry defines the element to remove
  112005. */
  112006. removeMesh(entry: T): void;
  112007. /**
  112008. * Selects an array of meshes within the frustum
  112009. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  112010. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  112011. * @returns array of meshes within the frustum
  112012. */
  112013. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  112014. /**
  112015. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  112016. * @param sphereCenter defines the bounding sphere center
  112017. * @param sphereRadius defines the bounding sphere radius
  112018. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112019. * @returns an array of objects that intersect the sphere
  112020. */
  112021. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  112022. /**
  112023. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  112024. * @param ray defines the ray to test with
  112025. * @returns array of intersected objects
  112026. */
  112027. intersectsRay(ray: Ray): SmartArray<T>;
  112028. /**
  112029. * Adds a mesh into the octree block if it intersects the block
  112030. */
  112031. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  112032. /**
  112033. * Adds a submesh into the octree block if it intersects the block
  112034. */
  112035. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  112036. }
  112037. }
  112038. declare module BABYLON {
  112039. interface Scene {
  112040. /**
  112041. * @hidden
  112042. * Backing Filed
  112043. */
  112044. _selectionOctree: Octree<AbstractMesh>;
  112045. /**
  112046. * Gets the octree used to boost mesh selection (picking)
  112047. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112048. */
  112049. selectionOctree: Octree<AbstractMesh>;
  112050. /**
  112051. * Creates or updates the octree used to boost selection (picking)
  112052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112053. * @param maxCapacity defines the maximum capacity per leaf
  112054. * @param maxDepth defines the maximum depth of the octree
  112055. * @returns an octree of AbstractMesh
  112056. */
  112057. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  112058. }
  112059. interface AbstractMesh {
  112060. /**
  112061. * @hidden
  112062. * Backing Field
  112063. */
  112064. _submeshesOctree: Octree<SubMesh>;
  112065. /**
  112066. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  112067. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112068. * @param maxCapacity defines the maximum size of each block (64 by default)
  112069. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  112070. * @returns the new octree
  112071. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  112072. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112073. */
  112074. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  112075. }
  112076. /**
  112077. * Defines the octree scene component responsible to manage any octrees
  112078. * in a given scene.
  112079. */
  112080. export class OctreeSceneComponent {
  112081. /**
  112082. * The component name help to identify the component in the list of scene components.
  112083. */
  112084. readonly name: string;
  112085. /**
  112086. * The scene the component belongs to.
  112087. */
  112088. scene: Scene;
  112089. /**
  112090. * Indicates if the meshes have been checked to make sure they are isEnabled()
  112091. */
  112092. readonly checksIsEnabled: boolean;
  112093. /**
  112094. * Creates a new instance of the component for the given scene
  112095. * @param scene Defines the scene to register the component in
  112096. */
  112097. constructor(scene: Scene);
  112098. /**
  112099. * Registers the component in a given scene
  112100. */
  112101. register(): void;
  112102. /**
  112103. * Return the list of active meshes
  112104. * @returns the list of active meshes
  112105. */
  112106. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112107. /**
  112108. * Return the list of active sub meshes
  112109. * @param mesh The mesh to get the candidates sub meshes from
  112110. * @returns the list of active sub meshes
  112111. */
  112112. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112113. private _tempRay;
  112114. /**
  112115. * Return the list of sub meshes intersecting with a given local ray
  112116. * @param mesh defines the mesh to find the submesh for
  112117. * @param localRay defines the ray in local space
  112118. * @returns the list of intersecting sub meshes
  112119. */
  112120. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  112121. /**
  112122. * Return the list of sub meshes colliding with a collider
  112123. * @param mesh defines the mesh to find the submesh for
  112124. * @param collider defines the collider to evaluate the collision against
  112125. * @returns the list of colliding sub meshes
  112126. */
  112127. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  112128. /**
  112129. * Rebuilds the elements related to this component in case of
  112130. * context lost for instance.
  112131. */
  112132. rebuild(): void;
  112133. /**
  112134. * Disposes the component and the associated ressources.
  112135. */
  112136. dispose(): void;
  112137. }
  112138. }
  112139. declare module BABYLON {
  112140. /**
  112141. * Renders a layer on top of an existing scene
  112142. */
  112143. export class UtilityLayerRenderer implements IDisposable {
  112144. /** the original scene that will be rendered on top of */
  112145. originalScene: Scene;
  112146. private _pointerCaptures;
  112147. private _lastPointerEvents;
  112148. private static _DefaultUtilityLayer;
  112149. private static _DefaultKeepDepthUtilityLayer;
  112150. private _sharedGizmoLight;
  112151. private _renderCamera;
  112152. /**
  112153. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  112154. * @returns the camera that is used when rendering the utility layer
  112155. */
  112156. getRenderCamera(): Nullable<Camera>;
  112157. /**
  112158. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  112159. * @param cam the camera that should be used when rendering the utility layer
  112160. */
  112161. setRenderCamera(cam: Nullable<Camera>): void;
  112162. /**
  112163. * @hidden
  112164. * Light which used by gizmos to get light shading
  112165. */
  112166. _getSharedGizmoLight(): HemisphericLight;
  112167. /**
  112168. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  112169. */
  112170. pickUtilitySceneFirst: boolean;
  112171. /**
  112172. * 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)
  112173. */
  112174. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  112175. /**
  112176. * 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)
  112177. */
  112178. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  112179. /**
  112180. * The scene that is rendered on top of the original scene
  112181. */
  112182. utilityLayerScene: Scene;
  112183. /**
  112184. * If the utility layer should automatically be rendered on top of existing scene
  112185. */
  112186. shouldRender: boolean;
  112187. /**
  112188. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  112189. */
  112190. onlyCheckPointerDownEvents: boolean;
  112191. /**
  112192. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  112193. */
  112194. processAllEvents: boolean;
  112195. /**
  112196. * Observable raised when the pointer move from the utility layer scene to the main scene
  112197. */
  112198. onPointerOutObservable: Observable<number>;
  112199. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  112200. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  112201. private _afterRenderObserver;
  112202. private _sceneDisposeObserver;
  112203. private _originalPointerObserver;
  112204. /**
  112205. * Instantiates a UtilityLayerRenderer
  112206. * @param originalScene the original scene that will be rendered on top of
  112207. * @param handleEvents boolean indicating if the utility layer should handle events
  112208. */
  112209. constructor(
  112210. /** the original scene that will be rendered on top of */
  112211. originalScene: Scene, handleEvents?: boolean);
  112212. private _notifyObservers;
  112213. /**
  112214. * Renders the utility layers scene on top of the original scene
  112215. */
  112216. render(): void;
  112217. /**
  112218. * Disposes of the renderer
  112219. */
  112220. dispose(): void;
  112221. private _updateCamera;
  112222. }
  112223. }
  112224. declare module BABYLON {
  112225. /**
  112226. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  112227. */
  112228. export class Gizmo implements IDisposable {
  112229. /** The utility layer the gizmo will be added to */
  112230. gizmoLayer: UtilityLayerRenderer;
  112231. /**
  112232. * The root mesh of the gizmo
  112233. */
  112234. _rootMesh: Mesh;
  112235. private _attachedMesh;
  112236. /**
  112237. * Ratio for the scale of the gizmo (Default: 1)
  112238. */
  112239. scaleRatio: number;
  112240. /**
  112241. * If a custom mesh has been set (Default: false)
  112242. */
  112243. protected _customMeshSet: boolean;
  112244. /**
  112245. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  112246. * * When set, interactions will be enabled
  112247. */
  112248. attachedMesh: Nullable<AbstractMesh>;
  112249. /**
  112250. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112251. * @param mesh The mesh to replace the default mesh of the gizmo
  112252. */
  112253. setCustomMesh(mesh: Mesh): void;
  112254. /**
  112255. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  112256. */
  112257. updateGizmoRotationToMatchAttachedMesh: boolean;
  112258. /**
  112259. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  112260. */
  112261. updateGizmoPositionToMatchAttachedMesh: boolean;
  112262. /**
  112263. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  112264. */
  112265. updateScale: boolean;
  112266. protected _interactionsEnabled: boolean;
  112267. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112268. private _beforeRenderObserver;
  112269. private _tempVector;
  112270. /**
  112271. * Creates a gizmo
  112272. * @param gizmoLayer The utility layer the gizmo will be added to
  112273. */
  112274. constructor(
  112275. /** The utility layer the gizmo will be added to */
  112276. gizmoLayer?: UtilityLayerRenderer);
  112277. /**
  112278. * Updates the gizmo to match the attached mesh's position/rotation
  112279. */
  112280. protected _update(): void;
  112281. /**
  112282. * Disposes of the gizmo
  112283. */
  112284. dispose(): void;
  112285. }
  112286. }
  112287. declare module BABYLON {
  112288. /**
  112289. * Single plane drag gizmo
  112290. */
  112291. export class PlaneDragGizmo extends Gizmo {
  112292. /**
  112293. * Drag behavior responsible for the gizmos dragging interactions
  112294. */
  112295. dragBehavior: PointerDragBehavior;
  112296. private _pointerObserver;
  112297. /**
  112298. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112299. */
  112300. snapDistance: number;
  112301. /**
  112302. * Event that fires each time the gizmo snaps to a new location.
  112303. * * snapDistance is the the change in distance
  112304. */
  112305. onSnapObservable: Observable<{
  112306. snapDistance: number;
  112307. }>;
  112308. private _plane;
  112309. private _coloredMaterial;
  112310. private _hoverMaterial;
  112311. private _isEnabled;
  112312. private _parent;
  112313. /** @hidden */
  112314. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  112315. /** @hidden */
  112316. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112317. /**
  112318. * Creates a PlaneDragGizmo
  112319. * @param gizmoLayer The utility layer the gizmo will be added to
  112320. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  112321. * @param color The color of the gizmo
  112322. */
  112323. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112324. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112325. /**
  112326. * If the gizmo is enabled
  112327. */
  112328. isEnabled: boolean;
  112329. /**
  112330. * Disposes of the gizmo
  112331. */
  112332. dispose(): void;
  112333. }
  112334. }
  112335. declare module BABYLON {
  112336. /**
  112337. * Gizmo that enables dragging a mesh along 3 axis
  112338. */
  112339. export class PositionGizmo extends Gizmo {
  112340. /**
  112341. * Internal gizmo used for interactions on the x axis
  112342. */
  112343. xGizmo: AxisDragGizmo;
  112344. /**
  112345. * Internal gizmo used for interactions on the y axis
  112346. */
  112347. yGizmo: AxisDragGizmo;
  112348. /**
  112349. * Internal gizmo used for interactions on the z axis
  112350. */
  112351. zGizmo: AxisDragGizmo;
  112352. /**
  112353. * Internal gizmo used for interactions on the yz plane
  112354. */
  112355. xPlaneGizmo: PlaneDragGizmo;
  112356. /**
  112357. * Internal gizmo used for interactions on the xz plane
  112358. */
  112359. yPlaneGizmo: PlaneDragGizmo;
  112360. /**
  112361. * Internal gizmo used for interactions on the xy plane
  112362. */
  112363. zPlaneGizmo: PlaneDragGizmo;
  112364. /**
  112365. * private variables
  112366. */
  112367. private _meshAttached;
  112368. private _updateGizmoRotationToMatchAttachedMesh;
  112369. private _snapDistance;
  112370. private _scaleRatio;
  112371. /** Fires an event when any of it's sub gizmos are dragged */
  112372. onDragStartObservable: Observable<unknown>;
  112373. /** Fires an event when any of it's sub gizmos are released from dragging */
  112374. onDragEndObservable: Observable<unknown>;
  112375. /**
  112376. * If set to true, planar drag is enabled
  112377. */
  112378. private _planarGizmoEnabled;
  112379. attachedMesh: Nullable<AbstractMesh>;
  112380. /**
  112381. * Creates a PositionGizmo
  112382. * @param gizmoLayer The utility layer the gizmo will be added to
  112383. */
  112384. constructor(gizmoLayer?: UtilityLayerRenderer);
  112385. /**
  112386. * If the planar drag gizmo is enabled
  112387. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  112388. */
  112389. planarGizmoEnabled: boolean;
  112390. updateGizmoRotationToMatchAttachedMesh: boolean;
  112391. /**
  112392. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112393. */
  112394. snapDistance: number;
  112395. /**
  112396. * Ratio for the scale of the gizmo (Default: 1)
  112397. */
  112398. scaleRatio: number;
  112399. /**
  112400. * Disposes of the gizmo
  112401. */
  112402. dispose(): void;
  112403. /**
  112404. * CustomMeshes are not supported by this gizmo
  112405. * @param mesh The mesh to replace the default mesh of the gizmo
  112406. */
  112407. setCustomMesh(mesh: Mesh): void;
  112408. }
  112409. }
  112410. declare module BABYLON {
  112411. /**
  112412. * Single axis drag gizmo
  112413. */
  112414. export class AxisDragGizmo extends Gizmo {
  112415. /**
  112416. * Drag behavior responsible for the gizmos dragging interactions
  112417. */
  112418. dragBehavior: PointerDragBehavior;
  112419. private _pointerObserver;
  112420. /**
  112421. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112422. */
  112423. snapDistance: number;
  112424. /**
  112425. * Event that fires each time the gizmo snaps to a new location.
  112426. * * snapDistance is the the change in distance
  112427. */
  112428. onSnapObservable: Observable<{
  112429. snapDistance: number;
  112430. }>;
  112431. private _isEnabled;
  112432. private _parent;
  112433. private _arrow;
  112434. private _coloredMaterial;
  112435. private _hoverMaterial;
  112436. /** @hidden */
  112437. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  112438. /** @hidden */
  112439. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112440. /**
  112441. * Creates an AxisDragGizmo
  112442. * @param gizmoLayer The utility layer the gizmo will be added to
  112443. * @param dragAxis The axis which the gizmo will be able to drag on
  112444. * @param color The color of the gizmo
  112445. */
  112446. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112447. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112448. /**
  112449. * If the gizmo is enabled
  112450. */
  112451. isEnabled: boolean;
  112452. /**
  112453. * Disposes of the gizmo
  112454. */
  112455. dispose(): void;
  112456. }
  112457. }
  112458. declare module BABYLON.Debug {
  112459. /**
  112460. * The Axes viewer will show 3 axes in a specific point in space
  112461. */
  112462. export class AxesViewer {
  112463. private _xAxis;
  112464. private _yAxis;
  112465. private _zAxis;
  112466. private _scaleLinesFactor;
  112467. private _instanced;
  112468. /**
  112469. * Gets the hosting scene
  112470. */
  112471. scene: Scene;
  112472. /**
  112473. * Gets or sets a number used to scale line length
  112474. */
  112475. scaleLines: number;
  112476. /** Gets the node hierarchy used to render x-axis */
  112477. readonly xAxis: TransformNode;
  112478. /** Gets the node hierarchy used to render y-axis */
  112479. readonly yAxis: TransformNode;
  112480. /** Gets the node hierarchy used to render z-axis */
  112481. readonly zAxis: TransformNode;
  112482. /**
  112483. * Creates a new AxesViewer
  112484. * @param scene defines the hosting scene
  112485. * @param scaleLines defines a number used to scale line length (1 by default)
  112486. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  112487. * @param xAxis defines the node hierarchy used to render the x-axis
  112488. * @param yAxis defines the node hierarchy used to render the y-axis
  112489. * @param zAxis defines the node hierarchy used to render the z-axis
  112490. */
  112491. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  112492. /**
  112493. * Force the viewer to update
  112494. * @param position defines the position of the viewer
  112495. * @param xaxis defines the x axis of the viewer
  112496. * @param yaxis defines the y axis of the viewer
  112497. * @param zaxis defines the z axis of the viewer
  112498. */
  112499. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  112500. /**
  112501. * Creates an instance of this axes viewer.
  112502. * @returns a new axes viewer with instanced meshes
  112503. */
  112504. createInstance(): AxesViewer;
  112505. /** Releases resources */
  112506. dispose(): void;
  112507. private static _SetRenderingGroupId;
  112508. }
  112509. }
  112510. declare module BABYLON.Debug {
  112511. /**
  112512. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  112513. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  112514. */
  112515. export class BoneAxesViewer extends AxesViewer {
  112516. /**
  112517. * Gets or sets the target mesh where to display the axes viewer
  112518. */
  112519. mesh: Nullable<Mesh>;
  112520. /**
  112521. * Gets or sets the target bone where to display the axes viewer
  112522. */
  112523. bone: Nullable<Bone>;
  112524. /** Gets current position */
  112525. pos: Vector3;
  112526. /** Gets direction of X axis */
  112527. xaxis: Vector3;
  112528. /** Gets direction of Y axis */
  112529. yaxis: Vector3;
  112530. /** Gets direction of Z axis */
  112531. zaxis: Vector3;
  112532. /**
  112533. * Creates a new BoneAxesViewer
  112534. * @param scene defines the hosting scene
  112535. * @param bone defines the target bone
  112536. * @param mesh defines the target mesh
  112537. * @param scaleLines defines a scaling factor for line length (1 by default)
  112538. */
  112539. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  112540. /**
  112541. * Force the viewer to update
  112542. */
  112543. update(): void;
  112544. /** Releases resources */
  112545. dispose(): void;
  112546. }
  112547. }
  112548. declare module BABYLON {
  112549. /**
  112550. * Interface used to define scene explorer extensibility option
  112551. */
  112552. export interface IExplorerExtensibilityOption {
  112553. /**
  112554. * Define the option label
  112555. */
  112556. label: string;
  112557. /**
  112558. * Defines the action to execute on click
  112559. */
  112560. action: (entity: any) => void;
  112561. }
  112562. /**
  112563. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  112564. */
  112565. export interface IExplorerExtensibilityGroup {
  112566. /**
  112567. * Defines a predicate to test if a given type mut be extended
  112568. */
  112569. predicate: (entity: any) => boolean;
  112570. /**
  112571. * Gets the list of options added to a type
  112572. */
  112573. entries: IExplorerExtensibilityOption[];
  112574. }
  112575. /**
  112576. * Interface used to define the options to use to create the Inspector
  112577. */
  112578. export interface IInspectorOptions {
  112579. /**
  112580. * Display in overlay mode (default: false)
  112581. */
  112582. overlay?: boolean;
  112583. /**
  112584. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  112585. */
  112586. globalRoot?: HTMLElement;
  112587. /**
  112588. * Display the Scene explorer
  112589. */
  112590. showExplorer?: boolean;
  112591. /**
  112592. * Display the property inspector
  112593. */
  112594. showInspector?: boolean;
  112595. /**
  112596. * Display in embed mode (both panes on the right)
  112597. */
  112598. embedMode?: boolean;
  112599. /**
  112600. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  112601. */
  112602. handleResize?: boolean;
  112603. /**
  112604. * Allow the panes to popup (default: true)
  112605. */
  112606. enablePopup?: boolean;
  112607. /**
  112608. * Allow the panes to be closed by users (default: true)
  112609. */
  112610. enableClose?: boolean;
  112611. /**
  112612. * Optional list of extensibility entries
  112613. */
  112614. explorerExtensibility?: IExplorerExtensibilityGroup[];
  112615. /**
  112616. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  112617. */
  112618. inspectorURL?: string;
  112619. }
  112620. interface Scene {
  112621. /**
  112622. * @hidden
  112623. * Backing field
  112624. */
  112625. _debugLayer: DebugLayer;
  112626. /**
  112627. * Gets the debug layer (aka Inspector) associated with the scene
  112628. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112629. */
  112630. debugLayer: DebugLayer;
  112631. }
  112632. /**
  112633. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112634. * what is happening in your scene
  112635. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112636. */
  112637. export class DebugLayer {
  112638. /**
  112639. * Define the url to get the inspector script from.
  112640. * By default it uses the babylonjs CDN.
  112641. * @ignoreNaming
  112642. */
  112643. static InspectorURL: string;
  112644. private _scene;
  112645. private BJSINSPECTOR;
  112646. private _onPropertyChangedObservable?;
  112647. /**
  112648. * Observable triggered when a property is changed through the inspector.
  112649. */
  112650. readonly onPropertyChangedObservable: any;
  112651. /**
  112652. * Instantiates a new debug layer.
  112653. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112654. * what is happening in your scene
  112655. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112656. * @param scene Defines the scene to inspect
  112657. */
  112658. constructor(scene: Scene);
  112659. /** Creates the inspector window. */
  112660. private _createInspector;
  112661. /**
  112662. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  112663. * @param entity defines the entity to select
  112664. * @param lineContainerTitle defines the specific block to highlight
  112665. */
  112666. select(entity: any, lineContainerTitle?: string): void;
  112667. /** Get the inspector from bundle or global */
  112668. private _getGlobalInspector;
  112669. /**
  112670. * Get if the inspector is visible or not.
  112671. * @returns true if visible otherwise, false
  112672. */
  112673. isVisible(): boolean;
  112674. /**
  112675. * Hide the inspector and close its window.
  112676. */
  112677. hide(): void;
  112678. /**
  112679. * Launch the debugLayer.
  112680. * @param config Define the configuration of the inspector
  112681. * @return a promise fulfilled when the debug layer is visible
  112682. */
  112683. show(config?: IInspectorOptions): Promise<DebugLayer>;
  112684. }
  112685. }
  112686. declare module BABYLON {
  112687. /**
  112688. * Class containing static functions to help procedurally build meshes
  112689. */
  112690. export class BoxBuilder {
  112691. /**
  112692. * Creates a box mesh
  112693. * * The parameter `size` sets the size (float) of each box side (default 1)
  112694. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  112695. * * 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)
  112696. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  112697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112700. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  112701. * @param name defines the name of the mesh
  112702. * @param options defines the options used to create the mesh
  112703. * @param scene defines the hosting scene
  112704. * @returns the box mesh
  112705. */
  112706. static CreateBox(name: string, options: {
  112707. size?: number;
  112708. width?: number;
  112709. height?: number;
  112710. depth?: number;
  112711. faceUV?: Vector4[];
  112712. faceColors?: Color4[];
  112713. sideOrientation?: number;
  112714. frontUVs?: Vector4;
  112715. backUVs?: Vector4;
  112716. wrap?: boolean;
  112717. topBaseAt?: number;
  112718. bottomBaseAt?: number;
  112719. updatable?: boolean;
  112720. }, scene?: Nullable<Scene>): Mesh;
  112721. }
  112722. }
  112723. declare module BABYLON {
  112724. /**
  112725. * Class containing static functions to help procedurally build meshes
  112726. */
  112727. export class SphereBuilder {
  112728. /**
  112729. * Creates a sphere mesh
  112730. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  112731. * * 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`)
  112732. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  112733. * * 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
  112734. * * 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)
  112735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112738. * @param name defines the name of the mesh
  112739. * @param options defines the options used to create the mesh
  112740. * @param scene defines the hosting scene
  112741. * @returns the sphere mesh
  112742. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  112743. */
  112744. static CreateSphere(name: string, options: {
  112745. segments?: number;
  112746. diameter?: number;
  112747. diameterX?: number;
  112748. diameterY?: number;
  112749. diameterZ?: number;
  112750. arc?: number;
  112751. slice?: number;
  112752. sideOrientation?: number;
  112753. frontUVs?: Vector4;
  112754. backUVs?: Vector4;
  112755. updatable?: boolean;
  112756. }, scene?: Nullable<Scene>): Mesh;
  112757. }
  112758. }
  112759. declare module BABYLON.Debug {
  112760. /**
  112761. * Used to show the physics impostor around the specific mesh
  112762. */
  112763. export class PhysicsViewer {
  112764. /** @hidden */
  112765. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  112766. /** @hidden */
  112767. protected _meshes: Array<Nullable<AbstractMesh>>;
  112768. /** @hidden */
  112769. protected _scene: Nullable<Scene>;
  112770. /** @hidden */
  112771. protected _numMeshes: number;
  112772. /** @hidden */
  112773. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  112774. private _renderFunction;
  112775. private _utilityLayer;
  112776. private _debugBoxMesh;
  112777. private _debugSphereMesh;
  112778. private _debugCylinderMesh;
  112779. private _debugMaterial;
  112780. private _debugMeshMeshes;
  112781. /**
  112782. * Creates a new PhysicsViewer
  112783. * @param scene defines the hosting scene
  112784. */
  112785. constructor(scene: Scene);
  112786. /** @hidden */
  112787. protected _updateDebugMeshes(): void;
  112788. /**
  112789. * Renders a specified physic impostor
  112790. * @param impostor defines the impostor to render
  112791. * @param targetMesh defines the mesh represented by the impostor
  112792. * @returns the new debug mesh used to render the impostor
  112793. */
  112794. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  112795. /**
  112796. * Hides a specified physic impostor
  112797. * @param impostor defines the impostor to hide
  112798. */
  112799. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  112800. private _getDebugMaterial;
  112801. private _getDebugBoxMesh;
  112802. private _getDebugSphereMesh;
  112803. private _getDebugCylinderMesh;
  112804. private _getDebugMeshMesh;
  112805. private _getDebugMesh;
  112806. /** Releases all resources */
  112807. dispose(): void;
  112808. }
  112809. }
  112810. declare module BABYLON {
  112811. /**
  112812. * Class containing static functions to help procedurally build meshes
  112813. */
  112814. export class LinesBuilder {
  112815. /**
  112816. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  112817. * * 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
  112818. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  112819. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  112820. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  112821. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  112822. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  112823. * * 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
  112824. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  112825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  112827. * @param name defines the name of the new line system
  112828. * @param options defines the options used to create the line system
  112829. * @param scene defines the hosting scene
  112830. * @returns a new line system mesh
  112831. */
  112832. static CreateLineSystem(name: string, options: {
  112833. lines: Vector3[][];
  112834. updatable?: boolean;
  112835. instance?: Nullable<LinesMesh>;
  112836. colors?: Nullable<Color4[][]>;
  112837. useVertexAlpha?: boolean;
  112838. }, scene: Nullable<Scene>): LinesMesh;
  112839. /**
  112840. * Creates a line mesh
  112841. * 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
  112842. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112843. * * The parameter `points` is an array successive Vector3
  112844. * * 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
  112845. * * The optional parameter `colors` is an array of successive Color4, one per line point
  112846. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  112847. * * When updating an instance, remember that only point positions can change, not the number of points
  112848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  112850. * @param name defines the name of the new line system
  112851. * @param options defines the options used to create the line system
  112852. * @param scene defines the hosting scene
  112853. * @returns a new line mesh
  112854. */
  112855. static CreateLines(name: string, options: {
  112856. points: Vector3[];
  112857. updatable?: boolean;
  112858. instance?: Nullable<LinesMesh>;
  112859. colors?: Color4[];
  112860. useVertexAlpha?: boolean;
  112861. }, scene?: Nullable<Scene>): LinesMesh;
  112862. /**
  112863. * Creates a dashed line mesh
  112864. * * 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
  112865. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112866. * * The parameter `points` is an array successive Vector3
  112867. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  112868. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  112869. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  112870. * * 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
  112871. * * When updating an instance, remember that only point positions can change, not the number of points
  112872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112873. * @param name defines the name of the mesh
  112874. * @param options defines the options used to create the mesh
  112875. * @param scene defines the hosting scene
  112876. * @returns the dashed line mesh
  112877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  112878. */
  112879. static CreateDashedLines(name: string, options: {
  112880. points: Vector3[];
  112881. dashSize?: number;
  112882. gapSize?: number;
  112883. dashNb?: number;
  112884. updatable?: boolean;
  112885. instance?: LinesMesh;
  112886. }, scene?: Nullable<Scene>): LinesMesh;
  112887. }
  112888. }
  112889. declare module BABYLON {
  112890. /**
  112891. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112892. * in order to better appreciate the issue one might have.
  112893. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112894. */
  112895. export class RayHelper {
  112896. /**
  112897. * Defines the ray we are currently tryin to visualize.
  112898. */
  112899. ray: Nullable<Ray>;
  112900. private _renderPoints;
  112901. private _renderLine;
  112902. private _renderFunction;
  112903. private _scene;
  112904. private _updateToMeshFunction;
  112905. private _attachedToMesh;
  112906. private _meshSpaceDirection;
  112907. private _meshSpaceOrigin;
  112908. /**
  112909. * Helper function to create a colored helper in a scene in one line.
  112910. * @param ray Defines the ray we are currently tryin to visualize
  112911. * @param scene Defines the scene the ray is used in
  112912. * @param color Defines the color we want to see the ray in
  112913. * @returns The newly created ray helper.
  112914. */
  112915. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  112916. /**
  112917. * Instantiate a new ray helper.
  112918. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112919. * in order to better appreciate the issue one might have.
  112920. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112921. * @param ray Defines the ray we are currently tryin to visualize
  112922. */
  112923. constructor(ray: Ray);
  112924. /**
  112925. * Shows the ray we are willing to debug.
  112926. * @param scene Defines the scene the ray needs to be rendered in
  112927. * @param color Defines the color the ray needs to be rendered in
  112928. */
  112929. show(scene: Scene, color?: Color3): void;
  112930. /**
  112931. * Hides the ray we are debugging.
  112932. */
  112933. hide(): void;
  112934. private _render;
  112935. /**
  112936. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  112937. * @param mesh Defines the mesh we want the helper attached to
  112938. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  112939. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  112940. * @param length Defines the length of the ray
  112941. */
  112942. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  112943. /**
  112944. * Detach the ray helper from the mesh it has previously been attached to.
  112945. */
  112946. detachFromMesh(): void;
  112947. private _updateToMesh;
  112948. /**
  112949. * Dispose the helper and release its associated resources.
  112950. */
  112951. dispose(): void;
  112952. }
  112953. }
  112954. declare module BABYLON.Debug {
  112955. /**
  112956. * Class used to render a debug view of a given skeleton
  112957. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  112958. */
  112959. export class SkeletonViewer {
  112960. /** defines the skeleton to render */
  112961. skeleton: Skeleton;
  112962. /** defines the mesh attached to the skeleton */
  112963. mesh: AbstractMesh;
  112964. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112965. autoUpdateBonesMatrices: boolean;
  112966. /** defines the rendering group id to use with the viewer */
  112967. renderingGroupId: number;
  112968. /** Gets or sets the color used to render the skeleton */
  112969. color: Color3;
  112970. private _scene;
  112971. private _debugLines;
  112972. private _debugMesh;
  112973. private _isEnabled;
  112974. private _renderFunction;
  112975. private _utilityLayer;
  112976. /**
  112977. * Returns the mesh used to render the bones
  112978. */
  112979. readonly debugMesh: Nullable<LinesMesh>;
  112980. /**
  112981. * Creates a new SkeletonViewer
  112982. * @param skeleton defines the skeleton to render
  112983. * @param mesh defines the mesh attached to the skeleton
  112984. * @param scene defines the hosting scene
  112985. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112986. * @param renderingGroupId defines the rendering group id to use with the viewer
  112987. */
  112988. constructor(
  112989. /** defines the skeleton to render */
  112990. skeleton: Skeleton,
  112991. /** defines the mesh attached to the skeleton */
  112992. mesh: AbstractMesh, scene: Scene,
  112993. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112994. autoUpdateBonesMatrices?: boolean,
  112995. /** defines the rendering group id to use with the viewer */
  112996. renderingGroupId?: number);
  112997. /** Gets or sets a boolean indicating if the viewer is enabled */
  112998. isEnabled: boolean;
  112999. private _getBonePosition;
  113000. private _getLinesForBonesWithLength;
  113001. private _getLinesForBonesNoLength;
  113002. /** Update the viewer to sync with current skeleton state */
  113003. update(): void;
  113004. /** Release associated resources */
  113005. dispose(): void;
  113006. }
  113007. }
  113008. declare module BABYLON {
  113009. /**
  113010. * Options to create the null engine
  113011. */
  113012. export class NullEngineOptions {
  113013. /**
  113014. * Render width (Default: 512)
  113015. */
  113016. renderWidth: number;
  113017. /**
  113018. * Render height (Default: 256)
  113019. */
  113020. renderHeight: number;
  113021. /**
  113022. * Texture size (Default: 512)
  113023. */
  113024. textureSize: number;
  113025. /**
  113026. * If delta time between frames should be constant
  113027. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113028. */
  113029. deterministicLockstep: boolean;
  113030. /**
  113031. * Maximum about of steps between frames (Default: 4)
  113032. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113033. */
  113034. lockstepMaxSteps: number;
  113035. }
  113036. /**
  113037. * The null engine class provides support for headless version of babylon.js.
  113038. * This can be used in server side scenario or for testing purposes
  113039. */
  113040. export class NullEngine extends Engine {
  113041. private _options;
  113042. /**
  113043. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113044. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113045. * @returns true if engine is in deterministic lock step mode
  113046. */
  113047. isDeterministicLockStep(): boolean;
  113048. /**
  113049. * Gets the max steps when engine is running in deterministic lock step
  113050. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113051. * @returns the max steps
  113052. */
  113053. getLockstepMaxSteps(): number;
  113054. /**
  113055. * Gets the current hardware scaling level.
  113056. * By default the hardware scaling level is computed from the window device ratio.
  113057. * 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.
  113058. * @returns a number indicating the current hardware scaling level
  113059. */
  113060. getHardwareScalingLevel(): number;
  113061. constructor(options?: NullEngineOptions);
  113062. /**
  113063. * Creates a vertex buffer
  113064. * @param vertices the data for the vertex buffer
  113065. * @returns the new WebGL static buffer
  113066. */
  113067. createVertexBuffer(vertices: FloatArray): DataBuffer;
  113068. /**
  113069. * Creates a new index buffer
  113070. * @param indices defines the content of the index buffer
  113071. * @param updatable defines if the index buffer must be updatable
  113072. * @returns a new webGL buffer
  113073. */
  113074. createIndexBuffer(indices: IndicesArray): DataBuffer;
  113075. /**
  113076. * Clear the current render buffer or the current render target (if any is set up)
  113077. * @param color defines the color to use
  113078. * @param backBuffer defines if the back buffer must be cleared
  113079. * @param depth defines if the depth buffer must be cleared
  113080. * @param stencil defines if the stencil buffer must be cleared
  113081. */
  113082. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113083. /**
  113084. * Gets the current render width
  113085. * @param useScreen defines if screen size must be used (or the current render target if any)
  113086. * @returns a number defining the current render width
  113087. */
  113088. getRenderWidth(useScreen?: boolean): number;
  113089. /**
  113090. * Gets the current render height
  113091. * @param useScreen defines if screen size must be used (or the current render target if any)
  113092. * @returns a number defining the current render height
  113093. */
  113094. getRenderHeight(useScreen?: boolean): number;
  113095. /**
  113096. * Set the WebGL's viewport
  113097. * @param viewport defines the viewport element to be used
  113098. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  113099. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  113100. */
  113101. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  113102. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  113103. /**
  113104. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113105. * @param pipelineContext defines the pipeline context to use
  113106. * @param uniformsNames defines the list of uniform names
  113107. * @returns an array of webGL uniform locations
  113108. */
  113109. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113110. /**
  113111. * Gets the lsit of active attributes for a given webGL program
  113112. * @param pipelineContext defines the pipeline context to use
  113113. * @param attributesNames defines the list of attribute names to get
  113114. * @returns an array of indices indicating the offset of each attribute
  113115. */
  113116. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113117. /**
  113118. * Binds an effect to the webGL context
  113119. * @param effect defines the effect to bind
  113120. */
  113121. bindSamplers(effect: Effect): void;
  113122. /**
  113123. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113124. * @param effect defines the effect to activate
  113125. */
  113126. enableEffect(effect: Effect): void;
  113127. /**
  113128. * Set various states to the webGL context
  113129. * @param culling defines backface culling state
  113130. * @param zOffset defines the value to apply to zOffset (0 by default)
  113131. * @param force defines if states must be applied even if cache is up to date
  113132. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113133. */
  113134. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113135. /**
  113136. * Set the value of an uniform to an array of int32
  113137. * @param uniform defines the webGL uniform location where to store the value
  113138. * @param array defines the array of int32 to store
  113139. */
  113140. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113141. /**
  113142. * Set the value of an uniform to an array of int32 (stored as vec2)
  113143. * @param uniform defines the webGL uniform location where to store the value
  113144. * @param array defines the array of int32 to store
  113145. */
  113146. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113147. /**
  113148. * Set the value of an uniform to an array of int32 (stored as vec3)
  113149. * @param uniform defines the webGL uniform location where to store the value
  113150. * @param array defines the array of int32 to store
  113151. */
  113152. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113153. /**
  113154. * Set the value of an uniform to an array of int32 (stored as vec4)
  113155. * @param uniform defines the webGL uniform location where to store the value
  113156. * @param array defines the array of int32 to store
  113157. */
  113158. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113159. /**
  113160. * Set the value of an uniform to an array of float32
  113161. * @param uniform defines the webGL uniform location where to store the value
  113162. * @param array defines the array of float32 to store
  113163. */
  113164. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113165. /**
  113166. * Set the value of an uniform to an array of float32 (stored as vec2)
  113167. * @param uniform defines the webGL uniform location where to store the value
  113168. * @param array defines the array of float32 to store
  113169. */
  113170. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113171. /**
  113172. * Set the value of an uniform to an array of float32 (stored as vec3)
  113173. * @param uniform defines the webGL uniform location where to store the value
  113174. * @param array defines the array of float32 to store
  113175. */
  113176. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113177. /**
  113178. * Set the value of an uniform to an array of float32 (stored as vec4)
  113179. * @param uniform defines the webGL uniform location where to store the value
  113180. * @param array defines the array of float32 to store
  113181. */
  113182. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113183. /**
  113184. * Set the value of an uniform to an array of number
  113185. * @param uniform defines the webGL uniform location where to store the value
  113186. * @param array defines the array of number to store
  113187. */
  113188. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113189. /**
  113190. * Set the value of an uniform to an array of number (stored as vec2)
  113191. * @param uniform defines the webGL uniform location where to store the value
  113192. * @param array defines the array of number to store
  113193. */
  113194. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113195. /**
  113196. * Set the value of an uniform to an array of number (stored as vec3)
  113197. * @param uniform defines the webGL uniform location where to store the value
  113198. * @param array defines the array of number to store
  113199. */
  113200. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113201. /**
  113202. * Set the value of an uniform to an array of number (stored as vec4)
  113203. * @param uniform defines the webGL uniform location where to store the value
  113204. * @param array defines the array of number to store
  113205. */
  113206. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113207. /**
  113208. * Set the value of an uniform to an array of float32 (stored as matrices)
  113209. * @param uniform defines the webGL uniform location where to store the value
  113210. * @param matrices defines the array of float32 to store
  113211. */
  113212. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113213. /**
  113214. * Set the value of an uniform to a matrix (3x3)
  113215. * @param uniform defines the webGL uniform location where to store the value
  113216. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113217. */
  113218. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113219. /**
  113220. * Set the value of an uniform to a matrix (2x2)
  113221. * @param uniform defines the webGL uniform location where to store the value
  113222. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113223. */
  113224. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113225. /**
  113226. * Set the value of an uniform to a number (float)
  113227. * @param uniform defines the webGL uniform location where to store the value
  113228. * @param value defines the float number to store
  113229. */
  113230. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113231. /**
  113232. * Set the value of an uniform to a vec2
  113233. * @param uniform defines the webGL uniform location where to store the value
  113234. * @param x defines the 1st component of the value
  113235. * @param y defines the 2nd component of the value
  113236. */
  113237. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113238. /**
  113239. * Set the value of an uniform to a vec3
  113240. * @param uniform defines the webGL uniform location where to store the value
  113241. * @param x defines the 1st component of the value
  113242. * @param y defines the 2nd component of the value
  113243. * @param z defines the 3rd component of the value
  113244. */
  113245. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113246. /**
  113247. * Set the value of an uniform to a boolean
  113248. * @param uniform defines the webGL uniform location where to store the value
  113249. * @param bool defines the boolean to store
  113250. */
  113251. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113252. /**
  113253. * Set the value of an uniform to a vec4
  113254. * @param uniform defines the webGL uniform location where to store the value
  113255. * @param x defines the 1st component of the value
  113256. * @param y defines the 2nd component of the value
  113257. * @param z defines the 3rd component of the value
  113258. * @param w defines the 4th component of the value
  113259. */
  113260. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113261. /**
  113262. * Sets the current alpha mode
  113263. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113264. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113265. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113266. */
  113267. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113268. /**
  113269. * Bind webGl buffers directly to the webGL context
  113270. * @param vertexBuffers defines the vertex buffer to bind
  113271. * @param indexBuffer defines the index buffer to bind
  113272. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  113273. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  113274. * @param effect defines the effect associated with the vertex buffer
  113275. */
  113276. bindBuffers(vertexBuffers: {
  113277. [key: string]: VertexBuffer;
  113278. }, indexBuffer: DataBuffer, effect: Effect): void;
  113279. /**
  113280. * Force the entire cache to be cleared
  113281. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113282. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113283. */
  113284. wipeCaches(bruteForce?: boolean): void;
  113285. /**
  113286. * Send a draw order
  113287. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113288. * @param indexStart defines the starting index
  113289. * @param indexCount defines the number of index to draw
  113290. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113291. */
  113292. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113293. /**
  113294. * Draw a list of indexed primitives
  113295. * @param fillMode defines the primitive to use
  113296. * @param indexStart defines the starting index
  113297. * @param indexCount defines the number of index to draw
  113298. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113299. */
  113300. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113301. /**
  113302. * Draw a list of unindexed primitives
  113303. * @param fillMode defines the primitive to use
  113304. * @param verticesStart defines the index of first vertex to draw
  113305. * @param verticesCount defines the count of vertices to draw
  113306. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113307. */
  113308. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113309. /** @hidden */
  113310. _createTexture(): WebGLTexture;
  113311. /** @hidden */
  113312. _releaseTexture(texture: InternalTexture): void;
  113313. /**
  113314. * Usually called from Texture.ts.
  113315. * Passed information to create a WebGLTexture
  113316. * @param urlArg defines a value which contains one of the following:
  113317. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113318. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113319. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113320. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113321. * @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)
  113322. * @param scene needed for loading to the correct scene
  113323. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113324. * @param onLoad optional callback to be called upon successful completion
  113325. * @param onError optional callback to be called upon failure
  113326. * @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
  113327. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113328. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113329. * @param forcedExtension defines the extension to use to pick the right loader
  113330. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  113331. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113332. */
  113333. 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;
  113334. /**
  113335. * Creates a new render target texture
  113336. * @param size defines the size of the texture
  113337. * @param options defines the options used to create the texture
  113338. * @returns a new render target texture stored in an InternalTexture
  113339. */
  113340. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  113341. /**
  113342. * Update the sampling mode of a given texture
  113343. * @param samplingMode defines the required sampling mode
  113344. * @param texture defines the texture to update
  113345. */
  113346. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113347. /**
  113348. * Binds the frame buffer to the specified texture.
  113349. * @param texture The texture to render to or null for the default canvas
  113350. * @param faceIndex The face of the texture to render to in case of cube texture
  113351. * @param requiredWidth The width of the target to render to
  113352. * @param requiredHeight The height of the target to render to
  113353. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  113354. * @param depthStencilTexture The depth stencil texture to use to render
  113355. * @param lodLevel defines le lod level to bind to the frame buffer
  113356. */
  113357. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113358. /**
  113359. * Unbind the current render target texture from the webGL context
  113360. * @param texture defines the render target texture to unbind
  113361. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113362. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113363. */
  113364. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113365. /**
  113366. * Creates a dynamic vertex buffer
  113367. * @param vertices the data for the dynamic vertex buffer
  113368. * @returns the new WebGL dynamic buffer
  113369. */
  113370. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  113371. /**
  113372. * Update the content of a dynamic texture
  113373. * @param texture defines the texture to update
  113374. * @param canvas defines the canvas containing the source
  113375. * @param invertY defines if data must be stored with Y axis inverted
  113376. * @param premulAlpha defines if alpha is stored as premultiplied
  113377. * @param format defines the format of the data
  113378. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113379. */
  113380. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  113381. /**
  113382. * Gets a boolean indicating if all created effects are ready
  113383. * @returns true if all effects are ready
  113384. */
  113385. areAllEffectsReady(): boolean;
  113386. /**
  113387. * @hidden
  113388. * Get the current error code of the webGL context
  113389. * @returns the error code
  113390. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113391. */
  113392. getError(): number;
  113393. /** @hidden */
  113394. _getUnpackAlignement(): number;
  113395. /** @hidden */
  113396. _unpackFlipY(value: boolean): void;
  113397. /**
  113398. * Update a dynamic index buffer
  113399. * @param indexBuffer defines the target index buffer
  113400. * @param indices defines the data to update
  113401. * @param offset defines the offset in the target index buffer where update should start
  113402. */
  113403. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  113404. /**
  113405. * Updates a dynamic vertex buffer.
  113406. * @param vertexBuffer the vertex buffer to update
  113407. * @param vertices the data used to update the vertex buffer
  113408. * @param byteOffset the byte offset of the data (optional)
  113409. * @param byteLength the byte length of the data (optional)
  113410. */
  113411. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  113412. /** @hidden */
  113413. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  113414. /** @hidden */
  113415. _bindTexture(channel: number, texture: InternalTexture): void;
  113416. protected _deleteBuffer(buffer: WebGLBuffer): void;
  113417. /**
  113418. * 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
  113419. */
  113420. releaseEffects(): void;
  113421. displayLoadingUI(): void;
  113422. hideLoadingUI(): void;
  113423. /** @hidden */
  113424. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113425. /** @hidden */
  113426. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113427. /** @hidden */
  113428. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113429. /** @hidden */
  113430. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113431. }
  113432. }
  113433. declare module BABYLON {
  113434. /** @hidden */
  113435. export class _OcclusionDataStorage {
  113436. /** @hidden */
  113437. occlusionInternalRetryCounter: number;
  113438. /** @hidden */
  113439. isOcclusionQueryInProgress: boolean;
  113440. /** @hidden */
  113441. isOccluded: boolean;
  113442. /** @hidden */
  113443. occlusionRetryCount: number;
  113444. /** @hidden */
  113445. occlusionType: number;
  113446. /** @hidden */
  113447. occlusionQueryAlgorithmType: number;
  113448. }
  113449. interface Engine {
  113450. /**
  113451. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  113452. * @return the new query
  113453. */
  113454. createQuery(): WebGLQuery;
  113455. /**
  113456. * Delete and release a webGL query
  113457. * @param query defines the query to delete
  113458. * @return the current engine
  113459. */
  113460. deleteQuery(query: WebGLQuery): Engine;
  113461. /**
  113462. * Check if a given query has resolved and got its value
  113463. * @param query defines the query to check
  113464. * @returns true if the query got its value
  113465. */
  113466. isQueryResultAvailable(query: WebGLQuery): boolean;
  113467. /**
  113468. * Gets the value of a given query
  113469. * @param query defines the query to check
  113470. * @returns the value of the query
  113471. */
  113472. getQueryResult(query: WebGLQuery): number;
  113473. /**
  113474. * Initiates an occlusion query
  113475. * @param algorithmType defines the algorithm to use
  113476. * @param query defines the query to use
  113477. * @returns the current engine
  113478. * @see http://doc.babylonjs.com/features/occlusionquery
  113479. */
  113480. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  113481. /**
  113482. * Ends an occlusion query
  113483. * @see http://doc.babylonjs.com/features/occlusionquery
  113484. * @param algorithmType defines the algorithm to use
  113485. * @returns the current engine
  113486. */
  113487. endOcclusionQuery(algorithmType: number): Engine;
  113488. /**
  113489. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  113490. * Please note that only one query can be issued at a time
  113491. * @returns a time token used to track the time span
  113492. */
  113493. startTimeQuery(): Nullable<_TimeToken>;
  113494. /**
  113495. * Ends a time query
  113496. * @param token defines the token used to measure the time span
  113497. * @returns the time spent (in ns)
  113498. */
  113499. endTimeQuery(token: _TimeToken): int;
  113500. /** @hidden */
  113501. _currentNonTimestampToken: Nullable<_TimeToken>;
  113502. /** @hidden */
  113503. _createTimeQuery(): WebGLQuery;
  113504. /** @hidden */
  113505. _deleteTimeQuery(query: WebGLQuery): void;
  113506. /** @hidden */
  113507. _getGlAlgorithmType(algorithmType: number): number;
  113508. /** @hidden */
  113509. _getTimeQueryResult(query: WebGLQuery): any;
  113510. /** @hidden */
  113511. _getTimeQueryAvailability(query: WebGLQuery): any;
  113512. }
  113513. interface AbstractMesh {
  113514. /**
  113515. * Backing filed
  113516. * @hidden
  113517. */
  113518. __occlusionDataStorage: _OcclusionDataStorage;
  113519. /**
  113520. * Access property
  113521. * @hidden
  113522. */
  113523. _occlusionDataStorage: _OcclusionDataStorage;
  113524. /**
  113525. * 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.
  113526. * The default value is -1 which means don't break the query and wait till the result
  113527. * @see http://doc.babylonjs.com/features/occlusionquery
  113528. */
  113529. occlusionRetryCount: number;
  113530. /**
  113531. * 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:
  113532. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  113533. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  113534. * * 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.
  113535. * @see http://doc.babylonjs.com/features/occlusionquery
  113536. */
  113537. occlusionType: number;
  113538. /**
  113539. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  113540. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  113541. * * 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.
  113542. * @see http://doc.babylonjs.com/features/occlusionquery
  113543. */
  113544. occlusionQueryAlgorithmType: number;
  113545. /**
  113546. * 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
  113547. * @see http://doc.babylonjs.com/features/occlusionquery
  113548. */
  113549. isOccluded: boolean;
  113550. /**
  113551. * Flag to check the progress status of the query
  113552. * @see http://doc.babylonjs.com/features/occlusionquery
  113553. */
  113554. isOcclusionQueryInProgress: boolean;
  113555. }
  113556. }
  113557. declare module BABYLON {
  113558. /** @hidden */
  113559. export var _forceTransformFeedbackToBundle: boolean;
  113560. interface Engine {
  113561. /**
  113562. * Creates a webGL transform feedback object
  113563. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  113564. * @returns the webGL transform feedback object
  113565. */
  113566. createTransformFeedback(): WebGLTransformFeedback;
  113567. /**
  113568. * Delete a webGL transform feedback object
  113569. * @param value defines the webGL transform feedback object to delete
  113570. */
  113571. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  113572. /**
  113573. * Bind a webGL transform feedback object to the webgl context
  113574. * @param value defines the webGL transform feedback object to bind
  113575. */
  113576. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  113577. /**
  113578. * Begins a transform feedback operation
  113579. * @param usePoints defines if points or triangles must be used
  113580. */
  113581. beginTransformFeedback(usePoints: boolean): void;
  113582. /**
  113583. * Ends a transform feedback operation
  113584. */
  113585. endTransformFeedback(): void;
  113586. /**
  113587. * Specify the varyings to use with transform feedback
  113588. * @param program defines the associated webGL program
  113589. * @param value defines the list of strings representing the varying names
  113590. */
  113591. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  113592. /**
  113593. * Bind a webGL buffer for a transform feedback operation
  113594. * @param value defines the webGL buffer to bind
  113595. */
  113596. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  113597. }
  113598. }
  113599. declare module BABYLON {
  113600. /**
  113601. * Creation options of the multi render target texture.
  113602. */
  113603. export interface IMultiRenderTargetOptions {
  113604. /**
  113605. * Define if the texture needs to create mip maps after render.
  113606. */
  113607. generateMipMaps?: boolean;
  113608. /**
  113609. * Define the types of all the draw buffers we want to create
  113610. */
  113611. types?: number[];
  113612. /**
  113613. * Define the sampling modes of all the draw buffers we want to create
  113614. */
  113615. samplingModes?: number[];
  113616. /**
  113617. * Define if a depth buffer is required
  113618. */
  113619. generateDepthBuffer?: boolean;
  113620. /**
  113621. * Define if a stencil buffer is required
  113622. */
  113623. generateStencilBuffer?: boolean;
  113624. /**
  113625. * Define if a depth texture is required instead of a depth buffer
  113626. */
  113627. generateDepthTexture?: boolean;
  113628. /**
  113629. * Define the number of desired draw buffers
  113630. */
  113631. textureCount?: number;
  113632. /**
  113633. * Define if aspect ratio should be adapted to the texture or stay the scene one
  113634. */
  113635. doNotChangeAspectRatio?: boolean;
  113636. /**
  113637. * Define the default type of the buffers we are creating
  113638. */
  113639. defaultType?: number;
  113640. }
  113641. /**
  113642. * A multi render target, like a render target provides the ability to render to a texture.
  113643. * Unlike the render target, it can render to several draw buffers in one draw.
  113644. * This is specially interesting in deferred rendering or for any effects requiring more than
  113645. * just one color from a single pass.
  113646. */
  113647. export class MultiRenderTarget extends RenderTargetTexture {
  113648. private _internalTextures;
  113649. private _textures;
  113650. private _multiRenderTargetOptions;
  113651. /**
  113652. * Get if draw buffers are currently supported by the used hardware and browser.
  113653. */
  113654. readonly isSupported: boolean;
  113655. /**
  113656. * Get the list of textures generated by the multi render target.
  113657. */
  113658. readonly textures: Texture[];
  113659. /**
  113660. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  113661. */
  113662. readonly depthTexture: Texture;
  113663. /**
  113664. * Set the wrapping mode on U of all the textures we are rendering to.
  113665. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113666. */
  113667. wrapU: number;
  113668. /**
  113669. * Set the wrapping mode on V of all the textures we are rendering to.
  113670. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113671. */
  113672. wrapV: number;
  113673. /**
  113674. * Instantiate a new multi render target texture.
  113675. * A multi render target, like a render target provides the ability to render to a texture.
  113676. * Unlike the render target, it can render to several draw buffers in one draw.
  113677. * This is specially interesting in deferred rendering or for any effects requiring more than
  113678. * just one color from a single pass.
  113679. * @param name Define the name of the texture
  113680. * @param size Define the size of the buffers to render to
  113681. * @param count Define the number of target we are rendering into
  113682. * @param scene Define the scene the texture belongs to
  113683. * @param options Define the options used to create the multi render target
  113684. */
  113685. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  113686. /** @hidden */
  113687. _rebuild(): void;
  113688. private _createInternalTextures;
  113689. private _createTextures;
  113690. /**
  113691. * Define the number of samples used if MSAA is enabled.
  113692. */
  113693. samples: number;
  113694. /**
  113695. * Resize all the textures in the multi render target.
  113696. * Be carrefull as it will recreate all the data in the new texture.
  113697. * @param size Define the new size
  113698. */
  113699. resize(size: any): void;
  113700. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  113701. /**
  113702. * Dispose the render targets and their associated resources
  113703. */
  113704. dispose(): void;
  113705. /**
  113706. * Release all the underlying texture used as draw buffers.
  113707. */
  113708. releaseInternalTextures(): void;
  113709. }
  113710. }
  113711. declare module BABYLON {
  113712. interface ThinEngine {
  113713. /**
  113714. * Unbind a list of render target textures from the webGL context
  113715. * This is used only when drawBuffer extension or webGL2 are active
  113716. * @param textures defines the render target textures to unbind
  113717. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113718. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113719. */
  113720. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  113721. /**
  113722. * Create a multi render target texture
  113723. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  113724. * @param size defines the size of the texture
  113725. * @param options defines the creation options
  113726. * @returns the cube texture as an InternalTexture
  113727. */
  113728. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  113729. /**
  113730. * Update the sample count for a given multiple render target texture
  113731. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  113732. * @param textures defines the textures to update
  113733. * @param samples defines the sample count to set
  113734. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  113735. */
  113736. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  113737. }
  113738. }
  113739. declare module BABYLON {
  113740. /**
  113741. * Class used to define an additional view for the engine
  113742. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113743. */
  113744. export class EngineView {
  113745. /** Defines the canvas where to render the view */
  113746. target: HTMLCanvasElement;
  113747. /** Defines an optional camera used to render the view (will use active camera else) */
  113748. camera?: Camera;
  113749. }
  113750. interface Engine {
  113751. /**
  113752. * Gets or sets the HTML element to use for attaching events
  113753. */
  113754. inputElement: Nullable<HTMLElement>;
  113755. /**
  113756. * Gets the current engine view
  113757. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113758. */
  113759. activeView: Nullable<EngineView>;
  113760. /** Gets or sets the list of views */
  113761. views: EngineView[];
  113762. /**
  113763. * Register a new child canvas
  113764. * @param canvas defines the canvas to register
  113765. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  113766. * @returns the associated view
  113767. */
  113768. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  113769. /**
  113770. * Remove a registered child canvas
  113771. * @param canvas defines the canvas to remove
  113772. * @returns the current engine
  113773. */
  113774. unRegisterView(canvas: HTMLCanvasElement): Engine;
  113775. }
  113776. }
  113777. declare module BABYLON {
  113778. /**
  113779. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  113780. */
  113781. export interface CubeMapInfo {
  113782. /**
  113783. * The pixel array for the front face.
  113784. * This is stored in format, left to right, up to down format.
  113785. */
  113786. front: Nullable<ArrayBufferView>;
  113787. /**
  113788. * The pixel array for the back face.
  113789. * This is stored in format, left to right, up to down format.
  113790. */
  113791. back: Nullable<ArrayBufferView>;
  113792. /**
  113793. * The pixel array for the left face.
  113794. * This is stored in format, left to right, up to down format.
  113795. */
  113796. left: Nullable<ArrayBufferView>;
  113797. /**
  113798. * The pixel array for the right face.
  113799. * This is stored in format, left to right, up to down format.
  113800. */
  113801. right: Nullable<ArrayBufferView>;
  113802. /**
  113803. * The pixel array for the up face.
  113804. * This is stored in format, left to right, up to down format.
  113805. */
  113806. up: Nullable<ArrayBufferView>;
  113807. /**
  113808. * The pixel array for the down face.
  113809. * This is stored in format, left to right, up to down format.
  113810. */
  113811. down: Nullable<ArrayBufferView>;
  113812. /**
  113813. * The size of the cubemap stored.
  113814. *
  113815. * Each faces will be size * size pixels.
  113816. */
  113817. size: number;
  113818. /**
  113819. * The format of the texture.
  113820. *
  113821. * RGBA, RGB.
  113822. */
  113823. format: number;
  113824. /**
  113825. * The type of the texture data.
  113826. *
  113827. * UNSIGNED_INT, FLOAT.
  113828. */
  113829. type: number;
  113830. /**
  113831. * Specifies whether the texture is in gamma space.
  113832. */
  113833. gammaSpace: boolean;
  113834. }
  113835. /**
  113836. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  113837. */
  113838. export class PanoramaToCubeMapTools {
  113839. private static FACE_FRONT;
  113840. private static FACE_BACK;
  113841. private static FACE_RIGHT;
  113842. private static FACE_LEFT;
  113843. private static FACE_DOWN;
  113844. private static FACE_UP;
  113845. /**
  113846. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  113847. *
  113848. * @param float32Array The source data.
  113849. * @param inputWidth The width of the input panorama.
  113850. * @param inputHeight The height of the input panorama.
  113851. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  113852. * @return The cubemap data
  113853. */
  113854. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  113855. private static CreateCubemapTexture;
  113856. private static CalcProjectionSpherical;
  113857. }
  113858. }
  113859. declare module BABYLON {
  113860. /**
  113861. * Helper class dealing with the extraction of spherical polynomial dataArray
  113862. * from a cube map.
  113863. */
  113864. export class CubeMapToSphericalPolynomialTools {
  113865. private static FileFaces;
  113866. /**
  113867. * Converts a texture to the according Spherical Polynomial data.
  113868. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113869. *
  113870. * @param texture The texture to extract the information from.
  113871. * @return The Spherical Polynomial data.
  113872. */
  113873. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  113874. /**
  113875. * Converts a cubemap to the according Spherical Polynomial data.
  113876. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113877. *
  113878. * @param cubeInfo The Cube map to extract the information from.
  113879. * @return The Spherical Polynomial data.
  113880. */
  113881. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  113882. }
  113883. }
  113884. declare module BABYLON {
  113885. interface BaseTexture {
  113886. /**
  113887. * Get the polynomial representation of the texture data.
  113888. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  113889. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  113890. */
  113891. sphericalPolynomial: Nullable<SphericalPolynomial>;
  113892. }
  113893. }
  113894. declare module BABYLON {
  113895. /** @hidden */
  113896. export var rgbdEncodePixelShader: {
  113897. name: string;
  113898. shader: string;
  113899. };
  113900. }
  113901. declare module BABYLON {
  113902. /** @hidden */
  113903. export var rgbdDecodePixelShader: {
  113904. name: string;
  113905. shader: string;
  113906. };
  113907. }
  113908. declare module BABYLON {
  113909. /**
  113910. * Raw texture data and descriptor sufficient for WebGL texture upload
  113911. */
  113912. export interface EnvironmentTextureInfo {
  113913. /**
  113914. * Version of the environment map
  113915. */
  113916. version: number;
  113917. /**
  113918. * Width of image
  113919. */
  113920. width: number;
  113921. /**
  113922. * Irradiance information stored in the file.
  113923. */
  113924. irradiance: any;
  113925. /**
  113926. * Specular information stored in the file.
  113927. */
  113928. specular: any;
  113929. }
  113930. /**
  113931. * Defines One Image in the file. It requires only the position in the file
  113932. * as well as the length.
  113933. */
  113934. interface BufferImageData {
  113935. /**
  113936. * Length of the image data.
  113937. */
  113938. length: number;
  113939. /**
  113940. * Position of the data from the null terminator delimiting the end of the JSON.
  113941. */
  113942. position: number;
  113943. }
  113944. /**
  113945. * Defines the specular data enclosed in the file.
  113946. * This corresponds to the version 1 of the data.
  113947. */
  113948. export interface EnvironmentTextureSpecularInfoV1 {
  113949. /**
  113950. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  113951. */
  113952. specularDataPosition?: number;
  113953. /**
  113954. * This contains all the images data needed to reconstruct the cubemap.
  113955. */
  113956. mipmaps: Array<BufferImageData>;
  113957. /**
  113958. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  113959. */
  113960. lodGenerationScale: number;
  113961. }
  113962. /**
  113963. * Sets of helpers addressing the serialization and deserialization of environment texture
  113964. * stored in a BabylonJS env file.
  113965. * Those files are usually stored as .env files.
  113966. */
  113967. export class EnvironmentTextureTools {
  113968. /**
  113969. * Magic number identifying the env file.
  113970. */
  113971. private static _MagicBytes;
  113972. /**
  113973. * Gets the environment info from an env file.
  113974. * @param data The array buffer containing the .env bytes.
  113975. * @returns the environment file info (the json header) if successfully parsed.
  113976. */
  113977. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  113978. /**
  113979. * Creates an environment texture from a loaded cube texture.
  113980. * @param texture defines the cube texture to convert in env file
  113981. * @return a promise containing the environment data if succesfull.
  113982. */
  113983. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113984. /**
  113985. * Creates a JSON representation of the spherical data.
  113986. * @param texture defines the texture containing the polynomials
  113987. * @return the JSON representation of the spherical info
  113988. */
  113989. private static _CreateEnvTextureIrradiance;
  113990. /**
  113991. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113992. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113993. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113994. * @return the views described by info providing access to the underlying buffer
  113995. */
  113996. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113997. /**
  113998. * Uploads the texture info contained in the env file to the GPU.
  113999. * @param texture defines the internal texture to upload to
  114000. * @param arrayBuffer defines the buffer cotaining the data to load
  114001. * @param info defines the texture info retrieved through the GetEnvInfo method
  114002. * @returns a promise
  114003. */
  114004. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  114005. private static _OnImageReadyAsync;
  114006. /**
  114007. * Uploads the levels of image data to the GPU.
  114008. * @param texture defines the internal texture to upload to
  114009. * @param imageData defines the array buffer views of image data [mipmap][face]
  114010. * @returns a promise
  114011. */
  114012. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  114013. /**
  114014. * Uploads spherical polynomials information to the texture.
  114015. * @param texture defines the texture we are trying to upload the information to
  114016. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  114017. */
  114018. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  114019. /** @hidden */
  114020. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114021. }
  114022. }
  114023. declare module BABYLON {
  114024. /**
  114025. * Contains position and normal vectors for a vertex
  114026. */
  114027. export class PositionNormalVertex {
  114028. /** the position of the vertex (defaut: 0,0,0) */
  114029. position: Vector3;
  114030. /** the normal of the vertex (defaut: 0,1,0) */
  114031. normal: Vector3;
  114032. /**
  114033. * Creates a PositionNormalVertex
  114034. * @param position the position of the vertex (defaut: 0,0,0)
  114035. * @param normal the normal of the vertex (defaut: 0,1,0)
  114036. */
  114037. constructor(
  114038. /** the position of the vertex (defaut: 0,0,0) */
  114039. position?: Vector3,
  114040. /** the normal of the vertex (defaut: 0,1,0) */
  114041. normal?: Vector3);
  114042. /**
  114043. * Clones the PositionNormalVertex
  114044. * @returns the cloned PositionNormalVertex
  114045. */
  114046. clone(): PositionNormalVertex;
  114047. }
  114048. /**
  114049. * Contains position, normal and uv vectors for a vertex
  114050. */
  114051. export class PositionNormalTextureVertex {
  114052. /** the position of the vertex (defaut: 0,0,0) */
  114053. position: Vector3;
  114054. /** the normal of the vertex (defaut: 0,1,0) */
  114055. normal: Vector3;
  114056. /** the uv of the vertex (default: 0,0) */
  114057. uv: Vector2;
  114058. /**
  114059. * Creates a PositionNormalTextureVertex
  114060. * @param position the position of the vertex (defaut: 0,0,0)
  114061. * @param normal the normal of the vertex (defaut: 0,1,0)
  114062. * @param uv the uv of the vertex (default: 0,0)
  114063. */
  114064. constructor(
  114065. /** the position of the vertex (defaut: 0,0,0) */
  114066. position?: Vector3,
  114067. /** the normal of the vertex (defaut: 0,1,0) */
  114068. normal?: Vector3,
  114069. /** the uv of the vertex (default: 0,0) */
  114070. uv?: Vector2);
  114071. /**
  114072. * Clones the PositionNormalTextureVertex
  114073. * @returns the cloned PositionNormalTextureVertex
  114074. */
  114075. clone(): PositionNormalTextureVertex;
  114076. }
  114077. }
  114078. declare module BABYLON {
  114079. /** @hidden */
  114080. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  114081. private _genericAttributeLocation;
  114082. private _varyingLocationCount;
  114083. private _varyingLocationMap;
  114084. private _replacements;
  114085. private _textureCount;
  114086. private _uniforms;
  114087. lineProcessor(line: string): string;
  114088. attributeProcessor(attribute: string): string;
  114089. varyingProcessor(varying: string, isFragment: boolean): string;
  114090. uniformProcessor(uniform: string): string;
  114091. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  114092. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114093. }
  114094. }
  114095. declare module BABYLON {
  114096. /**
  114097. * Container for accessors for natively-stored mesh data buffers.
  114098. */
  114099. class NativeDataBuffer extends DataBuffer {
  114100. /**
  114101. * Accessor value used to identify/retrieve a natively-stored index buffer.
  114102. */
  114103. nativeIndexBuffer?: any;
  114104. /**
  114105. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  114106. */
  114107. nativeVertexBuffer?: any;
  114108. }
  114109. /** @hidden */
  114110. class NativeTexture extends InternalTexture {
  114111. getInternalTexture(): InternalTexture;
  114112. getViewCount(): number;
  114113. }
  114114. /** @hidden */
  114115. export class NativeEngine extends Engine {
  114116. private readonly _native;
  114117. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  114118. private readonly INVALID_HANDLE;
  114119. getHardwareScalingLevel(): number;
  114120. constructor();
  114121. /**
  114122. * Can be used to override the current requestAnimationFrame requester.
  114123. * @hidden
  114124. */
  114125. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114126. /**
  114127. * Override default engine behavior.
  114128. * @param color
  114129. * @param backBuffer
  114130. * @param depth
  114131. * @param stencil
  114132. */
  114133. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114134. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114135. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  114136. createVertexBuffer(data: DataArray): NativeDataBuffer;
  114137. recordVertexArrayObject(vertexBuffers: {
  114138. [key: string]: VertexBuffer;
  114139. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114140. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114141. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114142. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114143. /**
  114144. * Draw a list of indexed primitives
  114145. * @param fillMode defines the primitive to use
  114146. * @param indexStart defines the starting index
  114147. * @param indexCount defines the number of index to draw
  114148. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114149. */
  114150. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114151. /**
  114152. * Draw a list of unindexed primitives
  114153. * @param fillMode defines the primitive to use
  114154. * @param verticesStart defines the index of first vertex to draw
  114155. * @param verticesCount defines the count of vertices to draw
  114156. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114157. */
  114158. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114159. createPipelineContext(): IPipelineContext;
  114160. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114161. /** @hidden */
  114162. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114163. /** @hidden */
  114164. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114165. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114166. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114167. protected _setProgram(program: WebGLProgram): void;
  114168. _releaseEffect(effect: Effect): void;
  114169. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114170. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  114171. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  114172. bindSamplers(effect: Effect): void;
  114173. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  114174. getRenderWidth(useScreen?: boolean): number;
  114175. getRenderHeight(useScreen?: boolean): number;
  114176. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  114177. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114178. /**
  114179. * Set the z offset to apply to current rendering
  114180. * @param value defines the offset to apply
  114181. */
  114182. setZOffset(value: number): void;
  114183. /**
  114184. * Gets the current value of the zOffset
  114185. * @returns the current zOffset state
  114186. */
  114187. getZOffset(): number;
  114188. /**
  114189. * Enable or disable depth buffering
  114190. * @param enable defines the state to set
  114191. */
  114192. setDepthBuffer(enable: boolean): void;
  114193. /**
  114194. * Gets a boolean indicating if depth writing is enabled
  114195. * @returns the current depth writing state
  114196. */
  114197. getDepthWrite(): boolean;
  114198. /**
  114199. * Enable or disable depth writing
  114200. * @param enable defines the state to set
  114201. */
  114202. setDepthWrite(enable: boolean): void;
  114203. /**
  114204. * Enable or disable color writing
  114205. * @param enable defines the state to set
  114206. */
  114207. setColorWrite(enable: boolean): void;
  114208. /**
  114209. * Gets a boolean indicating if color writing is enabled
  114210. * @returns the current color writing state
  114211. */
  114212. getColorWrite(): boolean;
  114213. /**
  114214. * Sets alpha constants used by some alpha blending modes
  114215. * @param r defines the red component
  114216. * @param g defines the green component
  114217. * @param b defines the blue component
  114218. * @param a defines the alpha component
  114219. */
  114220. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114221. /**
  114222. * Sets the current alpha mode
  114223. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  114224. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114225. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114226. */
  114227. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114228. /**
  114229. * Gets the current alpha mode
  114230. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114231. * @returns the current alpha mode
  114232. */
  114233. getAlphaMode(): number;
  114234. setInt(uniform: WebGLUniformLocation, int: number): void;
  114235. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  114236. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  114237. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  114238. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  114239. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  114240. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  114241. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  114242. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  114243. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  114244. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  114245. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  114246. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  114247. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  114248. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114249. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114250. setFloat(uniform: WebGLUniformLocation, value: number): void;
  114251. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  114252. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  114253. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  114254. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  114255. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  114256. wipeCaches(bruteForce?: boolean): void;
  114257. _createTexture(): WebGLTexture;
  114258. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114259. /**
  114260. * Usually called from BABYLON.Texture.ts.
  114261. * Passed information to create a WebGLTexture
  114262. * @param urlArg defines a value which contains one of the following:
  114263. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114264. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114265. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114266. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114267. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  114268. * @param scene needed for loading to the correct scene
  114269. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  114270. * @param onLoad optional callback to be called upon successful completion
  114271. * @param onError optional callback to be called upon failure
  114272. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  114273. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114274. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114275. * @param forcedExtension defines the extension to use to pick the right loader
  114276. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114277. */
  114278. 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;
  114279. /**
  114280. * Creates a cube texture
  114281. * @param rootUrl defines the url where the files to load is located
  114282. * @param scene defines the current scene
  114283. * @param files defines the list of files to load (1 per face)
  114284. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  114285. * @param onLoad defines an optional callback raised when the texture is loaded
  114286. * @param onError defines an optional callback raised if there is an issue to load the texture
  114287. * @param format defines the format of the data
  114288. * @param forcedExtension defines the extension to use to pick the right loader
  114289. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  114290. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114291. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114292. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  114293. * @returns the cube texture as an InternalTexture
  114294. */
  114295. 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;
  114296. private _getSamplingFilter;
  114297. private static _GetNativeTextureFormat;
  114298. createRenderTargetTexture(size: number | {
  114299. width: number;
  114300. height: number;
  114301. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  114302. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  114303. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  114304. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114305. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114306. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114307. /**
  114308. * Updates a dynamic vertex buffer.
  114309. * @param vertexBuffer the vertex buffer to update
  114310. * @param data the data used to update the vertex buffer
  114311. * @param byteOffset the byte offset of the data (optional)
  114312. * @param byteLength the byte length of the data (optional)
  114313. */
  114314. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114315. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114316. private _updateAnisotropicLevel;
  114317. private _getAddressMode;
  114318. /** @hidden */
  114319. _bindTexture(channel: number, texture: InternalTexture): void;
  114320. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  114321. releaseEffects(): void;
  114322. /** @hidden */
  114323. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114324. /** @hidden */
  114325. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114326. /** @hidden */
  114327. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114328. /** @hidden */
  114329. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  114330. }
  114331. }
  114332. declare module BABYLON {
  114333. /**
  114334. * Gather the list of clipboard event types as constants.
  114335. */
  114336. export class ClipboardEventTypes {
  114337. /**
  114338. * The clipboard event is fired when a copy command is active (pressed).
  114339. */
  114340. static readonly COPY: number;
  114341. /**
  114342. * The clipboard event is fired when a cut command is active (pressed).
  114343. */
  114344. static readonly CUT: number;
  114345. /**
  114346. * The clipboard event is fired when a paste command is active (pressed).
  114347. */
  114348. static readonly PASTE: number;
  114349. }
  114350. /**
  114351. * This class is used to store clipboard related info for the onClipboardObservable event.
  114352. */
  114353. export class ClipboardInfo {
  114354. /**
  114355. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114356. */
  114357. type: number;
  114358. /**
  114359. * Defines the related dom event
  114360. */
  114361. event: ClipboardEvent;
  114362. /**
  114363. *Creates an instance of ClipboardInfo.
  114364. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  114365. * @param event Defines the related dom event
  114366. */
  114367. constructor(
  114368. /**
  114369. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114370. */
  114371. type: number,
  114372. /**
  114373. * Defines the related dom event
  114374. */
  114375. event: ClipboardEvent);
  114376. /**
  114377. * Get the clipboard event's type from the keycode.
  114378. * @param keyCode Defines the keyCode for the current keyboard event.
  114379. * @return {number}
  114380. */
  114381. static GetTypeFromCharacter(keyCode: number): number;
  114382. }
  114383. }
  114384. declare module BABYLON {
  114385. /**
  114386. * Google Daydream controller
  114387. */
  114388. export class DaydreamController extends WebVRController {
  114389. /**
  114390. * Base Url for the controller model.
  114391. */
  114392. static MODEL_BASE_URL: string;
  114393. /**
  114394. * File name for the controller model.
  114395. */
  114396. static MODEL_FILENAME: string;
  114397. /**
  114398. * Gamepad Id prefix used to identify Daydream Controller.
  114399. */
  114400. static readonly GAMEPAD_ID_PREFIX: string;
  114401. /**
  114402. * Creates a new DaydreamController from a gamepad
  114403. * @param vrGamepad the gamepad that the controller should be created from
  114404. */
  114405. constructor(vrGamepad: any);
  114406. /**
  114407. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114408. * @param scene scene in which to add meshes
  114409. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114410. */
  114411. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114412. /**
  114413. * Called once for each button that changed state since the last frame
  114414. * @param buttonIdx Which button index changed
  114415. * @param state New state of the button
  114416. * @param changes Which properties on the state changed since last frame
  114417. */
  114418. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114419. }
  114420. }
  114421. declare module BABYLON {
  114422. /**
  114423. * Gear VR Controller
  114424. */
  114425. export class GearVRController extends WebVRController {
  114426. /**
  114427. * Base Url for the controller model.
  114428. */
  114429. static MODEL_BASE_URL: string;
  114430. /**
  114431. * File name for the controller model.
  114432. */
  114433. static MODEL_FILENAME: string;
  114434. /**
  114435. * Gamepad Id prefix used to identify this controller.
  114436. */
  114437. static readonly GAMEPAD_ID_PREFIX: string;
  114438. private readonly _buttonIndexToObservableNameMap;
  114439. /**
  114440. * Creates a new GearVRController from a gamepad
  114441. * @param vrGamepad the gamepad that the controller should be created from
  114442. */
  114443. constructor(vrGamepad: any);
  114444. /**
  114445. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114446. * @param scene scene in which to add meshes
  114447. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114448. */
  114449. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114450. /**
  114451. * Called once for each button that changed state since the last frame
  114452. * @param buttonIdx Which button index changed
  114453. * @param state New state of the button
  114454. * @param changes Which properties on the state changed since last frame
  114455. */
  114456. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114457. }
  114458. }
  114459. declare module BABYLON {
  114460. /**
  114461. * Class containing static functions to help procedurally build meshes
  114462. */
  114463. export class PolyhedronBuilder {
  114464. /**
  114465. * Creates a polyhedron mesh
  114466. * * 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
  114467. * * The parameter `size` (positive float, default 1) sets the polygon size
  114468. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114469. * * 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`
  114470. * * 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
  114471. * * 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)`)
  114472. * * 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
  114473. * * 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
  114474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114477. * @param name defines the name of the mesh
  114478. * @param options defines the options used to create the mesh
  114479. * @param scene defines the hosting scene
  114480. * @returns the polyhedron mesh
  114481. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  114482. */
  114483. static CreatePolyhedron(name: string, options: {
  114484. type?: number;
  114485. size?: number;
  114486. sizeX?: number;
  114487. sizeY?: number;
  114488. sizeZ?: number;
  114489. custom?: any;
  114490. faceUV?: Vector4[];
  114491. faceColors?: Color4[];
  114492. flat?: boolean;
  114493. updatable?: boolean;
  114494. sideOrientation?: number;
  114495. frontUVs?: Vector4;
  114496. backUVs?: Vector4;
  114497. }, scene?: Nullable<Scene>): Mesh;
  114498. }
  114499. }
  114500. declare module BABYLON {
  114501. /**
  114502. * Gizmo that enables scaling a mesh along 3 axis
  114503. */
  114504. export class ScaleGizmo extends Gizmo {
  114505. /**
  114506. * Internal gizmo used for interactions on the x axis
  114507. */
  114508. xGizmo: AxisScaleGizmo;
  114509. /**
  114510. * Internal gizmo used for interactions on the y axis
  114511. */
  114512. yGizmo: AxisScaleGizmo;
  114513. /**
  114514. * Internal gizmo used for interactions on the z axis
  114515. */
  114516. zGizmo: AxisScaleGizmo;
  114517. /**
  114518. * Internal gizmo used to scale all axis equally
  114519. */
  114520. uniformScaleGizmo: AxisScaleGizmo;
  114521. private _meshAttached;
  114522. private _updateGizmoRotationToMatchAttachedMesh;
  114523. private _snapDistance;
  114524. private _scaleRatio;
  114525. private _uniformScalingMesh;
  114526. private _octahedron;
  114527. private _sensitivity;
  114528. /** Fires an event when any of it's sub gizmos are dragged */
  114529. onDragStartObservable: Observable<unknown>;
  114530. /** Fires an event when any of it's sub gizmos are released from dragging */
  114531. onDragEndObservable: Observable<unknown>;
  114532. attachedMesh: Nullable<AbstractMesh>;
  114533. /**
  114534. * Creates a ScaleGizmo
  114535. * @param gizmoLayer The utility layer the gizmo will be added to
  114536. */
  114537. constructor(gizmoLayer?: UtilityLayerRenderer);
  114538. updateGizmoRotationToMatchAttachedMesh: boolean;
  114539. /**
  114540. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114541. */
  114542. snapDistance: number;
  114543. /**
  114544. * Ratio for the scale of the gizmo (Default: 1)
  114545. */
  114546. scaleRatio: number;
  114547. /**
  114548. * Sensitivity factor for dragging (Default: 1)
  114549. */
  114550. sensitivity: number;
  114551. /**
  114552. * Disposes of the gizmo
  114553. */
  114554. dispose(): void;
  114555. }
  114556. }
  114557. declare module BABYLON {
  114558. /**
  114559. * Single axis scale gizmo
  114560. */
  114561. export class AxisScaleGizmo extends Gizmo {
  114562. /**
  114563. * Drag behavior responsible for the gizmos dragging interactions
  114564. */
  114565. dragBehavior: PointerDragBehavior;
  114566. private _pointerObserver;
  114567. /**
  114568. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114569. */
  114570. snapDistance: number;
  114571. /**
  114572. * Event that fires each time the gizmo snaps to a new location.
  114573. * * snapDistance is the the change in distance
  114574. */
  114575. onSnapObservable: Observable<{
  114576. snapDistance: number;
  114577. }>;
  114578. /**
  114579. * If the scaling operation should be done on all axis (default: false)
  114580. */
  114581. uniformScaling: boolean;
  114582. /**
  114583. * Custom sensitivity value for the drag strength
  114584. */
  114585. sensitivity: number;
  114586. private _isEnabled;
  114587. private _parent;
  114588. private _arrow;
  114589. private _coloredMaterial;
  114590. private _hoverMaterial;
  114591. /**
  114592. * Creates an AxisScaleGizmo
  114593. * @param gizmoLayer The utility layer the gizmo will be added to
  114594. * @param dragAxis The axis which the gizmo will be able to scale on
  114595. * @param color The color of the gizmo
  114596. */
  114597. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  114598. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114599. /**
  114600. * If the gizmo is enabled
  114601. */
  114602. isEnabled: boolean;
  114603. /**
  114604. * Disposes of the gizmo
  114605. */
  114606. dispose(): void;
  114607. /**
  114608. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  114609. * @param mesh The mesh to replace the default mesh of the gizmo
  114610. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  114611. */
  114612. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  114613. }
  114614. }
  114615. declare module BABYLON {
  114616. /**
  114617. * Bounding box gizmo
  114618. */
  114619. export class BoundingBoxGizmo extends Gizmo {
  114620. private _lineBoundingBox;
  114621. private _rotateSpheresParent;
  114622. private _scaleBoxesParent;
  114623. private _boundingDimensions;
  114624. private _renderObserver;
  114625. private _pointerObserver;
  114626. private _scaleDragSpeed;
  114627. private _tmpQuaternion;
  114628. private _tmpVector;
  114629. private _tmpRotationMatrix;
  114630. /**
  114631. * 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)
  114632. */
  114633. ignoreChildren: boolean;
  114634. /**
  114635. * 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)
  114636. */
  114637. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  114638. /**
  114639. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  114640. */
  114641. rotationSphereSize: number;
  114642. /**
  114643. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  114644. */
  114645. scaleBoxSize: number;
  114646. /**
  114647. * 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)
  114648. */
  114649. fixedDragMeshScreenSize: boolean;
  114650. /**
  114651. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  114652. */
  114653. fixedDragMeshScreenSizeDistanceFactor: number;
  114654. /**
  114655. * Fired when a rotation sphere or scale box is dragged
  114656. */
  114657. onDragStartObservable: Observable<{}>;
  114658. /**
  114659. * Fired when a scale box is dragged
  114660. */
  114661. onScaleBoxDragObservable: Observable<{}>;
  114662. /**
  114663. * Fired when a scale box drag is ended
  114664. */
  114665. onScaleBoxDragEndObservable: Observable<{}>;
  114666. /**
  114667. * Fired when a rotation sphere is dragged
  114668. */
  114669. onRotationSphereDragObservable: Observable<{}>;
  114670. /**
  114671. * Fired when a rotation sphere drag is ended
  114672. */
  114673. onRotationSphereDragEndObservable: Observable<{}>;
  114674. /**
  114675. * 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)
  114676. */
  114677. scalePivot: Nullable<Vector3>;
  114678. /**
  114679. * Mesh used as a pivot to rotate the attached mesh
  114680. */
  114681. private _anchorMesh;
  114682. private _existingMeshScale;
  114683. private _dragMesh;
  114684. private pointerDragBehavior;
  114685. private coloredMaterial;
  114686. private hoverColoredMaterial;
  114687. /**
  114688. * Sets the color of the bounding box gizmo
  114689. * @param color the color to set
  114690. */
  114691. setColor(color: Color3): void;
  114692. /**
  114693. * Creates an BoundingBoxGizmo
  114694. * @param gizmoLayer The utility layer the gizmo will be added to
  114695. * @param color The color of the gizmo
  114696. */
  114697. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  114698. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114699. private _selectNode;
  114700. /**
  114701. * Updates the bounding box information for the Gizmo
  114702. */
  114703. updateBoundingBox(): void;
  114704. private _updateRotationSpheres;
  114705. private _updateScaleBoxes;
  114706. /**
  114707. * Enables rotation on the specified axis and disables rotation on the others
  114708. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  114709. */
  114710. setEnabledRotationAxis(axis: string): void;
  114711. /**
  114712. * Enables/disables scaling
  114713. * @param enable if scaling should be enabled
  114714. */
  114715. setEnabledScaling(enable: boolean): void;
  114716. private _updateDummy;
  114717. /**
  114718. * Enables a pointer drag behavior on the bounding box of the gizmo
  114719. */
  114720. enableDragBehavior(): void;
  114721. /**
  114722. * Disposes of the gizmo
  114723. */
  114724. dispose(): void;
  114725. /**
  114726. * 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)
  114727. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  114728. * @returns the bounding box mesh with the passed in mesh as a child
  114729. */
  114730. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  114731. /**
  114732. * CustomMeshes are not supported by this gizmo
  114733. * @param mesh The mesh to replace the default mesh of the gizmo
  114734. */
  114735. setCustomMesh(mesh: Mesh): void;
  114736. }
  114737. }
  114738. declare module BABYLON {
  114739. /**
  114740. * Single plane rotation gizmo
  114741. */
  114742. export class PlaneRotationGizmo extends Gizmo {
  114743. /**
  114744. * Drag behavior responsible for the gizmos dragging interactions
  114745. */
  114746. dragBehavior: PointerDragBehavior;
  114747. private _pointerObserver;
  114748. /**
  114749. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  114750. */
  114751. snapDistance: number;
  114752. /**
  114753. * Event that fires each time the gizmo snaps to a new location.
  114754. * * snapDistance is the the change in distance
  114755. */
  114756. onSnapObservable: Observable<{
  114757. snapDistance: number;
  114758. }>;
  114759. private _isEnabled;
  114760. private _parent;
  114761. /**
  114762. * Creates a PlaneRotationGizmo
  114763. * @param gizmoLayer The utility layer the gizmo will be added to
  114764. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  114765. * @param color The color of the gizmo
  114766. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114767. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114768. */
  114769. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  114770. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114771. /**
  114772. * If the gizmo is enabled
  114773. */
  114774. isEnabled: boolean;
  114775. /**
  114776. * Disposes of the gizmo
  114777. */
  114778. dispose(): void;
  114779. }
  114780. }
  114781. declare module BABYLON {
  114782. /**
  114783. * Gizmo that enables rotating a mesh along 3 axis
  114784. */
  114785. export class RotationGizmo extends Gizmo {
  114786. /**
  114787. * Internal gizmo used for interactions on the x axis
  114788. */
  114789. xGizmo: PlaneRotationGizmo;
  114790. /**
  114791. * Internal gizmo used for interactions on the y axis
  114792. */
  114793. yGizmo: PlaneRotationGizmo;
  114794. /**
  114795. * Internal gizmo used for interactions on the z axis
  114796. */
  114797. zGizmo: PlaneRotationGizmo;
  114798. /** Fires an event when any of it's sub gizmos are dragged */
  114799. onDragStartObservable: Observable<unknown>;
  114800. /** Fires an event when any of it's sub gizmos are released from dragging */
  114801. onDragEndObservable: Observable<unknown>;
  114802. private _meshAttached;
  114803. attachedMesh: Nullable<AbstractMesh>;
  114804. /**
  114805. * Creates a RotationGizmo
  114806. * @param gizmoLayer The utility layer the gizmo will be added to
  114807. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114808. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114809. */
  114810. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  114811. updateGizmoRotationToMatchAttachedMesh: boolean;
  114812. /**
  114813. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114814. */
  114815. snapDistance: number;
  114816. /**
  114817. * Ratio for the scale of the gizmo (Default: 1)
  114818. */
  114819. scaleRatio: number;
  114820. /**
  114821. * Disposes of the gizmo
  114822. */
  114823. dispose(): void;
  114824. /**
  114825. * CustomMeshes are not supported by this gizmo
  114826. * @param mesh The mesh to replace the default mesh of the gizmo
  114827. */
  114828. setCustomMesh(mesh: Mesh): void;
  114829. }
  114830. }
  114831. declare module BABYLON {
  114832. /**
  114833. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  114834. */
  114835. export class GizmoManager implements IDisposable {
  114836. private scene;
  114837. /**
  114838. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  114839. */
  114840. gizmos: {
  114841. positionGizmo: Nullable<PositionGizmo>;
  114842. rotationGizmo: Nullable<RotationGizmo>;
  114843. scaleGizmo: Nullable<ScaleGizmo>;
  114844. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  114845. };
  114846. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  114847. clearGizmoOnEmptyPointerEvent: boolean;
  114848. /** Fires an event when the manager is attached to a mesh */
  114849. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  114850. private _gizmosEnabled;
  114851. private _pointerObserver;
  114852. private _attachedMesh;
  114853. private _boundingBoxColor;
  114854. private _defaultUtilityLayer;
  114855. private _defaultKeepDepthUtilityLayer;
  114856. /**
  114857. * When bounding box gizmo is enabled, this can be used to track drag/end events
  114858. */
  114859. boundingBoxDragBehavior: SixDofDragBehavior;
  114860. /**
  114861. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  114862. */
  114863. attachableMeshes: Nullable<Array<AbstractMesh>>;
  114864. /**
  114865. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  114866. */
  114867. usePointerToAttachGizmos: boolean;
  114868. /**
  114869. * Utility layer that the bounding box gizmo belongs to
  114870. */
  114871. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  114872. /**
  114873. * Utility layer that all gizmos besides bounding box belong to
  114874. */
  114875. readonly utilityLayer: UtilityLayerRenderer;
  114876. /**
  114877. * Instatiates a gizmo manager
  114878. * @param scene the scene to overlay the gizmos on top of
  114879. */
  114880. constructor(scene: Scene);
  114881. /**
  114882. * Attaches a set of gizmos to the specified mesh
  114883. * @param mesh The mesh the gizmo's should be attached to
  114884. */
  114885. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114886. /**
  114887. * If the position gizmo is enabled
  114888. */
  114889. positionGizmoEnabled: boolean;
  114890. /**
  114891. * If the rotation gizmo is enabled
  114892. */
  114893. rotationGizmoEnabled: boolean;
  114894. /**
  114895. * If the scale gizmo is enabled
  114896. */
  114897. scaleGizmoEnabled: boolean;
  114898. /**
  114899. * If the boundingBox gizmo is enabled
  114900. */
  114901. boundingBoxGizmoEnabled: boolean;
  114902. /**
  114903. * Disposes of the gizmo manager
  114904. */
  114905. dispose(): void;
  114906. }
  114907. }
  114908. declare module BABYLON {
  114909. /**
  114910. * A directional light is defined by a direction (what a surprise!).
  114911. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  114912. * 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.
  114913. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114914. */
  114915. export class DirectionalLight extends ShadowLight {
  114916. private _shadowFrustumSize;
  114917. /**
  114918. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  114919. */
  114920. /**
  114921. * Specifies a fix frustum size for the shadow generation.
  114922. */
  114923. shadowFrustumSize: number;
  114924. private _shadowOrthoScale;
  114925. /**
  114926. * Gets the shadow projection scale against the optimal computed one.
  114927. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114928. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114929. */
  114930. /**
  114931. * Sets the shadow projection scale against the optimal computed one.
  114932. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114933. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114934. */
  114935. shadowOrthoScale: number;
  114936. /**
  114937. * Automatically compute the projection matrix to best fit (including all the casters)
  114938. * on each frame.
  114939. */
  114940. autoUpdateExtends: boolean;
  114941. private _orthoLeft;
  114942. private _orthoRight;
  114943. private _orthoTop;
  114944. private _orthoBottom;
  114945. /**
  114946. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  114947. * The directional light is emitted from everywhere in the given direction.
  114948. * It can cast shadows.
  114949. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114950. * @param name The friendly name of the light
  114951. * @param direction The direction of the light
  114952. * @param scene The scene the light belongs to
  114953. */
  114954. constructor(name: string, direction: Vector3, scene: Scene);
  114955. /**
  114956. * Returns the string "DirectionalLight".
  114957. * @return The class name
  114958. */
  114959. getClassName(): string;
  114960. /**
  114961. * Returns the integer 1.
  114962. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114963. */
  114964. getTypeID(): number;
  114965. /**
  114966. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  114967. * Returns the DirectionalLight Shadow projection matrix.
  114968. */
  114969. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114970. /**
  114971. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  114972. * Returns the DirectionalLight Shadow projection matrix.
  114973. */
  114974. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  114975. /**
  114976. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  114977. * Returns the DirectionalLight Shadow projection matrix.
  114978. */
  114979. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114980. protected _buildUniformLayout(): void;
  114981. /**
  114982. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  114983. * @param effect The effect to update
  114984. * @param lightIndex The index of the light in the effect to update
  114985. * @returns The directional light
  114986. */
  114987. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  114988. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  114989. /**
  114990. * Gets the minZ used for shadow according to both the scene and the light.
  114991. *
  114992. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114993. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114994. * @param activeCamera The camera we are returning the min for
  114995. * @returns the depth min z
  114996. */
  114997. getDepthMinZ(activeCamera: Camera): number;
  114998. /**
  114999. * Gets the maxZ used for shadow according to both the scene and the light.
  115000. *
  115001. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115002. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115003. * @param activeCamera The camera we are returning the max for
  115004. * @returns the depth max z
  115005. */
  115006. getDepthMaxZ(activeCamera: Camera): number;
  115007. /**
  115008. * Prepares the list of defines specific to the light type.
  115009. * @param defines the list of defines
  115010. * @param lightIndex defines the index of the light for the effect
  115011. */
  115012. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115013. }
  115014. }
  115015. declare module BABYLON {
  115016. /**
  115017. * Class containing static functions to help procedurally build meshes
  115018. */
  115019. export class HemisphereBuilder {
  115020. /**
  115021. * Creates a hemisphere mesh
  115022. * @param name defines the name of the mesh
  115023. * @param options defines the options used to create the mesh
  115024. * @param scene defines the hosting scene
  115025. * @returns the hemisphere mesh
  115026. */
  115027. static CreateHemisphere(name: string, options: {
  115028. segments?: number;
  115029. diameter?: number;
  115030. sideOrientation?: number;
  115031. }, scene: any): Mesh;
  115032. }
  115033. }
  115034. declare module BABYLON {
  115035. /**
  115036. * A spot light is defined by a position, a direction, an angle, and an exponent.
  115037. * These values define a cone of light starting from the position, emitting toward the direction.
  115038. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  115039. * and the exponent defines the speed of the decay of the light with distance (reach).
  115040. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115041. */
  115042. export class SpotLight extends ShadowLight {
  115043. private _angle;
  115044. private _innerAngle;
  115045. private _cosHalfAngle;
  115046. private _lightAngleScale;
  115047. private _lightAngleOffset;
  115048. /**
  115049. * Gets the cone angle of the spot light in Radians.
  115050. */
  115051. /**
  115052. * Sets the cone angle of the spot light in Radians.
  115053. */
  115054. angle: number;
  115055. /**
  115056. * Only used in gltf falloff mode, this defines the angle where
  115057. * the directional falloff will start before cutting at angle which could be seen
  115058. * as outer angle.
  115059. */
  115060. /**
  115061. * Only used in gltf falloff mode, this defines the angle where
  115062. * the directional falloff will start before cutting at angle which could be seen
  115063. * as outer angle.
  115064. */
  115065. innerAngle: number;
  115066. private _shadowAngleScale;
  115067. /**
  115068. * Allows scaling the angle of the light for shadow generation only.
  115069. */
  115070. /**
  115071. * Allows scaling the angle of the light for shadow generation only.
  115072. */
  115073. shadowAngleScale: number;
  115074. /**
  115075. * The light decay speed with the distance from the emission spot.
  115076. */
  115077. exponent: number;
  115078. private _projectionTextureMatrix;
  115079. /**
  115080. * Allows reading the projecton texture
  115081. */
  115082. readonly projectionTextureMatrix: Matrix;
  115083. protected _projectionTextureLightNear: number;
  115084. /**
  115085. * Gets the near clip of the Spotlight for texture projection.
  115086. */
  115087. /**
  115088. * Sets the near clip of the Spotlight for texture projection.
  115089. */
  115090. projectionTextureLightNear: number;
  115091. protected _projectionTextureLightFar: number;
  115092. /**
  115093. * Gets the far clip of the Spotlight for texture projection.
  115094. */
  115095. /**
  115096. * Sets the far clip of the Spotlight for texture projection.
  115097. */
  115098. projectionTextureLightFar: number;
  115099. protected _projectionTextureUpDirection: Vector3;
  115100. /**
  115101. * Gets the Up vector of the Spotlight for texture projection.
  115102. */
  115103. /**
  115104. * Sets the Up vector of the Spotlight for texture projection.
  115105. */
  115106. projectionTextureUpDirection: Vector3;
  115107. private _projectionTexture;
  115108. /**
  115109. * Gets the projection texture of the light.
  115110. */
  115111. /**
  115112. * Sets the projection texture of the light.
  115113. */
  115114. projectionTexture: Nullable<BaseTexture>;
  115115. private _projectionTextureViewLightDirty;
  115116. private _projectionTextureProjectionLightDirty;
  115117. private _projectionTextureDirty;
  115118. private _projectionTextureViewTargetVector;
  115119. private _projectionTextureViewLightMatrix;
  115120. private _projectionTextureProjectionLightMatrix;
  115121. private _projectionTextureScalingMatrix;
  115122. /**
  115123. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  115124. * It can cast shadows.
  115125. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115126. * @param name The light friendly name
  115127. * @param position The position of the spot light in the scene
  115128. * @param direction The direction of the light in the scene
  115129. * @param angle The cone angle of the light in Radians
  115130. * @param exponent The light decay speed with the distance from the emission spot
  115131. * @param scene The scene the lights belongs to
  115132. */
  115133. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  115134. /**
  115135. * Returns the string "SpotLight".
  115136. * @returns the class name
  115137. */
  115138. getClassName(): string;
  115139. /**
  115140. * Returns the integer 2.
  115141. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115142. */
  115143. getTypeID(): number;
  115144. /**
  115145. * Overrides the direction setter to recompute the projection texture view light Matrix.
  115146. */
  115147. protected _setDirection(value: Vector3): void;
  115148. /**
  115149. * Overrides the position setter to recompute the projection texture view light Matrix.
  115150. */
  115151. protected _setPosition(value: Vector3): void;
  115152. /**
  115153. * 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.
  115154. * Returns the SpotLight.
  115155. */
  115156. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115157. protected _computeProjectionTextureViewLightMatrix(): void;
  115158. protected _computeProjectionTextureProjectionLightMatrix(): void;
  115159. /**
  115160. * Main function for light texture projection matrix computing.
  115161. */
  115162. protected _computeProjectionTextureMatrix(): void;
  115163. protected _buildUniformLayout(): void;
  115164. private _computeAngleValues;
  115165. /**
  115166. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  115167. * @param effect The effect to update
  115168. * @param lightIndex The index of the light in the effect to update
  115169. * @returns The spot light
  115170. */
  115171. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  115172. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115173. /**
  115174. * Disposes the light and the associated resources.
  115175. */
  115176. dispose(): void;
  115177. /**
  115178. * Prepares the list of defines specific to the light type.
  115179. * @param defines the list of defines
  115180. * @param lightIndex defines the index of the light for the effect
  115181. */
  115182. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115183. }
  115184. }
  115185. declare module BABYLON {
  115186. /**
  115187. * Gizmo that enables viewing a light
  115188. */
  115189. export class LightGizmo extends Gizmo {
  115190. private _lightMesh;
  115191. private _material;
  115192. private _cachedPosition;
  115193. private _cachedForward;
  115194. private _attachedMeshParent;
  115195. /**
  115196. * Creates a LightGizmo
  115197. * @param gizmoLayer The utility layer the gizmo will be added to
  115198. */
  115199. constructor(gizmoLayer?: UtilityLayerRenderer);
  115200. private _light;
  115201. /**
  115202. * The light that the gizmo is attached to
  115203. */
  115204. light: Nullable<Light>;
  115205. /**
  115206. * Gets the material used to render the light gizmo
  115207. */
  115208. readonly material: StandardMaterial;
  115209. /**
  115210. * @hidden
  115211. * Updates the gizmo to match the attached mesh's position/rotation
  115212. */
  115213. protected _update(): void;
  115214. private static _Scale;
  115215. /**
  115216. * Creates the lines for a light mesh
  115217. */
  115218. private static _CreateLightLines;
  115219. /**
  115220. * Disposes of the light gizmo
  115221. */
  115222. dispose(): void;
  115223. private static _CreateHemisphericLightMesh;
  115224. private static _CreatePointLightMesh;
  115225. private static _CreateSpotLightMesh;
  115226. private static _CreateDirectionalLightMesh;
  115227. }
  115228. }
  115229. declare module BABYLON {
  115230. /** @hidden */
  115231. export var backgroundFragmentDeclaration: {
  115232. name: string;
  115233. shader: string;
  115234. };
  115235. }
  115236. declare module BABYLON {
  115237. /** @hidden */
  115238. export var backgroundUboDeclaration: {
  115239. name: string;
  115240. shader: string;
  115241. };
  115242. }
  115243. declare module BABYLON {
  115244. /** @hidden */
  115245. export var backgroundPixelShader: {
  115246. name: string;
  115247. shader: string;
  115248. };
  115249. }
  115250. declare module BABYLON {
  115251. /** @hidden */
  115252. export var backgroundVertexDeclaration: {
  115253. name: string;
  115254. shader: string;
  115255. };
  115256. }
  115257. declare module BABYLON {
  115258. /** @hidden */
  115259. export var backgroundVertexShader: {
  115260. name: string;
  115261. shader: string;
  115262. };
  115263. }
  115264. declare module BABYLON {
  115265. /**
  115266. * Background material used to create an efficient environement around your scene.
  115267. */
  115268. export class BackgroundMaterial extends PushMaterial {
  115269. /**
  115270. * Standard reflectance value at parallel view angle.
  115271. */
  115272. static StandardReflectance0: number;
  115273. /**
  115274. * Standard reflectance value at grazing angle.
  115275. */
  115276. static StandardReflectance90: number;
  115277. protected _primaryColor: Color3;
  115278. /**
  115279. * Key light Color (multiply against the environement texture)
  115280. */
  115281. primaryColor: Color3;
  115282. protected __perceptualColor: Nullable<Color3>;
  115283. /**
  115284. * Experimental Internal Use Only.
  115285. *
  115286. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  115287. * This acts as a helper to set the primary color to a more "human friendly" value.
  115288. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  115289. * output color as close as possible from the chosen value.
  115290. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  115291. * part of lighting setup.)
  115292. */
  115293. _perceptualColor: Nullable<Color3>;
  115294. protected _primaryColorShadowLevel: float;
  115295. /**
  115296. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  115297. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  115298. */
  115299. primaryColorShadowLevel: float;
  115300. protected _primaryColorHighlightLevel: float;
  115301. /**
  115302. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  115303. * The primary color is used at the level chosen to define what the white area would look.
  115304. */
  115305. primaryColorHighlightLevel: float;
  115306. protected _reflectionTexture: Nullable<BaseTexture>;
  115307. /**
  115308. * Reflection Texture used in the material.
  115309. * Should be author in a specific way for the best result (refer to the documentation).
  115310. */
  115311. reflectionTexture: Nullable<BaseTexture>;
  115312. protected _reflectionBlur: float;
  115313. /**
  115314. * Reflection Texture level of blur.
  115315. *
  115316. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  115317. * texture twice.
  115318. */
  115319. reflectionBlur: float;
  115320. protected _diffuseTexture: Nullable<BaseTexture>;
  115321. /**
  115322. * Diffuse Texture used in the material.
  115323. * Should be author in a specific way for the best result (refer to the documentation).
  115324. */
  115325. diffuseTexture: Nullable<BaseTexture>;
  115326. protected _shadowLights: Nullable<IShadowLight[]>;
  115327. /**
  115328. * Specify the list of lights casting shadow on the material.
  115329. * All scene shadow lights will be included if null.
  115330. */
  115331. shadowLights: Nullable<IShadowLight[]>;
  115332. protected _shadowLevel: float;
  115333. /**
  115334. * Helps adjusting the shadow to a softer level if required.
  115335. * 0 means black shadows and 1 means no shadows.
  115336. */
  115337. shadowLevel: float;
  115338. protected _sceneCenter: Vector3;
  115339. /**
  115340. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  115341. * It is usually zero but might be interesting to modify according to your setup.
  115342. */
  115343. sceneCenter: Vector3;
  115344. protected _opacityFresnel: boolean;
  115345. /**
  115346. * This helps specifying that the material is falling off to the sky box at grazing angle.
  115347. * This helps ensuring a nice transition when the camera goes under the ground.
  115348. */
  115349. opacityFresnel: boolean;
  115350. protected _reflectionFresnel: boolean;
  115351. /**
  115352. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  115353. * This helps adding a mirror texture on the ground.
  115354. */
  115355. reflectionFresnel: boolean;
  115356. protected _reflectionFalloffDistance: number;
  115357. /**
  115358. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  115359. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  115360. */
  115361. reflectionFalloffDistance: number;
  115362. protected _reflectionAmount: number;
  115363. /**
  115364. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  115365. */
  115366. reflectionAmount: number;
  115367. protected _reflectionReflectance0: number;
  115368. /**
  115369. * This specifies the weight of the reflection at grazing angle.
  115370. */
  115371. reflectionReflectance0: number;
  115372. protected _reflectionReflectance90: number;
  115373. /**
  115374. * This specifies the weight of the reflection at a perpendicular point of view.
  115375. */
  115376. reflectionReflectance90: number;
  115377. /**
  115378. * Sets the reflection reflectance fresnel values according to the default standard
  115379. * empirically know to work well :-)
  115380. */
  115381. reflectionStandardFresnelWeight: number;
  115382. protected _useRGBColor: boolean;
  115383. /**
  115384. * Helps to directly use the maps channels instead of their level.
  115385. */
  115386. useRGBColor: boolean;
  115387. protected _enableNoise: boolean;
  115388. /**
  115389. * This helps reducing the banding effect that could occur on the background.
  115390. */
  115391. enableNoise: boolean;
  115392. /**
  115393. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115394. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  115395. * Recommended to be keep at 1.0 except for special cases.
  115396. */
  115397. fovMultiplier: number;
  115398. private _fovMultiplier;
  115399. /**
  115400. * Enable the FOV adjustment feature controlled by fovMultiplier.
  115401. */
  115402. useEquirectangularFOV: boolean;
  115403. private _maxSimultaneousLights;
  115404. /**
  115405. * Number of Simultaneous lights allowed on the material.
  115406. */
  115407. maxSimultaneousLights: int;
  115408. /**
  115409. * Default configuration related to image processing available in the Background Material.
  115410. */
  115411. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115412. /**
  115413. * Keep track of the image processing observer to allow dispose and replace.
  115414. */
  115415. private _imageProcessingObserver;
  115416. /**
  115417. * Attaches a new image processing configuration to the PBR Material.
  115418. * @param configuration (if null the scene configuration will be use)
  115419. */
  115420. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115421. /**
  115422. * Gets the image processing configuration used either in this material.
  115423. */
  115424. /**
  115425. * Sets the Default image processing configuration used either in the this material.
  115426. *
  115427. * If sets to null, the scene one is in use.
  115428. */
  115429. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  115430. /**
  115431. * Gets wether the color curves effect is enabled.
  115432. */
  115433. /**
  115434. * Sets wether the color curves effect is enabled.
  115435. */
  115436. cameraColorCurvesEnabled: boolean;
  115437. /**
  115438. * Gets wether the color grading effect is enabled.
  115439. */
  115440. /**
  115441. * Gets wether the color grading effect is enabled.
  115442. */
  115443. cameraColorGradingEnabled: boolean;
  115444. /**
  115445. * Gets wether tonemapping is enabled or not.
  115446. */
  115447. /**
  115448. * Sets wether tonemapping is enabled or not
  115449. */
  115450. cameraToneMappingEnabled: boolean;
  115451. /**
  115452. * The camera exposure used on this material.
  115453. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115454. * This corresponds to a photographic exposure.
  115455. */
  115456. /**
  115457. * The camera exposure used on this material.
  115458. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115459. * This corresponds to a photographic exposure.
  115460. */
  115461. cameraExposure: float;
  115462. /**
  115463. * Gets The camera contrast used on this material.
  115464. */
  115465. /**
  115466. * Sets The camera contrast used on this material.
  115467. */
  115468. cameraContrast: float;
  115469. /**
  115470. * Gets the Color Grading 2D Lookup Texture.
  115471. */
  115472. /**
  115473. * Sets the Color Grading 2D Lookup Texture.
  115474. */
  115475. cameraColorGradingTexture: Nullable<BaseTexture>;
  115476. /**
  115477. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115478. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115479. * 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;
  115480. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115481. */
  115482. /**
  115483. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115484. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115485. * 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;
  115486. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115487. */
  115488. cameraColorCurves: Nullable<ColorCurves>;
  115489. /**
  115490. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  115491. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  115492. */
  115493. switchToBGR: boolean;
  115494. private _renderTargets;
  115495. private _reflectionControls;
  115496. private _white;
  115497. private _primaryShadowColor;
  115498. private _primaryHighlightColor;
  115499. /**
  115500. * Instantiates a Background Material in the given scene
  115501. * @param name The friendly name of the material
  115502. * @param scene The scene to add the material to
  115503. */
  115504. constructor(name: string, scene: Scene);
  115505. /**
  115506. * Gets a boolean indicating that current material needs to register RTT
  115507. */
  115508. readonly hasRenderTargetTextures: boolean;
  115509. /**
  115510. * The entire material has been created in order to prevent overdraw.
  115511. * @returns false
  115512. */
  115513. needAlphaTesting(): boolean;
  115514. /**
  115515. * The entire material has been created in order to prevent overdraw.
  115516. * @returns true if blending is enable
  115517. */
  115518. needAlphaBlending(): boolean;
  115519. /**
  115520. * Checks wether the material is ready to be rendered for a given mesh.
  115521. * @param mesh The mesh to render
  115522. * @param subMesh The submesh to check against
  115523. * @param useInstances Specify wether or not the material is used with instances
  115524. * @returns true if all the dependencies are ready (Textures, Effects...)
  115525. */
  115526. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115527. /**
  115528. * Compute the primary color according to the chosen perceptual color.
  115529. */
  115530. private _computePrimaryColorFromPerceptualColor;
  115531. /**
  115532. * Compute the highlights and shadow colors according to their chosen levels.
  115533. */
  115534. private _computePrimaryColors;
  115535. /**
  115536. * Build the uniform buffer used in the material.
  115537. */
  115538. buildUniformLayout(): void;
  115539. /**
  115540. * Unbind the material.
  115541. */
  115542. unbind(): void;
  115543. /**
  115544. * Bind only the world matrix to the material.
  115545. * @param world The world matrix to bind.
  115546. */
  115547. bindOnlyWorldMatrix(world: Matrix): void;
  115548. /**
  115549. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  115550. * @param world The world matrix to bind.
  115551. * @param subMesh The submesh to bind for.
  115552. */
  115553. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115554. /**
  115555. * Checks to see if a texture is used in the material.
  115556. * @param texture - Base texture to use.
  115557. * @returns - Boolean specifying if a texture is used in the material.
  115558. */
  115559. hasTexture(texture: BaseTexture): boolean;
  115560. /**
  115561. * Dispose the material.
  115562. * @param forceDisposeEffect Force disposal of the associated effect.
  115563. * @param forceDisposeTextures Force disposal of the associated textures.
  115564. */
  115565. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115566. /**
  115567. * Clones the material.
  115568. * @param name The cloned name.
  115569. * @returns The cloned material.
  115570. */
  115571. clone(name: string): BackgroundMaterial;
  115572. /**
  115573. * Serializes the current material to its JSON representation.
  115574. * @returns The JSON representation.
  115575. */
  115576. serialize(): any;
  115577. /**
  115578. * Gets the class name of the material
  115579. * @returns "BackgroundMaterial"
  115580. */
  115581. getClassName(): string;
  115582. /**
  115583. * Parse a JSON input to create back a background material.
  115584. * @param source The JSON data to parse
  115585. * @param scene The scene to create the parsed material in
  115586. * @param rootUrl The root url of the assets the material depends upon
  115587. * @returns the instantiated BackgroundMaterial.
  115588. */
  115589. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  115590. }
  115591. }
  115592. declare module BABYLON {
  115593. /**
  115594. * Represents the different options available during the creation of
  115595. * a Environment helper.
  115596. *
  115597. * This can control the default ground, skybox and image processing setup of your scene.
  115598. */
  115599. export interface IEnvironmentHelperOptions {
  115600. /**
  115601. * Specifies wether or not to create a ground.
  115602. * True by default.
  115603. */
  115604. createGround: boolean;
  115605. /**
  115606. * Specifies the ground size.
  115607. * 15 by default.
  115608. */
  115609. groundSize: number;
  115610. /**
  115611. * The texture used on the ground for the main color.
  115612. * Comes from the BabylonJS CDN by default.
  115613. *
  115614. * Remarks: Can be either a texture or a url.
  115615. */
  115616. groundTexture: string | BaseTexture;
  115617. /**
  115618. * The color mixed in the ground texture by default.
  115619. * BabylonJS clearColor by default.
  115620. */
  115621. groundColor: Color3;
  115622. /**
  115623. * Specifies the ground opacity.
  115624. * 1 by default.
  115625. */
  115626. groundOpacity: number;
  115627. /**
  115628. * Enables the ground to receive shadows.
  115629. * True by default.
  115630. */
  115631. enableGroundShadow: boolean;
  115632. /**
  115633. * Helps preventing the shadow to be fully black on the ground.
  115634. * 0.5 by default.
  115635. */
  115636. groundShadowLevel: number;
  115637. /**
  115638. * Creates a mirror texture attach to the ground.
  115639. * false by default.
  115640. */
  115641. enableGroundMirror: boolean;
  115642. /**
  115643. * Specifies the ground mirror size ratio.
  115644. * 0.3 by default as the default kernel is 64.
  115645. */
  115646. groundMirrorSizeRatio: number;
  115647. /**
  115648. * Specifies the ground mirror blur kernel size.
  115649. * 64 by default.
  115650. */
  115651. groundMirrorBlurKernel: number;
  115652. /**
  115653. * Specifies the ground mirror visibility amount.
  115654. * 1 by default
  115655. */
  115656. groundMirrorAmount: number;
  115657. /**
  115658. * Specifies the ground mirror reflectance weight.
  115659. * This uses the standard weight of the background material to setup the fresnel effect
  115660. * of the mirror.
  115661. * 1 by default.
  115662. */
  115663. groundMirrorFresnelWeight: number;
  115664. /**
  115665. * Specifies the ground mirror Falloff distance.
  115666. * This can helps reducing the size of the reflection.
  115667. * 0 by Default.
  115668. */
  115669. groundMirrorFallOffDistance: number;
  115670. /**
  115671. * Specifies the ground mirror texture type.
  115672. * Unsigned Int by Default.
  115673. */
  115674. groundMirrorTextureType: number;
  115675. /**
  115676. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  115677. * the shown objects.
  115678. */
  115679. groundYBias: number;
  115680. /**
  115681. * Specifies wether or not to create a skybox.
  115682. * True by default.
  115683. */
  115684. createSkybox: boolean;
  115685. /**
  115686. * Specifies the skybox size.
  115687. * 20 by default.
  115688. */
  115689. skyboxSize: number;
  115690. /**
  115691. * The texture used on the skybox for the main color.
  115692. * Comes from the BabylonJS CDN by default.
  115693. *
  115694. * Remarks: Can be either a texture or a url.
  115695. */
  115696. skyboxTexture: string | BaseTexture;
  115697. /**
  115698. * The color mixed in the skybox texture by default.
  115699. * BabylonJS clearColor by default.
  115700. */
  115701. skyboxColor: Color3;
  115702. /**
  115703. * The background rotation around the Y axis of the scene.
  115704. * This helps aligning the key lights of your scene with the background.
  115705. * 0 by default.
  115706. */
  115707. backgroundYRotation: number;
  115708. /**
  115709. * Compute automatically the size of the elements to best fit with the scene.
  115710. */
  115711. sizeAuto: boolean;
  115712. /**
  115713. * Default position of the rootMesh if autoSize is not true.
  115714. */
  115715. rootPosition: Vector3;
  115716. /**
  115717. * Sets up the image processing in the scene.
  115718. * true by default.
  115719. */
  115720. setupImageProcessing: boolean;
  115721. /**
  115722. * The texture used as your environment texture in the scene.
  115723. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  115724. *
  115725. * Remarks: Can be either a texture or a url.
  115726. */
  115727. environmentTexture: string | BaseTexture;
  115728. /**
  115729. * The value of the exposure to apply to the scene.
  115730. * 0.6 by default if setupImageProcessing is true.
  115731. */
  115732. cameraExposure: number;
  115733. /**
  115734. * The value of the contrast to apply to the scene.
  115735. * 1.6 by default if setupImageProcessing is true.
  115736. */
  115737. cameraContrast: number;
  115738. /**
  115739. * Specifies wether or not tonemapping should be enabled in the scene.
  115740. * true by default if setupImageProcessing is true.
  115741. */
  115742. toneMappingEnabled: boolean;
  115743. }
  115744. /**
  115745. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  115746. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  115747. * It also helps with the default setup of your imageProcessing configuration.
  115748. */
  115749. export class EnvironmentHelper {
  115750. /**
  115751. * Default ground texture URL.
  115752. */
  115753. private static _groundTextureCDNUrl;
  115754. /**
  115755. * Default skybox texture URL.
  115756. */
  115757. private static _skyboxTextureCDNUrl;
  115758. /**
  115759. * Default environment texture URL.
  115760. */
  115761. private static _environmentTextureCDNUrl;
  115762. /**
  115763. * Creates the default options for the helper.
  115764. */
  115765. private static _getDefaultOptions;
  115766. private _rootMesh;
  115767. /**
  115768. * Gets the root mesh created by the helper.
  115769. */
  115770. readonly rootMesh: Mesh;
  115771. private _skybox;
  115772. /**
  115773. * Gets the skybox created by the helper.
  115774. */
  115775. readonly skybox: Nullable<Mesh>;
  115776. private _skyboxTexture;
  115777. /**
  115778. * Gets the skybox texture created by the helper.
  115779. */
  115780. readonly skyboxTexture: Nullable<BaseTexture>;
  115781. private _skyboxMaterial;
  115782. /**
  115783. * Gets the skybox material created by the helper.
  115784. */
  115785. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  115786. private _ground;
  115787. /**
  115788. * Gets the ground mesh created by the helper.
  115789. */
  115790. readonly ground: Nullable<Mesh>;
  115791. private _groundTexture;
  115792. /**
  115793. * Gets the ground texture created by the helper.
  115794. */
  115795. readonly groundTexture: Nullable<BaseTexture>;
  115796. private _groundMirror;
  115797. /**
  115798. * Gets the ground mirror created by the helper.
  115799. */
  115800. readonly groundMirror: Nullable<MirrorTexture>;
  115801. /**
  115802. * Gets the ground mirror render list to helps pushing the meshes
  115803. * you wish in the ground reflection.
  115804. */
  115805. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  115806. private _groundMaterial;
  115807. /**
  115808. * Gets the ground material created by the helper.
  115809. */
  115810. readonly groundMaterial: Nullable<BackgroundMaterial>;
  115811. /**
  115812. * Stores the creation options.
  115813. */
  115814. private readonly _scene;
  115815. private _options;
  115816. /**
  115817. * This observable will be notified with any error during the creation of the environment,
  115818. * mainly texture creation errors.
  115819. */
  115820. onErrorObservable: Observable<{
  115821. message?: string;
  115822. exception?: any;
  115823. }>;
  115824. /**
  115825. * constructor
  115826. * @param options Defines the options we want to customize the helper
  115827. * @param scene The scene to add the material to
  115828. */
  115829. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  115830. /**
  115831. * Updates the background according to the new options
  115832. * @param options
  115833. */
  115834. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  115835. /**
  115836. * Sets the primary color of all the available elements.
  115837. * @param color the main color to affect to the ground and the background
  115838. */
  115839. setMainColor(color: Color3): void;
  115840. /**
  115841. * Setup the image processing according to the specified options.
  115842. */
  115843. private _setupImageProcessing;
  115844. /**
  115845. * Setup the environment texture according to the specified options.
  115846. */
  115847. private _setupEnvironmentTexture;
  115848. /**
  115849. * Setup the background according to the specified options.
  115850. */
  115851. private _setupBackground;
  115852. /**
  115853. * Get the scene sizes according to the setup.
  115854. */
  115855. private _getSceneSize;
  115856. /**
  115857. * Setup the ground according to the specified options.
  115858. */
  115859. private _setupGround;
  115860. /**
  115861. * Setup the ground material according to the specified options.
  115862. */
  115863. private _setupGroundMaterial;
  115864. /**
  115865. * Setup the ground diffuse texture according to the specified options.
  115866. */
  115867. private _setupGroundDiffuseTexture;
  115868. /**
  115869. * Setup the ground mirror texture according to the specified options.
  115870. */
  115871. private _setupGroundMirrorTexture;
  115872. /**
  115873. * Setup the ground to receive the mirror texture.
  115874. */
  115875. private _setupMirrorInGroundMaterial;
  115876. /**
  115877. * Setup the skybox according to the specified options.
  115878. */
  115879. private _setupSkybox;
  115880. /**
  115881. * Setup the skybox material according to the specified options.
  115882. */
  115883. private _setupSkyboxMaterial;
  115884. /**
  115885. * Setup the skybox reflection texture according to the specified options.
  115886. */
  115887. private _setupSkyboxReflectionTexture;
  115888. private _errorHandler;
  115889. /**
  115890. * Dispose all the elements created by the Helper.
  115891. */
  115892. dispose(): void;
  115893. }
  115894. }
  115895. declare module BABYLON {
  115896. /**
  115897. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  115898. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  115899. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  115900. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115901. */
  115902. export class PhotoDome extends TransformNode {
  115903. /**
  115904. * Define the image as a Monoscopic panoramic 360 image.
  115905. */
  115906. static readonly MODE_MONOSCOPIC: number;
  115907. /**
  115908. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115909. */
  115910. static readonly MODE_TOPBOTTOM: number;
  115911. /**
  115912. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115913. */
  115914. static readonly MODE_SIDEBYSIDE: number;
  115915. private _useDirectMapping;
  115916. /**
  115917. * The texture being displayed on the sphere
  115918. */
  115919. protected _photoTexture: Texture;
  115920. /**
  115921. * Gets or sets the texture being displayed on the sphere
  115922. */
  115923. photoTexture: Texture;
  115924. /**
  115925. * Observable raised when an error occured while loading the 360 image
  115926. */
  115927. onLoadErrorObservable: Observable<string>;
  115928. /**
  115929. * The skybox material
  115930. */
  115931. protected _material: BackgroundMaterial;
  115932. /**
  115933. * The surface used for the skybox
  115934. */
  115935. protected _mesh: Mesh;
  115936. /**
  115937. * Gets the mesh used for the skybox.
  115938. */
  115939. readonly mesh: Mesh;
  115940. /**
  115941. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115942. * Also see the options.resolution property.
  115943. */
  115944. fovMultiplier: number;
  115945. private _imageMode;
  115946. /**
  115947. * Gets or set the current video mode for the video. It can be:
  115948. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  115949. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115950. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115951. */
  115952. imageMode: number;
  115953. /**
  115954. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  115955. * @param name Element's name, child elements will append suffixes for their own names.
  115956. * @param urlsOfPhoto defines the url of the photo to display
  115957. * @param options defines an object containing optional or exposed sub element properties
  115958. * @param onError defines a callback called when an error occured while loading the texture
  115959. */
  115960. constructor(name: string, urlOfPhoto: string, options: {
  115961. resolution?: number;
  115962. size?: number;
  115963. useDirectMapping?: boolean;
  115964. faceForward?: boolean;
  115965. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  115966. private _onBeforeCameraRenderObserver;
  115967. private _changeImageMode;
  115968. /**
  115969. * Releases resources associated with this node.
  115970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115972. */
  115973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115974. }
  115975. }
  115976. declare module BABYLON {
  115977. /**
  115978. * Class used to host RGBD texture specific utilities
  115979. */
  115980. export class RGBDTextureTools {
  115981. /**
  115982. * Expand the RGBD Texture from RGBD to Half Float if possible.
  115983. * @param texture the texture to expand.
  115984. */
  115985. static ExpandRGBDTexture(texture: Texture): void;
  115986. }
  115987. }
  115988. declare module BABYLON {
  115989. /**
  115990. * Class used to host texture specific utilities
  115991. */
  115992. export class BRDFTextureTools {
  115993. /**
  115994. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115995. * @param scene defines the hosting scene
  115996. * @returns the environment BRDF texture
  115997. */
  115998. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115999. private static _environmentBRDFBase64Texture;
  116000. }
  116001. }
  116002. declare module BABYLON {
  116003. /**
  116004. * @hidden
  116005. */
  116006. export interface IMaterialClearCoatDefines {
  116007. CLEARCOAT: boolean;
  116008. CLEARCOAT_DEFAULTIOR: boolean;
  116009. CLEARCOAT_TEXTURE: boolean;
  116010. CLEARCOAT_TEXTUREDIRECTUV: number;
  116011. CLEARCOAT_BUMP: boolean;
  116012. CLEARCOAT_BUMPDIRECTUV: number;
  116013. CLEARCOAT_TINT: boolean;
  116014. CLEARCOAT_TINT_TEXTURE: boolean;
  116015. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116016. /** @hidden */
  116017. _areTexturesDirty: boolean;
  116018. }
  116019. /**
  116020. * Define the code related to the clear coat parameters of the pbr material.
  116021. */
  116022. export class PBRClearCoatConfiguration {
  116023. /**
  116024. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116025. * The default fits with a polyurethane material.
  116026. */
  116027. private static readonly _DefaultIndexOfRefraction;
  116028. private _isEnabled;
  116029. /**
  116030. * Defines if the clear coat is enabled in the material.
  116031. */
  116032. isEnabled: boolean;
  116033. /**
  116034. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  116035. */
  116036. intensity: number;
  116037. /**
  116038. * Defines the clear coat layer roughness.
  116039. */
  116040. roughness: number;
  116041. private _indexOfRefraction;
  116042. /**
  116043. * Defines the index of refraction of the clear coat.
  116044. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116045. * The default fits with a polyurethane material.
  116046. * Changing the default value is more performance intensive.
  116047. */
  116048. indexOfRefraction: number;
  116049. private _texture;
  116050. /**
  116051. * Stores the clear coat values in a texture.
  116052. */
  116053. texture: Nullable<BaseTexture>;
  116054. private _bumpTexture;
  116055. /**
  116056. * Define the clear coat specific bump texture.
  116057. */
  116058. bumpTexture: Nullable<BaseTexture>;
  116059. private _isTintEnabled;
  116060. /**
  116061. * Defines if the clear coat tint is enabled in the material.
  116062. */
  116063. isTintEnabled: boolean;
  116064. /**
  116065. * Defines the clear coat tint of the material.
  116066. * This is only use if tint is enabled
  116067. */
  116068. tintColor: Color3;
  116069. /**
  116070. * Defines the distance at which the tint color should be found in the
  116071. * clear coat media.
  116072. * This is only use if tint is enabled
  116073. */
  116074. tintColorAtDistance: number;
  116075. /**
  116076. * Defines the clear coat layer thickness.
  116077. * This is only use if tint is enabled
  116078. */
  116079. tintThickness: number;
  116080. private _tintTexture;
  116081. /**
  116082. * Stores the clear tint values in a texture.
  116083. * rgb is tint
  116084. * a is a thickness factor
  116085. */
  116086. tintTexture: Nullable<BaseTexture>;
  116087. /** @hidden */
  116088. private _internalMarkAllSubMeshesAsTexturesDirty;
  116089. /** @hidden */
  116090. _markAllSubMeshesAsTexturesDirty(): void;
  116091. /**
  116092. * Instantiate a new istance of clear coat configuration.
  116093. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116094. */
  116095. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116096. /**
  116097. * Gets wehter the submesh is ready to be used or not.
  116098. * @param defines the list of "defines" to update.
  116099. * @param scene defines the scene the material belongs to.
  116100. * @param engine defines the engine the material belongs to.
  116101. * @param disableBumpMap defines wether the material disables bump or not.
  116102. * @returns - boolean indicating that the submesh is ready or not.
  116103. */
  116104. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  116105. /**
  116106. * Checks to see if a texture is used in the material.
  116107. * @param defines the list of "defines" to update.
  116108. * @param scene defines the scene to the material belongs to.
  116109. */
  116110. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  116111. /**
  116112. * Binds the material data.
  116113. * @param uniformBuffer defines the Uniform buffer to fill in.
  116114. * @param scene defines the scene the material belongs to.
  116115. * @param engine defines the engine the material belongs to.
  116116. * @param disableBumpMap defines wether the material disables bump or not.
  116117. * @param isFrozen defines wether the material is frozen or not.
  116118. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116119. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116120. */
  116121. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  116122. /**
  116123. * Checks to see if a texture is used in the material.
  116124. * @param texture - Base texture to use.
  116125. * @returns - Boolean specifying if a texture is used in the material.
  116126. */
  116127. hasTexture(texture: BaseTexture): boolean;
  116128. /**
  116129. * Returns an array of the actively used textures.
  116130. * @param activeTextures Array of BaseTextures
  116131. */
  116132. getActiveTextures(activeTextures: BaseTexture[]): void;
  116133. /**
  116134. * Returns the animatable textures.
  116135. * @param animatables Array of animatable textures.
  116136. */
  116137. getAnimatables(animatables: IAnimatable[]): void;
  116138. /**
  116139. * Disposes the resources of the material.
  116140. * @param forceDisposeTextures - Forces the disposal of all textures.
  116141. */
  116142. dispose(forceDisposeTextures?: boolean): void;
  116143. /**
  116144. * Get the current class name of the texture useful for serialization or dynamic coding.
  116145. * @returns "PBRClearCoatConfiguration"
  116146. */
  116147. getClassName(): string;
  116148. /**
  116149. * Add fallbacks to the effect fallbacks list.
  116150. * @param defines defines the Base texture to use.
  116151. * @param fallbacks defines the current fallback list.
  116152. * @param currentRank defines the current fallback rank.
  116153. * @returns the new fallback rank.
  116154. */
  116155. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116156. /**
  116157. * Add the required uniforms to the current list.
  116158. * @param uniforms defines the current uniform list.
  116159. */
  116160. static AddUniforms(uniforms: string[]): void;
  116161. /**
  116162. * Add the required samplers to the current list.
  116163. * @param samplers defines the current sampler list.
  116164. */
  116165. static AddSamplers(samplers: string[]): void;
  116166. /**
  116167. * Add the required uniforms to the current buffer.
  116168. * @param uniformBuffer defines the current uniform buffer.
  116169. */
  116170. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116171. /**
  116172. * Makes a duplicate of the current configuration into another one.
  116173. * @param clearCoatConfiguration define the config where to copy the info
  116174. */
  116175. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  116176. /**
  116177. * Serializes this clear coat configuration.
  116178. * @returns - An object with the serialized config.
  116179. */
  116180. serialize(): any;
  116181. /**
  116182. * Parses a anisotropy Configuration from a serialized object.
  116183. * @param source - Serialized object.
  116184. * @param scene Defines the scene we are parsing for
  116185. * @param rootUrl Defines the rootUrl to load from
  116186. */
  116187. parse(source: any, scene: Scene, rootUrl: string): void;
  116188. }
  116189. }
  116190. declare module BABYLON {
  116191. /**
  116192. * @hidden
  116193. */
  116194. export interface IMaterialAnisotropicDefines {
  116195. ANISOTROPIC: boolean;
  116196. ANISOTROPIC_TEXTURE: boolean;
  116197. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116198. MAINUV1: boolean;
  116199. _areTexturesDirty: boolean;
  116200. _needUVs: boolean;
  116201. }
  116202. /**
  116203. * Define the code related to the anisotropic parameters of the pbr material.
  116204. */
  116205. export class PBRAnisotropicConfiguration {
  116206. private _isEnabled;
  116207. /**
  116208. * Defines if the anisotropy is enabled in the material.
  116209. */
  116210. isEnabled: boolean;
  116211. /**
  116212. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  116213. */
  116214. intensity: number;
  116215. /**
  116216. * Defines if the effect is along the tangents, bitangents or in between.
  116217. * By default, the effect is "strectching" the highlights along the tangents.
  116218. */
  116219. direction: Vector2;
  116220. private _texture;
  116221. /**
  116222. * Stores the anisotropy values in a texture.
  116223. * rg is direction (like normal from -1 to 1)
  116224. * b is a intensity
  116225. */
  116226. texture: Nullable<BaseTexture>;
  116227. /** @hidden */
  116228. private _internalMarkAllSubMeshesAsTexturesDirty;
  116229. /** @hidden */
  116230. _markAllSubMeshesAsTexturesDirty(): void;
  116231. /**
  116232. * Instantiate a new istance of anisotropy configuration.
  116233. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116234. */
  116235. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116236. /**
  116237. * Specifies that the submesh is ready to be used.
  116238. * @param defines the list of "defines" to update.
  116239. * @param scene defines the scene the material belongs to.
  116240. * @returns - boolean indicating that the submesh is ready or not.
  116241. */
  116242. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  116243. /**
  116244. * Checks to see if a texture is used in the material.
  116245. * @param defines the list of "defines" to update.
  116246. * @param mesh the mesh we are preparing the defines for.
  116247. * @param scene defines the scene the material belongs to.
  116248. */
  116249. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  116250. /**
  116251. * Binds the material data.
  116252. * @param uniformBuffer defines the Uniform buffer to fill in.
  116253. * @param scene defines the scene the material belongs to.
  116254. * @param isFrozen defines wether the material is frozen or not.
  116255. */
  116256. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116257. /**
  116258. * Checks to see if a texture is used in the material.
  116259. * @param texture - Base texture to use.
  116260. * @returns - Boolean specifying if a texture is used in the material.
  116261. */
  116262. hasTexture(texture: BaseTexture): boolean;
  116263. /**
  116264. * Returns an array of the actively used textures.
  116265. * @param activeTextures Array of BaseTextures
  116266. */
  116267. getActiveTextures(activeTextures: BaseTexture[]): void;
  116268. /**
  116269. * Returns the animatable textures.
  116270. * @param animatables Array of animatable textures.
  116271. */
  116272. getAnimatables(animatables: IAnimatable[]): void;
  116273. /**
  116274. * Disposes the resources of the material.
  116275. * @param forceDisposeTextures - Forces the disposal of all textures.
  116276. */
  116277. dispose(forceDisposeTextures?: boolean): void;
  116278. /**
  116279. * Get the current class name of the texture useful for serialization or dynamic coding.
  116280. * @returns "PBRAnisotropicConfiguration"
  116281. */
  116282. getClassName(): string;
  116283. /**
  116284. * Add fallbacks to the effect fallbacks list.
  116285. * @param defines defines the Base texture to use.
  116286. * @param fallbacks defines the current fallback list.
  116287. * @param currentRank defines the current fallback rank.
  116288. * @returns the new fallback rank.
  116289. */
  116290. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116291. /**
  116292. * Add the required uniforms to the current list.
  116293. * @param uniforms defines the current uniform list.
  116294. */
  116295. static AddUniforms(uniforms: string[]): void;
  116296. /**
  116297. * Add the required uniforms to the current buffer.
  116298. * @param uniformBuffer defines the current uniform buffer.
  116299. */
  116300. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116301. /**
  116302. * Add the required samplers to the current list.
  116303. * @param samplers defines the current sampler list.
  116304. */
  116305. static AddSamplers(samplers: string[]): void;
  116306. /**
  116307. * Makes a duplicate of the current configuration into another one.
  116308. * @param anisotropicConfiguration define the config where to copy the info
  116309. */
  116310. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  116311. /**
  116312. * Serializes this anisotropy configuration.
  116313. * @returns - An object with the serialized config.
  116314. */
  116315. serialize(): any;
  116316. /**
  116317. * Parses a anisotropy Configuration from a serialized object.
  116318. * @param source - Serialized object.
  116319. * @param scene Defines the scene we are parsing for
  116320. * @param rootUrl Defines the rootUrl to load from
  116321. */
  116322. parse(source: any, scene: Scene, rootUrl: string): void;
  116323. }
  116324. }
  116325. declare module BABYLON {
  116326. /**
  116327. * @hidden
  116328. */
  116329. export interface IMaterialBRDFDefines {
  116330. BRDF_V_HEIGHT_CORRELATED: boolean;
  116331. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116332. SPHERICAL_HARMONICS: boolean;
  116333. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116334. /** @hidden */
  116335. _areMiscDirty: boolean;
  116336. }
  116337. /**
  116338. * Define the code related to the BRDF parameters of the pbr material.
  116339. */
  116340. export class PBRBRDFConfiguration {
  116341. /**
  116342. * Default value used for the energy conservation.
  116343. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116344. */
  116345. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  116346. /**
  116347. * Default value used for the Smith Visibility Height Correlated mode.
  116348. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116349. */
  116350. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  116351. /**
  116352. * Default value used for the IBL diffuse part.
  116353. * This can help switching back to the polynomials mode globally which is a tiny bit
  116354. * less GPU intensive at the drawback of a lower quality.
  116355. */
  116356. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  116357. /**
  116358. * Default value used for activating energy conservation for the specular workflow.
  116359. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116360. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116361. */
  116362. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  116363. private _useEnergyConservation;
  116364. /**
  116365. * Defines if the material uses energy conservation.
  116366. */
  116367. useEnergyConservation: boolean;
  116368. private _useSmithVisibilityHeightCorrelated;
  116369. /**
  116370. * LEGACY Mode set to false
  116371. * Defines if the material uses height smith correlated visibility term.
  116372. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  116373. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  116374. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  116375. * Not relying on height correlated will also disable energy conservation.
  116376. */
  116377. useSmithVisibilityHeightCorrelated: boolean;
  116378. private _useSphericalHarmonics;
  116379. /**
  116380. * LEGACY Mode set to false
  116381. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  116382. * diffuse part of the IBL.
  116383. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  116384. * to the ground truth.
  116385. */
  116386. useSphericalHarmonics: boolean;
  116387. private _useSpecularGlossinessInputEnergyConservation;
  116388. /**
  116389. * Defines if the material uses energy conservation, when the specular workflow is active.
  116390. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116391. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116392. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  116393. */
  116394. useSpecularGlossinessInputEnergyConservation: boolean;
  116395. /** @hidden */
  116396. private _internalMarkAllSubMeshesAsMiscDirty;
  116397. /** @hidden */
  116398. _markAllSubMeshesAsMiscDirty(): void;
  116399. /**
  116400. * Instantiate a new istance of clear coat configuration.
  116401. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  116402. */
  116403. constructor(markAllSubMeshesAsMiscDirty: () => void);
  116404. /**
  116405. * Checks to see if a texture is used in the material.
  116406. * @param defines the list of "defines" to update.
  116407. */
  116408. prepareDefines(defines: IMaterialBRDFDefines): void;
  116409. /**
  116410. * Get the current class name of the texture useful for serialization or dynamic coding.
  116411. * @returns "PBRClearCoatConfiguration"
  116412. */
  116413. getClassName(): string;
  116414. /**
  116415. * Makes a duplicate of the current configuration into another one.
  116416. * @param brdfConfiguration define the config where to copy the info
  116417. */
  116418. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  116419. /**
  116420. * Serializes this BRDF configuration.
  116421. * @returns - An object with the serialized config.
  116422. */
  116423. serialize(): any;
  116424. /**
  116425. * Parses a anisotropy Configuration from a serialized object.
  116426. * @param source - Serialized object.
  116427. * @param scene Defines the scene we are parsing for
  116428. * @param rootUrl Defines the rootUrl to load from
  116429. */
  116430. parse(source: any, scene: Scene, rootUrl: string): void;
  116431. }
  116432. }
  116433. declare module BABYLON {
  116434. /**
  116435. * @hidden
  116436. */
  116437. export interface IMaterialSheenDefines {
  116438. SHEEN: boolean;
  116439. SHEEN_TEXTURE: boolean;
  116440. SHEEN_TEXTUREDIRECTUV: number;
  116441. SHEEN_LINKWITHALBEDO: boolean;
  116442. /** @hidden */
  116443. _areTexturesDirty: boolean;
  116444. }
  116445. /**
  116446. * Define the code related to the Sheen parameters of the pbr material.
  116447. */
  116448. export class PBRSheenConfiguration {
  116449. private _isEnabled;
  116450. /**
  116451. * Defines if the material uses sheen.
  116452. */
  116453. isEnabled: boolean;
  116454. private _linkSheenWithAlbedo;
  116455. /**
  116456. * Defines if the sheen is linked to the sheen color.
  116457. */
  116458. linkSheenWithAlbedo: boolean;
  116459. /**
  116460. * Defines the sheen intensity.
  116461. */
  116462. intensity: number;
  116463. /**
  116464. * Defines the sheen color.
  116465. */
  116466. color: Color3;
  116467. private _texture;
  116468. /**
  116469. * Stores the sheen tint values in a texture.
  116470. * rgb is tint
  116471. * a is a intensity
  116472. */
  116473. texture: Nullable<BaseTexture>;
  116474. /** @hidden */
  116475. private _internalMarkAllSubMeshesAsTexturesDirty;
  116476. /** @hidden */
  116477. _markAllSubMeshesAsTexturesDirty(): void;
  116478. /**
  116479. * Instantiate a new istance of clear coat configuration.
  116480. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116481. */
  116482. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116483. /**
  116484. * Specifies that the submesh is ready to be used.
  116485. * @param defines the list of "defines" to update.
  116486. * @param scene defines the scene the material belongs to.
  116487. * @returns - boolean indicating that the submesh is ready or not.
  116488. */
  116489. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  116490. /**
  116491. * Checks to see if a texture is used in the material.
  116492. * @param defines the list of "defines" to update.
  116493. * @param scene defines the scene the material belongs to.
  116494. */
  116495. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  116496. /**
  116497. * Binds the material data.
  116498. * @param uniformBuffer defines the Uniform buffer to fill in.
  116499. * @param scene defines the scene the material belongs to.
  116500. * @param isFrozen defines wether the material is frozen or not.
  116501. */
  116502. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116503. /**
  116504. * Checks to see if a texture is used in the material.
  116505. * @param texture - Base texture to use.
  116506. * @returns - Boolean specifying if a texture is used in the material.
  116507. */
  116508. hasTexture(texture: BaseTexture): boolean;
  116509. /**
  116510. * Returns an array of the actively used textures.
  116511. * @param activeTextures Array of BaseTextures
  116512. */
  116513. getActiveTextures(activeTextures: BaseTexture[]): void;
  116514. /**
  116515. * Returns the animatable textures.
  116516. * @param animatables Array of animatable textures.
  116517. */
  116518. getAnimatables(animatables: IAnimatable[]): void;
  116519. /**
  116520. * Disposes the resources of the material.
  116521. * @param forceDisposeTextures - Forces the disposal of all textures.
  116522. */
  116523. dispose(forceDisposeTextures?: boolean): void;
  116524. /**
  116525. * Get the current class name of the texture useful for serialization or dynamic coding.
  116526. * @returns "PBRSheenConfiguration"
  116527. */
  116528. getClassName(): string;
  116529. /**
  116530. * Add fallbacks to the effect fallbacks list.
  116531. * @param defines defines the Base texture to use.
  116532. * @param fallbacks defines the current fallback list.
  116533. * @param currentRank defines the current fallback rank.
  116534. * @returns the new fallback rank.
  116535. */
  116536. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116537. /**
  116538. * Add the required uniforms to the current list.
  116539. * @param uniforms defines the current uniform list.
  116540. */
  116541. static AddUniforms(uniforms: string[]): void;
  116542. /**
  116543. * Add the required uniforms to the current buffer.
  116544. * @param uniformBuffer defines the current uniform buffer.
  116545. */
  116546. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116547. /**
  116548. * Add the required samplers to the current list.
  116549. * @param samplers defines the current sampler list.
  116550. */
  116551. static AddSamplers(samplers: string[]): void;
  116552. /**
  116553. * Makes a duplicate of the current configuration into another one.
  116554. * @param sheenConfiguration define the config where to copy the info
  116555. */
  116556. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  116557. /**
  116558. * Serializes this BRDF configuration.
  116559. * @returns - An object with the serialized config.
  116560. */
  116561. serialize(): any;
  116562. /**
  116563. * Parses a anisotropy Configuration from a serialized object.
  116564. * @param source - Serialized object.
  116565. * @param scene Defines the scene we are parsing for
  116566. * @param rootUrl Defines the rootUrl to load from
  116567. */
  116568. parse(source: any, scene: Scene, rootUrl: string): void;
  116569. }
  116570. }
  116571. declare module BABYLON {
  116572. /**
  116573. * @hidden
  116574. */
  116575. export interface IMaterialSubSurfaceDefines {
  116576. SUBSURFACE: boolean;
  116577. SS_REFRACTION: boolean;
  116578. SS_TRANSLUCENCY: boolean;
  116579. SS_SCATERRING: boolean;
  116580. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116581. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116582. SS_REFRACTIONMAP_3D: boolean;
  116583. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116584. SS_LODINREFRACTIONALPHA: boolean;
  116585. SS_GAMMAREFRACTION: boolean;
  116586. SS_RGBDREFRACTION: boolean;
  116587. SS_LINEARSPECULARREFRACTION: boolean;
  116588. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116589. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116590. /** @hidden */
  116591. _areTexturesDirty: boolean;
  116592. }
  116593. /**
  116594. * Define the code related to the sub surface parameters of the pbr material.
  116595. */
  116596. export class PBRSubSurfaceConfiguration {
  116597. private _isRefractionEnabled;
  116598. /**
  116599. * Defines if the refraction is enabled in the material.
  116600. */
  116601. isRefractionEnabled: boolean;
  116602. private _isTranslucencyEnabled;
  116603. /**
  116604. * Defines if the translucency is enabled in the material.
  116605. */
  116606. isTranslucencyEnabled: boolean;
  116607. private _isScatteringEnabled;
  116608. /**
  116609. * Defines the refraction intensity of the material.
  116610. * The refraction when enabled replaces the Diffuse part of the material.
  116611. * The intensity helps transitionning between diffuse and refraction.
  116612. */
  116613. refractionIntensity: number;
  116614. /**
  116615. * Defines the translucency intensity of the material.
  116616. * When translucency has been enabled, this defines how much of the "translucency"
  116617. * is addded to the diffuse part of the material.
  116618. */
  116619. translucencyIntensity: number;
  116620. /**
  116621. * Defines the scattering intensity of the material.
  116622. * When scattering has been enabled, this defines how much of the "scattered light"
  116623. * is addded to the diffuse part of the material.
  116624. */
  116625. scatteringIntensity: number;
  116626. private _thicknessTexture;
  116627. /**
  116628. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  116629. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  116630. * 0 would mean minimumThickness
  116631. * 1 would mean maximumThickness
  116632. * The other channels might be use as a mask to vary the different effects intensity.
  116633. */
  116634. thicknessTexture: Nullable<BaseTexture>;
  116635. private _refractionTexture;
  116636. /**
  116637. * Defines the texture to use for refraction.
  116638. */
  116639. refractionTexture: Nullable<BaseTexture>;
  116640. private _indexOfRefraction;
  116641. /**
  116642. * Defines the index of refraction used in the material.
  116643. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  116644. */
  116645. indexOfRefraction: number;
  116646. private _invertRefractionY;
  116647. /**
  116648. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116649. */
  116650. invertRefractionY: boolean;
  116651. private _linkRefractionWithTransparency;
  116652. /**
  116653. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116654. * Materials half opaque for instance using refraction could benefit from this control.
  116655. */
  116656. linkRefractionWithTransparency: boolean;
  116657. /**
  116658. * Defines the minimum thickness stored in the thickness map.
  116659. * If no thickness map is defined, this value will be used to simulate thickness.
  116660. */
  116661. minimumThickness: number;
  116662. /**
  116663. * Defines the maximum thickness stored in the thickness map.
  116664. */
  116665. maximumThickness: number;
  116666. /**
  116667. * Defines the volume tint of the material.
  116668. * This is used for both translucency and scattering.
  116669. */
  116670. tintColor: Color3;
  116671. /**
  116672. * Defines the distance at which the tint color should be found in the media.
  116673. * This is used for refraction only.
  116674. */
  116675. tintColorAtDistance: number;
  116676. /**
  116677. * Defines how far each channel transmit through the media.
  116678. * It is defined as a color to simplify it selection.
  116679. */
  116680. diffusionDistance: Color3;
  116681. private _useMaskFromThicknessTexture;
  116682. /**
  116683. * Stores the intensity of the different subsurface effects in the thickness texture.
  116684. * * the green channel is the translucency intensity.
  116685. * * the blue channel is the scattering intensity.
  116686. * * the alpha channel is the refraction intensity.
  116687. */
  116688. useMaskFromThicknessTexture: boolean;
  116689. /** @hidden */
  116690. private _internalMarkAllSubMeshesAsTexturesDirty;
  116691. /** @hidden */
  116692. _markAllSubMeshesAsTexturesDirty(): void;
  116693. /**
  116694. * Instantiate a new istance of sub surface configuration.
  116695. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116696. */
  116697. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116698. /**
  116699. * Gets wehter the submesh is ready to be used or not.
  116700. * @param defines the list of "defines" to update.
  116701. * @param scene defines the scene the material belongs to.
  116702. * @returns - boolean indicating that the submesh is ready or not.
  116703. */
  116704. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  116705. /**
  116706. * Checks to see if a texture is used in the material.
  116707. * @param defines the list of "defines" to update.
  116708. * @param scene defines the scene to the material belongs to.
  116709. */
  116710. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  116711. /**
  116712. * Binds the material data.
  116713. * @param uniformBuffer defines the Uniform buffer to fill in.
  116714. * @param scene defines the scene the material belongs to.
  116715. * @param engine defines the engine the material belongs to.
  116716. * @param isFrozen defines wether the material is frozen or not.
  116717. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  116718. */
  116719. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  116720. /**
  116721. * Unbinds the material from the mesh.
  116722. * @param activeEffect defines the effect that should be unbound from.
  116723. * @returns true if unbound, otherwise false
  116724. */
  116725. unbind(activeEffect: Effect): boolean;
  116726. /**
  116727. * Returns the texture used for refraction or null if none is used.
  116728. * @param scene defines the scene the material belongs to.
  116729. * @returns - Refraction texture if present. If no refraction texture and refraction
  116730. * is linked with transparency, returns environment texture. Otherwise, returns null.
  116731. */
  116732. private _getRefractionTexture;
  116733. /**
  116734. * Returns true if alpha blending should be disabled.
  116735. */
  116736. readonly disableAlphaBlending: boolean;
  116737. /**
  116738. * Fills the list of render target textures.
  116739. * @param renderTargets the list of render targets to update
  116740. */
  116741. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  116742. /**
  116743. * Checks to see if a texture is used in the material.
  116744. * @param texture - Base texture to use.
  116745. * @returns - Boolean specifying if a texture is used in the material.
  116746. */
  116747. hasTexture(texture: BaseTexture): boolean;
  116748. /**
  116749. * Gets a boolean indicating that current material needs to register RTT
  116750. * @returns true if this uses a render target otherwise false.
  116751. */
  116752. hasRenderTargetTextures(): boolean;
  116753. /**
  116754. * Returns an array of the actively used textures.
  116755. * @param activeTextures Array of BaseTextures
  116756. */
  116757. getActiveTextures(activeTextures: BaseTexture[]): void;
  116758. /**
  116759. * Returns the animatable textures.
  116760. * @param animatables Array of animatable textures.
  116761. */
  116762. getAnimatables(animatables: IAnimatable[]): void;
  116763. /**
  116764. * Disposes the resources of the material.
  116765. * @param forceDisposeTextures - Forces the disposal of all textures.
  116766. */
  116767. dispose(forceDisposeTextures?: boolean): void;
  116768. /**
  116769. * Get the current class name of the texture useful for serialization or dynamic coding.
  116770. * @returns "PBRSubSurfaceConfiguration"
  116771. */
  116772. getClassName(): string;
  116773. /**
  116774. * Add fallbacks to the effect fallbacks list.
  116775. * @param defines defines the Base texture to use.
  116776. * @param fallbacks defines the current fallback list.
  116777. * @param currentRank defines the current fallback rank.
  116778. * @returns the new fallback rank.
  116779. */
  116780. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116781. /**
  116782. * Add the required uniforms to the current list.
  116783. * @param uniforms defines the current uniform list.
  116784. */
  116785. static AddUniforms(uniforms: string[]): void;
  116786. /**
  116787. * Add the required samplers to the current list.
  116788. * @param samplers defines the current sampler list.
  116789. */
  116790. static AddSamplers(samplers: string[]): void;
  116791. /**
  116792. * Add the required uniforms to the current buffer.
  116793. * @param uniformBuffer defines the current uniform buffer.
  116794. */
  116795. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116796. /**
  116797. * Makes a duplicate of the current configuration into another one.
  116798. * @param configuration define the config where to copy the info
  116799. */
  116800. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  116801. /**
  116802. * Serializes this Sub Surface configuration.
  116803. * @returns - An object with the serialized config.
  116804. */
  116805. serialize(): any;
  116806. /**
  116807. * Parses a anisotropy Configuration from a serialized object.
  116808. * @param source - Serialized object.
  116809. * @param scene Defines the scene we are parsing for
  116810. * @param rootUrl Defines the rootUrl to load from
  116811. */
  116812. parse(source: any, scene: Scene, rootUrl: string): void;
  116813. }
  116814. }
  116815. declare module BABYLON {
  116816. /** @hidden */
  116817. export var pbrFragmentDeclaration: {
  116818. name: string;
  116819. shader: string;
  116820. };
  116821. }
  116822. declare module BABYLON {
  116823. /** @hidden */
  116824. export var pbrUboDeclaration: {
  116825. name: string;
  116826. shader: string;
  116827. };
  116828. }
  116829. declare module BABYLON {
  116830. /** @hidden */
  116831. export var pbrFragmentExtraDeclaration: {
  116832. name: string;
  116833. shader: string;
  116834. };
  116835. }
  116836. declare module BABYLON {
  116837. /** @hidden */
  116838. export var pbrFragmentSamplersDeclaration: {
  116839. name: string;
  116840. shader: string;
  116841. };
  116842. }
  116843. declare module BABYLON {
  116844. /** @hidden */
  116845. export var pbrHelperFunctions: {
  116846. name: string;
  116847. shader: string;
  116848. };
  116849. }
  116850. declare module BABYLON {
  116851. /** @hidden */
  116852. export var harmonicsFunctions: {
  116853. name: string;
  116854. shader: string;
  116855. };
  116856. }
  116857. declare module BABYLON {
  116858. /** @hidden */
  116859. export var pbrDirectLightingSetupFunctions: {
  116860. name: string;
  116861. shader: string;
  116862. };
  116863. }
  116864. declare module BABYLON {
  116865. /** @hidden */
  116866. export var pbrDirectLightingFalloffFunctions: {
  116867. name: string;
  116868. shader: string;
  116869. };
  116870. }
  116871. declare module BABYLON {
  116872. /** @hidden */
  116873. export var pbrBRDFFunctions: {
  116874. name: string;
  116875. shader: string;
  116876. };
  116877. }
  116878. declare module BABYLON {
  116879. /** @hidden */
  116880. export var pbrDirectLightingFunctions: {
  116881. name: string;
  116882. shader: string;
  116883. };
  116884. }
  116885. declare module BABYLON {
  116886. /** @hidden */
  116887. export var pbrIBLFunctions: {
  116888. name: string;
  116889. shader: string;
  116890. };
  116891. }
  116892. declare module BABYLON {
  116893. /** @hidden */
  116894. export var pbrDebug: {
  116895. name: string;
  116896. shader: string;
  116897. };
  116898. }
  116899. declare module BABYLON {
  116900. /** @hidden */
  116901. export var pbrPixelShader: {
  116902. name: string;
  116903. shader: string;
  116904. };
  116905. }
  116906. declare module BABYLON {
  116907. /** @hidden */
  116908. export var pbrVertexDeclaration: {
  116909. name: string;
  116910. shader: string;
  116911. };
  116912. }
  116913. declare module BABYLON {
  116914. /** @hidden */
  116915. export var pbrVertexShader: {
  116916. name: string;
  116917. shader: string;
  116918. };
  116919. }
  116920. declare module BABYLON {
  116921. /**
  116922. * Manages the defines for the PBR Material.
  116923. * @hidden
  116924. */
  116925. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  116926. PBR: boolean;
  116927. MAINUV1: boolean;
  116928. MAINUV2: boolean;
  116929. UV1: boolean;
  116930. UV2: boolean;
  116931. ALBEDO: boolean;
  116932. ALBEDODIRECTUV: number;
  116933. VERTEXCOLOR: boolean;
  116934. AMBIENT: boolean;
  116935. AMBIENTDIRECTUV: number;
  116936. AMBIENTINGRAYSCALE: boolean;
  116937. OPACITY: boolean;
  116938. VERTEXALPHA: boolean;
  116939. OPACITYDIRECTUV: number;
  116940. OPACITYRGB: boolean;
  116941. ALPHATEST: boolean;
  116942. DEPTHPREPASS: boolean;
  116943. ALPHABLEND: boolean;
  116944. ALPHAFROMALBEDO: boolean;
  116945. ALPHATESTVALUE: string;
  116946. SPECULAROVERALPHA: boolean;
  116947. RADIANCEOVERALPHA: boolean;
  116948. ALPHAFRESNEL: boolean;
  116949. LINEARALPHAFRESNEL: boolean;
  116950. PREMULTIPLYALPHA: boolean;
  116951. EMISSIVE: boolean;
  116952. EMISSIVEDIRECTUV: number;
  116953. REFLECTIVITY: boolean;
  116954. REFLECTIVITYDIRECTUV: number;
  116955. SPECULARTERM: boolean;
  116956. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  116957. MICROSURFACEAUTOMATIC: boolean;
  116958. LODBASEDMICROSFURACE: boolean;
  116959. MICROSURFACEMAP: boolean;
  116960. MICROSURFACEMAPDIRECTUV: number;
  116961. METALLICWORKFLOW: boolean;
  116962. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  116963. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  116964. METALLNESSSTOREINMETALMAPBLUE: boolean;
  116965. AOSTOREINMETALMAPRED: boolean;
  116966. METALLICF0FACTORFROMMETALLICMAP: boolean;
  116967. ENVIRONMENTBRDF: boolean;
  116968. ENVIRONMENTBRDF_RGBD: boolean;
  116969. NORMAL: boolean;
  116970. TANGENT: boolean;
  116971. BUMP: boolean;
  116972. BUMPDIRECTUV: number;
  116973. OBJECTSPACE_NORMALMAP: boolean;
  116974. PARALLAX: boolean;
  116975. PARALLAXOCCLUSION: boolean;
  116976. NORMALXYSCALE: boolean;
  116977. LIGHTMAP: boolean;
  116978. LIGHTMAPDIRECTUV: number;
  116979. USELIGHTMAPASSHADOWMAP: boolean;
  116980. GAMMALIGHTMAP: boolean;
  116981. RGBDLIGHTMAP: boolean;
  116982. REFLECTION: boolean;
  116983. REFLECTIONMAP_3D: boolean;
  116984. REFLECTIONMAP_SPHERICAL: boolean;
  116985. REFLECTIONMAP_PLANAR: boolean;
  116986. REFLECTIONMAP_CUBIC: boolean;
  116987. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  116988. REFLECTIONMAP_PROJECTION: boolean;
  116989. REFLECTIONMAP_SKYBOX: boolean;
  116990. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  116991. REFLECTIONMAP_EXPLICIT: boolean;
  116992. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  116993. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116994. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116995. INVERTCUBICMAP: boolean;
  116996. USESPHERICALFROMREFLECTIONMAP: boolean;
  116997. USEIRRADIANCEMAP: boolean;
  116998. SPHERICAL_HARMONICS: boolean;
  116999. USESPHERICALINVERTEX: boolean;
  117000. REFLECTIONMAP_OPPOSITEZ: boolean;
  117001. LODINREFLECTIONALPHA: boolean;
  117002. GAMMAREFLECTION: boolean;
  117003. RGBDREFLECTION: boolean;
  117004. LINEARSPECULARREFLECTION: boolean;
  117005. RADIANCEOCCLUSION: boolean;
  117006. HORIZONOCCLUSION: boolean;
  117007. INSTANCES: boolean;
  117008. NUM_BONE_INFLUENCERS: number;
  117009. BonesPerMesh: number;
  117010. BONETEXTURE: boolean;
  117011. NONUNIFORMSCALING: boolean;
  117012. MORPHTARGETS: boolean;
  117013. MORPHTARGETS_NORMAL: boolean;
  117014. MORPHTARGETS_TANGENT: boolean;
  117015. MORPHTARGETS_UV: boolean;
  117016. NUM_MORPH_INFLUENCERS: number;
  117017. IMAGEPROCESSING: boolean;
  117018. VIGNETTE: boolean;
  117019. VIGNETTEBLENDMODEMULTIPLY: boolean;
  117020. VIGNETTEBLENDMODEOPAQUE: boolean;
  117021. TONEMAPPING: boolean;
  117022. TONEMAPPING_ACES: boolean;
  117023. CONTRAST: boolean;
  117024. COLORCURVES: boolean;
  117025. COLORGRADING: boolean;
  117026. COLORGRADING3D: boolean;
  117027. SAMPLER3DGREENDEPTH: boolean;
  117028. SAMPLER3DBGRMAP: boolean;
  117029. IMAGEPROCESSINGPOSTPROCESS: boolean;
  117030. EXPOSURE: boolean;
  117031. MULTIVIEW: boolean;
  117032. USEPHYSICALLIGHTFALLOFF: boolean;
  117033. USEGLTFLIGHTFALLOFF: boolean;
  117034. TWOSIDEDLIGHTING: boolean;
  117035. SHADOWFLOAT: boolean;
  117036. CLIPPLANE: boolean;
  117037. CLIPPLANE2: boolean;
  117038. CLIPPLANE3: boolean;
  117039. CLIPPLANE4: boolean;
  117040. POINTSIZE: boolean;
  117041. FOG: boolean;
  117042. LOGARITHMICDEPTH: boolean;
  117043. FORCENORMALFORWARD: boolean;
  117044. SPECULARAA: boolean;
  117045. CLEARCOAT: boolean;
  117046. CLEARCOAT_DEFAULTIOR: boolean;
  117047. CLEARCOAT_TEXTURE: boolean;
  117048. CLEARCOAT_TEXTUREDIRECTUV: number;
  117049. CLEARCOAT_BUMP: boolean;
  117050. CLEARCOAT_BUMPDIRECTUV: number;
  117051. CLEARCOAT_TINT: boolean;
  117052. CLEARCOAT_TINT_TEXTURE: boolean;
  117053. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  117054. ANISOTROPIC: boolean;
  117055. ANISOTROPIC_TEXTURE: boolean;
  117056. ANISOTROPIC_TEXTUREDIRECTUV: number;
  117057. BRDF_V_HEIGHT_CORRELATED: boolean;
  117058. MS_BRDF_ENERGY_CONSERVATION: boolean;
  117059. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  117060. SHEEN: boolean;
  117061. SHEEN_TEXTURE: boolean;
  117062. SHEEN_TEXTUREDIRECTUV: number;
  117063. SHEEN_LINKWITHALBEDO: boolean;
  117064. SUBSURFACE: boolean;
  117065. SS_REFRACTION: boolean;
  117066. SS_TRANSLUCENCY: boolean;
  117067. SS_SCATERRING: boolean;
  117068. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117069. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117070. SS_REFRACTIONMAP_3D: boolean;
  117071. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117072. SS_LODINREFRACTIONALPHA: boolean;
  117073. SS_GAMMAREFRACTION: boolean;
  117074. SS_RGBDREFRACTION: boolean;
  117075. SS_LINEARSPECULARREFRACTION: boolean;
  117076. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117077. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117078. UNLIT: boolean;
  117079. DEBUGMODE: number;
  117080. /**
  117081. * Initializes the PBR Material defines.
  117082. */
  117083. constructor();
  117084. /**
  117085. * Resets the PBR Material defines.
  117086. */
  117087. reset(): void;
  117088. }
  117089. /**
  117090. * The Physically based material base class of BJS.
  117091. *
  117092. * This offers the main features of a standard PBR material.
  117093. * For more information, please refer to the documentation :
  117094. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117095. */
  117096. export abstract class PBRBaseMaterial extends PushMaterial {
  117097. /**
  117098. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117099. */
  117100. static readonly PBRMATERIAL_OPAQUE: number;
  117101. /**
  117102. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117103. */
  117104. static readonly PBRMATERIAL_ALPHATEST: number;
  117105. /**
  117106. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117107. */
  117108. static readonly PBRMATERIAL_ALPHABLEND: number;
  117109. /**
  117110. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117111. * They are also discarded below the alpha cutoff threshold to improve performances.
  117112. */
  117113. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117114. /**
  117115. * Defines the default value of how much AO map is occluding the analytical lights
  117116. * (point spot...).
  117117. */
  117118. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117119. /**
  117120. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  117121. */
  117122. static readonly LIGHTFALLOFF_PHYSICAL: number;
  117123. /**
  117124. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  117125. * to enhance interoperability with other engines.
  117126. */
  117127. static readonly LIGHTFALLOFF_GLTF: number;
  117128. /**
  117129. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  117130. * to enhance interoperability with other materials.
  117131. */
  117132. static readonly LIGHTFALLOFF_STANDARD: number;
  117133. /**
  117134. * Intensity of the direct lights e.g. the four lights available in your scene.
  117135. * This impacts both the direct diffuse and specular highlights.
  117136. */
  117137. protected _directIntensity: number;
  117138. /**
  117139. * Intensity of the emissive part of the material.
  117140. * This helps controlling the emissive effect without modifying the emissive color.
  117141. */
  117142. protected _emissiveIntensity: number;
  117143. /**
  117144. * Intensity of the environment e.g. how much the environment will light the object
  117145. * either through harmonics for rough material or through the refelction for shiny ones.
  117146. */
  117147. protected _environmentIntensity: number;
  117148. /**
  117149. * This is a special control allowing the reduction of the specular highlights coming from the
  117150. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117151. */
  117152. protected _specularIntensity: number;
  117153. /**
  117154. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  117155. */
  117156. private _lightingInfos;
  117157. /**
  117158. * Debug Control allowing disabling the bump map on this material.
  117159. */
  117160. protected _disableBumpMap: boolean;
  117161. /**
  117162. * AKA Diffuse Texture in standard nomenclature.
  117163. */
  117164. protected _albedoTexture: Nullable<BaseTexture>;
  117165. /**
  117166. * AKA Occlusion Texture in other nomenclature.
  117167. */
  117168. protected _ambientTexture: Nullable<BaseTexture>;
  117169. /**
  117170. * AKA Occlusion Texture Intensity in other nomenclature.
  117171. */
  117172. protected _ambientTextureStrength: number;
  117173. /**
  117174. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117175. * 1 means it completely occludes it
  117176. * 0 mean it has no impact
  117177. */
  117178. protected _ambientTextureImpactOnAnalyticalLights: number;
  117179. /**
  117180. * Stores the alpha values in a texture.
  117181. */
  117182. protected _opacityTexture: Nullable<BaseTexture>;
  117183. /**
  117184. * Stores the reflection values in a texture.
  117185. */
  117186. protected _reflectionTexture: Nullable<BaseTexture>;
  117187. /**
  117188. * Stores the emissive values in a texture.
  117189. */
  117190. protected _emissiveTexture: Nullable<BaseTexture>;
  117191. /**
  117192. * AKA Specular texture in other nomenclature.
  117193. */
  117194. protected _reflectivityTexture: Nullable<BaseTexture>;
  117195. /**
  117196. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117197. */
  117198. protected _metallicTexture: Nullable<BaseTexture>;
  117199. /**
  117200. * Specifies the metallic scalar of the metallic/roughness workflow.
  117201. * Can also be used to scale the metalness values of the metallic texture.
  117202. */
  117203. protected _metallic: Nullable<number>;
  117204. /**
  117205. * Specifies the roughness scalar of the metallic/roughness workflow.
  117206. * Can also be used to scale the roughness values of the metallic texture.
  117207. */
  117208. protected _roughness: Nullable<number>;
  117209. /**
  117210. * Specifies the an F0 factor to help configuring the material F0.
  117211. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117212. * to 0.5 the previously hard coded value stays the same.
  117213. * Can also be used to scale the F0 values of the metallic texture.
  117214. */
  117215. protected _metallicF0Factor: number;
  117216. /**
  117217. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117218. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117219. * your expectation as it multiplies with the texture data.
  117220. */
  117221. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  117222. /**
  117223. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117224. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117225. */
  117226. protected _microSurfaceTexture: Nullable<BaseTexture>;
  117227. /**
  117228. * Stores surface normal data used to displace a mesh in a texture.
  117229. */
  117230. protected _bumpTexture: Nullable<BaseTexture>;
  117231. /**
  117232. * Stores the pre-calculated light information of a mesh in a texture.
  117233. */
  117234. protected _lightmapTexture: Nullable<BaseTexture>;
  117235. /**
  117236. * The color of a material in ambient lighting.
  117237. */
  117238. protected _ambientColor: Color3;
  117239. /**
  117240. * AKA Diffuse Color in other nomenclature.
  117241. */
  117242. protected _albedoColor: Color3;
  117243. /**
  117244. * AKA Specular Color in other nomenclature.
  117245. */
  117246. protected _reflectivityColor: Color3;
  117247. /**
  117248. * The color applied when light is reflected from a material.
  117249. */
  117250. protected _reflectionColor: Color3;
  117251. /**
  117252. * The color applied when light is emitted from a material.
  117253. */
  117254. protected _emissiveColor: Color3;
  117255. /**
  117256. * AKA Glossiness in other nomenclature.
  117257. */
  117258. protected _microSurface: number;
  117259. /**
  117260. * Specifies that the material will use the light map as a show map.
  117261. */
  117262. protected _useLightmapAsShadowmap: boolean;
  117263. /**
  117264. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117265. * makes the reflect vector face the model (under horizon).
  117266. */
  117267. protected _useHorizonOcclusion: boolean;
  117268. /**
  117269. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117270. * too much the area relying on ambient texture to define their ambient occlusion.
  117271. */
  117272. protected _useRadianceOcclusion: boolean;
  117273. /**
  117274. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117275. */
  117276. protected _useAlphaFromAlbedoTexture: boolean;
  117277. /**
  117278. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  117279. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117280. */
  117281. protected _useSpecularOverAlpha: boolean;
  117282. /**
  117283. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117284. */
  117285. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117286. /**
  117287. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117288. */
  117289. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  117290. /**
  117291. * Specifies if the metallic texture contains the roughness information in its green channel.
  117292. */
  117293. protected _useRoughnessFromMetallicTextureGreen: boolean;
  117294. /**
  117295. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117296. */
  117297. protected _useMetallnessFromMetallicTextureBlue: boolean;
  117298. /**
  117299. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117300. */
  117301. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  117302. /**
  117303. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117304. */
  117305. protected _useAmbientInGrayScale: boolean;
  117306. /**
  117307. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117308. * The material will try to infer what glossiness each pixel should be.
  117309. */
  117310. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  117311. /**
  117312. * Defines the falloff type used in this material.
  117313. * It by default is Physical.
  117314. */
  117315. protected _lightFalloff: number;
  117316. /**
  117317. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117318. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117319. */
  117320. protected _useRadianceOverAlpha: boolean;
  117321. /**
  117322. * Allows using an object space normal map (instead of tangent space).
  117323. */
  117324. protected _useObjectSpaceNormalMap: boolean;
  117325. /**
  117326. * Allows using the bump map in parallax mode.
  117327. */
  117328. protected _useParallax: boolean;
  117329. /**
  117330. * Allows using the bump map in parallax occlusion mode.
  117331. */
  117332. protected _useParallaxOcclusion: boolean;
  117333. /**
  117334. * Controls the scale bias of the parallax mode.
  117335. */
  117336. protected _parallaxScaleBias: number;
  117337. /**
  117338. * If sets to true, disables all the lights affecting the material.
  117339. */
  117340. protected _disableLighting: boolean;
  117341. /**
  117342. * Number of Simultaneous lights allowed on the material.
  117343. */
  117344. protected _maxSimultaneousLights: number;
  117345. /**
  117346. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  117347. */
  117348. protected _invertNormalMapX: boolean;
  117349. /**
  117350. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  117351. */
  117352. protected _invertNormalMapY: boolean;
  117353. /**
  117354. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117355. */
  117356. protected _twoSidedLighting: boolean;
  117357. /**
  117358. * Defines the alpha limits in alpha test mode.
  117359. */
  117360. protected _alphaCutOff: number;
  117361. /**
  117362. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117363. */
  117364. protected _forceAlphaTest: boolean;
  117365. /**
  117366. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117367. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117368. */
  117369. protected _useAlphaFresnel: boolean;
  117370. /**
  117371. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117372. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117373. */
  117374. protected _useLinearAlphaFresnel: boolean;
  117375. /**
  117376. * The transparency mode of the material.
  117377. */
  117378. protected _transparencyMode: Nullable<number>;
  117379. /**
  117380. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  117381. * from cos thetav and roughness:
  117382. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  117383. */
  117384. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  117385. /**
  117386. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117387. */
  117388. protected _forceIrradianceInFragment: boolean;
  117389. /**
  117390. * Force normal to face away from face.
  117391. */
  117392. protected _forceNormalForward: boolean;
  117393. /**
  117394. * Enables specular anti aliasing in the PBR shader.
  117395. * It will both interacts on the Geometry for analytical and IBL lighting.
  117396. * It also prefilter the roughness map based on the bump values.
  117397. */
  117398. protected _enableSpecularAntiAliasing: boolean;
  117399. /**
  117400. * Default configuration related to image processing available in the PBR Material.
  117401. */
  117402. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117403. /**
  117404. * Keep track of the image processing observer to allow dispose and replace.
  117405. */
  117406. private _imageProcessingObserver;
  117407. /**
  117408. * Attaches a new image processing configuration to the PBR Material.
  117409. * @param configuration
  117410. */
  117411. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117412. /**
  117413. * Stores the available render targets.
  117414. */
  117415. private _renderTargets;
  117416. /**
  117417. * Sets the global ambient color for the material used in lighting calculations.
  117418. */
  117419. private _globalAmbientColor;
  117420. /**
  117421. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  117422. */
  117423. private _useLogarithmicDepth;
  117424. /**
  117425. * If set to true, no lighting calculations will be applied.
  117426. */
  117427. private _unlit;
  117428. private _debugMode;
  117429. /**
  117430. * @hidden
  117431. * This is reserved for the inspector.
  117432. * Defines the material debug mode.
  117433. * It helps seeing only some components of the material while troubleshooting.
  117434. */
  117435. debugMode: number;
  117436. /**
  117437. * @hidden
  117438. * This is reserved for the inspector.
  117439. * Specify from where on screen the debug mode should start.
  117440. * The value goes from -1 (full screen) to 1 (not visible)
  117441. * It helps with side by side comparison against the final render
  117442. * This defaults to -1
  117443. */
  117444. private debugLimit;
  117445. /**
  117446. * @hidden
  117447. * This is reserved for the inspector.
  117448. * As the default viewing range might not be enough (if the ambient is really small for instance)
  117449. * You can use the factor to better multiply the final value.
  117450. */
  117451. private debugFactor;
  117452. /**
  117453. * Defines the clear coat layer parameters for the material.
  117454. */
  117455. readonly clearCoat: PBRClearCoatConfiguration;
  117456. /**
  117457. * Defines the anisotropic parameters for the material.
  117458. */
  117459. readonly anisotropy: PBRAnisotropicConfiguration;
  117460. /**
  117461. * Defines the BRDF parameters for the material.
  117462. */
  117463. readonly brdf: PBRBRDFConfiguration;
  117464. /**
  117465. * Defines the Sheen parameters for the material.
  117466. */
  117467. readonly sheen: PBRSheenConfiguration;
  117468. /**
  117469. * Defines the SubSurface parameters for the material.
  117470. */
  117471. readonly subSurface: PBRSubSurfaceConfiguration;
  117472. /**
  117473. * Custom callback helping to override the default shader used in the material.
  117474. */
  117475. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  117476. protected _rebuildInParallel: boolean;
  117477. /**
  117478. * Instantiates a new PBRMaterial instance.
  117479. *
  117480. * @param name The material name
  117481. * @param scene The scene the material will be use in.
  117482. */
  117483. constructor(name: string, scene: Scene);
  117484. /**
  117485. * Gets a boolean indicating that current material needs to register RTT
  117486. */
  117487. readonly hasRenderTargetTextures: boolean;
  117488. /**
  117489. * Gets the name of the material class.
  117490. */
  117491. getClassName(): string;
  117492. /**
  117493. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117494. */
  117495. /**
  117496. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117497. */
  117498. useLogarithmicDepth: boolean;
  117499. /**
  117500. * Gets the current transparency mode.
  117501. */
  117502. /**
  117503. * Sets the transparency mode of the material.
  117504. *
  117505. * | Value | Type | Description |
  117506. * | ----- | ----------------------------------- | ----------- |
  117507. * | 0 | OPAQUE | |
  117508. * | 1 | ALPHATEST | |
  117509. * | 2 | ALPHABLEND | |
  117510. * | 3 | ALPHATESTANDBLEND | |
  117511. *
  117512. */
  117513. transparencyMode: Nullable<number>;
  117514. /**
  117515. * Returns true if alpha blending should be disabled.
  117516. */
  117517. private readonly _disableAlphaBlending;
  117518. /**
  117519. * Specifies whether or not this material should be rendered in alpha blend mode.
  117520. */
  117521. needAlphaBlending(): boolean;
  117522. /**
  117523. * Specifies if the mesh will require alpha blending.
  117524. * @param mesh - BJS mesh.
  117525. */
  117526. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  117527. /**
  117528. * Specifies whether or not this material should be rendered in alpha test mode.
  117529. */
  117530. needAlphaTesting(): boolean;
  117531. /**
  117532. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  117533. */
  117534. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  117535. /**
  117536. * Gets the texture used for the alpha test.
  117537. */
  117538. getAlphaTestTexture(): Nullable<BaseTexture>;
  117539. /**
  117540. * Specifies that the submesh is ready to be used.
  117541. * @param mesh - BJS mesh.
  117542. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  117543. * @param useInstances - Specifies that instances should be used.
  117544. * @returns - boolean indicating that the submesh is ready or not.
  117545. */
  117546. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117547. /**
  117548. * Specifies if the material uses metallic roughness workflow.
  117549. * @returns boolean specifiying if the material uses metallic roughness workflow.
  117550. */
  117551. isMetallicWorkflow(): boolean;
  117552. private _prepareEffect;
  117553. private _prepareDefines;
  117554. /**
  117555. * Force shader compilation
  117556. */
  117557. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  117558. /**
  117559. * Initializes the uniform buffer layout for the shader.
  117560. */
  117561. buildUniformLayout(): void;
  117562. /**
  117563. * Unbinds the material from the mesh
  117564. */
  117565. unbind(): void;
  117566. /**
  117567. * Binds the submesh data.
  117568. * @param world - The world matrix.
  117569. * @param mesh - The BJS mesh.
  117570. * @param subMesh - A submesh of the BJS mesh.
  117571. */
  117572. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117573. /**
  117574. * Returns the animatable textures.
  117575. * @returns - Array of animatable textures.
  117576. */
  117577. getAnimatables(): IAnimatable[];
  117578. /**
  117579. * Returns the texture used for reflections.
  117580. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  117581. */
  117582. private _getReflectionTexture;
  117583. /**
  117584. * Returns an array of the actively used textures.
  117585. * @returns - Array of BaseTextures
  117586. */
  117587. getActiveTextures(): BaseTexture[];
  117588. /**
  117589. * Checks to see if a texture is used in the material.
  117590. * @param texture - Base texture to use.
  117591. * @returns - Boolean specifying if a texture is used in the material.
  117592. */
  117593. hasTexture(texture: BaseTexture): boolean;
  117594. /**
  117595. * Disposes the resources of the material.
  117596. * @param forceDisposeEffect - Forces the disposal of effects.
  117597. * @param forceDisposeTextures - Forces the disposal of all textures.
  117598. */
  117599. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  117600. }
  117601. }
  117602. declare module BABYLON {
  117603. /**
  117604. * The Physically based material of BJS.
  117605. *
  117606. * This offers the main features of a standard PBR material.
  117607. * For more information, please refer to the documentation :
  117608. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117609. */
  117610. export class PBRMaterial extends PBRBaseMaterial {
  117611. /**
  117612. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117613. */
  117614. static readonly PBRMATERIAL_OPAQUE: number;
  117615. /**
  117616. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117617. */
  117618. static readonly PBRMATERIAL_ALPHATEST: number;
  117619. /**
  117620. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117621. */
  117622. static readonly PBRMATERIAL_ALPHABLEND: number;
  117623. /**
  117624. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117625. * They are also discarded below the alpha cutoff threshold to improve performances.
  117626. */
  117627. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117628. /**
  117629. * Defines the default value of how much AO map is occluding the analytical lights
  117630. * (point spot...).
  117631. */
  117632. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117633. /**
  117634. * Intensity of the direct lights e.g. the four lights available in your scene.
  117635. * This impacts both the direct diffuse and specular highlights.
  117636. */
  117637. directIntensity: number;
  117638. /**
  117639. * Intensity of the emissive part of the material.
  117640. * This helps controlling the emissive effect without modifying the emissive color.
  117641. */
  117642. emissiveIntensity: number;
  117643. /**
  117644. * Intensity of the environment e.g. how much the environment will light the object
  117645. * either through harmonics for rough material or through the refelction for shiny ones.
  117646. */
  117647. environmentIntensity: number;
  117648. /**
  117649. * This is a special control allowing the reduction of the specular highlights coming from the
  117650. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117651. */
  117652. specularIntensity: number;
  117653. /**
  117654. * Debug Control allowing disabling the bump map on this material.
  117655. */
  117656. disableBumpMap: boolean;
  117657. /**
  117658. * AKA Diffuse Texture in standard nomenclature.
  117659. */
  117660. albedoTexture: BaseTexture;
  117661. /**
  117662. * AKA Occlusion Texture in other nomenclature.
  117663. */
  117664. ambientTexture: BaseTexture;
  117665. /**
  117666. * AKA Occlusion Texture Intensity in other nomenclature.
  117667. */
  117668. ambientTextureStrength: number;
  117669. /**
  117670. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117671. * 1 means it completely occludes it
  117672. * 0 mean it has no impact
  117673. */
  117674. ambientTextureImpactOnAnalyticalLights: number;
  117675. /**
  117676. * Stores the alpha values in a texture.
  117677. */
  117678. opacityTexture: BaseTexture;
  117679. /**
  117680. * Stores the reflection values in a texture.
  117681. */
  117682. reflectionTexture: Nullable<BaseTexture>;
  117683. /**
  117684. * Stores the emissive values in a texture.
  117685. */
  117686. emissiveTexture: BaseTexture;
  117687. /**
  117688. * AKA Specular texture in other nomenclature.
  117689. */
  117690. reflectivityTexture: BaseTexture;
  117691. /**
  117692. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117693. */
  117694. metallicTexture: BaseTexture;
  117695. /**
  117696. * Specifies the metallic scalar of the metallic/roughness workflow.
  117697. * Can also be used to scale the metalness values of the metallic texture.
  117698. */
  117699. metallic: Nullable<number>;
  117700. /**
  117701. * Specifies the roughness scalar of the metallic/roughness workflow.
  117702. * Can also be used to scale the roughness values of the metallic texture.
  117703. */
  117704. roughness: Nullable<number>;
  117705. /**
  117706. * Specifies the an F0 factor to help configuring the material F0.
  117707. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117708. * to 0.5 the previously hard coded value stays the same.
  117709. * Can also be used to scale the F0 values of the metallic texture.
  117710. */
  117711. metallicF0Factor: number;
  117712. /**
  117713. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117714. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117715. * your expectation as it multiplies with the texture data.
  117716. */
  117717. useMetallicF0FactorFromMetallicTexture: boolean;
  117718. /**
  117719. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117720. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117721. */
  117722. microSurfaceTexture: BaseTexture;
  117723. /**
  117724. * Stores surface normal data used to displace a mesh in a texture.
  117725. */
  117726. bumpTexture: BaseTexture;
  117727. /**
  117728. * Stores the pre-calculated light information of a mesh in a texture.
  117729. */
  117730. lightmapTexture: BaseTexture;
  117731. /**
  117732. * Stores the refracted light information in a texture.
  117733. */
  117734. refractionTexture: Nullable<BaseTexture>;
  117735. /**
  117736. * The color of a material in ambient lighting.
  117737. */
  117738. ambientColor: Color3;
  117739. /**
  117740. * AKA Diffuse Color in other nomenclature.
  117741. */
  117742. albedoColor: Color3;
  117743. /**
  117744. * AKA Specular Color in other nomenclature.
  117745. */
  117746. reflectivityColor: Color3;
  117747. /**
  117748. * The color reflected from the material.
  117749. */
  117750. reflectionColor: Color3;
  117751. /**
  117752. * The color emitted from the material.
  117753. */
  117754. emissiveColor: Color3;
  117755. /**
  117756. * AKA Glossiness in other nomenclature.
  117757. */
  117758. microSurface: number;
  117759. /**
  117760. * source material index of refraction (IOR)' / 'destination material IOR.
  117761. */
  117762. indexOfRefraction: number;
  117763. /**
  117764. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117765. */
  117766. invertRefractionY: boolean;
  117767. /**
  117768. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117769. * Materials half opaque for instance using refraction could benefit from this control.
  117770. */
  117771. linkRefractionWithTransparency: boolean;
  117772. /**
  117773. * If true, the light map contains occlusion information instead of lighting info.
  117774. */
  117775. useLightmapAsShadowmap: boolean;
  117776. /**
  117777. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117778. */
  117779. useAlphaFromAlbedoTexture: boolean;
  117780. /**
  117781. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117782. */
  117783. forceAlphaTest: boolean;
  117784. /**
  117785. * Defines the alpha limits in alpha test mode.
  117786. */
  117787. alphaCutOff: number;
  117788. /**
  117789. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  117790. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117791. */
  117792. useSpecularOverAlpha: boolean;
  117793. /**
  117794. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117795. */
  117796. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117797. /**
  117798. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117799. */
  117800. useRoughnessFromMetallicTextureAlpha: boolean;
  117801. /**
  117802. * Specifies if the metallic texture contains the roughness information in its green channel.
  117803. */
  117804. useRoughnessFromMetallicTextureGreen: boolean;
  117805. /**
  117806. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117807. */
  117808. useMetallnessFromMetallicTextureBlue: boolean;
  117809. /**
  117810. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117811. */
  117812. useAmbientOcclusionFromMetallicTextureRed: boolean;
  117813. /**
  117814. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117815. */
  117816. useAmbientInGrayScale: boolean;
  117817. /**
  117818. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117819. * The material will try to infer what glossiness each pixel should be.
  117820. */
  117821. useAutoMicroSurfaceFromReflectivityMap: boolean;
  117822. /**
  117823. * BJS is using an harcoded light falloff based on a manually sets up range.
  117824. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117825. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117826. */
  117827. /**
  117828. * BJS is using an harcoded light falloff based on a manually sets up range.
  117829. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117830. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117831. */
  117832. usePhysicalLightFalloff: boolean;
  117833. /**
  117834. * In order to support the falloff compatibility with gltf, a special mode has been added
  117835. * to reproduce the gltf light falloff.
  117836. */
  117837. /**
  117838. * In order to support the falloff compatibility with gltf, a special mode has been added
  117839. * to reproduce the gltf light falloff.
  117840. */
  117841. useGLTFLightFalloff: boolean;
  117842. /**
  117843. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117844. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117845. */
  117846. useRadianceOverAlpha: boolean;
  117847. /**
  117848. * Allows using an object space normal map (instead of tangent space).
  117849. */
  117850. useObjectSpaceNormalMap: boolean;
  117851. /**
  117852. * Allows using the bump map in parallax mode.
  117853. */
  117854. useParallax: boolean;
  117855. /**
  117856. * Allows using the bump map in parallax occlusion mode.
  117857. */
  117858. useParallaxOcclusion: boolean;
  117859. /**
  117860. * Controls the scale bias of the parallax mode.
  117861. */
  117862. parallaxScaleBias: number;
  117863. /**
  117864. * If sets to true, disables all the lights affecting the material.
  117865. */
  117866. disableLighting: boolean;
  117867. /**
  117868. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117869. */
  117870. forceIrradianceInFragment: boolean;
  117871. /**
  117872. * Number of Simultaneous lights allowed on the material.
  117873. */
  117874. maxSimultaneousLights: number;
  117875. /**
  117876. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117877. */
  117878. invertNormalMapX: boolean;
  117879. /**
  117880. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117881. */
  117882. invertNormalMapY: boolean;
  117883. /**
  117884. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117885. */
  117886. twoSidedLighting: boolean;
  117887. /**
  117888. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117889. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117890. */
  117891. useAlphaFresnel: boolean;
  117892. /**
  117893. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117894. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117895. */
  117896. useLinearAlphaFresnel: boolean;
  117897. /**
  117898. * Let user defines the brdf lookup texture used for IBL.
  117899. * A default 8bit version is embedded but you could point at :
  117900. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  117901. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  117902. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  117903. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  117904. */
  117905. environmentBRDFTexture: Nullable<BaseTexture>;
  117906. /**
  117907. * Force normal to face away from face.
  117908. */
  117909. forceNormalForward: boolean;
  117910. /**
  117911. * Enables specular anti aliasing in the PBR shader.
  117912. * It will both interacts on the Geometry for analytical and IBL lighting.
  117913. * It also prefilter the roughness map based on the bump values.
  117914. */
  117915. enableSpecularAntiAliasing: boolean;
  117916. /**
  117917. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117918. * makes the reflect vector face the model (under horizon).
  117919. */
  117920. useHorizonOcclusion: boolean;
  117921. /**
  117922. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117923. * too much the area relying on ambient texture to define their ambient occlusion.
  117924. */
  117925. useRadianceOcclusion: boolean;
  117926. /**
  117927. * If set to true, no lighting calculations will be applied.
  117928. */
  117929. unlit: boolean;
  117930. /**
  117931. * Gets the image processing configuration used either in this material.
  117932. */
  117933. /**
  117934. * Sets the Default image processing configuration used either in the this material.
  117935. *
  117936. * If sets to null, the scene one is in use.
  117937. */
  117938. imageProcessingConfiguration: ImageProcessingConfiguration;
  117939. /**
  117940. * Gets wether the color curves effect is enabled.
  117941. */
  117942. /**
  117943. * Sets wether the color curves effect is enabled.
  117944. */
  117945. cameraColorCurvesEnabled: boolean;
  117946. /**
  117947. * Gets wether the color grading effect is enabled.
  117948. */
  117949. /**
  117950. * Gets wether the color grading effect is enabled.
  117951. */
  117952. cameraColorGradingEnabled: boolean;
  117953. /**
  117954. * Gets wether tonemapping is enabled or not.
  117955. */
  117956. /**
  117957. * Sets wether tonemapping is enabled or not
  117958. */
  117959. cameraToneMappingEnabled: boolean;
  117960. /**
  117961. * The camera exposure used on this material.
  117962. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117963. * This corresponds to a photographic exposure.
  117964. */
  117965. /**
  117966. * The camera exposure used on this material.
  117967. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117968. * This corresponds to a photographic exposure.
  117969. */
  117970. cameraExposure: number;
  117971. /**
  117972. * Gets The camera contrast used on this material.
  117973. */
  117974. /**
  117975. * Sets The camera contrast used on this material.
  117976. */
  117977. cameraContrast: number;
  117978. /**
  117979. * Gets the Color Grading 2D Lookup Texture.
  117980. */
  117981. /**
  117982. * Sets the Color Grading 2D Lookup Texture.
  117983. */
  117984. cameraColorGradingTexture: Nullable<BaseTexture>;
  117985. /**
  117986. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117987. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117988. * 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;
  117989. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117990. */
  117991. /**
  117992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117994. * 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;
  117995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117996. */
  117997. cameraColorCurves: Nullable<ColorCurves>;
  117998. /**
  117999. * Instantiates a new PBRMaterial instance.
  118000. *
  118001. * @param name The material name
  118002. * @param scene The scene the material will be use in.
  118003. */
  118004. constructor(name: string, scene: Scene);
  118005. /**
  118006. * Returns the name of this material class.
  118007. */
  118008. getClassName(): string;
  118009. /**
  118010. * Makes a duplicate of the current material.
  118011. * @param name - name to use for the new material.
  118012. */
  118013. clone(name: string): PBRMaterial;
  118014. /**
  118015. * Serializes this PBR Material.
  118016. * @returns - An object with the serialized material.
  118017. */
  118018. serialize(): any;
  118019. /**
  118020. * Parses a PBR Material from a serialized object.
  118021. * @param source - Serialized object.
  118022. * @param scene - BJS scene instance.
  118023. * @param rootUrl - url for the scene object
  118024. * @returns - PBRMaterial
  118025. */
  118026. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  118027. }
  118028. }
  118029. declare module BABYLON {
  118030. /**
  118031. * Direct draw surface info
  118032. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  118033. */
  118034. export interface DDSInfo {
  118035. /**
  118036. * Width of the texture
  118037. */
  118038. width: number;
  118039. /**
  118040. * Width of the texture
  118041. */
  118042. height: number;
  118043. /**
  118044. * Number of Mipmaps for the texture
  118045. * @see https://en.wikipedia.org/wiki/Mipmap
  118046. */
  118047. mipmapCount: number;
  118048. /**
  118049. * If the textures format is a known fourCC format
  118050. * @see https://www.fourcc.org/
  118051. */
  118052. isFourCC: boolean;
  118053. /**
  118054. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  118055. */
  118056. isRGB: boolean;
  118057. /**
  118058. * If the texture is a lumincance format
  118059. */
  118060. isLuminance: boolean;
  118061. /**
  118062. * If this is a cube texture
  118063. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  118064. */
  118065. isCube: boolean;
  118066. /**
  118067. * If the texture is a compressed format eg. FOURCC_DXT1
  118068. */
  118069. isCompressed: boolean;
  118070. /**
  118071. * The dxgiFormat of the texture
  118072. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  118073. */
  118074. dxgiFormat: number;
  118075. /**
  118076. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  118077. */
  118078. textureType: number;
  118079. /**
  118080. * Sphericle polynomial created for the dds texture
  118081. */
  118082. sphericalPolynomial?: SphericalPolynomial;
  118083. }
  118084. /**
  118085. * Class used to provide DDS decompression tools
  118086. */
  118087. export class DDSTools {
  118088. /**
  118089. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  118090. */
  118091. static StoreLODInAlphaChannel: boolean;
  118092. /**
  118093. * Gets DDS information from an array buffer
  118094. * @param arrayBuffer defines the array buffer to read data from
  118095. * @returns the DDS information
  118096. */
  118097. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  118098. private static _FloatView;
  118099. private static _Int32View;
  118100. private static _ToHalfFloat;
  118101. private static _FromHalfFloat;
  118102. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  118103. private static _GetHalfFloatRGBAArrayBuffer;
  118104. private static _GetFloatRGBAArrayBuffer;
  118105. private static _GetFloatAsUIntRGBAArrayBuffer;
  118106. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  118107. private static _GetRGBAArrayBuffer;
  118108. private static _ExtractLongWordOrder;
  118109. private static _GetRGBArrayBuffer;
  118110. private static _GetLuminanceArrayBuffer;
  118111. /**
  118112. * Uploads DDS Levels to a Babylon Texture
  118113. * @hidden
  118114. */
  118115. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  118116. }
  118117. interface ThinEngine {
  118118. /**
  118119. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  118120. * @param rootUrl defines the url where the file to load is located
  118121. * @param scene defines the current scene
  118122. * @param lodScale defines scale to apply to the mip map selection
  118123. * @param lodOffset defines offset to apply to the mip map selection
  118124. * @param onLoad defines an optional callback raised when the texture is loaded
  118125. * @param onError defines an optional callback raised if there is an issue to load the texture
  118126. * @param format defines the format of the data
  118127. * @param forcedExtension defines the extension to use to pick the right loader
  118128. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  118129. * @returns the cube texture as an InternalTexture
  118130. */
  118131. 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;
  118132. }
  118133. }
  118134. declare module BABYLON {
  118135. /**
  118136. * Implementation of the DDS Texture Loader.
  118137. * @hidden
  118138. */
  118139. export class _DDSTextureLoader implements IInternalTextureLoader {
  118140. /**
  118141. * Defines wether the loader supports cascade loading the different faces.
  118142. */
  118143. readonly supportCascades: boolean;
  118144. /**
  118145. * This returns if the loader support the current file information.
  118146. * @param extension defines the file extension of the file being loaded
  118147. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118148. * @param fallback defines the fallback internal texture if any
  118149. * @param isBase64 defines whether the texture is encoded as a base64
  118150. * @param isBuffer defines whether the texture data are stored as a buffer
  118151. * @returns true if the loader can load the specified file
  118152. */
  118153. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118154. /**
  118155. * Transform the url before loading if required.
  118156. * @param rootUrl the url of the texture
  118157. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118158. * @returns the transformed texture
  118159. */
  118160. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118161. /**
  118162. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118163. * @param rootUrl the url of the texture
  118164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118165. * @returns the fallback texture
  118166. */
  118167. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118168. /**
  118169. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118170. * @param data contains the texture data
  118171. * @param texture defines the BabylonJS internal texture
  118172. * @param createPolynomials will be true if polynomials have been requested
  118173. * @param onLoad defines the callback to trigger once the texture is ready
  118174. * @param onError defines the callback to trigger in case of error
  118175. */
  118176. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118177. /**
  118178. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118179. * @param data contains the texture data
  118180. * @param texture defines the BabylonJS internal texture
  118181. * @param callback defines the method to call once ready to upload
  118182. */
  118183. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118184. }
  118185. }
  118186. declare module BABYLON {
  118187. /**
  118188. * Implementation of the ENV Texture Loader.
  118189. * @hidden
  118190. */
  118191. export class _ENVTextureLoader implements IInternalTextureLoader {
  118192. /**
  118193. * Defines wether the loader supports cascade loading the different faces.
  118194. */
  118195. readonly supportCascades: boolean;
  118196. /**
  118197. * This returns if the loader support the current file information.
  118198. * @param extension defines the file extension of the file being loaded
  118199. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118200. * @param fallback defines the fallback internal texture if any
  118201. * @param isBase64 defines whether the texture is encoded as a base64
  118202. * @param isBuffer defines whether the texture data are stored as a buffer
  118203. * @returns true if the loader can load the specified file
  118204. */
  118205. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118206. /**
  118207. * Transform the url before loading if required.
  118208. * @param rootUrl the url of the texture
  118209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118210. * @returns the transformed texture
  118211. */
  118212. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118213. /**
  118214. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118215. * @param rootUrl the url of the texture
  118216. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118217. * @returns the fallback texture
  118218. */
  118219. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118220. /**
  118221. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118222. * @param data contains the texture data
  118223. * @param texture defines the BabylonJS internal texture
  118224. * @param createPolynomials will be true if polynomials have been requested
  118225. * @param onLoad defines the callback to trigger once the texture is ready
  118226. * @param onError defines the callback to trigger in case of error
  118227. */
  118228. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118229. /**
  118230. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118231. * @param data contains the texture data
  118232. * @param texture defines the BabylonJS internal texture
  118233. * @param callback defines the method to call once ready to upload
  118234. */
  118235. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118236. }
  118237. }
  118238. declare module BABYLON {
  118239. /**
  118240. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  118241. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  118242. */
  118243. export class KhronosTextureContainer {
  118244. /** contents of the KTX container file */
  118245. arrayBuffer: any;
  118246. private static HEADER_LEN;
  118247. private static COMPRESSED_2D;
  118248. private static COMPRESSED_3D;
  118249. private static TEX_2D;
  118250. private static TEX_3D;
  118251. /**
  118252. * Gets the openGL type
  118253. */
  118254. glType: number;
  118255. /**
  118256. * Gets the openGL type size
  118257. */
  118258. glTypeSize: number;
  118259. /**
  118260. * Gets the openGL format
  118261. */
  118262. glFormat: number;
  118263. /**
  118264. * Gets the openGL internal format
  118265. */
  118266. glInternalFormat: number;
  118267. /**
  118268. * Gets the base internal format
  118269. */
  118270. glBaseInternalFormat: number;
  118271. /**
  118272. * Gets image width in pixel
  118273. */
  118274. pixelWidth: number;
  118275. /**
  118276. * Gets image height in pixel
  118277. */
  118278. pixelHeight: number;
  118279. /**
  118280. * Gets image depth in pixels
  118281. */
  118282. pixelDepth: number;
  118283. /**
  118284. * Gets the number of array elements
  118285. */
  118286. numberOfArrayElements: number;
  118287. /**
  118288. * Gets the number of faces
  118289. */
  118290. numberOfFaces: number;
  118291. /**
  118292. * Gets the number of mipmap levels
  118293. */
  118294. numberOfMipmapLevels: number;
  118295. /**
  118296. * Gets the bytes of key value data
  118297. */
  118298. bytesOfKeyValueData: number;
  118299. /**
  118300. * Gets the load type
  118301. */
  118302. loadType: number;
  118303. /**
  118304. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  118305. */
  118306. isInvalid: boolean;
  118307. /**
  118308. * Creates a new KhronosTextureContainer
  118309. * @param arrayBuffer contents of the KTX container file
  118310. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  118311. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  118312. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  118313. */
  118314. constructor(
  118315. /** contents of the KTX container file */
  118316. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  118317. /**
  118318. * Uploads KTX content to a Babylon Texture.
  118319. * It is assumed that the texture has already been created & is currently bound
  118320. * @hidden
  118321. */
  118322. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  118323. private _upload2DCompressedLevels;
  118324. }
  118325. }
  118326. declare module BABYLON {
  118327. /**
  118328. * Implementation of the KTX Texture Loader.
  118329. * @hidden
  118330. */
  118331. export class _KTXTextureLoader implements IInternalTextureLoader {
  118332. /**
  118333. * Defines wether the loader supports cascade loading the different faces.
  118334. */
  118335. readonly supportCascades: boolean;
  118336. /**
  118337. * This returns if the loader support the current file information.
  118338. * @param extension defines the file extension of the file being loaded
  118339. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118340. * @param fallback defines the fallback internal texture if any
  118341. * @param isBase64 defines whether the texture is encoded as a base64
  118342. * @param isBuffer defines whether the texture data are stored as a buffer
  118343. * @returns true if the loader can load the specified file
  118344. */
  118345. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118346. /**
  118347. * Transform the url before loading if required.
  118348. * @param rootUrl the url of the texture
  118349. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118350. * @returns the transformed texture
  118351. */
  118352. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118353. /**
  118354. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118355. * @param rootUrl the url of the texture
  118356. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118357. * @returns the fallback texture
  118358. */
  118359. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118360. /**
  118361. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118362. * @param data contains the texture data
  118363. * @param texture defines the BabylonJS internal texture
  118364. * @param createPolynomials will be true if polynomials have been requested
  118365. * @param onLoad defines the callback to trigger once the texture is ready
  118366. * @param onError defines the callback to trigger in case of error
  118367. */
  118368. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118369. /**
  118370. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118371. * @param data contains the texture data
  118372. * @param texture defines the BabylonJS internal texture
  118373. * @param callback defines the method to call once ready to upload
  118374. */
  118375. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  118376. }
  118377. }
  118378. declare module BABYLON {
  118379. /** @hidden */
  118380. export var _forceSceneHelpersToBundle: boolean;
  118381. interface Scene {
  118382. /**
  118383. * Creates a default light for the scene.
  118384. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  118385. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  118386. */
  118387. createDefaultLight(replace?: boolean): void;
  118388. /**
  118389. * Creates a default camera for the scene.
  118390. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  118391. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118392. * @param replace has default false, when true replaces the active camera in the scene
  118393. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  118394. */
  118395. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118396. /**
  118397. * Creates a default camera and a default light.
  118398. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  118399. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118400. * @param replace has the default false, when true replaces the active camera/light in the scene
  118401. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  118402. */
  118403. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118404. /**
  118405. * Creates a new sky box
  118406. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  118407. * @param environmentTexture defines the texture to use as environment texture
  118408. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  118409. * @param scale defines the overall scale of the skybox
  118410. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  118411. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  118412. * @returns a new mesh holding the sky box
  118413. */
  118414. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  118415. /**
  118416. * Creates a new environment
  118417. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  118418. * @param options defines the options you can use to configure the environment
  118419. * @returns the new EnvironmentHelper
  118420. */
  118421. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  118422. /**
  118423. * Creates a new VREXperienceHelper
  118424. * @see http://doc.babylonjs.com/how_to/webvr_helper
  118425. * @param webVROptions defines the options used to create the new VREXperienceHelper
  118426. * @returns a new VREXperienceHelper
  118427. */
  118428. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  118429. /**
  118430. * Creates a new WebXRDefaultExperience
  118431. * @see http://doc.babylonjs.com/how_to/webxr
  118432. * @param options experience options
  118433. * @returns a promise for a new WebXRDefaultExperience
  118434. */
  118435. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118436. }
  118437. }
  118438. declare module BABYLON {
  118439. /**
  118440. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  118441. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  118442. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  118443. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  118444. */
  118445. export class VideoDome extends TransformNode {
  118446. /**
  118447. * Define the video source as a Monoscopic panoramic 360 video.
  118448. */
  118449. static readonly MODE_MONOSCOPIC: number;
  118450. /**
  118451. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118452. */
  118453. static readonly MODE_TOPBOTTOM: number;
  118454. /**
  118455. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118456. */
  118457. static readonly MODE_SIDEBYSIDE: number;
  118458. private _halfDome;
  118459. private _useDirectMapping;
  118460. /**
  118461. * The video texture being displayed on the sphere
  118462. */
  118463. protected _videoTexture: VideoTexture;
  118464. /**
  118465. * Gets the video texture being displayed on the sphere
  118466. */
  118467. readonly videoTexture: VideoTexture;
  118468. /**
  118469. * The skybox material
  118470. */
  118471. protected _material: BackgroundMaterial;
  118472. /**
  118473. * The surface used for the skybox
  118474. */
  118475. protected _mesh: Mesh;
  118476. /**
  118477. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  118478. */
  118479. private _halfDomeMask;
  118480. /**
  118481. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118482. * Also see the options.resolution property.
  118483. */
  118484. fovMultiplier: number;
  118485. private _videoMode;
  118486. /**
  118487. * Gets or set the current video mode for the video. It can be:
  118488. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  118489. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118490. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118491. */
  118492. videoMode: number;
  118493. /**
  118494. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  118495. *
  118496. */
  118497. /**
  118498. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  118499. */
  118500. halfDome: boolean;
  118501. /**
  118502. * Oberserver used in Stereoscopic VR Mode.
  118503. */
  118504. private _onBeforeCameraRenderObserver;
  118505. /**
  118506. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  118507. * @param name Element's name, child elements will append suffixes for their own names.
  118508. * @param urlsOrVideo defines the url(s) or the video element to use
  118509. * @param options An object containing optional or exposed sub element properties
  118510. */
  118511. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  118512. resolution?: number;
  118513. clickToPlay?: boolean;
  118514. autoPlay?: boolean;
  118515. loop?: boolean;
  118516. size?: number;
  118517. poster?: string;
  118518. faceForward?: boolean;
  118519. useDirectMapping?: boolean;
  118520. halfDomeMode?: boolean;
  118521. }, scene: Scene);
  118522. private _changeVideoMode;
  118523. /**
  118524. * Releases resources associated with this node.
  118525. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118526. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118527. */
  118528. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118529. }
  118530. }
  118531. declare module BABYLON {
  118532. /**
  118533. * This class can be used to get instrumentation data from a Babylon engine
  118534. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118535. */
  118536. export class EngineInstrumentation implements IDisposable {
  118537. /**
  118538. * Define the instrumented engine.
  118539. */
  118540. engine: Engine;
  118541. private _captureGPUFrameTime;
  118542. private _gpuFrameTimeToken;
  118543. private _gpuFrameTime;
  118544. private _captureShaderCompilationTime;
  118545. private _shaderCompilationTime;
  118546. private _onBeginFrameObserver;
  118547. private _onEndFrameObserver;
  118548. private _onBeforeShaderCompilationObserver;
  118549. private _onAfterShaderCompilationObserver;
  118550. /**
  118551. * Gets the perf counter used for GPU frame time
  118552. */
  118553. readonly gpuFrameTimeCounter: PerfCounter;
  118554. /**
  118555. * Gets the GPU frame time capture status
  118556. */
  118557. /**
  118558. * Enable or disable the GPU frame time capture
  118559. */
  118560. captureGPUFrameTime: boolean;
  118561. /**
  118562. * Gets the perf counter used for shader compilation time
  118563. */
  118564. readonly shaderCompilationTimeCounter: PerfCounter;
  118565. /**
  118566. * Gets the shader compilation time capture status
  118567. */
  118568. /**
  118569. * Enable or disable the shader compilation time capture
  118570. */
  118571. captureShaderCompilationTime: boolean;
  118572. /**
  118573. * Instantiates a new engine instrumentation.
  118574. * This class can be used to get instrumentation data from a Babylon engine
  118575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118576. * @param engine Defines the engine to instrument
  118577. */
  118578. constructor(
  118579. /**
  118580. * Define the instrumented engine.
  118581. */
  118582. engine: Engine);
  118583. /**
  118584. * Dispose and release associated resources.
  118585. */
  118586. dispose(): void;
  118587. }
  118588. }
  118589. declare module BABYLON {
  118590. /**
  118591. * This class can be used to get instrumentation data from a Babylon engine
  118592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118593. */
  118594. export class SceneInstrumentation implements IDisposable {
  118595. /**
  118596. * Defines the scene to instrument
  118597. */
  118598. scene: Scene;
  118599. private _captureActiveMeshesEvaluationTime;
  118600. private _activeMeshesEvaluationTime;
  118601. private _captureRenderTargetsRenderTime;
  118602. private _renderTargetsRenderTime;
  118603. private _captureFrameTime;
  118604. private _frameTime;
  118605. private _captureRenderTime;
  118606. private _renderTime;
  118607. private _captureInterFrameTime;
  118608. private _interFrameTime;
  118609. private _captureParticlesRenderTime;
  118610. private _particlesRenderTime;
  118611. private _captureSpritesRenderTime;
  118612. private _spritesRenderTime;
  118613. private _capturePhysicsTime;
  118614. private _physicsTime;
  118615. private _captureAnimationsTime;
  118616. private _animationsTime;
  118617. private _captureCameraRenderTime;
  118618. private _cameraRenderTime;
  118619. private _onBeforeActiveMeshesEvaluationObserver;
  118620. private _onAfterActiveMeshesEvaluationObserver;
  118621. private _onBeforeRenderTargetsRenderObserver;
  118622. private _onAfterRenderTargetsRenderObserver;
  118623. private _onAfterRenderObserver;
  118624. private _onBeforeDrawPhaseObserver;
  118625. private _onAfterDrawPhaseObserver;
  118626. private _onBeforeAnimationsObserver;
  118627. private _onBeforeParticlesRenderingObserver;
  118628. private _onAfterParticlesRenderingObserver;
  118629. private _onBeforeSpritesRenderingObserver;
  118630. private _onAfterSpritesRenderingObserver;
  118631. private _onBeforePhysicsObserver;
  118632. private _onAfterPhysicsObserver;
  118633. private _onAfterAnimationsObserver;
  118634. private _onBeforeCameraRenderObserver;
  118635. private _onAfterCameraRenderObserver;
  118636. /**
  118637. * Gets the perf counter used for active meshes evaluation time
  118638. */
  118639. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  118640. /**
  118641. * Gets the active meshes evaluation time capture status
  118642. */
  118643. /**
  118644. * Enable or disable the active meshes evaluation time capture
  118645. */
  118646. captureActiveMeshesEvaluationTime: boolean;
  118647. /**
  118648. * Gets the perf counter used for render targets render time
  118649. */
  118650. readonly renderTargetsRenderTimeCounter: PerfCounter;
  118651. /**
  118652. * Gets the render targets render time capture status
  118653. */
  118654. /**
  118655. * Enable or disable the render targets render time capture
  118656. */
  118657. captureRenderTargetsRenderTime: boolean;
  118658. /**
  118659. * Gets the perf counter used for particles render time
  118660. */
  118661. readonly particlesRenderTimeCounter: PerfCounter;
  118662. /**
  118663. * Gets the particles render time capture status
  118664. */
  118665. /**
  118666. * Enable or disable the particles render time capture
  118667. */
  118668. captureParticlesRenderTime: boolean;
  118669. /**
  118670. * Gets the perf counter used for sprites render time
  118671. */
  118672. readonly spritesRenderTimeCounter: PerfCounter;
  118673. /**
  118674. * Gets the sprites render time capture status
  118675. */
  118676. /**
  118677. * Enable or disable the sprites render time capture
  118678. */
  118679. captureSpritesRenderTime: boolean;
  118680. /**
  118681. * Gets the perf counter used for physics time
  118682. */
  118683. readonly physicsTimeCounter: PerfCounter;
  118684. /**
  118685. * Gets the physics time capture status
  118686. */
  118687. /**
  118688. * Enable or disable the physics time capture
  118689. */
  118690. capturePhysicsTime: boolean;
  118691. /**
  118692. * Gets the perf counter used for animations time
  118693. */
  118694. readonly animationsTimeCounter: PerfCounter;
  118695. /**
  118696. * Gets the animations time capture status
  118697. */
  118698. /**
  118699. * Enable or disable the animations time capture
  118700. */
  118701. captureAnimationsTime: boolean;
  118702. /**
  118703. * Gets the perf counter used for frame time capture
  118704. */
  118705. readonly frameTimeCounter: PerfCounter;
  118706. /**
  118707. * Gets the frame time capture status
  118708. */
  118709. /**
  118710. * Enable or disable the frame time capture
  118711. */
  118712. captureFrameTime: boolean;
  118713. /**
  118714. * Gets the perf counter used for inter-frames time capture
  118715. */
  118716. readonly interFrameTimeCounter: PerfCounter;
  118717. /**
  118718. * Gets the inter-frames time capture status
  118719. */
  118720. /**
  118721. * Enable or disable the inter-frames time capture
  118722. */
  118723. captureInterFrameTime: boolean;
  118724. /**
  118725. * Gets the perf counter used for render time capture
  118726. */
  118727. readonly renderTimeCounter: PerfCounter;
  118728. /**
  118729. * Gets the render time capture status
  118730. */
  118731. /**
  118732. * Enable or disable the render time capture
  118733. */
  118734. captureRenderTime: boolean;
  118735. /**
  118736. * Gets the perf counter used for camera render time capture
  118737. */
  118738. readonly cameraRenderTimeCounter: PerfCounter;
  118739. /**
  118740. * Gets the camera render time capture status
  118741. */
  118742. /**
  118743. * Enable or disable the camera render time capture
  118744. */
  118745. captureCameraRenderTime: boolean;
  118746. /**
  118747. * Gets the perf counter used for draw calls
  118748. */
  118749. readonly drawCallsCounter: PerfCounter;
  118750. /**
  118751. * Instantiates a new scene instrumentation.
  118752. * This class can be used to get instrumentation data from a Babylon engine
  118753. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118754. * @param scene Defines the scene to instrument
  118755. */
  118756. constructor(
  118757. /**
  118758. * Defines the scene to instrument
  118759. */
  118760. scene: Scene);
  118761. /**
  118762. * Dispose and release associated resources.
  118763. */
  118764. dispose(): void;
  118765. }
  118766. }
  118767. declare module BABYLON {
  118768. /** @hidden */
  118769. export var glowMapGenerationPixelShader: {
  118770. name: string;
  118771. shader: string;
  118772. };
  118773. }
  118774. declare module BABYLON {
  118775. /** @hidden */
  118776. export var glowMapGenerationVertexShader: {
  118777. name: string;
  118778. shader: string;
  118779. };
  118780. }
  118781. declare module BABYLON {
  118782. /**
  118783. * Effect layer options. This helps customizing the behaviour
  118784. * of the effect layer.
  118785. */
  118786. export interface IEffectLayerOptions {
  118787. /**
  118788. * Multiplication factor apply to the canvas size to compute the render target size
  118789. * used to generated the objects (the smaller the faster).
  118790. */
  118791. mainTextureRatio: number;
  118792. /**
  118793. * Enforces a fixed size texture to ensure effect stability across devices.
  118794. */
  118795. mainTextureFixedSize?: number;
  118796. /**
  118797. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  118798. */
  118799. alphaBlendingMode: number;
  118800. /**
  118801. * The camera attached to the layer.
  118802. */
  118803. camera: Nullable<Camera>;
  118804. /**
  118805. * The rendering group to draw the layer in.
  118806. */
  118807. renderingGroupId: number;
  118808. }
  118809. /**
  118810. * The effect layer Helps adding post process effect blended with the main pass.
  118811. *
  118812. * This can be for instance use to generate glow or higlight effects on the scene.
  118813. *
  118814. * The effect layer class can not be used directly and is intented to inherited from to be
  118815. * customized per effects.
  118816. */
  118817. export abstract class EffectLayer {
  118818. private _vertexBuffers;
  118819. private _indexBuffer;
  118820. private _cachedDefines;
  118821. private _effectLayerMapGenerationEffect;
  118822. private _effectLayerOptions;
  118823. private _mergeEffect;
  118824. protected _scene: Scene;
  118825. protected _engine: Engine;
  118826. protected _maxSize: number;
  118827. protected _mainTextureDesiredSize: ISize;
  118828. protected _mainTexture: RenderTargetTexture;
  118829. protected _shouldRender: boolean;
  118830. protected _postProcesses: PostProcess[];
  118831. protected _textures: BaseTexture[];
  118832. protected _emissiveTextureAndColor: {
  118833. texture: Nullable<BaseTexture>;
  118834. color: Color4;
  118835. };
  118836. /**
  118837. * The name of the layer
  118838. */
  118839. name: string;
  118840. /**
  118841. * The clear color of the texture used to generate the glow map.
  118842. */
  118843. neutralColor: Color4;
  118844. /**
  118845. * Specifies wether the highlight layer is enabled or not.
  118846. */
  118847. isEnabled: boolean;
  118848. /**
  118849. * Gets the camera attached to the layer.
  118850. */
  118851. readonly camera: Nullable<Camera>;
  118852. /**
  118853. * Gets the rendering group id the layer should render in.
  118854. */
  118855. renderingGroupId: number;
  118856. /**
  118857. * An event triggered when the effect layer has been disposed.
  118858. */
  118859. onDisposeObservable: Observable<EffectLayer>;
  118860. /**
  118861. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  118862. */
  118863. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  118864. /**
  118865. * An event triggered when the generated texture is being merged in the scene.
  118866. */
  118867. onBeforeComposeObservable: Observable<EffectLayer>;
  118868. /**
  118869. * An event triggered when the mesh is rendered into the effect render target.
  118870. */
  118871. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  118872. /**
  118873. * An event triggered after the mesh has been rendered into the effect render target.
  118874. */
  118875. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  118876. /**
  118877. * An event triggered when the generated texture has been merged in the scene.
  118878. */
  118879. onAfterComposeObservable: Observable<EffectLayer>;
  118880. /**
  118881. * An event triggered when the efffect layer changes its size.
  118882. */
  118883. onSizeChangedObservable: Observable<EffectLayer>;
  118884. /** @hidden */
  118885. static _SceneComponentInitialization: (scene: Scene) => void;
  118886. /**
  118887. * Instantiates a new effect Layer and references it in the scene.
  118888. * @param name The name of the layer
  118889. * @param scene The scene to use the layer in
  118890. */
  118891. constructor(
  118892. /** The Friendly of the effect in the scene */
  118893. name: string, scene: Scene);
  118894. /**
  118895. * Get the effect name of the layer.
  118896. * @return The effect name
  118897. */
  118898. abstract getEffectName(): string;
  118899. /**
  118900. * Checks for the readiness of the element composing the layer.
  118901. * @param subMesh the mesh to check for
  118902. * @param useInstances specify wether or not to use instances to render the mesh
  118903. * @return true if ready otherwise, false
  118904. */
  118905. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118906. /**
  118907. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118908. * @returns true if the effect requires stencil during the main canvas render pass.
  118909. */
  118910. abstract needStencil(): boolean;
  118911. /**
  118912. * Create the merge effect. This is the shader use to blit the information back
  118913. * to the main canvas at the end of the scene rendering.
  118914. * @returns The effect containing the shader used to merge the effect on the main canvas
  118915. */
  118916. protected abstract _createMergeEffect(): Effect;
  118917. /**
  118918. * Creates the render target textures and post processes used in the effect layer.
  118919. */
  118920. protected abstract _createTextureAndPostProcesses(): void;
  118921. /**
  118922. * Implementation specific of rendering the generating effect on the main canvas.
  118923. * @param effect The effect used to render through
  118924. */
  118925. protected abstract _internalRender(effect: Effect): void;
  118926. /**
  118927. * Sets the required values for both the emissive texture and and the main color.
  118928. */
  118929. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118930. /**
  118931. * Free any resources and references associated to a mesh.
  118932. * Internal use
  118933. * @param mesh The mesh to free.
  118934. */
  118935. abstract _disposeMesh(mesh: Mesh): void;
  118936. /**
  118937. * Serializes this layer (Glow or Highlight for example)
  118938. * @returns a serialized layer object
  118939. */
  118940. abstract serialize?(): any;
  118941. /**
  118942. * Initializes the effect layer with the required options.
  118943. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118944. */
  118945. protected _init(options: Partial<IEffectLayerOptions>): void;
  118946. /**
  118947. * Generates the index buffer of the full screen quad blending to the main canvas.
  118948. */
  118949. private _generateIndexBuffer;
  118950. /**
  118951. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118952. */
  118953. private _generateVertexBuffer;
  118954. /**
  118955. * Sets the main texture desired size which is the closest power of two
  118956. * of the engine canvas size.
  118957. */
  118958. private _setMainTextureSize;
  118959. /**
  118960. * Creates the main texture for the effect layer.
  118961. */
  118962. protected _createMainTexture(): void;
  118963. /**
  118964. * Adds specific effects defines.
  118965. * @param defines The defines to add specifics to.
  118966. */
  118967. protected _addCustomEffectDefines(defines: string[]): void;
  118968. /**
  118969. * Checks for the readiness of the element composing the layer.
  118970. * @param subMesh the mesh to check for
  118971. * @param useInstances specify wether or not to use instances to render the mesh
  118972. * @param emissiveTexture the associated emissive texture used to generate the glow
  118973. * @return true if ready otherwise, false
  118974. */
  118975. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118976. /**
  118977. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118978. */
  118979. render(): void;
  118980. /**
  118981. * Determine if a given mesh will be used in the current effect.
  118982. * @param mesh mesh to test
  118983. * @returns true if the mesh will be used
  118984. */
  118985. hasMesh(mesh: AbstractMesh): boolean;
  118986. /**
  118987. * Returns true if the layer contains information to display, otherwise false.
  118988. * @returns true if the glow layer should be rendered
  118989. */
  118990. shouldRender(): boolean;
  118991. /**
  118992. * Returns true if the mesh should render, otherwise false.
  118993. * @param mesh The mesh to render
  118994. * @returns true if it should render otherwise false
  118995. */
  118996. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118997. /**
  118998. * Returns true if the mesh can be rendered, otherwise false.
  118999. * @param mesh The mesh to render
  119000. * @param material The material used on the mesh
  119001. * @returns true if it can be rendered otherwise false
  119002. */
  119003. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119004. /**
  119005. * Returns true if the mesh should render, otherwise false.
  119006. * @param mesh The mesh to render
  119007. * @returns true if it should render otherwise false
  119008. */
  119009. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  119010. /**
  119011. * Renders the submesh passed in parameter to the generation map.
  119012. */
  119013. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  119014. /**
  119015. * Defines wether the current material of the mesh should be use to render the effect.
  119016. * @param mesh defines the current mesh to render
  119017. */
  119018. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119019. /**
  119020. * Rebuild the required buffers.
  119021. * @hidden Internal use only.
  119022. */
  119023. _rebuild(): void;
  119024. /**
  119025. * Dispose only the render target textures and post process.
  119026. */
  119027. private _disposeTextureAndPostProcesses;
  119028. /**
  119029. * Dispose the highlight layer and free resources.
  119030. */
  119031. dispose(): void;
  119032. /**
  119033. * Gets the class name of the effect layer
  119034. * @returns the string with the class name of the effect layer
  119035. */
  119036. getClassName(): string;
  119037. /**
  119038. * Creates an effect layer from parsed effect layer data
  119039. * @param parsedEffectLayer defines effect layer data
  119040. * @param scene defines the current scene
  119041. * @param rootUrl defines the root URL containing the effect layer information
  119042. * @returns a parsed effect Layer
  119043. */
  119044. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  119045. }
  119046. }
  119047. declare module BABYLON {
  119048. interface AbstractScene {
  119049. /**
  119050. * The list of effect layers (highlights/glow) added to the scene
  119051. * @see http://doc.babylonjs.com/how_to/highlight_layer
  119052. * @see http://doc.babylonjs.com/how_to/glow_layer
  119053. */
  119054. effectLayers: Array<EffectLayer>;
  119055. /**
  119056. * Removes the given effect layer from this scene.
  119057. * @param toRemove defines the effect layer to remove
  119058. * @returns the index of the removed effect layer
  119059. */
  119060. removeEffectLayer(toRemove: EffectLayer): number;
  119061. /**
  119062. * Adds the given effect layer to this scene
  119063. * @param newEffectLayer defines the effect layer to add
  119064. */
  119065. addEffectLayer(newEffectLayer: EffectLayer): void;
  119066. }
  119067. /**
  119068. * Defines the layer scene component responsible to manage any effect layers
  119069. * in a given scene.
  119070. */
  119071. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  119072. /**
  119073. * The component name helpfull to identify the component in the list of scene components.
  119074. */
  119075. readonly name: string;
  119076. /**
  119077. * The scene the component belongs to.
  119078. */
  119079. scene: Scene;
  119080. private _engine;
  119081. private _renderEffects;
  119082. private _needStencil;
  119083. private _previousStencilState;
  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. * Serializes the component data to the specified json object
  119100. * @param serializationObject The object to serialize to
  119101. */
  119102. serialize(serializationObject: any): void;
  119103. /**
  119104. * Adds all the elements from the container to the scene
  119105. * @param container the container holding the elements
  119106. */
  119107. addFromContainer(container: AbstractScene): void;
  119108. /**
  119109. * Removes all the elements in the container from the scene
  119110. * @param container contains the elements to remove
  119111. * @param dispose if the removed element should be disposed (default: false)
  119112. */
  119113. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119114. /**
  119115. * Disposes the component and the associated ressources.
  119116. */
  119117. dispose(): void;
  119118. private _isReadyForMesh;
  119119. private _renderMainTexture;
  119120. private _setStencil;
  119121. private _setStencilBack;
  119122. private _draw;
  119123. private _drawCamera;
  119124. private _drawRenderingGroup;
  119125. }
  119126. }
  119127. declare module BABYLON {
  119128. /** @hidden */
  119129. export var glowMapMergePixelShader: {
  119130. name: string;
  119131. shader: string;
  119132. };
  119133. }
  119134. declare module BABYLON {
  119135. /** @hidden */
  119136. export var glowMapMergeVertexShader: {
  119137. name: string;
  119138. shader: string;
  119139. };
  119140. }
  119141. declare module BABYLON {
  119142. interface AbstractScene {
  119143. /**
  119144. * Return a the first highlight layer of the scene with a given name.
  119145. * @param name The name of the highlight layer to look for.
  119146. * @return The highlight layer if found otherwise null.
  119147. */
  119148. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  119149. }
  119150. /**
  119151. * Glow layer options. This helps customizing the behaviour
  119152. * of the glow layer.
  119153. */
  119154. export interface IGlowLayerOptions {
  119155. /**
  119156. * Multiplication factor apply to the canvas size to compute the render target size
  119157. * used to generated the glowing objects (the smaller the faster).
  119158. */
  119159. mainTextureRatio: number;
  119160. /**
  119161. * Enforces a fixed size texture to ensure resize independant blur.
  119162. */
  119163. mainTextureFixedSize?: number;
  119164. /**
  119165. * How big is the kernel of the blur texture.
  119166. */
  119167. blurKernelSize: number;
  119168. /**
  119169. * The camera attached to the layer.
  119170. */
  119171. camera: Nullable<Camera>;
  119172. /**
  119173. * Enable MSAA by chosing the number of samples.
  119174. */
  119175. mainTextureSamples?: number;
  119176. /**
  119177. * The rendering group to draw the layer in.
  119178. */
  119179. renderingGroupId: number;
  119180. }
  119181. /**
  119182. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  119183. *
  119184. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  119185. *
  119186. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  119187. */
  119188. export class GlowLayer extends EffectLayer {
  119189. /**
  119190. * Effect Name of the layer.
  119191. */
  119192. static readonly EffectName: string;
  119193. /**
  119194. * The default blur kernel size used for the glow.
  119195. */
  119196. static DefaultBlurKernelSize: number;
  119197. /**
  119198. * The default texture size ratio used for the glow.
  119199. */
  119200. static DefaultTextureRatio: number;
  119201. /**
  119202. * Sets the kernel size of the blur.
  119203. */
  119204. /**
  119205. * Gets the kernel size of the blur.
  119206. */
  119207. blurKernelSize: number;
  119208. /**
  119209. * Sets the glow intensity.
  119210. */
  119211. /**
  119212. * Gets the glow intensity.
  119213. */
  119214. intensity: number;
  119215. private _options;
  119216. private _intensity;
  119217. private _horizontalBlurPostprocess1;
  119218. private _verticalBlurPostprocess1;
  119219. private _horizontalBlurPostprocess2;
  119220. private _verticalBlurPostprocess2;
  119221. private _blurTexture1;
  119222. private _blurTexture2;
  119223. private _postProcesses1;
  119224. private _postProcesses2;
  119225. private _includedOnlyMeshes;
  119226. private _excludedMeshes;
  119227. private _meshesUsingTheirOwnMaterials;
  119228. /**
  119229. * Callback used to let the user override the color selection on a per mesh basis
  119230. */
  119231. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  119232. /**
  119233. * Callback used to let the user override the texture selection on a per mesh basis
  119234. */
  119235. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  119236. /**
  119237. * Instantiates a new glow Layer and references it to the scene.
  119238. * @param name The name of the layer
  119239. * @param scene The scene to use the layer in
  119240. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  119241. */
  119242. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  119243. /**
  119244. * Get the effect name of the layer.
  119245. * @return The effect name
  119246. */
  119247. getEffectName(): string;
  119248. /**
  119249. * Create the merge effect. This is the shader use to blit the information back
  119250. * to the main canvas at the end of the scene rendering.
  119251. */
  119252. protected _createMergeEffect(): Effect;
  119253. /**
  119254. * Creates the render target textures and post processes used in the glow layer.
  119255. */
  119256. protected _createTextureAndPostProcesses(): void;
  119257. /**
  119258. * Checks for the readiness of the element composing the layer.
  119259. * @param subMesh the mesh to check for
  119260. * @param useInstances specify wether or not to use instances to render the mesh
  119261. * @param emissiveTexture the associated emissive texture used to generate the glow
  119262. * @return true if ready otherwise, false
  119263. */
  119264. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119265. /**
  119266. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119267. */
  119268. needStencil(): boolean;
  119269. /**
  119270. * Returns true if the mesh can be rendered, otherwise false.
  119271. * @param mesh The mesh to render
  119272. * @param material The material used on the mesh
  119273. * @returns true if it can be rendered otherwise false
  119274. */
  119275. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119276. /**
  119277. * Implementation specific of rendering the generating effect on the main canvas.
  119278. * @param effect The effect used to render through
  119279. */
  119280. protected _internalRender(effect: Effect): void;
  119281. /**
  119282. * Sets the required values for both the emissive texture and and the main color.
  119283. */
  119284. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119285. /**
  119286. * Returns true if the mesh should render, otherwise false.
  119287. * @param mesh The mesh to render
  119288. * @returns true if it should render otherwise false
  119289. */
  119290. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119291. /**
  119292. * Adds specific effects defines.
  119293. * @param defines The defines to add specifics to.
  119294. */
  119295. protected _addCustomEffectDefines(defines: string[]): void;
  119296. /**
  119297. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  119298. * @param mesh The mesh to exclude from the glow layer
  119299. */
  119300. addExcludedMesh(mesh: Mesh): void;
  119301. /**
  119302. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  119303. * @param mesh The mesh to remove
  119304. */
  119305. removeExcludedMesh(mesh: Mesh): void;
  119306. /**
  119307. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  119308. * @param mesh The mesh to include in the glow layer
  119309. */
  119310. addIncludedOnlyMesh(mesh: Mesh): void;
  119311. /**
  119312. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  119313. * @param mesh The mesh to remove
  119314. */
  119315. removeIncludedOnlyMesh(mesh: Mesh): void;
  119316. /**
  119317. * Determine if a given mesh will be used in the glow layer
  119318. * @param mesh The mesh to test
  119319. * @returns true if the mesh will be highlighted by the current glow layer
  119320. */
  119321. hasMesh(mesh: AbstractMesh): boolean;
  119322. /**
  119323. * Defines wether the current material of the mesh should be use to render the effect.
  119324. * @param mesh defines the current mesh to render
  119325. */
  119326. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119327. /**
  119328. * Add a mesh to be rendered through its own material and not with emissive only.
  119329. * @param mesh The mesh for which we need to use its material
  119330. */
  119331. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  119332. /**
  119333. * Remove a mesh from being rendered through its own material and not with emissive only.
  119334. * @param mesh The mesh for which we need to not use its material
  119335. */
  119336. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  119337. /**
  119338. * Free any resources and references associated to a mesh.
  119339. * Internal use
  119340. * @param mesh The mesh to free.
  119341. * @hidden
  119342. */
  119343. _disposeMesh(mesh: Mesh): void;
  119344. /**
  119345. * Gets the class name of the effect layer
  119346. * @returns the string with the class name of the effect layer
  119347. */
  119348. getClassName(): string;
  119349. /**
  119350. * Serializes this glow layer
  119351. * @returns a serialized glow layer object
  119352. */
  119353. serialize(): any;
  119354. /**
  119355. * Creates a Glow Layer from parsed glow layer data
  119356. * @param parsedGlowLayer defines glow layer data
  119357. * @param scene defines the current scene
  119358. * @param rootUrl defines the root URL containing the glow layer information
  119359. * @returns a parsed Glow Layer
  119360. */
  119361. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  119362. }
  119363. }
  119364. declare module BABYLON {
  119365. /** @hidden */
  119366. export var glowBlurPostProcessPixelShader: {
  119367. name: string;
  119368. shader: string;
  119369. };
  119370. }
  119371. declare module BABYLON {
  119372. interface AbstractScene {
  119373. /**
  119374. * Return a the first highlight layer of the scene with a given name.
  119375. * @param name The name of the highlight layer to look for.
  119376. * @return The highlight layer if found otherwise null.
  119377. */
  119378. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  119379. }
  119380. /**
  119381. * Highlight layer options. This helps customizing the behaviour
  119382. * of the highlight layer.
  119383. */
  119384. export interface IHighlightLayerOptions {
  119385. /**
  119386. * Multiplication factor apply to the canvas size to compute the render target size
  119387. * used to generated the glowing objects (the smaller the faster).
  119388. */
  119389. mainTextureRatio: number;
  119390. /**
  119391. * Enforces a fixed size texture to ensure resize independant blur.
  119392. */
  119393. mainTextureFixedSize?: number;
  119394. /**
  119395. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  119396. * of the picture to blur (the smaller the faster).
  119397. */
  119398. blurTextureSizeRatio: number;
  119399. /**
  119400. * How big in texel of the blur texture is the vertical blur.
  119401. */
  119402. blurVerticalSize: number;
  119403. /**
  119404. * How big in texel of the blur texture is the horizontal blur.
  119405. */
  119406. blurHorizontalSize: number;
  119407. /**
  119408. * Alpha blending mode used to apply the blur. Default is combine.
  119409. */
  119410. alphaBlendingMode: number;
  119411. /**
  119412. * The camera attached to the layer.
  119413. */
  119414. camera: Nullable<Camera>;
  119415. /**
  119416. * Should we display highlight as a solid stroke?
  119417. */
  119418. isStroke?: boolean;
  119419. /**
  119420. * The rendering group to draw the layer in.
  119421. */
  119422. renderingGroupId: number;
  119423. }
  119424. /**
  119425. * The highlight layer Helps adding a glow effect around a mesh.
  119426. *
  119427. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  119428. * glowy meshes to your scene.
  119429. *
  119430. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  119431. */
  119432. export class HighlightLayer extends EffectLayer {
  119433. name: string;
  119434. /**
  119435. * Effect Name of the highlight layer.
  119436. */
  119437. static readonly EffectName: string;
  119438. /**
  119439. * The neutral color used during the preparation of the glow effect.
  119440. * This is black by default as the blend operation is a blend operation.
  119441. */
  119442. static NeutralColor: Color4;
  119443. /**
  119444. * Stencil value used for glowing meshes.
  119445. */
  119446. static GlowingMeshStencilReference: number;
  119447. /**
  119448. * Stencil value used for the other meshes in the scene.
  119449. */
  119450. static NormalMeshStencilReference: number;
  119451. /**
  119452. * Specifies whether or not the inner glow is ACTIVE in the layer.
  119453. */
  119454. innerGlow: boolean;
  119455. /**
  119456. * Specifies whether or not the outer glow is ACTIVE in the layer.
  119457. */
  119458. outerGlow: boolean;
  119459. /**
  119460. * Specifies the horizontal size of the blur.
  119461. */
  119462. /**
  119463. * Gets the horizontal size of the blur.
  119464. */
  119465. blurHorizontalSize: number;
  119466. /**
  119467. * Specifies the vertical size of the blur.
  119468. */
  119469. /**
  119470. * Gets the vertical size of the blur.
  119471. */
  119472. blurVerticalSize: number;
  119473. /**
  119474. * An event triggered when the highlight layer is being blurred.
  119475. */
  119476. onBeforeBlurObservable: Observable<HighlightLayer>;
  119477. /**
  119478. * An event triggered when the highlight layer has been blurred.
  119479. */
  119480. onAfterBlurObservable: Observable<HighlightLayer>;
  119481. private _instanceGlowingMeshStencilReference;
  119482. private _options;
  119483. private _downSamplePostprocess;
  119484. private _horizontalBlurPostprocess;
  119485. private _verticalBlurPostprocess;
  119486. private _blurTexture;
  119487. private _meshes;
  119488. private _excludedMeshes;
  119489. /**
  119490. * Instantiates a new highlight Layer and references it to the scene..
  119491. * @param name The name of the layer
  119492. * @param scene The scene to use the layer in
  119493. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  119494. */
  119495. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  119496. /**
  119497. * Get the effect name of the layer.
  119498. * @return The effect name
  119499. */
  119500. getEffectName(): string;
  119501. /**
  119502. * Create the merge effect. This is the shader use to blit the information back
  119503. * to the main canvas at the end of the scene rendering.
  119504. */
  119505. protected _createMergeEffect(): Effect;
  119506. /**
  119507. * Creates the render target textures and post processes used in the highlight layer.
  119508. */
  119509. protected _createTextureAndPostProcesses(): void;
  119510. /**
  119511. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119512. */
  119513. needStencil(): boolean;
  119514. /**
  119515. * Checks for the readiness of the element composing the layer.
  119516. * @param subMesh the mesh to check for
  119517. * @param useInstances specify wether or not to use instances to render the mesh
  119518. * @param emissiveTexture the associated emissive texture used to generate the glow
  119519. * @return true if ready otherwise, false
  119520. */
  119521. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119522. /**
  119523. * Implementation specific of rendering the generating effect on the main canvas.
  119524. * @param effect The effect used to render through
  119525. */
  119526. protected _internalRender(effect: Effect): void;
  119527. /**
  119528. * Returns true if the layer contains information to display, otherwise false.
  119529. */
  119530. shouldRender(): boolean;
  119531. /**
  119532. * Returns true if the mesh should render, otherwise false.
  119533. * @param mesh The mesh to render
  119534. * @returns true if it should render otherwise false
  119535. */
  119536. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119537. /**
  119538. * Sets the required values for both the emissive texture and and the main color.
  119539. */
  119540. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119541. /**
  119542. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  119543. * @param mesh The mesh to exclude from the highlight layer
  119544. */
  119545. addExcludedMesh(mesh: Mesh): void;
  119546. /**
  119547. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  119548. * @param mesh The mesh to highlight
  119549. */
  119550. removeExcludedMesh(mesh: Mesh): void;
  119551. /**
  119552. * Determine if a given mesh will be highlighted by the current HighlightLayer
  119553. * @param mesh mesh to test
  119554. * @returns true if the mesh will be highlighted by the current HighlightLayer
  119555. */
  119556. hasMesh(mesh: AbstractMesh): boolean;
  119557. /**
  119558. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  119559. * @param mesh The mesh to highlight
  119560. * @param color The color of the highlight
  119561. * @param glowEmissiveOnly Extract the glow from the emissive texture
  119562. */
  119563. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  119564. /**
  119565. * Remove a mesh from the highlight layer in order to make it stop glowing.
  119566. * @param mesh The mesh to highlight
  119567. */
  119568. removeMesh(mesh: Mesh): void;
  119569. /**
  119570. * Force the stencil to the normal expected value for none glowing parts
  119571. */
  119572. private _defaultStencilReference;
  119573. /**
  119574. * Free any resources and references associated to a mesh.
  119575. * Internal use
  119576. * @param mesh The mesh to free.
  119577. * @hidden
  119578. */
  119579. _disposeMesh(mesh: Mesh): void;
  119580. /**
  119581. * Dispose the highlight layer and free resources.
  119582. */
  119583. dispose(): void;
  119584. /**
  119585. * Gets the class name of the effect layer
  119586. * @returns the string with the class name of the effect layer
  119587. */
  119588. getClassName(): string;
  119589. /**
  119590. * Serializes this Highlight layer
  119591. * @returns a serialized Highlight layer object
  119592. */
  119593. serialize(): any;
  119594. /**
  119595. * Creates a Highlight layer from parsed Highlight layer data
  119596. * @param parsedHightlightLayer defines the Highlight layer data
  119597. * @param scene defines the current scene
  119598. * @param rootUrl defines the root URL containing the Highlight layer information
  119599. * @returns a parsed Highlight layer
  119600. */
  119601. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  119602. }
  119603. }
  119604. declare module BABYLON {
  119605. interface AbstractScene {
  119606. /**
  119607. * The list of layers (background and foreground) of the scene
  119608. */
  119609. layers: Array<Layer>;
  119610. }
  119611. /**
  119612. * Defines the layer scene component responsible to manage any layers
  119613. * in a given scene.
  119614. */
  119615. export class LayerSceneComponent implements ISceneComponent {
  119616. /**
  119617. * The component name helpfull to identify the component in the list of scene components.
  119618. */
  119619. readonly name: string;
  119620. /**
  119621. * The scene the component belongs to.
  119622. */
  119623. scene: Scene;
  119624. private _engine;
  119625. /**
  119626. * Creates a new instance of the component for the given scene
  119627. * @param scene Defines the scene to register the component in
  119628. */
  119629. constructor(scene: Scene);
  119630. /**
  119631. * Registers the component in a given scene
  119632. */
  119633. register(): void;
  119634. /**
  119635. * Rebuilds the elements related to this component in case of
  119636. * context lost for instance.
  119637. */
  119638. rebuild(): void;
  119639. /**
  119640. * Disposes the component and the associated ressources.
  119641. */
  119642. dispose(): void;
  119643. private _draw;
  119644. private _drawCameraPredicate;
  119645. private _drawCameraBackground;
  119646. private _drawCameraForeground;
  119647. private _drawRenderTargetPredicate;
  119648. private _drawRenderTargetBackground;
  119649. private _drawRenderTargetForeground;
  119650. /**
  119651. * Adds all the elements from the container to the scene
  119652. * @param container the container holding the elements
  119653. */
  119654. addFromContainer(container: AbstractScene): void;
  119655. /**
  119656. * Removes all the elements in the container from the scene
  119657. * @param container contains the elements to remove
  119658. * @param dispose if the removed element should be disposed (default: false)
  119659. */
  119660. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119661. }
  119662. }
  119663. declare module BABYLON {
  119664. /** @hidden */
  119665. export var layerPixelShader: {
  119666. name: string;
  119667. shader: string;
  119668. };
  119669. }
  119670. declare module BABYLON {
  119671. /** @hidden */
  119672. export var layerVertexShader: {
  119673. name: string;
  119674. shader: string;
  119675. };
  119676. }
  119677. declare module BABYLON {
  119678. /**
  119679. * This represents a full screen 2d layer.
  119680. * This can be useful to display a picture in the background of your scene for instance.
  119681. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119682. */
  119683. export class Layer {
  119684. /**
  119685. * Define the name of the layer.
  119686. */
  119687. name: string;
  119688. /**
  119689. * Define the texture the layer should display.
  119690. */
  119691. texture: Nullable<Texture>;
  119692. /**
  119693. * Is the layer in background or foreground.
  119694. */
  119695. isBackground: boolean;
  119696. /**
  119697. * Define the color of the layer (instead of texture).
  119698. */
  119699. color: Color4;
  119700. /**
  119701. * Define the scale of the layer in order to zoom in out of the texture.
  119702. */
  119703. scale: Vector2;
  119704. /**
  119705. * Define an offset for the layer in order to shift the texture.
  119706. */
  119707. offset: Vector2;
  119708. /**
  119709. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  119710. */
  119711. alphaBlendingMode: number;
  119712. /**
  119713. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  119714. * Alpha test will not mix with the background color in case of transparency.
  119715. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  119716. */
  119717. alphaTest: boolean;
  119718. /**
  119719. * Define a mask to restrict the layer to only some of the scene cameras.
  119720. */
  119721. layerMask: number;
  119722. /**
  119723. * Define the list of render target the layer is visible into.
  119724. */
  119725. renderTargetTextures: RenderTargetTexture[];
  119726. /**
  119727. * Define if the layer is only used in renderTarget or if it also
  119728. * renders in the main frame buffer of the canvas.
  119729. */
  119730. renderOnlyInRenderTargetTextures: boolean;
  119731. private _scene;
  119732. private _vertexBuffers;
  119733. private _indexBuffer;
  119734. private _effect;
  119735. private _alphaTestEffect;
  119736. /**
  119737. * An event triggered when the layer is disposed.
  119738. */
  119739. onDisposeObservable: Observable<Layer>;
  119740. private _onDisposeObserver;
  119741. /**
  119742. * Back compatibility with callback before the onDisposeObservable existed.
  119743. * The set callback will be triggered when the layer has been disposed.
  119744. */
  119745. onDispose: () => void;
  119746. /**
  119747. * An event triggered before rendering the scene
  119748. */
  119749. onBeforeRenderObservable: Observable<Layer>;
  119750. private _onBeforeRenderObserver;
  119751. /**
  119752. * Back compatibility with callback before the onBeforeRenderObservable existed.
  119753. * The set callback will be triggered just before rendering the layer.
  119754. */
  119755. onBeforeRender: () => void;
  119756. /**
  119757. * An event triggered after rendering the scene
  119758. */
  119759. onAfterRenderObservable: Observable<Layer>;
  119760. private _onAfterRenderObserver;
  119761. /**
  119762. * Back compatibility with callback before the onAfterRenderObservable existed.
  119763. * The set callback will be triggered just after rendering the layer.
  119764. */
  119765. onAfterRender: () => void;
  119766. /**
  119767. * Instantiates a new layer.
  119768. * This represents a full screen 2d layer.
  119769. * This can be useful to display a picture in the background of your scene for instance.
  119770. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119771. * @param name Define the name of the layer in the scene
  119772. * @param imgUrl Define the url of the texture to display in the layer
  119773. * @param scene Define the scene the layer belongs to
  119774. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  119775. * @param color Defines a color for the layer
  119776. */
  119777. constructor(
  119778. /**
  119779. * Define the name of the layer.
  119780. */
  119781. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  119782. private _createIndexBuffer;
  119783. /** @hidden */
  119784. _rebuild(): void;
  119785. /**
  119786. * Renders the layer in the scene.
  119787. */
  119788. render(): void;
  119789. /**
  119790. * Disposes and releases the associated ressources.
  119791. */
  119792. dispose(): void;
  119793. }
  119794. }
  119795. declare module BABYLON {
  119796. /** @hidden */
  119797. export var lensFlarePixelShader: {
  119798. name: string;
  119799. shader: string;
  119800. };
  119801. }
  119802. declare module BABYLON {
  119803. /** @hidden */
  119804. export var lensFlareVertexShader: {
  119805. name: string;
  119806. shader: string;
  119807. };
  119808. }
  119809. declare module BABYLON {
  119810. /**
  119811. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119812. * It is usually composed of several `lensFlare`.
  119813. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119814. */
  119815. export class LensFlareSystem {
  119816. /**
  119817. * Define the name of the lens flare system
  119818. */
  119819. name: string;
  119820. /**
  119821. * List of lens flares used in this system.
  119822. */
  119823. lensFlares: LensFlare[];
  119824. /**
  119825. * Define a limit from the border the lens flare can be visible.
  119826. */
  119827. borderLimit: number;
  119828. /**
  119829. * Define a viewport border we do not want to see the lens flare in.
  119830. */
  119831. viewportBorder: number;
  119832. /**
  119833. * Define a predicate which could limit the list of meshes able to occlude the effect.
  119834. */
  119835. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119836. /**
  119837. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  119838. */
  119839. layerMask: number;
  119840. /**
  119841. * Define the id of the lens flare system in the scene.
  119842. * (equal to name by default)
  119843. */
  119844. id: string;
  119845. private _scene;
  119846. private _emitter;
  119847. private _vertexBuffers;
  119848. private _indexBuffer;
  119849. private _effect;
  119850. private _positionX;
  119851. private _positionY;
  119852. private _isEnabled;
  119853. /** @hidden */
  119854. static _SceneComponentInitialization: (scene: Scene) => void;
  119855. /**
  119856. * Instantiates a lens flare system.
  119857. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119858. * It is usually composed of several `lensFlare`.
  119859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119860. * @param name Define the name of the lens flare system in the scene
  119861. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  119862. * @param scene Define the scene the lens flare system belongs to
  119863. */
  119864. constructor(
  119865. /**
  119866. * Define the name of the lens flare system
  119867. */
  119868. name: string, emitter: any, scene: Scene);
  119869. /**
  119870. * Define if the lens flare system is enabled.
  119871. */
  119872. isEnabled: boolean;
  119873. /**
  119874. * Get the scene the effects belongs to.
  119875. * @returns the scene holding the lens flare system
  119876. */
  119877. getScene(): Scene;
  119878. /**
  119879. * Get the emitter of the lens flare system.
  119880. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119881. * @returns the emitter of the lens flare system
  119882. */
  119883. getEmitter(): any;
  119884. /**
  119885. * Set the emitter of the lens flare system.
  119886. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119887. * @param newEmitter Define the new emitter of the system
  119888. */
  119889. setEmitter(newEmitter: any): void;
  119890. /**
  119891. * Get the lens flare system emitter position.
  119892. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  119893. * @returns the position
  119894. */
  119895. getEmitterPosition(): Vector3;
  119896. /**
  119897. * @hidden
  119898. */
  119899. computeEffectivePosition(globalViewport: Viewport): boolean;
  119900. /** @hidden */
  119901. _isVisible(): boolean;
  119902. /**
  119903. * @hidden
  119904. */
  119905. render(): boolean;
  119906. /**
  119907. * Dispose and release the lens flare with its associated resources.
  119908. */
  119909. dispose(): void;
  119910. /**
  119911. * Parse a lens flare system from a JSON repressentation
  119912. * @param parsedLensFlareSystem Define the JSON to parse
  119913. * @param scene Define the scene the parsed system should be instantiated in
  119914. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  119915. * @returns the parsed system
  119916. */
  119917. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  119918. /**
  119919. * Serialize the current Lens Flare System into a JSON representation.
  119920. * @returns the serialized JSON
  119921. */
  119922. serialize(): any;
  119923. }
  119924. }
  119925. declare module BABYLON {
  119926. /**
  119927. * This represents one of the lens effect in a `lensFlareSystem`.
  119928. * It controls one of the indiviual texture used in the effect.
  119929. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119930. */
  119931. export class LensFlare {
  119932. /**
  119933. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119934. */
  119935. size: number;
  119936. /**
  119937. * 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.
  119938. */
  119939. position: number;
  119940. /**
  119941. * Define the lens color.
  119942. */
  119943. color: Color3;
  119944. /**
  119945. * Define the lens texture.
  119946. */
  119947. texture: Nullable<Texture>;
  119948. /**
  119949. * Define the alpha mode to render this particular lens.
  119950. */
  119951. alphaMode: number;
  119952. private _system;
  119953. /**
  119954. * Creates a new Lens Flare.
  119955. * This represents one of the lens effect in a `lensFlareSystem`.
  119956. * It controls one of the indiviual texture used in the effect.
  119957. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119958. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119959. * @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.
  119960. * @param color Define the lens color
  119961. * @param imgUrl Define the lens texture url
  119962. * @param system Define the `lensFlareSystem` this flare is part of
  119963. * @returns The newly created Lens Flare
  119964. */
  119965. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119966. /**
  119967. * Instantiates a new Lens Flare.
  119968. * This represents one of the lens effect in a `lensFlareSystem`.
  119969. * It controls one of the indiviual texture used in the effect.
  119970. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119971. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119972. * @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.
  119973. * @param color Define the lens color
  119974. * @param imgUrl Define the lens texture url
  119975. * @param system Define the `lensFlareSystem` this flare is part of
  119976. */
  119977. constructor(
  119978. /**
  119979. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119980. */
  119981. size: number,
  119982. /**
  119983. * 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.
  119984. */
  119985. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119986. /**
  119987. * Dispose and release the lens flare with its associated resources.
  119988. */
  119989. dispose(): void;
  119990. }
  119991. }
  119992. declare module BABYLON {
  119993. interface AbstractScene {
  119994. /**
  119995. * The list of lens flare system added to the scene
  119996. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119997. */
  119998. lensFlareSystems: Array<LensFlareSystem>;
  119999. /**
  120000. * Removes the given lens flare system from this scene.
  120001. * @param toRemove The lens flare system to remove
  120002. * @returns The index of the removed lens flare system
  120003. */
  120004. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  120005. /**
  120006. * Adds the given lens flare system to this scene
  120007. * @param newLensFlareSystem The lens flare system to add
  120008. */
  120009. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  120010. /**
  120011. * Gets a lens flare system using its name
  120012. * @param name defines the name to look for
  120013. * @returns the lens flare system or null if not found
  120014. */
  120015. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  120016. /**
  120017. * Gets a lens flare system using its id
  120018. * @param id defines the id to look for
  120019. * @returns the lens flare system or null if not found
  120020. */
  120021. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  120022. }
  120023. /**
  120024. * Defines the lens flare scene component responsible to manage any lens flares
  120025. * in a given scene.
  120026. */
  120027. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  120028. /**
  120029. * The component name helpfull to identify the component in the list of scene components.
  120030. */
  120031. readonly name: string;
  120032. /**
  120033. * The scene the component belongs to.
  120034. */
  120035. scene: Scene;
  120036. /**
  120037. * Creates a new instance of the component for the given scene
  120038. * @param scene Defines the scene to register the component in
  120039. */
  120040. constructor(scene: Scene);
  120041. /**
  120042. * Registers the component in a given scene
  120043. */
  120044. register(): void;
  120045. /**
  120046. * Rebuilds the elements related to this component in case of
  120047. * context lost for instance.
  120048. */
  120049. rebuild(): void;
  120050. /**
  120051. * Adds all the elements from the container to the scene
  120052. * @param container the container holding the elements
  120053. */
  120054. addFromContainer(container: AbstractScene): void;
  120055. /**
  120056. * Removes all the elements in the container from the scene
  120057. * @param container contains the elements to remove
  120058. * @param dispose if the removed element should be disposed (default: false)
  120059. */
  120060. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120061. /**
  120062. * Serializes the component data to the specified json object
  120063. * @param serializationObject The object to serialize to
  120064. */
  120065. serialize(serializationObject: any): void;
  120066. /**
  120067. * Disposes the component and the associated ressources.
  120068. */
  120069. dispose(): void;
  120070. private _draw;
  120071. }
  120072. }
  120073. declare module BABYLON {
  120074. /**
  120075. * Defines the shadow generator component responsible to manage any shadow generators
  120076. * in a given scene.
  120077. */
  120078. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  120079. /**
  120080. * The component name helpfull to identify the component in the list of scene components.
  120081. */
  120082. readonly name: string;
  120083. /**
  120084. * The scene the component belongs to.
  120085. */
  120086. scene: Scene;
  120087. /**
  120088. * Creates a new instance of the component for the given scene
  120089. * @param scene Defines the scene to register the component in
  120090. */
  120091. constructor(scene: Scene);
  120092. /**
  120093. * Registers the component in a given scene
  120094. */
  120095. register(): void;
  120096. /**
  120097. * Rebuilds the elements related to this component in case of
  120098. * context lost for instance.
  120099. */
  120100. rebuild(): void;
  120101. /**
  120102. * Serializes the component data to the specified json object
  120103. * @param serializationObject The object to serialize to
  120104. */
  120105. serialize(serializationObject: any): void;
  120106. /**
  120107. * Adds all the elements from the container to the scene
  120108. * @param container the container holding the elements
  120109. */
  120110. addFromContainer(container: AbstractScene): void;
  120111. /**
  120112. * Removes all the elements in the container from the scene
  120113. * @param container contains the elements to remove
  120114. * @param dispose if the removed element should be disposed (default: false)
  120115. */
  120116. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120117. /**
  120118. * Rebuilds the elements related to this component in case of
  120119. * context lost for instance.
  120120. */
  120121. dispose(): void;
  120122. private _gatherRenderTargets;
  120123. }
  120124. }
  120125. declare module BABYLON {
  120126. /**
  120127. * A point light is a light defined by an unique point in world space.
  120128. * The light is emitted in every direction from this point.
  120129. * A good example of a point light is a standard light bulb.
  120130. * Documentation: https://doc.babylonjs.com/babylon101/lights
  120131. */
  120132. export class PointLight extends ShadowLight {
  120133. private _shadowAngle;
  120134. /**
  120135. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120136. * This specifies what angle the shadow will use to be created.
  120137. *
  120138. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120139. */
  120140. /**
  120141. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120142. * This specifies what angle the shadow will use to be created.
  120143. *
  120144. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120145. */
  120146. shadowAngle: number;
  120147. /**
  120148. * Gets the direction if it has been set.
  120149. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120150. */
  120151. /**
  120152. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120153. */
  120154. direction: Vector3;
  120155. /**
  120156. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  120157. * A PointLight emits the light in every direction.
  120158. * It can cast shadows.
  120159. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  120160. * ```javascript
  120161. * var pointLight = new PointLight("pl", camera.position, scene);
  120162. * ```
  120163. * Documentation : https://doc.babylonjs.com/babylon101/lights
  120164. * @param name The light friendly name
  120165. * @param position The position of the point light in the scene
  120166. * @param scene The scene the lights belongs to
  120167. */
  120168. constructor(name: string, position: Vector3, scene: Scene);
  120169. /**
  120170. * Returns the string "PointLight"
  120171. * @returns the class name
  120172. */
  120173. getClassName(): string;
  120174. /**
  120175. * Returns the integer 0.
  120176. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  120177. */
  120178. getTypeID(): number;
  120179. /**
  120180. * Specifies wether or not the shadowmap should be a cube texture.
  120181. * @returns true if the shadowmap needs to be a cube texture.
  120182. */
  120183. needCube(): boolean;
  120184. /**
  120185. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  120186. * @param faceIndex The index of the face we are computed the direction to generate shadow
  120187. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  120188. */
  120189. getShadowDirection(faceIndex?: number): Vector3;
  120190. /**
  120191. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  120192. * - fov = PI / 2
  120193. * - aspect ratio : 1.0
  120194. * - z-near and far equal to the active camera minZ and maxZ.
  120195. * Returns the PointLight.
  120196. */
  120197. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  120198. protected _buildUniformLayout(): void;
  120199. /**
  120200. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  120201. * @param effect The effect to update
  120202. * @param lightIndex The index of the light in the effect to update
  120203. * @returns The point light
  120204. */
  120205. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  120206. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  120207. /**
  120208. * Prepares the list of defines specific to the light type.
  120209. * @param defines the list of defines
  120210. * @param lightIndex defines the index of the light for the effect
  120211. */
  120212. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  120213. }
  120214. }
  120215. declare module BABYLON {
  120216. /**
  120217. * Header information of HDR texture files.
  120218. */
  120219. export interface HDRInfo {
  120220. /**
  120221. * The height of the texture in pixels.
  120222. */
  120223. height: number;
  120224. /**
  120225. * The width of the texture in pixels.
  120226. */
  120227. width: number;
  120228. /**
  120229. * The index of the beginning of the data in the binary file.
  120230. */
  120231. dataPosition: number;
  120232. }
  120233. /**
  120234. * This groups tools to convert HDR texture to native colors array.
  120235. */
  120236. export class HDRTools {
  120237. private static Ldexp;
  120238. private static Rgbe2float;
  120239. private static readStringLine;
  120240. /**
  120241. * Reads header information from an RGBE texture stored in a native array.
  120242. * More information on this format are available here:
  120243. * https://en.wikipedia.org/wiki/RGBE_image_format
  120244. *
  120245. * @param uint8array The binary file stored in native array.
  120246. * @return The header information.
  120247. */
  120248. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  120249. /**
  120250. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  120251. * This RGBE texture needs to store the information as a panorama.
  120252. *
  120253. * More information on this format are available here:
  120254. * https://en.wikipedia.org/wiki/RGBE_image_format
  120255. *
  120256. * @param buffer The binary file stored in an array buffer.
  120257. * @param size The expected size of the extracted cubemap.
  120258. * @return The Cube Map information.
  120259. */
  120260. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  120261. /**
  120262. * Returns the pixels data extracted from an RGBE texture.
  120263. * This pixels will be stored left to right up to down in the R G B order in one array.
  120264. *
  120265. * More information on this format are available here:
  120266. * https://en.wikipedia.org/wiki/RGBE_image_format
  120267. *
  120268. * @param uint8array The binary file stored in an array buffer.
  120269. * @param hdrInfo The header information of the file.
  120270. * @return The pixels data in RGB right to left up to down order.
  120271. */
  120272. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  120273. private static RGBE_ReadPixels_RLE;
  120274. }
  120275. }
  120276. declare module BABYLON {
  120277. /**
  120278. * This represents a texture coming from an HDR input.
  120279. *
  120280. * The only supported format is currently panorama picture stored in RGBE format.
  120281. * Example of such files can be found on HDRLib: http://hdrlib.com/
  120282. */
  120283. export class HDRCubeTexture extends BaseTexture {
  120284. private static _facesMapping;
  120285. private _generateHarmonics;
  120286. private _noMipmap;
  120287. private _textureMatrix;
  120288. private _size;
  120289. private _onLoad;
  120290. private _onError;
  120291. /**
  120292. * The texture URL.
  120293. */
  120294. url: string;
  120295. /**
  120296. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  120297. */
  120298. coordinatesMode: number;
  120299. protected _isBlocking: boolean;
  120300. /**
  120301. * Sets wether or not the texture is blocking during loading.
  120302. */
  120303. /**
  120304. * Gets wether or not the texture is blocking during loading.
  120305. */
  120306. isBlocking: boolean;
  120307. protected _rotationY: number;
  120308. /**
  120309. * Sets texture matrix rotation angle around Y axis in radians.
  120310. */
  120311. /**
  120312. * Gets texture matrix rotation angle around Y axis radians.
  120313. */
  120314. rotationY: number;
  120315. /**
  120316. * Gets or sets the center of the bounding box associated with the cube texture
  120317. * It must define where the camera used to render the texture was set
  120318. */
  120319. boundingBoxPosition: Vector3;
  120320. private _boundingBoxSize;
  120321. /**
  120322. * Gets or sets the size of the bounding box associated with the cube texture
  120323. * When defined, the cubemap will switch to local mode
  120324. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  120325. * @example https://www.babylonjs-playground.com/#RNASML
  120326. */
  120327. boundingBoxSize: Vector3;
  120328. /**
  120329. * Instantiates an HDRTexture from the following parameters.
  120330. *
  120331. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  120332. * @param scene The scene the texture will be used in
  120333. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120334. * @param noMipmap Forces to not generate the mipmap if true
  120335. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  120336. * @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)
  120337. * @param reserved Reserved flag for internal use.
  120338. */
  120339. 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>);
  120340. /**
  120341. * Get the current class name of the texture useful for serialization or dynamic coding.
  120342. * @returns "HDRCubeTexture"
  120343. */
  120344. getClassName(): string;
  120345. /**
  120346. * Occurs when the file is raw .hdr file.
  120347. */
  120348. private loadTexture;
  120349. clone(): HDRCubeTexture;
  120350. delayLoad(): void;
  120351. /**
  120352. * Get the texture reflection matrix used to rotate/transform the reflection.
  120353. * @returns the reflection matrix
  120354. */
  120355. getReflectionTextureMatrix(): Matrix;
  120356. /**
  120357. * Set the texture reflection matrix used to rotate/transform the reflection.
  120358. * @param value Define the reflection matrix to set
  120359. */
  120360. setReflectionTextureMatrix(value: Matrix): void;
  120361. /**
  120362. * Parses a JSON representation of an HDR Texture in order to create the texture
  120363. * @param parsedTexture Define the JSON representation
  120364. * @param scene Define the scene the texture should be created in
  120365. * @param rootUrl Define the root url in case we need to load relative dependencies
  120366. * @returns the newly created texture after parsing
  120367. */
  120368. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  120369. serialize(): any;
  120370. }
  120371. }
  120372. declare module BABYLON {
  120373. /**
  120374. * Class used to control physics engine
  120375. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120376. */
  120377. export class PhysicsEngine implements IPhysicsEngine {
  120378. private _physicsPlugin;
  120379. /**
  120380. * Global value used to control the smallest number supported by the simulation
  120381. */
  120382. static Epsilon: number;
  120383. private _impostors;
  120384. private _joints;
  120385. /**
  120386. * Gets the gravity vector used by the simulation
  120387. */
  120388. gravity: Vector3;
  120389. /**
  120390. * Factory used to create the default physics plugin.
  120391. * @returns The default physics plugin
  120392. */
  120393. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  120394. /**
  120395. * Creates a new Physics Engine
  120396. * @param gravity defines the gravity vector used by the simulation
  120397. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  120398. */
  120399. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  120400. /**
  120401. * Sets the gravity vector used by the simulation
  120402. * @param gravity defines the gravity vector to use
  120403. */
  120404. setGravity(gravity: Vector3): void;
  120405. /**
  120406. * Set the time step of the physics engine.
  120407. * Default is 1/60.
  120408. * To slow it down, enter 1/600 for example.
  120409. * To speed it up, 1/30
  120410. * @param newTimeStep defines the new timestep to apply to this world.
  120411. */
  120412. setTimeStep(newTimeStep?: number): void;
  120413. /**
  120414. * Get the time step of the physics engine.
  120415. * @returns the current time step
  120416. */
  120417. getTimeStep(): number;
  120418. /**
  120419. * Release all resources
  120420. */
  120421. dispose(): void;
  120422. /**
  120423. * Gets the name of the current physics plugin
  120424. * @returns the name of the plugin
  120425. */
  120426. getPhysicsPluginName(): string;
  120427. /**
  120428. * Adding a new impostor for the impostor tracking.
  120429. * This will be done by the impostor itself.
  120430. * @param impostor the impostor to add
  120431. */
  120432. addImpostor(impostor: PhysicsImpostor): void;
  120433. /**
  120434. * Remove an impostor from the engine.
  120435. * This impostor and its mesh will not longer be updated by the physics engine.
  120436. * @param impostor the impostor to remove
  120437. */
  120438. removeImpostor(impostor: PhysicsImpostor): void;
  120439. /**
  120440. * Add a joint to the physics engine
  120441. * @param mainImpostor defines the main impostor to which the joint is added.
  120442. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  120443. * @param joint defines the joint that will connect both impostors.
  120444. */
  120445. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120446. /**
  120447. * Removes a joint from the simulation
  120448. * @param mainImpostor defines the impostor used with the joint
  120449. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  120450. * @param joint defines the joint to remove
  120451. */
  120452. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120453. /**
  120454. * Called by the scene. No need to call it.
  120455. * @param delta defines the timespam between frames
  120456. */
  120457. _step(delta: number): void;
  120458. /**
  120459. * Gets the current plugin used to run the simulation
  120460. * @returns current plugin
  120461. */
  120462. getPhysicsPlugin(): IPhysicsEnginePlugin;
  120463. /**
  120464. * Gets the list of physic impostors
  120465. * @returns an array of PhysicsImpostor
  120466. */
  120467. getImpostors(): Array<PhysicsImpostor>;
  120468. /**
  120469. * Gets the impostor for a physics enabled object
  120470. * @param object defines the object impersonated by the impostor
  120471. * @returns the PhysicsImpostor or null if not found
  120472. */
  120473. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  120474. /**
  120475. * Gets the impostor for a physics body object
  120476. * @param body defines physics body used by the impostor
  120477. * @returns the PhysicsImpostor or null if not found
  120478. */
  120479. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  120480. /**
  120481. * Does a raycast in the physics world
  120482. * @param from when should the ray start?
  120483. * @param to when should the ray end?
  120484. * @returns PhysicsRaycastResult
  120485. */
  120486. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120487. }
  120488. }
  120489. declare module BABYLON {
  120490. /** @hidden */
  120491. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  120492. private _useDeltaForWorldStep;
  120493. world: any;
  120494. name: string;
  120495. private _physicsMaterials;
  120496. private _fixedTimeStep;
  120497. private _cannonRaycastResult;
  120498. private _raycastResult;
  120499. private _physicsBodysToRemoveAfterStep;
  120500. BJSCANNON: any;
  120501. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  120502. setGravity(gravity: Vector3): void;
  120503. setTimeStep(timeStep: number): void;
  120504. getTimeStep(): number;
  120505. executeStep(delta: number): void;
  120506. private _removeMarkedPhysicsBodiesFromWorld;
  120507. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120508. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120509. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120510. private _processChildMeshes;
  120511. removePhysicsBody(impostor: PhysicsImpostor): void;
  120512. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120513. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120514. private _addMaterial;
  120515. private _checkWithEpsilon;
  120516. private _createShape;
  120517. private _createHeightmap;
  120518. private _minus90X;
  120519. private _plus90X;
  120520. private _tmpPosition;
  120521. private _tmpDeltaPosition;
  120522. private _tmpUnityRotation;
  120523. private _updatePhysicsBodyTransformation;
  120524. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120525. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120526. isSupported(): boolean;
  120527. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120528. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120529. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120530. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120531. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120532. getBodyMass(impostor: PhysicsImpostor): number;
  120533. getBodyFriction(impostor: PhysicsImpostor): number;
  120534. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120535. getBodyRestitution(impostor: PhysicsImpostor): number;
  120536. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120537. sleepBody(impostor: PhysicsImpostor): void;
  120538. wakeUpBody(impostor: PhysicsImpostor): void;
  120539. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  120540. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120541. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120542. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120543. getRadius(impostor: PhysicsImpostor): number;
  120544. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120545. dispose(): void;
  120546. private _extendNamespace;
  120547. /**
  120548. * Does a raycast in the physics world
  120549. * @param from when should the ray start?
  120550. * @param to when should the ray end?
  120551. * @returns PhysicsRaycastResult
  120552. */
  120553. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120554. }
  120555. }
  120556. declare module BABYLON {
  120557. /** @hidden */
  120558. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  120559. world: any;
  120560. name: string;
  120561. BJSOIMO: any;
  120562. private _raycastResult;
  120563. constructor(iterations?: number, oimoInjection?: any);
  120564. setGravity(gravity: Vector3): void;
  120565. setTimeStep(timeStep: number): void;
  120566. getTimeStep(): number;
  120567. private _tmpImpostorsArray;
  120568. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120569. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120570. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120571. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120572. private _tmpPositionVector;
  120573. removePhysicsBody(impostor: PhysicsImpostor): void;
  120574. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120575. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120576. isSupported(): boolean;
  120577. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120578. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120579. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120580. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120581. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120582. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120583. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120584. getBodyMass(impostor: PhysicsImpostor): number;
  120585. getBodyFriction(impostor: PhysicsImpostor): number;
  120586. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120587. getBodyRestitution(impostor: PhysicsImpostor): number;
  120588. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120589. sleepBody(impostor: PhysicsImpostor): void;
  120590. wakeUpBody(impostor: PhysicsImpostor): void;
  120591. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120592. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  120593. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  120594. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120595. getRadius(impostor: PhysicsImpostor): number;
  120596. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120597. dispose(): void;
  120598. /**
  120599. * Does a raycast in the physics world
  120600. * @param from when should the ray start?
  120601. * @param to when should the ray end?
  120602. * @returns PhysicsRaycastResult
  120603. */
  120604. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120605. }
  120606. }
  120607. declare module BABYLON {
  120608. /**
  120609. * Class containing static functions to help procedurally build meshes
  120610. */
  120611. export class RibbonBuilder {
  120612. /**
  120613. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120614. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  120615. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  120616. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  120617. * * 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
  120618. * * 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
  120619. * * 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
  120620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120621. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120622. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120623. * * 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
  120624. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  120625. * * 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
  120626. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  120627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120628. * @param name defines the name of the mesh
  120629. * @param options defines the options used to create the mesh
  120630. * @param scene defines the hosting scene
  120631. * @returns the ribbon mesh
  120632. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  120633. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120634. */
  120635. static CreateRibbon(name: string, options: {
  120636. pathArray: Vector3[][];
  120637. closeArray?: boolean;
  120638. closePath?: boolean;
  120639. offset?: number;
  120640. updatable?: boolean;
  120641. sideOrientation?: number;
  120642. frontUVs?: Vector4;
  120643. backUVs?: Vector4;
  120644. instance?: Mesh;
  120645. invertUV?: boolean;
  120646. uvs?: Vector2[];
  120647. colors?: Color4[];
  120648. }, scene?: Nullable<Scene>): Mesh;
  120649. }
  120650. }
  120651. declare module BABYLON {
  120652. /**
  120653. * Class containing static functions to help procedurally build meshes
  120654. */
  120655. export class ShapeBuilder {
  120656. /**
  120657. * 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.
  120658. * * 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.
  120659. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120660. * * 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.
  120661. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  120662. * * 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
  120663. * * 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
  120664. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  120665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120667. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  120668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120669. * @param name defines the name of the mesh
  120670. * @param options defines the options used to create the mesh
  120671. * @param scene defines the hosting scene
  120672. * @returns the extruded shape mesh
  120673. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120675. */
  120676. static ExtrudeShape(name: string, options: {
  120677. shape: Vector3[];
  120678. path: Vector3[];
  120679. scale?: number;
  120680. rotation?: number;
  120681. cap?: number;
  120682. updatable?: boolean;
  120683. sideOrientation?: number;
  120684. frontUVs?: Vector4;
  120685. backUVs?: Vector4;
  120686. instance?: Mesh;
  120687. invertUV?: boolean;
  120688. }, scene?: Nullable<Scene>): Mesh;
  120689. /**
  120690. * Creates an custom extruded shape mesh.
  120691. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  120692. * * 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.
  120693. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120694. * * 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
  120695. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  120696. * * 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
  120697. * * It must returns a float value that will be the scale value applied to the shape on each path point
  120698. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  120699. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  120700. * * 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
  120701. * * 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
  120702. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120705. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120707. * @param name defines the name of the mesh
  120708. * @param options defines the options used to create the mesh
  120709. * @param scene defines the hosting scene
  120710. * @returns the custom extruded shape mesh
  120711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120712. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120714. */
  120715. static ExtrudeShapeCustom(name: string, options: {
  120716. shape: Vector3[];
  120717. path: Vector3[];
  120718. scaleFunction?: any;
  120719. rotationFunction?: any;
  120720. ribbonCloseArray?: boolean;
  120721. ribbonClosePath?: boolean;
  120722. cap?: number;
  120723. updatable?: boolean;
  120724. sideOrientation?: number;
  120725. frontUVs?: Vector4;
  120726. backUVs?: Vector4;
  120727. instance?: Mesh;
  120728. invertUV?: boolean;
  120729. }, scene?: Nullable<Scene>): Mesh;
  120730. private static _ExtrudeShapeGeneric;
  120731. }
  120732. }
  120733. declare module BABYLON {
  120734. /**
  120735. * AmmoJS Physics plugin
  120736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120737. * @see https://github.com/kripken/ammo.js/
  120738. */
  120739. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  120740. private _useDeltaForWorldStep;
  120741. /**
  120742. * Reference to the Ammo library
  120743. */
  120744. bjsAMMO: any;
  120745. /**
  120746. * Created ammoJS world which physics bodies are added to
  120747. */
  120748. world: any;
  120749. /**
  120750. * Name of the plugin
  120751. */
  120752. name: string;
  120753. private _timeStep;
  120754. private _fixedTimeStep;
  120755. private _maxSteps;
  120756. private _tmpQuaternion;
  120757. private _tmpAmmoTransform;
  120758. private _tmpAmmoQuaternion;
  120759. private _tmpAmmoConcreteContactResultCallback;
  120760. private _collisionConfiguration;
  120761. private _dispatcher;
  120762. private _overlappingPairCache;
  120763. private _solver;
  120764. private _softBodySolver;
  120765. private _tmpAmmoVectorA;
  120766. private _tmpAmmoVectorB;
  120767. private _tmpAmmoVectorC;
  120768. private _tmpAmmoVectorD;
  120769. private _tmpContactCallbackResult;
  120770. private _tmpAmmoVectorRCA;
  120771. private _tmpAmmoVectorRCB;
  120772. private _raycastResult;
  120773. private static readonly DISABLE_COLLISION_FLAG;
  120774. private static readonly KINEMATIC_FLAG;
  120775. private static readonly DISABLE_DEACTIVATION_FLAG;
  120776. /**
  120777. * Initializes the ammoJS plugin
  120778. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  120779. * @param ammoInjection can be used to inject your own ammo reference
  120780. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  120781. */
  120782. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  120783. /**
  120784. * Sets the gravity of the physics world (m/(s^2))
  120785. * @param gravity Gravity to set
  120786. */
  120787. setGravity(gravity: Vector3): void;
  120788. /**
  120789. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  120790. * @param timeStep timestep to use in seconds
  120791. */
  120792. setTimeStep(timeStep: number): void;
  120793. /**
  120794. * 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)
  120795. * @param fixedTimeStep fixedTimeStep to use in seconds
  120796. */
  120797. setFixedTimeStep(fixedTimeStep: number): void;
  120798. /**
  120799. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  120800. * @param maxSteps the maximum number of steps by the physics engine per frame
  120801. */
  120802. setMaxSteps(maxSteps: number): void;
  120803. /**
  120804. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  120805. * @returns the current timestep in seconds
  120806. */
  120807. getTimeStep(): number;
  120808. private _isImpostorInContact;
  120809. private _isImpostorPairInContact;
  120810. private _stepSimulation;
  120811. /**
  120812. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  120813. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  120814. * After the step the babylon meshes are set to the position of the physics imposters
  120815. * @param delta amount of time to step forward
  120816. * @param impostors array of imposters to update before/after the step
  120817. */
  120818. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120819. /**
  120820. * Update babylon mesh to match physics world object
  120821. * @param impostor imposter to match
  120822. */
  120823. private _afterSoftStep;
  120824. /**
  120825. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120826. * @param impostor imposter to match
  120827. */
  120828. private _ropeStep;
  120829. /**
  120830. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120831. * @param impostor imposter to match
  120832. */
  120833. private _softbodyOrClothStep;
  120834. private _tmpVector;
  120835. private _tmpMatrix;
  120836. /**
  120837. * Applies an impulse on the imposter
  120838. * @param impostor imposter to apply impulse to
  120839. * @param force amount of force to be applied to the imposter
  120840. * @param contactPoint the location to apply the impulse on the imposter
  120841. */
  120842. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120843. /**
  120844. * Applies a force on the imposter
  120845. * @param impostor imposter to apply force
  120846. * @param force amount of force to be applied to the imposter
  120847. * @param contactPoint the location to apply the force on the imposter
  120848. */
  120849. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120850. /**
  120851. * Creates a physics body using the plugin
  120852. * @param impostor the imposter to create the physics body on
  120853. */
  120854. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120855. /**
  120856. * Removes the physics body from the imposter and disposes of the body's memory
  120857. * @param impostor imposter to remove the physics body from
  120858. */
  120859. removePhysicsBody(impostor: PhysicsImpostor): void;
  120860. /**
  120861. * Generates a joint
  120862. * @param impostorJoint the imposter joint to create the joint with
  120863. */
  120864. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120865. /**
  120866. * Removes a joint
  120867. * @param impostorJoint the imposter joint to remove the joint from
  120868. */
  120869. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120870. private _addMeshVerts;
  120871. /**
  120872. * Initialise the soft body vertices to match its object's (mesh) vertices
  120873. * Softbody vertices (nodes) are in world space and to match this
  120874. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  120875. * @param impostor to create the softbody for
  120876. */
  120877. private _softVertexData;
  120878. /**
  120879. * Create an impostor's soft body
  120880. * @param impostor to create the softbody for
  120881. */
  120882. private _createSoftbody;
  120883. /**
  120884. * Create cloth for an impostor
  120885. * @param impostor to create the softbody for
  120886. */
  120887. private _createCloth;
  120888. /**
  120889. * Create rope for an impostor
  120890. * @param impostor to create the softbody for
  120891. */
  120892. private _createRope;
  120893. private _addHullVerts;
  120894. private _createShape;
  120895. /**
  120896. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  120897. * @param impostor imposter containing the physics body and babylon object
  120898. */
  120899. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120900. /**
  120901. * Sets the babylon object's position/rotation from the physics body's position/rotation
  120902. * @param impostor imposter containing the physics body and babylon object
  120903. * @param newPosition new position
  120904. * @param newRotation new rotation
  120905. */
  120906. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120907. /**
  120908. * If this plugin is supported
  120909. * @returns true if its supported
  120910. */
  120911. isSupported(): boolean;
  120912. /**
  120913. * Sets the linear velocity of the physics body
  120914. * @param impostor imposter to set the velocity on
  120915. * @param velocity velocity to set
  120916. */
  120917. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120918. /**
  120919. * Sets the angular velocity of the physics body
  120920. * @param impostor imposter to set the velocity on
  120921. * @param velocity velocity to set
  120922. */
  120923. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120924. /**
  120925. * gets the linear velocity
  120926. * @param impostor imposter to get linear velocity from
  120927. * @returns linear velocity
  120928. */
  120929. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120930. /**
  120931. * gets the angular velocity
  120932. * @param impostor imposter to get angular velocity from
  120933. * @returns angular velocity
  120934. */
  120935. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120936. /**
  120937. * Sets the mass of physics body
  120938. * @param impostor imposter to set the mass on
  120939. * @param mass mass to set
  120940. */
  120941. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120942. /**
  120943. * Gets the mass of the physics body
  120944. * @param impostor imposter to get the mass from
  120945. * @returns mass
  120946. */
  120947. getBodyMass(impostor: PhysicsImpostor): number;
  120948. /**
  120949. * Gets friction of the impostor
  120950. * @param impostor impostor to get friction from
  120951. * @returns friction value
  120952. */
  120953. getBodyFriction(impostor: PhysicsImpostor): number;
  120954. /**
  120955. * Sets friction of the impostor
  120956. * @param impostor impostor to set friction on
  120957. * @param friction friction value
  120958. */
  120959. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120960. /**
  120961. * Gets restitution of the impostor
  120962. * @param impostor impostor to get restitution from
  120963. * @returns restitution value
  120964. */
  120965. getBodyRestitution(impostor: PhysicsImpostor): number;
  120966. /**
  120967. * Sets resitution of the impostor
  120968. * @param impostor impostor to set resitution on
  120969. * @param restitution resitution value
  120970. */
  120971. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120972. /**
  120973. * Gets pressure inside the impostor
  120974. * @param impostor impostor to get pressure from
  120975. * @returns pressure value
  120976. */
  120977. getBodyPressure(impostor: PhysicsImpostor): number;
  120978. /**
  120979. * Sets pressure inside a soft body impostor
  120980. * Cloth and rope must remain 0 pressure
  120981. * @param impostor impostor to set pressure on
  120982. * @param pressure pressure value
  120983. */
  120984. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120985. /**
  120986. * Gets stiffness of the impostor
  120987. * @param impostor impostor to get stiffness from
  120988. * @returns pressure value
  120989. */
  120990. getBodyStiffness(impostor: PhysicsImpostor): number;
  120991. /**
  120992. * Sets stiffness of the impostor
  120993. * @param impostor impostor to set stiffness on
  120994. * @param stiffness stiffness value from 0 to 1
  120995. */
  120996. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120997. /**
  120998. * Gets velocityIterations of the impostor
  120999. * @param impostor impostor to get velocity iterations from
  121000. * @returns velocityIterations value
  121001. */
  121002. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  121003. /**
  121004. * Sets velocityIterations of the impostor
  121005. * @param impostor impostor to set velocity iterations on
  121006. * @param velocityIterations velocityIterations value
  121007. */
  121008. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  121009. /**
  121010. * Gets positionIterations of the impostor
  121011. * @param impostor impostor to get position iterations from
  121012. * @returns positionIterations value
  121013. */
  121014. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  121015. /**
  121016. * Sets positionIterations of the impostor
  121017. * @param impostor impostor to set position on
  121018. * @param positionIterations positionIterations value
  121019. */
  121020. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  121021. /**
  121022. * Append an anchor to a cloth object
  121023. * @param impostor is the cloth impostor to add anchor to
  121024. * @param otherImpostor is the rigid impostor to anchor to
  121025. * @param width ratio across width from 0 to 1
  121026. * @param height ratio up height from 0 to 1
  121027. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  121028. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121029. */
  121030. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121031. /**
  121032. * Append an hook to a rope object
  121033. * @param impostor is the rope impostor to add hook to
  121034. * @param otherImpostor is the rigid impostor to hook to
  121035. * @param length ratio along the rope from 0 to 1
  121036. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  121037. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121038. */
  121039. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121040. /**
  121041. * Sleeps the physics body and stops it from being active
  121042. * @param impostor impostor to sleep
  121043. */
  121044. sleepBody(impostor: PhysicsImpostor): void;
  121045. /**
  121046. * Activates the physics body
  121047. * @param impostor impostor to activate
  121048. */
  121049. wakeUpBody(impostor: PhysicsImpostor): void;
  121050. /**
  121051. * Updates the distance parameters of the joint
  121052. * @param joint joint to update
  121053. * @param maxDistance maximum distance of the joint
  121054. * @param minDistance minimum distance of the joint
  121055. */
  121056. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121057. /**
  121058. * Sets a motor on the joint
  121059. * @param joint joint to set motor on
  121060. * @param speed speed of the motor
  121061. * @param maxForce maximum force of the motor
  121062. * @param motorIndex index of the motor
  121063. */
  121064. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121065. /**
  121066. * Sets the motors limit
  121067. * @param joint joint to set limit on
  121068. * @param upperLimit upper limit
  121069. * @param lowerLimit lower limit
  121070. */
  121071. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121072. /**
  121073. * Syncs the position and rotation of a mesh with the impostor
  121074. * @param mesh mesh to sync
  121075. * @param impostor impostor to update the mesh with
  121076. */
  121077. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121078. /**
  121079. * Gets the radius of the impostor
  121080. * @param impostor impostor to get radius from
  121081. * @returns the radius
  121082. */
  121083. getRadius(impostor: PhysicsImpostor): number;
  121084. /**
  121085. * Gets the box size of the impostor
  121086. * @param impostor impostor to get box size from
  121087. * @param result the resulting box size
  121088. */
  121089. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121090. /**
  121091. * Disposes of the impostor
  121092. */
  121093. dispose(): void;
  121094. /**
  121095. * Does a raycast in the physics world
  121096. * @param from when should the ray start?
  121097. * @param to when should the ray end?
  121098. * @returns PhysicsRaycastResult
  121099. */
  121100. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121101. }
  121102. }
  121103. declare module BABYLON {
  121104. interface AbstractScene {
  121105. /**
  121106. * The list of reflection probes added to the scene
  121107. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121108. */
  121109. reflectionProbes: Array<ReflectionProbe>;
  121110. /**
  121111. * Removes the given reflection probe from this scene.
  121112. * @param toRemove The reflection probe to remove
  121113. * @returns The index of the removed reflection probe
  121114. */
  121115. removeReflectionProbe(toRemove: ReflectionProbe): number;
  121116. /**
  121117. * Adds the given reflection probe to this scene.
  121118. * @param newReflectionProbe The reflection probe to add
  121119. */
  121120. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  121121. }
  121122. /**
  121123. * Class used to generate realtime reflection / refraction cube textures
  121124. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121125. */
  121126. export class ReflectionProbe {
  121127. /** defines the name of the probe */
  121128. name: string;
  121129. private _scene;
  121130. private _renderTargetTexture;
  121131. private _projectionMatrix;
  121132. private _viewMatrix;
  121133. private _target;
  121134. private _add;
  121135. private _attachedMesh;
  121136. private _invertYAxis;
  121137. /** Gets or sets probe position (center of the cube map) */
  121138. position: Vector3;
  121139. /**
  121140. * Creates a new reflection probe
  121141. * @param name defines the name of the probe
  121142. * @param size defines the texture resolution (for each face)
  121143. * @param scene defines the hosting scene
  121144. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  121145. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  121146. */
  121147. constructor(
  121148. /** defines the name of the probe */
  121149. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  121150. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  121151. samples: number;
  121152. /** Gets or sets the refresh rate to use (on every frame by default) */
  121153. refreshRate: number;
  121154. /**
  121155. * Gets the hosting scene
  121156. * @returns a Scene
  121157. */
  121158. getScene(): Scene;
  121159. /** Gets the internal CubeTexture used to render to */
  121160. readonly cubeTexture: RenderTargetTexture;
  121161. /** Gets the list of meshes to render */
  121162. readonly renderList: Nullable<AbstractMesh[]>;
  121163. /**
  121164. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  121165. * @param mesh defines the mesh to attach to
  121166. */
  121167. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121168. /**
  121169. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  121170. * @param renderingGroupId The rendering group id corresponding to its index
  121171. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121172. */
  121173. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  121174. /**
  121175. * Clean all associated resources
  121176. */
  121177. dispose(): void;
  121178. /**
  121179. * Converts the reflection probe information to a readable string for debug purpose.
  121180. * @param fullDetails Supports for multiple levels of logging within scene loading
  121181. * @returns the human readable reflection probe info
  121182. */
  121183. toString(fullDetails?: boolean): string;
  121184. /**
  121185. * Get the class name of the relfection probe.
  121186. * @returns "ReflectionProbe"
  121187. */
  121188. getClassName(): string;
  121189. /**
  121190. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  121191. * @returns The JSON representation of the texture
  121192. */
  121193. serialize(): any;
  121194. /**
  121195. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  121196. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  121197. * @param scene Define the scene the parsed reflection probe should be instantiated in
  121198. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  121199. * @returns The parsed reflection probe if successful
  121200. */
  121201. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  121202. }
  121203. }
  121204. declare module BABYLON {
  121205. /** @hidden */
  121206. export var _BabylonLoaderRegistered: boolean;
  121207. /**
  121208. * Helps setting up some configuration for the babylon file loader.
  121209. */
  121210. export class BabylonFileLoaderConfiguration {
  121211. /**
  121212. * The loader does not allow injecting custom physix engine into the plugins.
  121213. * Unfortunately in ES6, we need to manually inject them into the plugin.
  121214. * So you could set this variable to your engine import to make it work.
  121215. */
  121216. static LoaderInjectedPhysicsEngine: any;
  121217. }
  121218. }
  121219. declare module BABYLON {
  121220. /**
  121221. * The Physically based simple base material of BJS.
  121222. *
  121223. * This enables better naming and convention enforcements on top of the pbrMaterial.
  121224. * It is used as the base class for both the specGloss and metalRough conventions.
  121225. */
  121226. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  121227. /**
  121228. * Number of Simultaneous lights allowed on the material.
  121229. */
  121230. maxSimultaneousLights: number;
  121231. /**
  121232. * If sets to true, disables all the lights affecting the material.
  121233. */
  121234. disableLighting: boolean;
  121235. /**
  121236. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  121237. */
  121238. environmentTexture: BaseTexture;
  121239. /**
  121240. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121241. */
  121242. invertNormalMapX: boolean;
  121243. /**
  121244. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121245. */
  121246. invertNormalMapY: boolean;
  121247. /**
  121248. * Normal map used in the model.
  121249. */
  121250. normalTexture: BaseTexture;
  121251. /**
  121252. * Emissivie color used to self-illuminate the model.
  121253. */
  121254. emissiveColor: Color3;
  121255. /**
  121256. * Emissivie texture used to self-illuminate the model.
  121257. */
  121258. emissiveTexture: BaseTexture;
  121259. /**
  121260. * Occlusion Channel Strenght.
  121261. */
  121262. occlusionStrength: number;
  121263. /**
  121264. * Occlusion Texture of the material (adding extra occlusion effects).
  121265. */
  121266. occlusionTexture: BaseTexture;
  121267. /**
  121268. * Defines the alpha limits in alpha test mode.
  121269. */
  121270. alphaCutOff: number;
  121271. /**
  121272. * Gets the current double sided mode.
  121273. */
  121274. /**
  121275. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121276. */
  121277. doubleSided: boolean;
  121278. /**
  121279. * Stores the pre-calculated light information of a mesh in a texture.
  121280. */
  121281. lightmapTexture: BaseTexture;
  121282. /**
  121283. * If true, the light map contains occlusion information instead of lighting info.
  121284. */
  121285. useLightmapAsShadowmap: boolean;
  121286. /**
  121287. * Instantiates a new PBRMaterial instance.
  121288. *
  121289. * @param name The material name
  121290. * @param scene The scene the material will be use in.
  121291. */
  121292. constructor(name: string, scene: Scene);
  121293. getClassName(): string;
  121294. }
  121295. }
  121296. declare module BABYLON {
  121297. /**
  121298. * The PBR material of BJS following the metal roughness convention.
  121299. *
  121300. * This fits to the PBR convention in the GLTF definition:
  121301. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  121302. */
  121303. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  121304. /**
  121305. * The base color has two different interpretations depending on the value of metalness.
  121306. * When the material is a metal, the base color is the specific measured reflectance value
  121307. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  121308. * of the material.
  121309. */
  121310. baseColor: Color3;
  121311. /**
  121312. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  121313. * well as opacity information in the alpha channel.
  121314. */
  121315. baseTexture: BaseTexture;
  121316. /**
  121317. * Specifies the metallic scalar value of the material.
  121318. * Can also be used to scale the metalness values of the metallic texture.
  121319. */
  121320. metallic: number;
  121321. /**
  121322. * Specifies the roughness scalar value of the material.
  121323. * Can also be used to scale the roughness values of the metallic texture.
  121324. */
  121325. roughness: number;
  121326. /**
  121327. * Texture containing both the metallic value in the B channel and the
  121328. * roughness value in the G channel to keep better precision.
  121329. */
  121330. metallicRoughnessTexture: BaseTexture;
  121331. /**
  121332. * Instantiates a new PBRMetalRoughnessMaterial instance.
  121333. *
  121334. * @param name The material name
  121335. * @param scene The scene the material will be use in.
  121336. */
  121337. constructor(name: string, scene: Scene);
  121338. /**
  121339. * Return the currrent class name of the material.
  121340. */
  121341. getClassName(): string;
  121342. /**
  121343. * Makes a duplicate of the current material.
  121344. * @param name - name to use for the new material.
  121345. */
  121346. clone(name: string): PBRMetallicRoughnessMaterial;
  121347. /**
  121348. * Serialize the material to a parsable JSON object.
  121349. */
  121350. serialize(): any;
  121351. /**
  121352. * Parses a JSON object correponding to the serialize function.
  121353. */
  121354. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  121355. }
  121356. }
  121357. declare module BABYLON {
  121358. /**
  121359. * The PBR material of BJS following the specular glossiness convention.
  121360. *
  121361. * This fits to the PBR convention in the GLTF definition:
  121362. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  121363. */
  121364. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  121365. /**
  121366. * Specifies the diffuse color of the material.
  121367. */
  121368. diffuseColor: Color3;
  121369. /**
  121370. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  121371. * channel.
  121372. */
  121373. diffuseTexture: BaseTexture;
  121374. /**
  121375. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  121376. */
  121377. specularColor: Color3;
  121378. /**
  121379. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  121380. */
  121381. glossiness: number;
  121382. /**
  121383. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  121384. */
  121385. specularGlossinessTexture: BaseTexture;
  121386. /**
  121387. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  121388. *
  121389. * @param name The material name
  121390. * @param scene The scene the material will be use in.
  121391. */
  121392. constructor(name: string, scene: Scene);
  121393. /**
  121394. * Return the currrent class name of the material.
  121395. */
  121396. getClassName(): string;
  121397. /**
  121398. * Makes a duplicate of the current material.
  121399. * @param name - name to use for the new material.
  121400. */
  121401. clone(name: string): PBRSpecularGlossinessMaterial;
  121402. /**
  121403. * Serialize the material to a parsable JSON object.
  121404. */
  121405. serialize(): any;
  121406. /**
  121407. * Parses a JSON object correponding to the serialize function.
  121408. */
  121409. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  121410. }
  121411. }
  121412. declare module BABYLON {
  121413. /**
  121414. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  121415. * It can help converting any input color in a desired output one. This can then be used to create effects
  121416. * from sepia, black and white to sixties or futuristic rendering...
  121417. *
  121418. * The only supported format is currently 3dl.
  121419. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  121420. */
  121421. export class ColorGradingTexture extends BaseTexture {
  121422. /**
  121423. * The current texture matrix. (will always be identity in color grading texture)
  121424. */
  121425. private _textureMatrix;
  121426. /**
  121427. * The texture URL.
  121428. */
  121429. url: string;
  121430. /**
  121431. * Empty line regex stored for GC.
  121432. */
  121433. private static _noneEmptyLineRegex;
  121434. private _engine;
  121435. /**
  121436. * Instantiates a ColorGradingTexture from the following parameters.
  121437. *
  121438. * @param url The location of the color gradind data (currently only supporting 3dl)
  121439. * @param scene The scene the texture will be used in
  121440. */
  121441. constructor(url: string, scene: Scene);
  121442. /**
  121443. * Returns the texture matrix used in most of the material.
  121444. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  121445. */
  121446. getTextureMatrix(): Matrix;
  121447. /**
  121448. * Occurs when the file being loaded is a .3dl LUT file.
  121449. */
  121450. private load3dlTexture;
  121451. /**
  121452. * Starts the loading process of the texture.
  121453. */
  121454. private loadTexture;
  121455. /**
  121456. * Clones the color gradind texture.
  121457. */
  121458. clone(): ColorGradingTexture;
  121459. /**
  121460. * Called during delayed load for textures.
  121461. */
  121462. delayLoad(): void;
  121463. /**
  121464. * Parses a color grading texture serialized by Babylon.
  121465. * @param parsedTexture The texture information being parsedTexture
  121466. * @param scene The scene to load the texture in
  121467. * @param rootUrl The root url of the data assets to load
  121468. * @return A color gradind texture
  121469. */
  121470. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  121471. /**
  121472. * Serializes the LUT texture to json format.
  121473. */
  121474. serialize(): any;
  121475. }
  121476. }
  121477. declare module BABYLON {
  121478. /**
  121479. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  121480. */
  121481. export class EquiRectangularCubeTexture extends BaseTexture {
  121482. /** The six faces of the cube. */
  121483. private static _FacesMapping;
  121484. private _noMipmap;
  121485. private _onLoad;
  121486. private _onError;
  121487. /** The size of the cubemap. */
  121488. private _size;
  121489. /** The buffer of the image. */
  121490. private _buffer;
  121491. /** The width of the input image. */
  121492. private _width;
  121493. /** The height of the input image. */
  121494. private _height;
  121495. /** The URL to the image. */
  121496. url: string;
  121497. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  121498. coordinatesMode: number;
  121499. /**
  121500. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  121501. * @param url The location of the image
  121502. * @param scene The scene the texture will be used in
  121503. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  121504. * @param noMipmap Forces to not generate the mipmap if true
  121505. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121506. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121507. * @param onLoad — defines a callback called when texture is loaded
  121508. * @param onError — defines a callback called if there is an error
  121509. */
  121510. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  121511. /**
  121512. * Load the image data, by putting the image on a canvas and extracting its buffer.
  121513. */
  121514. private loadImage;
  121515. /**
  121516. * Convert the image buffer into a cubemap and create a CubeTexture.
  121517. */
  121518. private loadTexture;
  121519. /**
  121520. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  121521. * @param buffer The ArrayBuffer that should be converted.
  121522. * @returns The buffer as Float32Array.
  121523. */
  121524. private getFloat32ArrayFromArrayBuffer;
  121525. /**
  121526. * Get the current class name of the texture useful for serialization or dynamic coding.
  121527. * @returns "EquiRectangularCubeTexture"
  121528. */
  121529. getClassName(): string;
  121530. /**
  121531. * Create a clone of the current EquiRectangularCubeTexture and return it.
  121532. * @returns A clone of the current EquiRectangularCubeTexture.
  121533. */
  121534. clone(): EquiRectangularCubeTexture;
  121535. }
  121536. }
  121537. declare module BABYLON {
  121538. /**
  121539. * Based on jsTGALoader - Javascript loader for TGA file
  121540. * By Vincent Thibault
  121541. * @see http://blog.robrowser.com/javascript-tga-loader.html
  121542. */
  121543. export class TGATools {
  121544. private static _TYPE_INDEXED;
  121545. private static _TYPE_RGB;
  121546. private static _TYPE_GREY;
  121547. private static _TYPE_RLE_INDEXED;
  121548. private static _TYPE_RLE_RGB;
  121549. private static _TYPE_RLE_GREY;
  121550. private static _ORIGIN_MASK;
  121551. private static _ORIGIN_SHIFT;
  121552. private static _ORIGIN_BL;
  121553. private static _ORIGIN_BR;
  121554. private static _ORIGIN_UL;
  121555. private static _ORIGIN_UR;
  121556. /**
  121557. * Gets the header of a TGA file
  121558. * @param data defines the TGA data
  121559. * @returns the header
  121560. */
  121561. static GetTGAHeader(data: Uint8Array): any;
  121562. /**
  121563. * Uploads TGA content to a Babylon Texture
  121564. * @hidden
  121565. */
  121566. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  121567. /** @hidden */
  121568. 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;
  121569. /** @hidden */
  121570. 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;
  121571. /** @hidden */
  121572. 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;
  121573. /** @hidden */
  121574. 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;
  121575. /** @hidden */
  121576. 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;
  121577. /** @hidden */
  121578. 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;
  121579. }
  121580. }
  121581. declare module BABYLON {
  121582. /**
  121583. * Implementation of the TGA Texture Loader.
  121584. * @hidden
  121585. */
  121586. export class _TGATextureLoader implements IInternalTextureLoader {
  121587. /**
  121588. * Defines wether the loader supports cascade loading the different faces.
  121589. */
  121590. readonly supportCascades: boolean;
  121591. /**
  121592. * This returns if the loader support the current file information.
  121593. * @param extension defines the file extension of the file being loaded
  121594. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121595. * @param fallback defines the fallback internal texture if any
  121596. * @param isBase64 defines whether the texture is encoded as a base64
  121597. * @param isBuffer defines whether the texture data are stored as a buffer
  121598. * @returns true if the loader can load the specified file
  121599. */
  121600. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121601. /**
  121602. * Transform the url before loading if required.
  121603. * @param rootUrl the url of the texture
  121604. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121605. * @returns the transformed texture
  121606. */
  121607. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121608. /**
  121609. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121610. * @param rootUrl the url of the texture
  121611. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121612. * @returns the fallback texture
  121613. */
  121614. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121615. /**
  121616. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121617. * @param data contains the texture data
  121618. * @param texture defines the BabylonJS internal texture
  121619. * @param createPolynomials will be true if polynomials have been requested
  121620. * @param onLoad defines the callback to trigger once the texture is ready
  121621. * @param onError defines the callback to trigger in case of error
  121622. */
  121623. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121624. /**
  121625. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121626. * @param data contains the texture data
  121627. * @param texture defines the BabylonJS internal texture
  121628. * @param callback defines the method to call once ready to upload
  121629. */
  121630. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121631. }
  121632. }
  121633. declare module BABYLON {
  121634. /**
  121635. * Info about the .basis files
  121636. */
  121637. class BasisFileInfo {
  121638. /**
  121639. * If the file has alpha
  121640. */
  121641. hasAlpha: boolean;
  121642. /**
  121643. * Info about each image of the basis file
  121644. */
  121645. images: Array<{
  121646. levels: Array<{
  121647. width: number;
  121648. height: number;
  121649. transcodedPixels: ArrayBufferView;
  121650. }>;
  121651. }>;
  121652. }
  121653. /**
  121654. * Result of transcoding a basis file
  121655. */
  121656. class TranscodeResult {
  121657. /**
  121658. * Info about the .basis file
  121659. */
  121660. fileInfo: BasisFileInfo;
  121661. /**
  121662. * Format to use when loading the file
  121663. */
  121664. format: number;
  121665. }
  121666. /**
  121667. * Configuration options for the Basis transcoder
  121668. */
  121669. export class BasisTranscodeConfiguration {
  121670. /**
  121671. * Supported compression formats used to determine the supported output format of the transcoder
  121672. */
  121673. supportedCompressionFormats?: {
  121674. /**
  121675. * etc1 compression format
  121676. */
  121677. etc1?: boolean;
  121678. /**
  121679. * s3tc compression format
  121680. */
  121681. s3tc?: boolean;
  121682. /**
  121683. * pvrtc compression format
  121684. */
  121685. pvrtc?: boolean;
  121686. /**
  121687. * etc2 compression format
  121688. */
  121689. etc2?: boolean;
  121690. };
  121691. /**
  121692. * If mipmap levels should be loaded for transcoded images (Default: true)
  121693. */
  121694. loadMipmapLevels?: boolean;
  121695. /**
  121696. * Index of a single image to load (Default: all images)
  121697. */
  121698. loadSingleImage?: number;
  121699. }
  121700. /**
  121701. * Used to load .Basis files
  121702. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  121703. */
  121704. export class BasisTools {
  121705. private static _IgnoreSupportedFormats;
  121706. /**
  121707. * URL to use when loading the basis transcoder
  121708. */
  121709. static JSModuleURL: string;
  121710. /**
  121711. * URL to use when loading the wasm module for the transcoder
  121712. */
  121713. static WasmModuleURL: string;
  121714. /**
  121715. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  121716. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  121717. * @returns internal format corresponding to the Basis format
  121718. */
  121719. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  121720. private static _WorkerPromise;
  121721. private static _Worker;
  121722. private static _actionId;
  121723. private static _CreateWorkerAsync;
  121724. /**
  121725. * Transcodes a loaded image file to compressed pixel data
  121726. * @param imageData image data to transcode
  121727. * @param config configuration options for the transcoding
  121728. * @returns a promise resulting in the transcoded image
  121729. */
  121730. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  121731. /**
  121732. * Loads a texture from the transcode result
  121733. * @param texture texture load to
  121734. * @param transcodeResult the result of transcoding the basis file to load from
  121735. */
  121736. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  121737. }
  121738. }
  121739. declare module BABYLON {
  121740. /**
  121741. * Loader for .basis file format
  121742. */
  121743. export class _BasisTextureLoader implements IInternalTextureLoader {
  121744. /**
  121745. * Defines whether the loader supports cascade loading the different faces.
  121746. */
  121747. readonly supportCascades: boolean;
  121748. /**
  121749. * This returns if the loader support the current file information.
  121750. * @param extension defines the file extension of the file being loaded
  121751. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121752. * @param fallback defines the fallback internal texture if any
  121753. * @param isBase64 defines whether the texture is encoded as a base64
  121754. * @param isBuffer defines whether the texture data are stored as a buffer
  121755. * @returns true if the loader can load the specified file
  121756. */
  121757. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121758. /**
  121759. * Transform the url before loading if required.
  121760. * @param rootUrl the url of the texture
  121761. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121762. * @returns the transformed texture
  121763. */
  121764. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121765. /**
  121766. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121767. * @param rootUrl the url of the texture
  121768. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121769. * @returns the fallback texture
  121770. */
  121771. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121772. /**
  121773. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  121774. * @param data contains the texture data
  121775. * @param texture defines the BabylonJS internal texture
  121776. * @param createPolynomials will be true if polynomials have been requested
  121777. * @param onLoad defines the callback to trigger once the texture is ready
  121778. * @param onError defines the callback to trigger in case of error
  121779. */
  121780. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121781. /**
  121782. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121783. * @param data contains the texture data
  121784. * @param texture defines the BabylonJS internal texture
  121785. * @param callback defines the method to call once ready to upload
  121786. */
  121787. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121788. }
  121789. }
  121790. declare module BABYLON {
  121791. /**
  121792. * 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.
  121793. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121794. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121795. */
  121796. export class CustomProceduralTexture extends ProceduralTexture {
  121797. private _animate;
  121798. private _time;
  121799. private _config;
  121800. private _texturePath;
  121801. /**
  121802. * Instantiates a new Custom Procedural Texture.
  121803. * 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.
  121804. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121805. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121806. * @param name Define the name of the texture
  121807. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  121808. * @param size Define the size of the texture to create
  121809. * @param scene Define the scene the texture belongs to
  121810. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  121811. * @param generateMipMaps Define if the texture should creates mip maps or not
  121812. */
  121813. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121814. private _loadJson;
  121815. /**
  121816. * Is the texture ready to be used ? (rendered at least once)
  121817. * @returns true if ready, otherwise, false.
  121818. */
  121819. isReady(): boolean;
  121820. /**
  121821. * Render the texture to its associated render target.
  121822. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  121823. */
  121824. render(useCameraPostProcess?: boolean): void;
  121825. /**
  121826. * Update the list of dependant textures samplers in the shader.
  121827. */
  121828. updateTextures(): void;
  121829. /**
  121830. * Update the uniform values of the procedural texture in the shader.
  121831. */
  121832. updateShaderUniforms(): void;
  121833. /**
  121834. * Define if the texture animates or not.
  121835. */
  121836. animate: boolean;
  121837. }
  121838. }
  121839. declare module BABYLON {
  121840. /** @hidden */
  121841. export var noisePixelShader: {
  121842. name: string;
  121843. shader: string;
  121844. };
  121845. }
  121846. declare module BABYLON {
  121847. /**
  121848. * Class used to generate noise procedural textures
  121849. */
  121850. export class NoiseProceduralTexture extends ProceduralTexture {
  121851. private _time;
  121852. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  121853. brightness: number;
  121854. /** Defines the number of octaves to process */
  121855. octaves: number;
  121856. /** Defines the level of persistence (0.8 by default) */
  121857. persistence: number;
  121858. /** Gets or sets animation speed factor (default is 1) */
  121859. animationSpeedFactor: number;
  121860. /**
  121861. * Creates a new NoiseProceduralTexture
  121862. * @param name defines the name fo the texture
  121863. * @param size defines the size of the texture (default is 256)
  121864. * @param scene defines the hosting scene
  121865. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  121866. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  121867. */
  121868. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121869. private _updateShaderUniforms;
  121870. protected _getDefines(): string;
  121871. /** Generate the current state of the procedural texture */
  121872. render(useCameraPostProcess?: boolean): void;
  121873. /**
  121874. * Serializes this noise procedural texture
  121875. * @returns a serialized noise procedural texture object
  121876. */
  121877. serialize(): any;
  121878. /**
  121879. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  121880. * @param parsedTexture defines parsed texture data
  121881. * @param scene defines the current scene
  121882. * @param rootUrl defines the root URL containing noise procedural texture information
  121883. * @returns a parsed NoiseProceduralTexture
  121884. */
  121885. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  121886. }
  121887. }
  121888. declare module BABYLON {
  121889. /**
  121890. * Raw cube texture where the raw buffers are passed in
  121891. */
  121892. export class RawCubeTexture extends CubeTexture {
  121893. /**
  121894. * Creates a cube texture where the raw buffers are passed in.
  121895. * @param scene defines the scene the texture is attached to
  121896. * @param data defines the array of data to use to create each face
  121897. * @param size defines the size of the textures
  121898. * @param format defines the format of the data
  121899. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  121900. * @param generateMipMaps defines if the engine should generate the mip levels
  121901. * @param invertY defines if data must be stored with Y axis inverted
  121902. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  121903. * @param compression defines the compression used (null by default)
  121904. */
  121905. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  121906. /**
  121907. * Updates the raw cube texture.
  121908. * @param data defines the data to store
  121909. * @param format defines the data format
  121910. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121911. * @param invertY defines if data must be stored with Y axis inverted
  121912. * @param compression defines the compression used (null by default)
  121913. * @param level defines which level of the texture to update
  121914. */
  121915. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  121916. /**
  121917. * Updates a raw cube texture with RGBD encoded data.
  121918. * @param data defines the array of data [mipmap][face] to use to create each face
  121919. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  121920. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121921. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121922. * @returns a promsie that resolves when the operation is complete
  121923. */
  121924. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  121925. /**
  121926. * Clones the raw cube texture.
  121927. * @return a new cube texture
  121928. */
  121929. clone(): CubeTexture;
  121930. /** @hidden */
  121931. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121932. }
  121933. }
  121934. declare module BABYLON {
  121935. /**
  121936. * Class used to store 3D textures containing user data
  121937. */
  121938. export class RawTexture3D extends Texture {
  121939. /** Gets or sets the texture format to use */
  121940. format: number;
  121941. private _engine;
  121942. /**
  121943. * Create a new RawTexture3D
  121944. * @param data defines the data of the texture
  121945. * @param width defines the width of the texture
  121946. * @param height defines the height of the texture
  121947. * @param depth defines the depth of the texture
  121948. * @param format defines the texture format to use
  121949. * @param scene defines the hosting scene
  121950. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121951. * @param invertY defines if texture must be stored with Y axis inverted
  121952. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121953. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121954. */
  121955. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121956. /** Gets or sets the texture format to use */
  121957. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121958. /**
  121959. * Update the texture with new data
  121960. * @param data defines the data to store in the texture
  121961. */
  121962. update(data: ArrayBufferView): void;
  121963. }
  121964. }
  121965. declare module BABYLON {
  121966. /**
  121967. * Class used to store 2D array textures containing user data
  121968. */
  121969. export class RawTexture2DArray extends Texture {
  121970. /** Gets or sets the texture format to use */
  121971. format: number;
  121972. private _engine;
  121973. /**
  121974. * Create a new RawTexture2DArray
  121975. * @param data defines the data of the texture
  121976. * @param width defines the width of the texture
  121977. * @param height defines the height of the texture
  121978. * @param depth defines the number of layers of the texture
  121979. * @param format defines the texture format to use
  121980. * @param scene defines the hosting scene
  121981. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121982. * @param invertY defines if texture must be stored with Y axis inverted
  121983. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121984. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121985. */
  121986. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121987. /** Gets or sets the texture format to use */
  121988. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121989. /**
  121990. * Update the texture with new data
  121991. * @param data defines the data to store in the texture
  121992. */
  121993. update(data: ArrayBufferView): void;
  121994. }
  121995. }
  121996. declare module BABYLON {
  121997. /**
  121998. * Creates a refraction texture used by refraction channel of the standard material.
  121999. * It is like a mirror but to see through a material.
  122000. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122001. */
  122002. export class RefractionTexture extends RenderTargetTexture {
  122003. /**
  122004. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  122005. * 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.
  122006. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122007. */
  122008. refractionPlane: Plane;
  122009. /**
  122010. * Define how deep under the surface we should see.
  122011. */
  122012. depth: number;
  122013. /**
  122014. * Creates a refraction texture used by refraction channel of the standard material.
  122015. * It is like a mirror but to see through a material.
  122016. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122017. * @param name Define the texture name
  122018. * @param size Define the size of the underlying texture
  122019. * @param scene Define the scene the refraction belongs to
  122020. * @param generateMipMaps Define if we need to generate mips level for the refraction
  122021. */
  122022. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  122023. /**
  122024. * Clone the refraction texture.
  122025. * @returns the cloned texture
  122026. */
  122027. clone(): RefractionTexture;
  122028. /**
  122029. * Serialize the texture to a JSON representation you could use in Parse later on
  122030. * @returns the serialized JSON representation
  122031. */
  122032. serialize(): any;
  122033. }
  122034. }
  122035. declare module BABYLON {
  122036. /**
  122037. * Defines the options related to the creation of an HtmlElementTexture
  122038. */
  122039. export interface IHtmlElementTextureOptions {
  122040. /**
  122041. * Defines wether mip maps should be created or not.
  122042. */
  122043. generateMipMaps?: boolean;
  122044. /**
  122045. * Defines the sampling mode of the texture.
  122046. */
  122047. samplingMode?: number;
  122048. /**
  122049. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  122050. */
  122051. engine: Nullable<ThinEngine>;
  122052. /**
  122053. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  122054. */
  122055. scene: Nullable<Scene>;
  122056. }
  122057. /**
  122058. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  122059. * To be as efficient as possible depending on your constraints nothing aside the first upload
  122060. * is automatically managed.
  122061. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  122062. * in your application.
  122063. *
  122064. * As the update is not automatic, you need to call them manually.
  122065. */
  122066. export class HtmlElementTexture extends BaseTexture {
  122067. /**
  122068. * The texture URL.
  122069. */
  122070. element: HTMLVideoElement | HTMLCanvasElement;
  122071. private static readonly DefaultOptions;
  122072. private _textureMatrix;
  122073. private _engine;
  122074. private _isVideo;
  122075. private _generateMipMaps;
  122076. private _samplingMode;
  122077. /**
  122078. * Instantiates a HtmlElementTexture from the following parameters.
  122079. *
  122080. * @param name Defines the name of the texture
  122081. * @param element Defines the video or canvas the texture is filled with
  122082. * @param options Defines the other none mandatory texture creation options
  122083. */
  122084. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  122085. private _createInternalTexture;
  122086. /**
  122087. * Returns the texture matrix used in most of the material.
  122088. */
  122089. getTextureMatrix(): Matrix;
  122090. /**
  122091. * Updates the content of the texture.
  122092. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  122093. */
  122094. update(invertY?: Nullable<boolean>): void;
  122095. }
  122096. }
  122097. declare module BABYLON {
  122098. /**
  122099. * Enum used to define the target of a block
  122100. */
  122101. export enum NodeMaterialBlockTargets {
  122102. /** Vertex shader */
  122103. Vertex = 1,
  122104. /** Fragment shader */
  122105. Fragment = 2,
  122106. /** Neutral */
  122107. Neutral = 4,
  122108. /** Vertex and Fragment */
  122109. VertexAndFragment = 3
  122110. }
  122111. }
  122112. declare module BABYLON {
  122113. /**
  122114. * Defines the kind of connection point for node based material
  122115. */
  122116. export enum NodeMaterialBlockConnectionPointTypes {
  122117. /** Float */
  122118. Float = 1,
  122119. /** Int */
  122120. Int = 2,
  122121. /** Vector2 */
  122122. Vector2 = 4,
  122123. /** Vector3 */
  122124. Vector3 = 8,
  122125. /** Vector4 */
  122126. Vector4 = 16,
  122127. /** Color3 */
  122128. Color3 = 32,
  122129. /** Color4 */
  122130. Color4 = 64,
  122131. /** Matrix */
  122132. Matrix = 128,
  122133. /** Detect type based on connection */
  122134. AutoDetect = 1024,
  122135. /** Output type that will be defined by input type */
  122136. BasedOnInput = 2048
  122137. }
  122138. }
  122139. declare module BABYLON {
  122140. /**
  122141. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  122142. */
  122143. export enum NodeMaterialBlockConnectionPointMode {
  122144. /** Value is an uniform */
  122145. Uniform = 0,
  122146. /** Value is a mesh attribute */
  122147. Attribute = 1,
  122148. /** Value is a varying between vertex and fragment shaders */
  122149. Varying = 2,
  122150. /** Mode is undefined */
  122151. Undefined = 3
  122152. }
  122153. }
  122154. declare module BABYLON {
  122155. /**
  122156. * Enum used to define system values e.g. values automatically provided by the system
  122157. */
  122158. export enum NodeMaterialSystemValues {
  122159. /** World */
  122160. World = 1,
  122161. /** View */
  122162. View = 2,
  122163. /** Projection */
  122164. Projection = 3,
  122165. /** ViewProjection */
  122166. ViewProjection = 4,
  122167. /** WorldView */
  122168. WorldView = 5,
  122169. /** WorldViewProjection */
  122170. WorldViewProjection = 6,
  122171. /** CameraPosition */
  122172. CameraPosition = 7,
  122173. /** Fog Color */
  122174. FogColor = 8,
  122175. /** Delta time */
  122176. DeltaTime = 9
  122177. }
  122178. }
  122179. declare module BABYLON {
  122180. /**
  122181. * Root class for all node material optimizers
  122182. */
  122183. export class NodeMaterialOptimizer {
  122184. /**
  122185. * Function used to optimize a NodeMaterial graph
  122186. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  122187. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  122188. */
  122189. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  122190. }
  122191. }
  122192. declare module BABYLON {
  122193. /**
  122194. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  122195. */
  122196. export class TransformBlock extends NodeMaterialBlock {
  122197. /**
  122198. * Defines the value to use to complement W value to transform it to a Vector4
  122199. */
  122200. complementW: number;
  122201. /**
  122202. * Defines the value to use to complement z value to transform it to a Vector4
  122203. */
  122204. complementZ: number;
  122205. /**
  122206. * Creates a new TransformBlock
  122207. * @param name defines the block name
  122208. */
  122209. constructor(name: string);
  122210. /**
  122211. * Gets the current class name
  122212. * @returns the class name
  122213. */
  122214. getClassName(): string;
  122215. /**
  122216. * Gets the vector input
  122217. */
  122218. readonly vector: NodeMaterialConnectionPoint;
  122219. /**
  122220. * Gets the output component
  122221. */
  122222. readonly output: NodeMaterialConnectionPoint;
  122223. /**
  122224. * Gets the matrix transform input
  122225. */
  122226. readonly transform: NodeMaterialConnectionPoint;
  122227. protected _buildBlock(state: NodeMaterialBuildState): this;
  122228. serialize(): any;
  122229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122230. protected _dumpPropertiesCode(): string;
  122231. }
  122232. }
  122233. declare module BABYLON {
  122234. /**
  122235. * Block used to output the vertex position
  122236. */
  122237. export class VertexOutputBlock extends NodeMaterialBlock {
  122238. /**
  122239. * Creates a new VertexOutputBlock
  122240. * @param name defines the block name
  122241. */
  122242. constructor(name: string);
  122243. /**
  122244. * Gets the current class name
  122245. * @returns the class name
  122246. */
  122247. getClassName(): string;
  122248. /**
  122249. * Gets the vector input component
  122250. */
  122251. readonly vector: NodeMaterialConnectionPoint;
  122252. protected _buildBlock(state: NodeMaterialBuildState): this;
  122253. }
  122254. }
  122255. declare module BABYLON {
  122256. /**
  122257. * Block used to output the final color
  122258. */
  122259. export class FragmentOutputBlock extends NodeMaterialBlock {
  122260. /**
  122261. * Create a new FragmentOutputBlock
  122262. * @param name defines the block name
  122263. */
  122264. constructor(name: string);
  122265. /**
  122266. * Gets the current class name
  122267. * @returns the class name
  122268. */
  122269. getClassName(): string;
  122270. /**
  122271. * Gets the rgba input component
  122272. */
  122273. readonly rgba: NodeMaterialConnectionPoint;
  122274. /**
  122275. * Gets the rgb input component
  122276. */
  122277. readonly rgb: NodeMaterialConnectionPoint;
  122278. /**
  122279. * Gets the a input component
  122280. */
  122281. readonly a: NodeMaterialConnectionPoint;
  122282. protected _buildBlock(state: NodeMaterialBuildState): this;
  122283. }
  122284. }
  122285. declare module BABYLON {
  122286. /**
  122287. * Block used to read a reflection texture from a sampler
  122288. */
  122289. export class ReflectionTextureBlock extends NodeMaterialBlock {
  122290. private _define3DName;
  122291. private _defineCubicName;
  122292. private _defineExplicitName;
  122293. private _defineProjectionName;
  122294. private _defineLocalCubicName;
  122295. private _defineSphericalName;
  122296. private _definePlanarName;
  122297. private _defineEquirectangularName;
  122298. private _defineMirroredEquirectangularFixedName;
  122299. private _defineEquirectangularFixedName;
  122300. private _defineSkyboxName;
  122301. private _cubeSamplerName;
  122302. private _2DSamplerName;
  122303. private _positionUVWName;
  122304. private _directionWName;
  122305. private _reflectionCoordsName;
  122306. private _reflection2DCoordsName;
  122307. private _reflectionColorName;
  122308. private _reflectionMatrixName;
  122309. /**
  122310. * Gets or sets the texture associated with the node
  122311. */
  122312. texture: Nullable<BaseTexture>;
  122313. /**
  122314. * Create a new TextureBlock
  122315. * @param name defines the block name
  122316. */
  122317. constructor(name: string);
  122318. /**
  122319. * Gets the current class name
  122320. * @returns the class name
  122321. */
  122322. getClassName(): string;
  122323. /**
  122324. * Gets the world position input component
  122325. */
  122326. readonly position: NodeMaterialConnectionPoint;
  122327. /**
  122328. * Gets the world position input component
  122329. */
  122330. readonly worldPosition: NodeMaterialConnectionPoint;
  122331. /**
  122332. * Gets the world normal input component
  122333. */
  122334. readonly worldNormal: NodeMaterialConnectionPoint;
  122335. /**
  122336. * Gets the world input component
  122337. */
  122338. readonly world: NodeMaterialConnectionPoint;
  122339. /**
  122340. * Gets the camera (or eye) position component
  122341. */
  122342. readonly cameraPosition: NodeMaterialConnectionPoint;
  122343. /**
  122344. * Gets the view input component
  122345. */
  122346. readonly view: NodeMaterialConnectionPoint;
  122347. /**
  122348. * Gets the rgb output component
  122349. */
  122350. readonly rgb: NodeMaterialConnectionPoint;
  122351. /**
  122352. * Gets the r output component
  122353. */
  122354. readonly r: NodeMaterialConnectionPoint;
  122355. /**
  122356. * Gets the g output component
  122357. */
  122358. readonly g: NodeMaterialConnectionPoint;
  122359. /**
  122360. * Gets the b output component
  122361. */
  122362. readonly b: NodeMaterialConnectionPoint;
  122363. autoConfigure(material: NodeMaterial): void;
  122364. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122365. isReady(): boolean;
  122366. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122367. private _injectVertexCode;
  122368. private _writeOutput;
  122369. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122370. protected _dumpPropertiesCode(): string;
  122371. serialize(): any;
  122372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122373. }
  122374. }
  122375. declare module BABYLON {
  122376. /**
  122377. * Interface used to configure the node material editor
  122378. */
  122379. export interface INodeMaterialEditorOptions {
  122380. /** Define the URl to load node editor script */
  122381. editorURL?: string;
  122382. }
  122383. /** @hidden */
  122384. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  122385. /** BONES */
  122386. NUM_BONE_INFLUENCERS: number;
  122387. BonesPerMesh: number;
  122388. BONETEXTURE: boolean;
  122389. /** MORPH TARGETS */
  122390. MORPHTARGETS: boolean;
  122391. MORPHTARGETS_NORMAL: boolean;
  122392. MORPHTARGETS_TANGENT: boolean;
  122393. MORPHTARGETS_UV: boolean;
  122394. NUM_MORPH_INFLUENCERS: number;
  122395. /** IMAGE PROCESSING */
  122396. IMAGEPROCESSING: boolean;
  122397. VIGNETTE: boolean;
  122398. VIGNETTEBLENDMODEMULTIPLY: boolean;
  122399. VIGNETTEBLENDMODEOPAQUE: boolean;
  122400. TONEMAPPING: boolean;
  122401. TONEMAPPING_ACES: boolean;
  122402. CONTRAST: boolean;
  122403. EXPOSURE: boolean;
  122404. COLORCURVES: boolean;
  122405. COLORGRADING: boolean;
  122406. COLORGRADING3D: boolean;
  122407. SAMPLER3DGREENDEPTH: boolean;
  122408. SAMPLER3DBGRMAP: boolean;
  122409. IMAGEPROCESSINGPOSTPROCESS: boolean;
  122410. /** MISC. */
  122411. BUMPDIRECTUV: number;
  122412. constructor();
  122413. setValue(name: string, value: boolean): void;
  122414. }
  122415. /**
  122416. * Class used to configure NodeMaterial
  122417. */
  122418. export interface INodeMaterialOptions {
  122419. /**
  122420. * Defines if blocks should emit comments
  122421. */
  122422. emitComments: boolean;
  122423. }
  122424. /**
  122425. * Class used to create a node based material built by assembling shader blocks
  122426. */
  122427. export class NodeMaterial extends PushMaterial {
  122428. private static _BuildIdGenerator;
  122429. private _options;
  122430. private _vertexCompilationState;
  122431. private _fragmentCompilationState;
  122432. private _sharedData;
  122433. private _buildId;
  122434. private _buildWasSuccessful;
  122435. private _cachedWorldViewMatrix;
  122436. private _cachedWorldViewProjectionMatrix;
  122437. private _optimizers;
  122438. private _animationFrame;
  122439. /** Define the URl to load node editor script */
  122440. static EditorURL: string;
  122441. private BJSNODEMATERIALEDITOR;
  122442. /** Get the inspector from bundle or global */
  122443. private _getGlobalNodeMaterialEditor;
  122444. /**
  122445. * Gets or sets data used by visual editor
  122446. * @see https://nme.babylonjs.com
  122447. */
  122448. editorData: any;
  122449. /**
  122450. * 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)
  122451. */
  122452. ignoreAlpha: boolean;
  122453. /**
  122454. * Defines the maximum number of lights that can be used in the material
  122455. */
  122456. maxSimultaneousLights: number;
  122457. /**
  122458. * Observable raised when the material is built
  122459. */
  122460. onBuildObservable: Observable<NodeMaterial>;
  122461. /**
  122462. * Gets or sets the root nodes of the material vertex shader
  122463. */
  122464. _vertexOutputNodes: NodeMaterialBlock[];
  122465. /**
  122466. * Gets or sets the root nodes of the material fragment (pixel) shader
  122467. */
  122468. _fragmentOutputNodes: NodeMaterialBlock[];
  122469. /** Gets or sets options to control the node material overall behavior */
  122470. options: INodeMaterialOptions;
  122471. /**
  122472. * Default configuration related to image processing available in the standard Material.
  122473. */
  122474. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122475. /**
  122476. * Gets the image processing configuration used either in this material.
  122477. */
  122478. /**
  122479. * Sets the Default image processing configuration used either in the this material.
  122480. *
  122481. * If sets to null, the scene one is in use.
  122482. */
  122483. imageProcessingConfiguration: ImageProcessingConfiguration;
  122484. /**
  122485. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  122486. */
  122487. attachedBlocks: NodeMaterialBlock[];
  122488. /**
  122489. * Create a new node based material
  122490. * @param name defines the material name
  122491. * @param scene defines the hosting scene
  122492. * @param options defines creation option
  122493. */
  122494. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  122495. /**
  122496. * Gets the current class name of the material e.g. "NodeMaterial"
  122497. * @returns the class name
  122498. */
  122499. getClassName(): string;
  122500. /**
  122501. * Keep track of the image processing observer to allow dispose and replace.
  122502. */
  122503. private _imageProcessingObserver;
  122504. /**
  122505. * Attaches a new image processing configuration to the Standard Material.
  122506. * @param configuration
  122507. */
  122508. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122509. /**
  122510. * Get a block by its name
  122511. * @param name defines the name of the block to retrieve
  122512. * @returns the required block or null if not found
  122513. */
  122514. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  122515. /**
  122516. * Get a block by its name
  122517. * @param predicate defines the predicate used to find the good candidate
  122518. * @returns the required block or null if not found
  122519. */
  122520. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  122521. /**
  122522. * Get an input block by its name
  122523. * @param predicate defines the predicate used to find the good candidate
  122524. * @returns the required input block or null if not found
  122525. */
  122526. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  122527. /**
  122528. * Gets the list of input blocks attached to this material
  122529. * @returns an array of InputBlocks
  122530. */
  122531. getInputBlocks(): InputBlock[];
  122532. /**
  122533. * Adds a new optimizer to the list of optimizers
  122534. * @param optimizer defines the optimizers to add
  122535. * @returns the current material
  122536. */
  122537. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  122538. /**
  122539. * Remove an optimizer from the list of optimizers
  122540. * @param optimizer defines the optimizers to remove
  122541. * @returns the current material
  122542. */
  122543. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  122544. /**
  122545. * Add a new block to the list of output nodes
  122546. * @param node defines the node to add
  122547. * @returns the current material
  122548. */
  122549. addOutputNode(node: NodeMaterialBlock): this;
  122550. /**
  122551. * Remove a block from the list of root nodes
  122552. * @param node defines the node to remove
  122553. * @returns the current material
  122554. */
  122555. removeOutputNode(node: NodeMaterialBlock): this;
  122556. private _addVertexOutputNode;
  122557. private _removeVertexOutputNode;
  122558. private _addFragmentOutputNode;
  122559. private _removeFragmentOutputNode;
  122560. /**
  122561. * Specifies if the material will require alpha blending
  122562. * @returns a boolean specifying if alpha blending is needed
  122563. */
  122564. needAlphaBlending(): boolean;
  122565. /**
  122566. * Specifies if this material should be rendered in alpha test mode
  122567. * @returns a boolean specifying if an alpha test is needed.
  122568. */
  122569. needAlphaTesting(): boolean;
  122570. private _initializeBlock;
  122571. private _resetDualBlocks;
  122572. /**
  122573. * Build the material and generates the inner effect
  122574. * @param verbose defines if the build should log activity
  122575. */
  122576. build(verbose?: boolean): void;
  122577. /**
  122578. * Runs an otpimization phase to try to improve the shader code
  122579. */
  122580. optimize(): void;
  122581. private _prepareDefinesForAttributes;
  122582. /**
  122583. * Get if the submesh is ready to be used and all its information available.
  122584. * Child classes can use it to update shaders
  122585. * @param mesh defines the mesh to check
  122586. * @param subMesh defines which submesh to check
  122587. * @param useInstances specifies that instances should be used
  122588. * @returns a boolean indicating that the submesh is ready or not
  122589. */
  122590. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122591. /**
  122592. * Get a string representing the shaders built by the current node graph
  122593. */
  122594. readonly compiledShaders: string;
  122595. /**
  122596. * Binds the world matrix to the material
  122597. * @param world defines the world transformation matrix
  122598. */
  122599. bindOnlyWorldMatrix(world: Matrix): void;
  122600. /**
  122601. * Binds the submesh to this material by preparing the effect and shader to draw
  122602. * @param world defines the world transformation matrix
  122603. * @param mesh defines the mesh containing the submesh
  122604. * @param subMesh defines the submesh to bind the material to
  122605. */
  122606. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122607. /**
  122608. * Gets the active textures from the material
  122609. * @returns an array of textures
  122610. */
  122611. getActiveTextures(): BaseTexture[];
  122612. /**
  122613. * Gets the list of texture blocks
  122614. * @returns an array of texture blocks
  122615. */
  122616. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  122617. /**
  122618. * Specifies if the material uses a texture
  122619. * @param texture defines the texture to check against the material
  122620. * @returns a boolean specifying if the material uses the texture
  122621. */
  122622. hasTexture(texture: BaseTexture): boolean;
  122623. /**
  122624. * Disposes the material
  122625. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  122626. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  122627. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  122628. */
  122629. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  122630. /** Creates the node editor window. */
  122631. private _createNodeEditor;
  122632. /**
  122633. * Launch the node material editor
  122634. * @param config Define the configuration of the editor
  122635. * @return a promise fulfilled when the node editor is visible
  122636. */
  122637. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  122638. /**
  122639. * Clear the current material
  122640. */
  122641. clear(): void;
  122642. /**
  122643. * Clear the current material and set it to a default state
  122644. */
  122645. setToDefault(): void;
  122646. /**
  122647. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  122648. * @param url defines the url to load from
  122649. * @returns a promise that will fullfil when the material is fully loaded
  122650. */
  122651. loadAsync(url: string): Promise<void>;
  122652. private _gatherBlocks;
  122653. /**
  122654. * Generate a string containing the code declaration required to create an equivalent of this material
  122655. * @returns a string
  122656. */
  122657. generateCode(): string;
  122658. /**
  122659. * Serializes this material in a JSON representation
  122660. * @returns the serialized material object
  122661. */
  122662. serialize(): any;
  122663. private _restoreConnections;
  122664. /**
  122665. * Clear the current graph and load a new one from a serialization object
  122666. * @param source defines the JSON representation of the material
  122667. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122668. */
  122669. loadFromSerialization(source: any, rootUrl?: string): void;
  122670. /**
  122671. * Creates a node material from parsed material data
  122672. * @param source defines the JSON representation of the material
  122673. * @param scene defines the hosting scene
  122674. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122675. * @returns a new node material
  122676. */
  122677. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  122678. /**
  122679. * Creates a new node material set to default basic configuration
  122680. * @param name defines the name of the material
  122681. * @param scene defines the hosting scene
  122682. * @returns a new NodeMaterial
  122683. */
  122684. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  122685. }
  122686. }
  122687. declare module BABYLON {
  122688. /**
  122689. * Block used to read a texture from a sampler
  122690. */
  122691. export class TextureBlock extends NodeMaterialBlock {
  122692. private _defineName;
  122693. private _linearDefineName;
  122694. private _tempTextureRead;
  122695. private _samplerName;
  122696. private _transformedUVName;
  122697. private _textureTransformName;
  122698. private _textureInfoName;
  122699. private _mainUVName;
  122700. private _mainUVDefineName;
  122701. /**
  122702. * Gets or sets the texture associated with the node
  122703. */
  122704. texture: Nullable<Texture>;
  122705. /**
  122706. * Create a new TextureBlock
  122707. * @param name defines the block name
  122708. */
  122709. constructor(name: string);
  122710. /**
  122711. * Gets the current class name
  122712. * @returns the class name
  122713. */
  122714. getClassName(): string;
  122715. /**
  122716. * Gets the uv input component
  122717. */
  122718. readonly uv: NodeMaterialConnectionPoint;
  122719. /**
  122720. * Gets the rgba output component
  122721. */
  122722. readonly rgba: NodeMaterialConnectionPoint;
  122723. /**
  122724. * Gets the rgb output component
  122725. */
  122726. readonly rgb: NodeMaterialConnectionPoint;
  122727. /**
  122728. * Gets the r output component
  122729. */
  122730. readonly r: NodeMaterialConnectionPoint;
  122731. /**
  122732. * Gets the g output component
  122733. */
  122734. readonly g: NodeMaterialConnectionPoint;
  122735. /**
  122736. * Gets the b output component
  122737. */
  122738. readonly b: NodeMaterialConnectionPoint;
  122739. /**
  122740. * Gets the a output component
  122741. */
  122742. readonly a: NodeMaterialConnectionPoint;
  122743. readonly target: NodeMaterialBlockTargets;
  122744. autoConfigure(material: NodeMaterial): void;
  122745. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122746. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122747. private _getTextureBase;
  122748. isReady(): boolean;
  122749. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122750. private readonly _isMixed;
  122751. private _injectVertexCode;
  122752. private _writeTextureRead;
  122753. private _writeOutput;
  122754. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122755. protected _dumpPropertiesCode(): string;
  122756. serialize(): any;
  122757. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122758. }
  122759. }
  122760. declare module BABYLON {
  122761. /**
  122762. * Class used to store shared data between 2 NodeMaterialBuildState
  122763. */
  122764. export class NodeMaterialBuildStateSharedData {
  122765. /**
  122766. * Gets the list of emitted varyings
  122767. */
  122768. temps: string[];
  122769. /**
  122770. * Gets the list of emitted varyings
  122771. */
  122772. varyings: string[];
  122773. /**
  122774. * Gets the varying declaration string
  122775. */
  122776. varyingDeclaration: string;
  122777. /**
  122778. * Input blocks
  122779. */
  122780. inputBlocks: InputBlock[];
  122781. /**
  122782. * Input blocks
  122783. */
  122784. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  122785. /**
  122786. * Bindable blocks (Blocks that need to set data to the effect)
  122787. */
  122788. bindableBlocks: NodeMaterialBlock[];
  122789. /**
  122790. * List of blocks that can provide a compilation fallback
  122791. */
  122792. blocksWithFallbacks: NodeMaterialBlock[];
  122793. /**
  122794. * List of blocks that can provide a define update
  122795. */
  122796. blocksWithDefines: NodeMaterialBlock[];
  122797. /**
  122798. * List of blocks that can provide a repeatable content
  122799. */
  122800. repeatableContentBlocks: NodeMaterialBlock[];
  122801. /**
  122802. * List of blocks that can provide a dynamic list of uniforms
  122803. */
  122804. dynamicUniformBlocks: NodeMaterialBlock[];
  122805. /**
  122806. * List of blocks that can block the isReady function for the material
  122807. */
  122808. blockingBlocks: NodeMaterialBlock[];
  122809. /**
  122810. * Gets the list of animated inputs
  122811. */
  122812. animatedInputs: InputBlock[];
  122813. /**
  122814. * Build Id used to avoid multiple recompilations
  122815. */
  122816. buildId: number;
  122817. /** List of emitted variables */
  122818. variableNames: {
  122819. [key: string]: number;
  122820. };
  122821. /** List of emitted defines */
  122822. defineNames: {
  122823. [key: string]: number;
  122824. };
  122825. /** Should emit comments? */
  122826. emitComments: boolean;
  122827. /** Emit build activity */
  122828. verbose: boolean;
  122829. /** Gets or sets the hosting scene */
  122830. scene: Scene;
  122831. /**
  122832. * Gets the compilation hints emitted at compilation time
  122833. */
  122834. hints: {
  122835. needWorldViewMatrix: boolean;
  122836. needWorldViewProjectionMatrix: boolean;
  122837. needAlphaBlending: boolean;
  122838. needAlphaTesting: boolean;
  122839. };
  122840. /**
  122841. * List of compilation checks
  122842. */
  122843. checks: {
  122844. emitVertex: boolean;
  122845. emitFragment: boolean;
  122846. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  122847. };
  122848. /** Creates a new shared data */
  122849. constructor();
  122850. /**
  122851. * Emits console errors and exceptions if there is a failing check
  122852. */
  122853. emitErrors(): void;
  122854. }
  122855. }
  122856. declare module BABYLON {
  122857. /**
  122858. * Class used to store node based material build state
  122859. */
  122860. export class NodeMaterialBuildState {
  122861. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  122862. supportUniformBuffers: boolean;
  122863. /**
  122864. * Gets the list of emitted attributes
  122865. */
  122866. attributes: string[];
  122867. /**
  122868. * Gets the list of emitted uniforms
  122869. */
  122870. uniforms: string[];
  122871. /**
  122872. * Gets the list of emitted constants
  122873. */
  122874. constants: string[];
  122875. /**
  122876. * Gets the list of emitted samplers
  122877. */
  122878. samplers: string[];
  122879. /**
  122880. * Gets the list of emitted functions
  122881. */
  122882. functions: {
  122883. [key: string]: string;
  122884. };
  122885. /**
  122886. * Gets the list of emitted extensions
  122887. */
  122888. extensions: {
  122889. [key: string]: string;
  122890. };
  122891. /**
  122892. * Gets the target of the compilation state
  122893. */
  122894. target: NodeMaterialBlockTargets;
  122895. /**
  122896. * Gets the list of emitted counters
  122897. */
  122898. counters: {
  122899. [key: string]: number;
  122900. };
  122901. /**
  122902. * Shared data between multiple NodeMaterialBuildState instances
  122903. */
  122904. sharedData: NodeMaterialBuildStateSharedData;
  122905. /** @hidden */
  122906. _vertexState: NodeMaterialBuildState;
  122907. /** @hidden */
  122908. _attributeDeclaration: string;
  122909. /** @hidden */
  122910. _uniformDeclaration: string;
  122911. /** @hidden */
  122912. _constantDeclaration: string;
  122913. /** @hidden */
  122914. _samplerDeclaration: string;
  122915. /** @hidden */
  122916. _varyingTransfer: string;
  122917. private _repeatableContentAnchorIndex;
  122918. /** @hidden */
  122919. _builtCompilationString: string;
  122920. /**
  122921. * Gets the emitted compilation strings
  122922. */
  122923. compilationString: string;
  122924. /**
  122925. * Finalize the compilation strings
  122926. * @param state defines the current compilation state
  122927. */
  122928. finalize(state: NodeMaterialBuildState): void;
  122929. /** @hidden */
  122930. readonly _repeatableContentAnchor: string;
  122931. /** @hidden */
  122932. _getFreeVariableName(prefix: string): string;
  122933. /** @hidden */
  122934. _getFreeDefineName(prefix: string): string;
  122935. /** @hidden */
  122936. _excludeVariableName(name: string): void;
  122937. /** @hidden */
  122938. _emit2DSampler(name: string): void;
  122939. /** @hidden */
  122940. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  122941. /** @hidden */
  122942. _emitExtension(name: string, extension: string): void;
  122943. /** @hidden */
  122944. _emitFunction(name: string, code: string, comments: string): void;
  122945. /** @hidden */
  122946. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122947. replaceStrings?: {
  122948. search: RegExp;
  122949. replace: string;
  122950. }[];
  122951. repeatKey?: string;
  122952. }): string;
  122953. /** @hidden */
  122954. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122955. repeatKey?: string;
  122956. removeAttributes?: boolean;
  122957. removeUniforms?: boolean;
  122958. removeVaryings?: boolean;
  122959. removeIfDef?: boolean;
  122960. replaceStrings?: {
  122961. search: RegExp;
  122962. replace: string;
  122963. }[];
  122964. }, storeKey?: string): void;
  122965. /** @hidden */
  122966. _registerTempVariable(name: string): boolean;
  122967. /** @hidden */
  122968. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122969. /** @hidden */
  122970. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122971. /** @hidden */
  122972. _emitFloat(value: number): string;
  122973. }
  122974. }
  122975. declare module BABYLON {
  122976. /**
  122977. * Defines a block that can be used inside a node based material
  122978. */
  122979. export class NodeMaterialBlock {
  122980. private _buildId;
  122981. private _buildTarget;
  122982. private _target;
  122983. private _isFinalMerger;
  122984. private _isInput;
  122985. protected _isUnique: boolean;
  122986. /** @hidden */
  122987. _codeVariableName: string;
  122988. /** @hidden */
  122989. _inputs: NodeMaterialConnectionPoint[];
  122990. /** @hidden */
  122991. _outputs: NodeMaterialConnectionPoint[];
  122992. /** @hidden */
  122993. _preparationId: number;
  122994. /**
  122995. * Gets or sets the name of the block
  122996. */
  122997. name: string;
  122998. /**
  122999. * Gets or sets the unique id of the node
  123000. */
  123001. uniqueId: number;
  123002. /**
  123003. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  123004. */
  123005. readonly isUnique: boolean;
  123006. /**
  123007. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  123008. */
  123009. readonly isFinalMerger: boolean;
  123010. /**
  123011. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  123012. */
  123013. readonly isInput: boolean;
  123014. /**
  123015. * Gets or sets the build Id
  123016. */
  123017. buildId: number;
  123018. /**
  123019. * Gets or sets the target of the block
  123020. */
  123021. target: NodeMaterialBlockTargets;
  123022. /**
  123023. * Gets the list of input points
  123024. */
  123025. readonly inputs: NodeMaterialConnectionPoint[];
  123026. /** Gets the list of output points */
  123027. readonly outputs: NodeMaterialConnectionPoint[];
  123028. /**
  123029. * Find an input by its name
  123030. * @param name defines the name of the input to look for
  123031. * @returns the input or null if not found
  123032. */
  123033. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123034. /**
  123035. * Find an output by its name
  123036. * @param name defines the name of the outputto look for
  123037. * @returns the output or null if not found
  123038. */
  123039. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123040. /**
  123041. * Creates a new NodeMaterialBlock
  123042. * @param name defines the block name
  123043. * @param target defines the target of that block (Vertex by default)
  123044. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  123045. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  123046. */
  123047. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  123048. /**
  123049. * Initialize the block and prepare the context for build
  123050. * @param state defines the state that will be used for the build
  123051. */
  123052. initialize(state: NodeMaterialBuildState): void;
  123053. /**
  123054. * Bind data to effect. Will only be called for blocks with isBindable === true
  123055. * @param effect defines the effect to bind data to
  123056. * @param nodeMaterial defines the hosting NodeMaterial
  123057. * @param mesh defines the mesh that will be rendered
  123058. */
  123059. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123060. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  123061. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  123062. protected _writeFloat(value: number): string;
  123063. /**
  123064. * Gets the current class name e.g. "NodeMaterialBlock"
  123065. * @returns the class name
  123066. */
  123067. getClassName(): string;
  123068. /**
  123069. * Register a new input. Must be called inside a block constructor
  123070. * @param name defines the connection point name
  123071. * @param type defines the connection point type
  123072. * @param isOptional defines a boolean indicating that this input can be omitted
  123073. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123074. * @returns the current block
  123075. */
  123076. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  123077. /**
  123078. * Register a new output. Must be called inside a block constructor
  123079. * @param name defines the connection point name
  123080. * @param type defines the connection point type
  123081. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123082. * @returns the current block
  123083. */
  123084. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  123085. /**
  123086. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  123087. * @param forOutput defines an optional connection point to check compatibility with
  123088. * @returns the first available input or null
  123089. */
  123090. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  123091. /**
  123092. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  123093. * @param forBlock defines an optional block to check compatibility with
  123094. * @returns the first available input or null
  123095. */
  123096. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  123097. /**
  123098. * Gets the sibling of the given output
  123099. * @param current defines the current output
  123100. * @returns the next output in the list or null
  123101. */
  123102. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  123103. /**
  123104. * Connect current block with another block
  123105. * @param other defines the block to connect with
  123106. * @param options define the various options to help pick the right connections
  123107. * @returns the current block
  123108. */
  123109. connectTo(other: NodeMaterialBlock, options?: {
  123110. input?: string;
  123111. output?: string;
  123112. outputSwizzle?: string;
  123113. }): this | undefined;
  123114. protected _buildBlock(state: NodeMaterialBuildState): void;
  123115. /**
  123116. * Add uniforms, samplers and uniform buffers at compilation time
  123117. * @param state defines the state to update
  123118. * @param nodeMaterial defines the node material requesting the update
  123119. * @param defines defines the material defines to update
  123120. * @param uniformBuffers defines the list of uniform buffer names
  123121. */
  123122. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123123. /**
  123124. * Add potential fallbacks if shader compilation fails
  123125. * @param mesh defines the mesh to be rendered
  123126. * @param fallbacks defines the current prioritized list of fallbacks
  123127. */
  123128. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  123129. /**
  123130. * Initialize defines for shader compilation
  123131. * @param mesh defines the mesh to be rendered
  123132. * @param nodeMaterial defines the node material requesting the update
  123133. * @param defines defines the material defines to update
  123134. * @param useInstances specifies that instances should be used
  123135. */
  123136. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123137. /**
  123138. * Update defines for shader compilation
  123139. * @param mesh defines the mesh to be rendered
  123140. * @param nodeMaterial defines the node material requesting the update
  123141. * @param defines defines the material defines to update
  123142. * @param useInstances specifies that instances should be used
  123143. */
  123144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123145. /**
  123146. * Lets the block try to connect some inputs automatically
  123147. * @param material defines the hosting NodeMaterial
  123148. */
  123149. autoConfigure(material: NodeMaterial): void;
  123150. /**
  123151. * Function called when a block is declared as repeatable content generator
  123152. * @param vertexShaderState defines the current compilation state for the vertex shader
  123153. * @param fragmentShaderState defines the current compilation state for the fragment shader
  123154. * @param mesh defines the mesh to be rendered
  123155. * @param defines defines the material defines to update
  123156. */
  123157. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  123158. /**
  123159. * Checks if the block is ready
  123160. * @param mesh defines the mesh to be rendered
  123161. * @param nodeMaterial defines the node material requesting the update
  123162. * @param defines defines the material defines to update
  123163. * @param useInstances specifies that instances should be used
  123164. * @returns true if the block is ready
  123165. */
  123166. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  123167. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  123168. private _processBuild;
  123169. /**
  123170. * Compile the current node and generate the shader code
  123171. * @param state defines the current compilation state (uniforms, samplers, current string)
  123172. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  123173. * @returns true if already built
  123174. */
  123175. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  123176. protected _inputRename(name: string): string;
  123177. protected _outputRename(name: string): string;
  123178. protected _dumpPropertiesCode(): string;
  123179. /** @hidden */
  123180. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  123181. /** @hidden */
  123182. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  123183. /**
  123184. * Clone the current block to a new identical block
  123185. * @param scene defines the hosting scene
  123186. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123187. * @returns a copy of the current block
  123188. */
  123189. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  123190. /**
  123191. * Serializes this block in a JSON representation
  123192. * @returns the serialized block object
  123193. */
  123194. serialize(): any;
  123195. /** @hidden */
  123196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123197. /**
  123198. * Release resources
  123199. */
  123200. dispose(): void;
  123201. }
  123202. }
  123203. declare module BABYLON {
  123204. /**
  123205. * Enum defining the type of animations supported by InputBlock
  123206. */
  123207. export enum AnimatedInputBlockTypes {
  123208. /** No animation */
  123209. None = 0,
  123210. /** Time based animation. Will only work for floats */
  123211. Time = 1
  123212. }
  123213. }
  123214. declare module BABYLON {
  123215. /**
  123216. * Block used to expose an input value
  123217. */
  123218. export class InputBlock extends NodeMaterialBlock {
  123219. private _mode;
  123220. private _associatedVariableName;
  123221. private _storedValue;
  123222. private _valueCallback;
  123223. private _type;
  123224. private _animationType;
  123225. /** Gets or set a value used to limit the range of float values */
  123226. min: number;
  123227. /** Gets or set a value used to limit the range of float values */
  123228. max: number;
  123229. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  123230. matrixMode: number;
  123231. /** @hidden */
  123232. _systemValue: Nullable<NodeMaterialSystemValues>;
  123233. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  123234. visibleInInspector: boolean;
  123235. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  123236. isConstant: boolean;
  123237. /**
  123238. * Gets or sets the connection point type (default is float)
  123239. */
  123240. readonly type: NodeMaterialBlockConnectionPointTypes;
  123241. /**
  123242. * Creates a new InputBlock
  123243. * @param name defines the block name
  123244. * @param target defines the target of that block (Vertex by default)
  123245. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  123246. */
  123247. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  123248. /**
  123249. * Gets the output component
  123250. */
  123251. readonly output: NodeMaterialConnectionPoint;
  123252. /**
  123253. * Set the source of this connection point to a vertex attribute
  123254. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  123255. * @returns the current connection point
  123256. */
  123257. setAsAttribute(attributeName?: string): InputBlock;
  123258. /**
  123259. * Set the source of this connection point to a system value
  123260. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  123261. * @returns the current connection point
  123262. */
  123263. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  123264. /**
  123265. * Gets or sets the value of that point.
  123266. * Please note that this value will be ignored if valueCallback is defined
  123267. */
  123268. value: any;
  123269. /**
  123270. * Gets or sets a callback used to get the value of that point.
  123271. * Please note that setting this value will force the connection point to ignore the value property
  123272. */
  123273. valueCallback: () => any;
  123274. /**
  123275. * Gets or sets the associated variable name in the shader
  123276. */
  123277. associatedVariableName: string;
  123278. /** Gets or sets the type of animation applied to the input */
  123279. animationType: AnimatedInputBlockTypes;
  123280. /**
  123281. * Gets a boolean indicating that this connection point not defined yet
  123282. */
  123283. readonly isUndefined: boolean;
  123284. /**
  123285. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  123286. * In this case the connection point name must be the name of the uniform to use.
  123287. * Can only be set on inputs
  123288. */
  123289. isUniform: boolean;
  123290. /**
  123291. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  123292. * In this case the connection point name must be the name of the attribute to use
  123293. * Can only be set on inputs
  123294. */
  123295. isAttribute: boolean;
  123296. /**
  123297. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  123298. * Can only be set on exit points
  123299. */
  123300. isVarying: boolean;
  123301. /**
  123302. * Gets a boolean indicating that the current connection point is a system value
  123303. */
  123304. readonly isSystemValue: boolean;
  123305. /**
  123306. * Gets or sets the current well known value or null if not defined as a system value
  123307. */
  123308. systemValue: Nullable<NodeMaterialSystemValues>;
  123309. /**
  123310. * Gets the current class name
  123311. * @returns the class name
  123312. */
  123313. getClassName(): string;
  123314. /**
  123315. * Animate the input if animationType !== None
  123316. * @param scene defines the rendering scene
  123317. */
  123318. animate(scene: Scene): void;
  123319. private _emitDefine;
  123320. initialize(state: NodeMaterialBuildState): void;
  123321. /**
  123322. * Set the input block to its default value (based on its type)
  123323. */
  123324. setDefaultValue(): void;
  123325. private _emitConstant;
  123326. private _emit;
  123327. /** @hidden */
  123328. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  123329. /** @hidden */
  123330. _transmit(effect: Effect, scene: Scene): void;
  123331. protected _buildBlock(state: NodeMaterialBuildState): void;
  123332. protected _dumpPropertiesCode(): string;
  123333. serialize(): any;
  123334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123335. }
  123336. }
  123337. declare module BABYLON {
  123338. /**
  123339. * Enum used to define the compatibility state between two connection points
  123340. */
  123341. export enum NodeMaterialConnectionPointCompatibilityStates {
  123342. /** Points are compatibles */
  123343. Compatible = 0,
  123344. /** Points are incompatible because of their types */
  123345. TypeIncompatible = 1,
  123346. /** Points are incompatible because of their targets (vertex vs fragment) */
  123347. TargetIncompatible = 2
  123348. }
  123349. /**
  123350. * Defines a connection point for a block
  123351. */
  123352. export class NodeMaterialConnectionPoint {
  123353. /** @hidden */
  123354. _ownerBlock: NodeMaterialBlock;
  123355. /** @hidden */
  123356. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123357. private _endpoints;
  123358. private _associatedVariableName;
  123359. /** @hidden */
  123360. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123361. /** @hidden */
  123362. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123363. private _type;
  123364. /** @hidden */
  123365. _enforceAssociatedVariableName: boolean;
  123366. /**
  123367. * Gets or sets the additional types supported by this connection point
  123368. */
  123369. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123370. /**
  123371. * Gets or sets the additional types excluded by this connection point
  123372. */
  123373. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123374. /**
  123375. * Observable triggered when this point is connected
  123376. */
  123377. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  123378. /**
  123379. * Gets or sets the associated variable name in the shader
  123380. */
  123381. associatedVariableName: string;
  123382. /**
  123383. * Gets or sets the connection point type (default is float)
  123384. */
  123385. type: NodeMaterialBlockConnectionPointTypes;
  123386. /**
  123387. * Gets or sets the connection point name
  123388. */
  123389. name: string;
  123390. /**
  123391. * Gets or sets a boolean indicating that this connection point can be omitted
  123392. */
  123393. isOptional: boolean;
  123394. /**
  123395. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  123396. */
  123397. define: string;
  123398. /** @hidden */
  123399. _prioritizeVertex: boolean;
  123400. private _target;
  123401. /** Gets or sets the target of that connection point */
  123402. target: NodeMaterialBlockTargets;
  123403. /**
  123404. * Gets a boolean indicating that the current point is connected
  123405. */
  123406. readonly isConnected: boolean;
  123407. /**
  123408. * Gets a boolean indicating that the current point is connected to an input block
  123409. */
  123410. readonly isConnectedToInputBlock: boolean;
  123411. /**
  123412. * Gets a the connected input block (if any)
  123413. */
  123414. readonly connectInputBlock: Nullable<InputBlock>;
  123415. /** Get the other side of the connection (if any) */
  123416. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123417. /** Get the block that owns this connection point */
  123418. readonly ownerBlock: NodeMaterialBlock;
  123419. /** Get the block connected on the other side of this connection (if any) */
  123420. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  123421. /** Get the block connected on the endpoints of this connection (if any) */
  123422. readonly connectedBlocks: Array<NodeMaterialBlock>;
  123423. /** Gets the list of connected endpoints */
  123424. readonly endpoints: NodeMaterialConnectionPoint[];
  123425. /** Gets a boolean indicating if that output point is connected to at least one input */
  123426. readonly hasEndpoints: boolean;
  123427. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  123428. readonly isConnectedInVertexShader: boolean;
  123429. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  123430. readonly isConnectedInFragmentShader: boolean;
  123431. /**
  123432. * Creates a new connection point
  123433. * @param name defines the connection point name
  123434. * @param ownerBlock defines the block hosting this connection point
  123435. */
  123436. constructor(name: string, ownerBlock: NodeMaterialBlock);
  123437. /**
  123438. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  123439. * @returns the class name
  123440. */
  123441. getClassName(): string;
  123442. /**
  123443. * Gets a boolean indicating if the current point can be connected to another point
  123444. * @param connectionPoint defines the other connection point
  123445. * @returns a boolean
  123446. */
  123447. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  123448. /**
  123449. * Gets a number indicating if the current point can be connected to another point
  123450. * @param connectionPoint defines the other connection point
  123451. * @returns a number defining the compatibility state
  123452. */
  123453. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  123454. /**
  123455. * Connect this point to another connection point
  123456. * @param connectionPoint defines the other connection point
  123457. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  123458. * @returns the current connection point
  123459. */
  123460. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  123461. /**
  123462. * Disconnect this point from one of his endpoint
  123463. * @param endpoint defines the other connection point
  123464. * @returns the current connection point
  123465. */
  123466. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  123467. /**
  123468. * Serializes this point in a JSON representation
  123469. * @returns the serialized point object
  123470. */
  123471. serialize(): any;
  123472. /**
  123473. * Release resources
  123474. */
  123475. dispose(): void;
  123476. }
  123477. }
  123478. declare module BABYLON {
  123479. /**
  123480. * Block used to add support for vertex skinning (bones)
  123481. */
  123482. export class BonesBlock extends NodeMaterialBlock {
  123483. /**
  123484. * Creates a new BonesBlock
  123485. * @param name defines the block name
  123486. */
  123487. constructor(name: string);
  123488. /**
  123489. * Initialize the block and prepare the context for build
  123490. * @param state defines the state that will be used for the build
  123491. */
  123492. initialize(state: NodeMaterialBuildState): void;
  123493. /**
  123494. * Gets the current class name
  123495. * @returns the class name
  123496. */
  123497. getClassName(): string;
  123498. /**
  123499. * Gets the matrix indices input component
  123500. */
  123501. readonly matricesIndices: NodeMaterialConnectionPoint;
  123502. /**
  123503. * Gets the matrix weights input component
  123504. */
  123505. readonly matricesWeights: NodeMaterialConnectionPoint;
  123506. /**
  123507. * Gets the extra matrix indices input component
  123508. */
  123509. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  123510. /**
  123511. * Gets the extra matrix weights input component
  123512. */
  123513. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  123514. /**
  123515. * Gets the world input component
  123516. */
  123517. readonly world: NodeMaterialConnectionPoint;
  123518. /**
  123519. * Gets the output component
  123520. */
  123521. readonly output: NodeMaterialConnectionPoint;
  123522. autoConfigure(material: NodeMaterial): void;
  123523. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  123524. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123525. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123526. protected _buildBlock(state: NodeMaterialBuildState): this;
  123527. }
  123528. }
  123529. declare module BABYLON {
  123530. /**
  123531. * Block used to add support for instances
  123532. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  123533. */
  123534. export class InstancesBlock extends NodeMaterialBlock {
  123535. /**
  123536. * Creates a new InstancesBlock
  123537. * @param name defines the block name
  123538. */
  123539. constructor(name: string);
  123540. /**
  123541. * Gets the current class name
  123542. * @returns the class name
  123543. */
  123544. getClassName(): string;
  123545. /**
  123546. * Gets the first world row input component
  123547. */
  123548. readonly world0: NodeMaterialConnectionPoint;
  123549. /**
  123550. * Gets the second world row input component
  123551. */
  123552. readonly world1: NodeMaterialConnectionPoint;
  123553. /**
  123554. * Gets the third world row input component
  123555. */
  123556. readonly world2: NodeMaterialConnectionPoint;
  123557. /**
  123558. * Gets the forth world row input component
  123559. */
  123560. readonly world3: NodeMaterialConnectionPoint;
  123561. /**
  123562. * Gets the world input component
  123563. */
  123564. readonly world: NodeMaterialConnectionPoint;
  123565. /**
  123566. * Gets the output component
  123567. */
  123568. readonly output: NodeMaterialConnectionPoint;
  123569. autoConfigure(material: NodeMaterial): void;
  123570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123571. protected _buildBlock(state: NodeMaterialBuildState): this;
  123572. }
  123573. }
  123574. declare module BABYLON {
  123575. /**
  123576. * Block used to add morph targets support to vertex shader
  123577. */
  123578. export class MorphTargetsBlock extends NodeMaterialBlock {
  123579. private _repeatableContentAnchor;
  123580. private _repeatebleContentGenerated;
  123581. /**
  123582. * Create a new MorphTargetsBlock
  123583. * @param name defines the block name
  123584. */
  123585. constructor(name: string);
  123586. /**
  123587. * Gets the current class name
  123588. * @returns the class name
  123589. */
  123590. getClassName(): string;
  123591. /**
  123592. * Gets the position input component
  123593. */
  123594. readonly position: NodeMaterialConnectionPoint;
  123595. /**
  123596. * Gets the normal input component
  123597. */
  123598. readonly normal: NodeMaterialConnectionPoint;
  123599. /**
  123600. * Gets the tangent input component
  123601. */
  123602. readonly tangent: NodeMaterialConnectionPoint;
  123603. /**
  123604. * Gets the tangent input component
  123605. */
  123606. readonly uv: NodeMaterialConnectionPoint;
  123607. /**
  123608. * Gets the position output component
  123609. */
  123610. readonly positionOutput: NodeMaterialConnectionPoint;
  123611. /**
  123612. * Gets the normal output component
  123613. */
  123614. readonly normalOutput: NodeMaterialConnectionPoint;
  123615. /**
  123616. * Gets the tangent output component
  123617. */
  123618. readonly tangentOutput: NodeMaterialConnectionPoint;
  123619. /**
  123620. * Gets the tangent output component
  123621. */
  123622. readonly uvOutput: NodeMaterialConnectionPoint;
  123623. initialize(state: NodeMaterialBuildState): void;
  123624. autoConfigure(material: NodeMaterial): void;
  123625. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123626. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123627. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  123628. protected _buildBlock(state: NodeMaterialBuildState): this;
  123629. }
  123630. }
  123631. declare module BABYLON {
  123632. /**
  123633. * Block used to get data information from a light
  123634. */
  123635. export class LightInformationBlock extends NodeMaterialBlock {
  123636. private _lightDataUniformName;
  123637. private _lightColorUniformName;
  123638. private _lightTypeDefineName;
  123639. /**
  123640. * Gets or sets the light associated with this block
  123641. */
  123642. light: Nullable<Light>;
  123643. /**
  123644. * Creates a new LightInformationBlock
  123645. * @param name defines the block name
  123646. */
  123647. constructor(name: string);
  123648. /**
  123649. * Gets the current class name
  123650. * @returns the class name
  123651. */
  123652. getClassName(): string;
  123653. /**
  123654. * Gets the world position input component
  123655. */
  123656. readonly worldPosition: NodeMaterialConnectionPoint;
  123657. /**
  123658. * Gets the direction output component
  123659. */
  123660. readonly direction: NodeMaterialConnectionPoint;
  123661. /**
  123662. * Gets the direction output component
  123663. */
  123664. readonly color: NodeMaterialConnectionPoint;
  123665. /**
  123666. * Gets the direction output component
  123667. */
  123668. readonly intensity: NodeMaterialConnectionPoint;
  123669. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123670. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123671. protected _buildBlock(state: NodeMaterialBuildState): this;
  123672. serialize(): any;
  123673. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123674. }
  123675. }
  123676. declare module BABYLON {
  123677. /**
  123678. * Block used to add image processing support to fragment shader
  123679. */
  123680. export class ImageProcessingBlock extends NodeMaterialBlock {
  123681. /**
  123682. * Create a new ImageProcessingBlock
  123683. * @param name defines the block name
  123684. */
  123685. constructor(name: string);
  123686. /**
  123687. * Gets the current class name
  123688. * @returns the class name
  123689. */
  123690. getClassName(): string;
  123691. /**
  123692. * Gets the color input component
  123693. */
  123694. readonly color: NodeMaterialConnectionPoint;
  123695. /**
  123696. * Gets the output component
  123697. */
  123698. readonly output: NodeMaterialConnectionPoint;
  123699. /**
  123700. * Initialize the block and prepare the context for build
  123701. * @param state defines the state that will be used for the build
  123702. */
  123703. initialize(state: NodeMaterialBuildState): void;
  123704. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  123705. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123706. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123707. protected _buildBlock(state: NodeMaterialBuildState): this;
  123708. }
  123709. }
  123710. declare module BABYLON {
  123711. /**
  123712. * Block used to pertub normals based on a normal map
  123713. */
  123714. export class PerturbNormalBlock extends NodeMaterialBlock {
  123715. private _tangentSpaceParameterName;
  123716. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  123717. invertX: boolean;
  123718. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  123719. invertY: boolean;
  123720. /**
  123721. * Create a new PerturbNormalBlock
  123722. * @param name defines the block name
  123723. */
  123724. constructor(name: string);
  123725. /**
  123726. * Gets the current class name
  123727. * @returns the class name
  123728. */
  123729. getClassName(): string;
  123730. /**
  123731. * Gets the world position input component
  123732. */
  123733. readonly worldPosition: NodeMaterialConnectionPoint;
  123734. /**
  123735. * Gets the world normal input component
  123736. */
  123737. readonly worldNormal: NodeMaterialConnectionPoint;
  123738. /**
  123739. * Gets the uv input component
  123740. */
  123741. readonly uv: NodeMaterialConnectionPoint;
  123742. /**
  123743. * Gets the normal map color input component
  123744. */
  123745. readonly normalMapColor: NodeMaterialConnectionPoint;
  123746. /**
  123747. * Gets the strength input component
  123748. */
  123749. readonly strength: NodeMaterialConnectionPoint;
  123750. /**
  123751. * Gets the output component
  123752. */
  123753. readonly output: NodeMaterialConnectionPoint;
  123754. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123755. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123756. autoConfigure(material: NodeMaterial): void;
  123757. protected _buildBlock(state: NodeMaterialBuildState): this;
  123758. protected _dumpPropertiesCode(): string;
  123759. serialize(): any;
  123760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123761. }
  123762. }
  123763. declare module BABYLON {
  123764. /**
  123765. * Block used to discard a pixel if a value is smaller than a cutoff
  123766. */
  123767. export class DiscardBlock extends NodeMaterialBlock {
  123768. /**
  123769. * Create a new DiscardBlock
  123770. * @param name defines the block name
  123771. */
  123772. constructor(name: string);
  123773. /**
  123774. * Gets the current class name
  123775. * @returns the class name
  123776. */
  123777. getClassName(): string;
  123778. /**
  123779. * Gets the color input component
  123780. */
  123781. readonly value: NodeMaterialConnectionPoint;
  123782. /**
  123783. * Gets the cutoff input component
  123784. */
  123785. readonly cutoff: NodeMaterialConnectionPoint;
  123786. protected _buildBlock(state: NodeMaterialBuildState): this;
  123787. }
  123788. }
  123789. declare module BABYLON {
  123790. /**
  123791. * Block used to test if the fragment shader is front facing
  123792. */
  123793. export class FrontFacingBlock extends NodeMaterialBlock {
  123794. /**
  123795. * Creates a new FrontFacingBlock
  123796. * @param name defines the block name
  123797. */
  123798. constructor(name: string);
  123799. /**
  123800. * Gets the current class name
  123801. * @returns the class name
  123802. */
  123803. getClassName(): string;
  123804. /**
  123805. * Gets the output component
  123806. */
  123807. readonly output: NodeMaterialConnectionPoint;
  123808. protected _buildBlock(state: NodeMaterialBuildState): this;
  123809. }
  123810. }
  123811. declare module BABYLON {
  123812. /**
  123813. * Block used to get the derivative value on x and y of a given input
  123814. */
  123815. export class DerivativeBlock extends NodeMaterialBlock {
  123816. /**
  123817. * Create a new DerivativeBlock
  123818. * @param name defines the block name
  123819. */
  123820. constructor(name: string);
  123821. /**
  123822. * Gets the current class name
  123823. * @returns the class name
  123824. */
  123825. getClassName(): string;
  123826. /**
  123827. * Gets the input component
  123828. */
  123829. readonly input: NodeMaterialConnectionPoint;
  123830. /**
  123831. * Gets the derivative output on x
  123832. */
  123833. readonly dx: NodeMaterialConnectionPoint;
  123834. /**
  123835. * Gets the derivative output on y
  123836. */
  123837. readonly dy: NodeMaterialConnectionPoint;
  123838. protected _buildBlock(state: NodeMaterialBuildState): this;
  123839. }
  123840. }
  123841. declare module BABYLON {
  123842. /**
  123843. * Block used to add support for scene fog
  123844. */
  123845. export class FogBlock extends NodeMaterialBlock {
  123846. private _fogDistanceName;
  123847. private _fogParameters;
  123848. /**
  123849. * Create a new FogBlock
  123850. * @param name defines the block name
  123851. */
  123852. constructor(name: string);
  123853. /**
  123854. * Gets the current class name
  123855. * @returns the class name
  123856. */
  123857. getClassName(): string;
  123858. /**
  123859. * Gets the world position input component
  123860. */
  123861. readonly worldPosition: NodeMaterialConnectionPoint;
  123862. /**
  123863. * Gets the view input component
  123864. */
  123865. readonly view: NodeMaterialConnectionPoint;
  123866. /**
  123867. * Gets the color input component
  123868. */
  123869. readonly input: NodeMaterialConnectionPoint;
  123870. /**
  123871. * Gets the fog color input component
  123872. */
  123873. readonly fogColor: NodeMaterialConnectionPoint;
  123874. /**
  123875. * Gets the output component
  123876. */
  123877. readonly output: NodeMaterialConnectionPoint;
  123878. autoConfigure(material: NodeMaterial): void;
  123879. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123880. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123881. protected _buildBlock(state: NodeMaterialBuildState): this;
  123882. }
  123883. }
  123884. declare module BABYLON {
  123885. /**
  123886. * Block used to add light in the fragment shader
  123887. */
  123888. export class LightBlock extends NodeMaterialBlock {
  123889. private _lightId;
  123890. /**
  123891. * Gets or sets the light associated with this block
  123892. */
  123893. light: Nullable<Light>;
  123894. /**
  123895. * Create a new LightBlock
  123896. * @param name defines the block name
  123897. */
  123898. constructor(name: string);
  123899. /**
  123900. * Gets the current class name
  123901. * @returns the class name
  123902. */
  123903. getClassName(): string;
  123904. /**
  123905. * Gets the world position input component
  123906. */
  123907. readonly worldPosition: NodeMaterialConnectionPoint;
  123908. /**
  123909. * Gets the world normal input component
  123910. */
  123911. readonly worldNormal: NodeMaterialConnectionPoint;
  123912. /**
  123913. * Gets the camera (or eye) position component
  123914. */
  123915. readonly cameraPosition: NodeMaterialConnectionPoint;
  123916. /**
  123917. * Gets the glossiness component
  123918. */
  123919. readonly glossiness: NodeMaterialConnectionPoint;
  123920. /**
  123921. * Gets the glossinness power component
  123922. */
  123923. readonly glossPower: NodeMaterialConnectionPoint;
  123924. /**
  123925. * Gets the diffuse color component
  123926. */
  123927. readonly diffuseColor: NodeMaterialConnectionPoint;
  123928. /**
  123929. * Gets the specular color component
  123930. */
  123931. readonly specularColor: NodeMaterialConnectionPoint;
  123932. /**
  123933. * Gets the diffuse output component
  123934. */
  123935. readonly diffuseOutput: NodeMaterialConnectionPoint;
  123936. /**
  123937. * Gets the specular output component
  123938. */
  123939. readonly specularOutput: NodeMaterialConnectionPoint;
  123940. autoConfigure(material: NodeMaterial): void;
  123941. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123942. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123943. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123944. private _injectVertexCode;
  123945. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123946. serialize(): any;
  123947. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123948. }
  123949. }
  123950. declare module BABYLON {
  123951. /**
  123952. * Block used to multiply 2 values
  123953. */
  123954. export class MultiplyBlock extends NodeMaterialBlock {
  123955. /**
  123956. * Creates a new MultiplyBlock
  123957. * @param name defines the block name
  123958. */
  123959. constructor(name: string);
  123960. /**
  123961. * Gets the current class name
  123962. * @returns the class name
  123963. */
  123964. getClassName(): string;
  123965. /**
  123966. * Gets the left operand input component
  123967. */
  123968. readonly left: NodeMaterialConnectionPoint;
  123969. /**
  123970. * Gets the right operand input component
  123971. */
  123972. readonly right: NodeMaterialConnectionPoint;
  123973. /**
  123974. * Gets the output component
  123975. */
  123976. readonly output: NodeMaterialConnectionPoint;
  123977. protected _buildBlock(state: NodeMaterialBuildState): this;
  123978. }
  123979. }
  123980. declare module BABYLON {
  123981. /**
  123982. * Block used to add 2 vectors
  123983. */
  123984. export class AddBlock extends NodeMaterialBlock {
  123985. /**
  123986. * Creates a new AddBlock
  123987. * @param name defines the block name
  123988. */
  123989. constructor(name: string);
  123990. /**
  123991. * Gets the current class name
  123992. * @returns the class name
  123993. */
  123994. getClassName(): string;
  123995. /**
  123996. * Gets the left operand input component
  123997. */
  123998. readonly left: NodeMaterialConnectionPoint;
  123999. /**
  124000. * Gets the right operand input component
  124001. */
  124002. readonly right: NodeMaterialConnectionPoint;
  124003. /**
  124004. * Gets the output component
  124005. */
  124006. readonly output: NodeMaterialConnectionPoint;
  124007. protected _buildBlock(state: NodeMaterialBuildState): this;
  124008. }
  124009. }
  124010. declare module BABYLON {
  124011. /**
  124012. * Block used to scale a vector by a float
  124013. */
  124014. export class ScaleBlock extends NodeMaterialBlock {
  124015. /**
  124016. * Creates a new ScaleBlock
  124017. * @param name defines the block name
  124018. */
  124019. constructor(name: string);
  124020. /**
  124021. * Gets the current class name
  124022. * @returns the class name
  124023. */
  124024. getClassName(): string;
  124025. /**
  124026. * Gets the input component
  124027. */
  124028. readonly input: NodeMaterialConnectionPoint;
  124029. /**
  124030. * Gets the factor input component
  124031. */
  124032. readonly factor: NodeMaterialConnectionPoint;
  124033. /**
  124034. * Gets the output component
  124035. */
  124036. readonly output: NodeMaterialConnectionPoint;
  124037. protected _buildBlock(state: NodeMaterialBuildState): this;
  124038. }
  124039. }
  124040. declare module BABYLON {
  124041. /**
  124042. * Block used to clamp a float
  124043. */
  124044. export class ClampBlock extends NodeMaterialBlock {
  124045. /** Gets or sets the minimum range */
  124046. minimum: number;
  124047. /** Gets or sets the maximum range */
  124048. maximum: number;
  124049. /**
  124050. * Creates a new ClampBlock
  124051. * @param name defines the block name
  124052. */
  124053. constructor(name: string);
  124054. /**
  124055. * Gets the current class name
  124056. * @returns the class name
  124057. */
  124058. getClassName(): string;
  124059. /**
  124060. * Gets the value input component
  124061. */
  124062. readonly value: NodeMaterialConnectionPoint;
  124063. /**
  124064. * Gets the output component
  124065. */
  124066. readonly output: NodeMaterialConnectionPoint;
  124067. protected _buildBlock(state: NodeMaterialBuildState): this;
  124068. protected _dumpPropertiesCode(): string;
  124069. serialize(): any;
  124070. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124071. }
  124072. }
  124073. declare module BABYLON {
  124074. /**
  124075. * Block used to apply a cross product between 2 vectors
  124076. */
  124077. export class CrossBlock extends NodeMaterialBlock {
  124078. /**
  124079. * Creates a new CrossBlock
  124080. * @param name defines the block name
  124081. */
  124082. constructor(name: string);
  124083. /**
  124084. * Gets the current class name
  124085. * @returns the class name
  124086. */
  124087. getClassName(): string;
  124088. /**
  124089. * Gets the left operand input component
  124090. */
  124091. readonly left: NodeMaterialConnectionPoint;
  124092. /**
  124093. * Gets the right operand input component
  124094. */
  124095. readonly right: NodeMaterialConnectionPoint;
  124096. /**
  124097. * Gets the output component
  124098. */
  124099. readonly output: NodeMaterialConnectionPoint;
  124100. protected _buildBlock(state: NodeMaterialBuildState): this;
  124101. }
  124102. }
  124103. declare module BABYLON {
  124104. /**
  124105. * Block used to apply a dot product between 2 vectors
  124106. */
  124107. export class DotBlock extends NodeMaterialBlock {
  124108. /**
  124109. * Creates a new DotBlock
  124110. * @param name defines the block name
  124111. */
  124112. constructor(name: string);
  124113. /**
  124114. * Gets the current class name
  124115. * @returns the class name
  124116. */
  124117. getClassName(): string;
  124118. /**
  124119. * Gets the left operand input component
  124120. */
  124121. readonly left: NodeMaterialConnectionPoint;
  124122. /**
  124123. * Gets the right operand input component
  124124. */
  124125. readonly right: NodeMaterialConnectionPoint;
  124126. /**
  124127. * Gets the output component
  124128. */
  124129. readonly output: NodeMaterialConnectionPoint;
  124130. protected _buildBlock(state: NodeMaterialBuildState): this;
  124131. }
  124132. }
  124133. declare module BABYLON {
  124134. /**
  124135. * Block used to remap a float from a range to a new one
  124136. */
  124137. export class RemapBlock extends NodeMaterialBlock {
  124138. /**
  124139. * Gets or sets the source range
  124140. */
  124141. sourceRange: Vector2;
  124142. /**
  124143. * Gets or sets the target range
  124144. */
  124145. targetRange: Vector2;
  124146. /**
  124147. * Creates a new RemapBlock
  124148. * @param name defines the block name
  124149. */
  124150. constructor(name: string);
  124151. /**
  124152. * Gets the current class name
  124153. * @returns the class name
  124154. */
  124155. getClassName(): string;
  124156. /**
  124157. * Gets the input component
  124158. */
  124159. readonly input: NodeMaterialConnectionPoint;
  124160. /**
  124161. * Gets the source min input component
  124162. */
  124163. readonly sourceMin: NodeMaterialConnectionPoint;
  124164. /**
  124165. * Gets the source max input component
  124166. */
  124167. readonly sourceMax: NodeMaterialConnectionPoint;
  124168. /**
  124169. * Gets the target min input component
  124170. */
  124171. readonly targetMin: NodeMaterialConnectionPoint;
  124172. /**
  124173. * Gets the target max input component
  124174. */
  124175. readonly targetMax: NodeMaterialConnectionPoint;
  124176. /**
  124177. * Gets the output component
  124178. */
  124179. readonly output: NodeMaterialConnectionPoint;
  124180. protected _buildBlock(state: NodeMaterialBuildState): this;
  124181. protected _dumpPropertiesCode(): string;
  124182. serialize(): any;
  124183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124184. }
  124185. }
  124186. declare module BABYLON {
  124187. /**
  124188. * Block used to normalize a vector
  124189. */
  124190. export class NormalizeBlock extends NodeMaterialBlock {
  124191. /**
  124192. * Creates a new NormalizeBlock
  124193. * @param name defines the block name
  124194. */
  124195. constructor(name: string);
  124196. /**
  124197. * Gets the current class name
  124198. * @returns the class name
  124199. */
  124200. getClassName(): string;
  124201. /**
  124202. * Gets the input component
  124203. */
  124204. readonly input: NodeMaterialConnectionPoint;
  124205. /**
  124206. * Gets the output component
  124207. */
  124208. readonly output: NodeMaterialConnectionPoint;
  124209. protected _buildBlock(state: NodeMaterialBuildState): this;
  124210. }
  124211. }
  124212. declare module BABYLON {
  124213. /**
  124214. * Operations supported by the Trigonometry block
  124215. */
  124216. export enum TrigonometryBlockOperations {
  124217. /** Cos */
  124218. Cos = 0,
  124219. /** Sin */
  124220. Sin = 1,
  124221. /** Abs */
  124222. Abs = 2,
  124223. /** Exp */
  124224. Exp = 3,
  124225. /** Exp2 */
  124226. Exp2 = 4,
  124227. /** Round */
  124228. Round = 5,
  124229. /** Floor */
  124230. Floor = 6,
  124231. /** Ceiling */
  124232. Ceiling = 7,
  124233. /** Square root */
  124234. Sqrt = 8,
  124235. /** Log */
  124236. Log = 9,
  124237. /** Tangent */
  124238. Tan = 10,
  124239. /** Arc tangent */
  124240. ArcTan = 11,
  124241. /** Arc cosinus */
  124242. ArcCos = 12,
  124243. /** Arc sinus */
  124244. ArcSin = 13,
  124245. /** Fraction */
  124246. Fract = 14,
  124247. /** Sign */
  124248. Sign = 15,
  124249. /** To radians (from degrees) */
  124250. Radians = 16,
  124251. /** To degrees (from radians) */
  124252. Degrees = 17
  124253. }
  124254. /**
  124255. * Block used to apply trigonometry operation to floats
  124256. */
  124257. export class TrigonometryBlock extends NodeMaterialBlock {
  124258. /**
  124259. * Gets or sets the operation applied by the block
  124260. */
  124261. operation: TrigonometryBlockOperations;
  124262. /**
  124263. * Creates a new TrigonometryBlock
  124264. * @param name defines the block name
  124265. */
  124266. constructor(name: string);
  124267. /**
  124268. * Gets the current class name
  124269. * @returns the class name
  124270. */
  124271. getClassName(): string;
  124272. /**
  124273. * Gets the input component
  124274. */
  124275. readonly input: NodeMaterialConnectionPoint;
  124276. /**
  124277. * Gets the output component
  124278. */
  124279. readonly output: NodeMaterialConnectionPoint;
  124280. protected _buildBlock(state: NodeMaterialBuildState): this;
  124281. serialize(): any;
  124282. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124283. protected _dumpPropertiesCode(): string;
  124284. }
  124285. }
  124286. declare module BABYLON {
  124287. /**
  124288. * Block used to create a Color3/4 out of individual inputs (one for each component)
  124289. */
  124290. export class ColorMergerBlock extends NodeMaterialBlock {
  124291. /**
  124292. * Create a new ColorMergerBlock
  124293. * @param name defines the block name
  124294. */
  124295. constructor(name: string);
  124296. /**
  124297. * Gets the current class name
  124298. * @returns the class name
  124299. */
  124300. getClassName(): string;
  124301. /**
  124302. * Gets the rgb component (input)
  124303. */
  124304. readonly rgbIn: NodeMaterialConnectionPoint;
  124305. /**
  124306. * Gets the r component (input)
  124307. */
  124308. readonly r: NodeMaterialConnectionPoint;
  124309. /**
  124310. * Gets the g component (input)
  124311. */
  124312. readonly g: NodeMaterialConnectionPoint;
  124313. /**
  124314. * Gets the b component (input)
  124315. */
  124316. readonly b: NodeMaterialConnectionPoint;
  124317. /**
  124318. * Gets the a component (input)
  124319. */
  124320. readonly a: NodeMaterialConnectionPoint;
  124321. /**
  124322. * Gets the rgba component (output)
  124323. */
  124324. readonly rgba: NodeMaterialConnectionPoint;
  124325. /**
  124326. * Gets the rgb component (output)
  124327. */
  124328. readonly rgbOut: NodeMaterialConnectionPoint;
  124329. /**
  124330. * Gets the rgb component (output)
  124331. * @deprecated Please use rgbOut instead
  124332. */
  124333. readonly rgb: NodeMaterialConnectionPoint;
  124334. protected _buildBlock(state: NodeMaterialBuildState): this;
  124335. }
  124336. }
  124337. declare module BABYLON {
  124338. /**
  124339. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  124340. */
  124341. export class VectorMergerBlock extends NodeMaterialBlock {
  124342. /**
  124343. * Create a new VectorMergerBlock
  124344. * @param name defines the block name
  124345. */
  124346. constructor(name: string);
  124347. /**
  124348. * Gets the current class name
  124349. * @returns the class name
  124350. */
  124351. getClassName(): string;
  124352. /**
  124353. * Gets the xyz component (input)
  124354. */
  124355. readonly xyzIn: NodeMaterialConnectionPoint;
  124356. /**
  124357. * Gets the xy component (input)
  124358. */
  124359. readonly xyIn: NodeMaterialConnectionPoint;
  124360. /**
  124361. * Gets the x component (input)
  124362. */
  124363. readonly x: NodeMaterialConnectionPoint;
  124364. /**
  124365. * Gets the y component (input)
  124366. */
  124367. readonly y: NodeMaterialConnectionPoint;
  124368. /**
  124369. * Gets the z component (input)
  124370. */
  124371. readonly z: NodeMaterialConnectionPoint;
  124372. /**
  124373. * Gets the w component (input)
  124374. */
  124375. readonly w: NodeMaterialConnectionPoint;
  124376. /**
  124377. * Gets the xyzw component (output)
  124378. */
  124379. readonly xyzw: NodeMaterialConnectionPoint;
  124380. /**
  124381. * Gets the xyz component (output)
  124382. */
  124383. readonly xyzOut: NodeMaterialConnectionPoint;
  124384. /**
  124385. * Gets the xy component (output)
  124386. */
  124387. readonly xyOut: NodeMaterialConnectionPoint;
  124388. /**
  124389. * Gets the xy component (output)
  124390. * @deprecated Please use xyOut instead
  124391. */
  124392. readonly xy: NodeMaterialConnectionPoint;
  124393. /**
  124394. * Gets the xyz component (output)
  124395. * @deprecated Please use xyzOut instead
  124396. */
  124397. readonly xyz: NodeMaterialConnectionPoint;
  124398. protected _buildBlock(state: NodeMaterialBuildState): this;
  124399. }
  124400. }
  124401. declare module BABYLON {
  124402. /**
  124403. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  124404. */
  124405. export class ColorSplitterBlock extends NodeMaterialBlock {
  124406. /**
  124407. * Create a new ColorSplitterBlock
  124408. * @param name defines the block name
  124409. */
  124410. constructor(name: string);
  124411. /**
  124412. * Gets the current class name
  124413. * @returns the class name
  124414. */
  124415. getClassName(): string;
  124416. /**
  124417. * Gets the rgba component (input)
  124418. */
  124419. readonly rgba: NodeMaterialConnectionPoint;
  124420. /**
  124421. * Gets the rgb component (input)
  124422. */
  124423. readonly rgbIn: NodeMaterialConnectionPoint;
  124424. /**
  124425. * Gets the rgb component (output)
  124426. */
  124427. readonly rgbOut: NodeMaterialConnectionPoint;
  124428. /**
  124429. * Gets the r component (output)
  124430. */
  124431. readonly r: NodeMaterialConnectionPoint;
  124432. /**
  124433. * Gets the g component (output)
  124434. */
  124435. readonly g: NodeMaterialConnectionPoint;
  124436. /**
  124437. * Gets the b component (output)
  124438. */
  124439. readonly b: NodeMaterialConnectionPoint;
  124440. /**
  124441. * Gets the a component (output)
  124442. */
  124443. readonly a: NodeMaterialConnectionPoint;
  124444. protected _inputRename(name: string): string;
  124445. protected _outputRename(name: string): string;
  124446. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124447. }
  124448. }
  124449. declare module BABYLON {
  124450. /**
  124451. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  124452. */
  124453. export class VectorSplitterBlock extends NodeMaterialBlock {
  124454. /**
  124455. * Create a new VectorSplitterBlock
  124456. * @param name defines the block name
  124457. */
  124458. constructor(name: string);
  124459. /**
  124460. * Gets the current class name
  124461. * @returns the class name
  124462. */
  124463. getClassName(): string;
  124464. /**
  124465. * Gets the xyzw component (input)
  124466. */
  124467. readonly xyzw: NodeMaterialConnectionPoint;
  124468. /**
  124469. * Gets the xyz component (input)
  124470. */
  124471. readonly xyzIn: NodeMaterialConnectionPoint;
  124472. /**
  124473. * Gets the xy component (input)
  124474. */
  124475. readonly xyIn: NodeMaterialConnectionPoint;
  124476. /**
  124477. * Gets the xyz component (output)
  124478. */
  124479. readonly xyzOut: NodeMaterialConnectionPoint;
  124480. /**
  124481. * Gets the xy component (output)
  124482. */
  124483. readonly xyOut: NodeMaterialConnectionPoint;
  124484. /**
  124485. * Gets the x component (output)
  124486. */
  124487. readonly x: NodeMaterialConnectionPoint;
  124488. /**
  124489. * Gets the y component (output)
  124490. */
  124491. readonly y: NodeMaterialConnectionPoint;
  124492. /**
  124493. * Gets the z component (output)
  124494. */
  124495. readonly z: NodeMaterialConnectionPoint;
  124496. /**
  124497. * Gets the w component (output)
  124498. */
  124499. readonly w: NodeMaterialConnectionPoint;
  124500. protected _inputRename(name: string): string;
  124501. protected _outputRename(name: string): string;
  124502. protected _buildBlock(state: NodeMaterialBuildState): this;
  124503. }
  124504. }
  124505. declare module BABYLON {
  124506. /**
  124507. * Block used to lerp between 2 values
  124508. */
  124509. export class LerpBlock extends NodeMaterialBlock {
  124510. /**
  124511. * Creates a new LerpBlock
  124512. * @param name defines the block name
  124513. */
  124514. constructor(name: string);
  124515. /**
  124516. * Gets the current class name
  124517. * @returns the class name
  124518. */
  124519. getClassName(): string;
  124520. /**
  124521. * Gets the left operand input component
  124522. */
  124523. readonly left: NodeMaterialConnectionPoint;
  124524. /**
  124525. * Gets the right operand input component
  124526. */
  124527. readonly right: NodeMaterialConnectionPoint;
  124528. /**
  124529. * Gets the gradient operand input component
  124530. */
  124531. readonly gradient: NodeMaterialConnectionPoint;
  124532. /**
  124533. * Gets the output component
  124534. */
  124535. readonly output: NodeMaterialConnectionPoint;
  124536. protected _buildBlock(state: NodeMaterialBuildState): this;
  124537. }
  124538. }
  124539. declare module BABYLON {
  124540. /**
  124541. * Block used to divide 2 vectors
  124542. */
  124543. export class DivideBlock extends NodeMaterialBlock {
  124544. /**
  124545. * Creates a new DivideBlock
  124546. * @param name defines the block name
  124547. */
  124548. constructor(name: string);
  124549. /**
  124550. * Gets the current class name
  124551. * @returns the class name
  124552. */
  124553. getClassName(): string;
  124554. /**
  124555. * Gets the left operand input component
  124556. */
  124557. readonly left: NodeMaterialConnectionPoint;
  124558. /**
  124559. * Gets the right operand input component
  124560. */
  124561. readonly right: NodeMaterialConnectionPoint;
  124562. /**
  124563. * Gets the output component
  124564. */
  124565. readonly output: NodeMaterialConnectionPoint;
  124566. protected _buildBlock(state: NodeMaterialBuildState): this;
  124567. }
  124568. }
  124569. declare module BABYLON {
  124570. /**
  124571. * Block used to subtract 2 vectors
  124572. */
  124573. export class SubtractBlock extends NodeMaterialBlock {
  124574. /**
  124575. * Creates a new SubtractBlock
  124576. * @param name defines the block name
  124577. */
  124578. constructor(name: string);
  124579. /**
  124580. * Gets the current class name
  124581. * @returns the class name
  124582. */
  124583. getClassName(): string;
  124584. /**
  124585. * Gets the left operand input component
  124586. */
  124587. readonly left: NodeMaterialConnectionPoint;
  124588. /**
  124589. * Gets the right operand input component
  124590. */
  124591. readonly right: NodeMaterialConnectionPoint;
  124592. /**
  124593. * Gets the output component
  124594. */
  124595. readonly output: NodeMaterialConnectionPoint;
  124596. protected _buildBlock(state: NodeMaterialBuildState): this;
  124597. }
  124598. }
  124599. declare module BABYLON {
  124600. /**
  124601. * Block used to step a value
  124602. */
  124603. export class StepBlock extends NodeMaterialBlock {
  124604. /**
  124605. * Creates a new StepBlock
  124606. * @param name defines the block name
  124607. */
  124608. constructor(name: string);
  124609. /**
  124610. * Gets the current class name
  124611. * @returns the class name
  124612. */
  124613. getClassName(): string;
  124614. /**
  124615. * Gets the value operand input component
  124616. */
  124617. readonly value: NodeMaterialConnectionPoint;
  124618. /**
  124619. * Gets the edge operand input component
  124620. */
  124621. readonly edge: NodeMaterialConnectionPoint;
  124622. /**
  124623. * Gets the output component
  124624. */
  124625. readonly output: NodeMaterialConnectionPoint;
  124626. protected _buildBlock(state: NodeMaterialBuildState): this;
  124627. }
  124628. }
  124629. declare module BABYLON {
  124630. /**
  124631. * Block used to get the opposite (1 - x) of a value
  124632. */
  124633. export class OneMinusBlock extends NodeMaterialBlock {
  124634. /**
  124635. * Creates a new OneMinusBlock
  124636. * @param name defines the block name
  124637. */
  124638. constructor(name: string);
  124639. /**
  124640. * Gets the current class name
  124641. * @returns the class name
  124642. */
  124643. getClassName(): string;
  124644. /**
  124645. * Gets the input component
  124646. */
  124647. readonly input: NodeMaterialConnectionPoint;
  124648. /**
  124649. * Gets the output component
  124650. */
  124651. readonly output: NodeMaterialConnectionPoint;
  124652. protected _buildBlock(state: NodeMaterialBuildState): this;
  124653. }
  124654. }
  124655. declare module BABYLON {
  124656. /**
  124657. * Block used to get the view direction
  124658. */
  124659. export class ViewDirectionBlock extends NodeMaterialBlock {
  124660. /**
  124661. * Creates a new ViewDirectionBlock
  124662. * @param name defines the block name
  124663. */
  124664. constructor(name: string);
  124665. /**
  124666. * Gets the current class name
  124667. * @returns the class name
  124668. */
  124669. getClassName(): string;
  124670. /**
  124671. * Gets the world position component
  124672. */
  124673. readonly worldPosition: NodeMaterialConnectionPoint;
  124674. /**
  124675. * Gets the camera position component
  124676. */
  124677. readonly cameraPosition: NodeMaterialConnectionPoint;
  124678. /**
  124679. * Gets the output component
  124680. */
  124681. readonly output: NodeMaterialConnectionPoint;
  124682. autoConfigure(material: NodeMaterial): void;
  124683. protected _buildBlock(state: NodeMaterialBuildState): this;
  124684. }
  124685. }
  124686. declare module BABYLON {
  124687. /**
  124688. * Block used to compute fresnel value
  124689. */
  124690. export class FresnelBlock extends NodeMaterialBlock {
  124691. /**
  124692. * Create a new FresnelBlock
  124693. * @param name defines the block name
  124694. */
  124695. constructor(name: string);
  124696. /**
  124697. * Gets the current class name
  124698. * @returns the class name
  124699. */
  124700. getClassName(): string;
  124701. /**
  124702. * Gets the world normal input component
  124703. */
  124704. readonly worldNormal: NodeMaterialConnectionPoint;
  124705. /**
  124706. * Gets the view direction input component
  124707. */
  124708. readonly viewDirection: NodeMaterialConnectionPoint;
  124709. /**
  124710. * Gets the bias input component
  124711. */
  124712. readonly bias: NodeMaterialConnectionPoint;
  124713. /**
  124714. * Gets the camera (or eye) position component
  124715. */
  124716. readonly power: NodeMaterialConnectionPoint;
  124717. /**
  124718. * Gets the fresnel output component
  124719. */
  124720. readonly fresnel: NodeMaterialConnectionPoint;
  124721. autoConfigure(material: NodeMaterial): void;
  124722. protected _buildBlock(state: NodeMaterialBuildState): this;
  124723. }
  124724. }
  124725. declare module BABYLON {
  124726. /**
  124727. * Block used to get the max of 2 values
  124728. */
  124729. export class MaxBlock extends NodeMaterialBlock {
  124730. /**
  124731. * Creates a new MaxBlock
  124732. * @param name defines the block name
  124733. */
  124734. constructor(name: string);
  124735. /**
  124736. * Gets the current class name
  124737. * @returns the class name
  124738. */
  124739. getClassName(): string;
  124740. /**
  124741. * Gets the left operand input component
  124742. */
  124743. readonly left: NodeMaterialConnectionPoint;
  124744. /**
  124745. * Gets the right operand input component
  124746. */
  124747. readonly right: NodeMaterialConnectionPoint;
  124748. /**
  124749. * Gets the output component
  124750. */
  124751. readonly output: NodeMaterialConnectionPoint;
  124752. protected _buildBlock(state: NodeMaterialBuildState): this;
  124753. }
  124754. }
  124755. declare module BABYLON {
  124756. /**
  124757. * Block used to get the min of 2 values
  124758. */
  124759. export class MinBlock extends NodeMaterialBlock {
  124760. /**
  124761. * Creates a new MinBlock
  124762. * @param name defines the block name
  124763. */
  124764. constructor(name: string);
  124765. /**
  124766. * Gets the current class name
  124767. * @returns the class name
  124768. */
  124769. getClassName(): string;
  124770. /**
  124771. * Gets the left operand input component
  124772. */
  124773. readonly left: NodeMaterialConnectionPoint;
  124774. /**
  124775. * Gets the right operand input component
  124776. */
  124777. readonly right: NodeMaterialConnectionPoint;
  124778. /**
  124779. * Gets the output component
  124780. */
  124781. readonly output: NodeMaterialConnectionPoint;
  124782. protected _buildBlock(state: NodeMaterialBuildState): this;
  124783. }
  124784. }
  124785. declare module BABYLON {
  124786. /**
  124787. * Block used to get the distance between 2 values
  124788. */
  124789. export class DistanceBlock extends NodeMaterialBlock {
  124790. /**
  124791. * Creates a new DistanceBlock
  124792. * @param name defines the block name
  124793. */
  124794. constructor(name: string);
  124795. /**
  124796. * Gets the current class name
  124797. * @returns the class name
  124798. */
  124799. getClassName(): string;
  124800. /**
  124801. * Gets the left operand input component
  124802. */
  124803. readonly left: NodeMaterialConnectionPoint;
  124804. /**
  124805. * Gets the right operand input component
  124806. */
  124807. readonly right: NodeMaterialConnectionPoint;
  124808. /**
  124809. * Gets the output component
  124810. */
  124811. readonly output: NodeMaterialConnectionPoint;
  124812. protected _buildBlock(state: NodeMaterialBuildState): this;
  124813. }
  124814. }
  124815. declare module BABYLON {
  124816. /**
  124817. * Block used to get the length of a vector
  124818. */
  124819. export class LengthBlock extends NodeMaterialBlock {
  124820. /**
  124821. * Creates a new LengthBlock
  124822. * @param name defines the block name
  124823. */
  124824. constructor(name: string);
  124825. /**
  124826. * Gets the current class name
  124827. * @returns the class name
  124828. */
  124829. getClassName(): string;
  124830. /**
  124831. * Gets the value input component
  124832. */
  124833. readonly value: NodeMaterialConnectionPoint;
  124834. /**
  124835. * Gets the output component
  124836. */
  124837. readonly output: NodeMaterialConnectionPoint;
  124838. protected _buildBlock(state: NodeMaterialBuildState): this;
  124839. }
  124840. }
  124841. declare module BABYLON {
  124842. /**
  124843. * Block used to get negative version of a value (i.e. x * -1)
  124844. */
  124845. export class NegateBlock extends NodeMaterialBlock {
  124846. /**
  124847. * Creates a new NegateBlock
  124848. * @param name defines the block name
  124849. */
  124850. constructor(name: string);
  124851. /**
  124852. * Gets the current class name
  124853. * @returns the class name
  124854. */
  124855. getClassName(): string;
  124856. /**
  124857. * Gets the value input component
  124858. */
  124859. readonly value: NodeMaterialConnectionPoint;
  124860. /**
  124861. * Gets the output component
  124862. */
  124863. readonly output: NodeMaterialConnectionPoint;
  124864. protected _buildBlock(state: NodeMaterialBuildState): this;
  124865. }
  124866. }
  124867. declare module BABYLON {
  124868. /**
  124869. * Block used to get the value of the first parameter raised to the power of the second
  124870. */
  124871. export class PowBlock extends NodeMaterialBlock {
  124872. /**
  124873. * Creates a new PowBlock
  124874. * @param name defines the block name
  124875. */
  124876. constructor(name: string);
  124877. /**
  124878. * Gets the current class name
  124879. * @returns the class name
  124880. */
  124881. getClassName(): string;
  124882. /**
  124883. * Gets the value operand input component
  124884. */
  124885. readonly value: NodeMaterialConnectionPoint;
  124886. /**
  124887. * Gets the power operand input component
  124888. */
  124889. readonly power: NodeMaterialConnectionPoint;
  124890. /**
  124891. * Gets the output component
  124892. */
  124893. readonly output: NodeMaterialConnectionPoint;
  124894. protected _buildBlock(state: NodeMaterialBuildState): this;
  124895. }
  124896. }
  124897. declare module BABYLON {
  124898. /**
  124899. * Block used to get a random number
  124900. */
  124901. export class RandomNumberBlock extends NodeMaterialBlock {
  124902. /**
  124903. * Creates a new RandomNumberBlock
  124904. * @param name defines the block name
  124905. */
  124906. constructor(name: string);
  124907. /**
  124908. * Gets the current class name
  124909. * @returns the class name
  124910. */
  124911. getClassName(): string;
  124912. /**
  124913. * Gets the seed input component
  124914. */
  124915. readonly seed: NodeMaterialConnectionPoint;
  124916. /**
  124917. * Gets the output component
  124918. */
  124919. readonly output: NodeMaterialConnectionPoint;
  124920. protected _buildBlock(state: NodeMaterialBuildState): this;
  124921. }
  124922. }
  124923. declare module BABYLON {
  124924. /**
  124925. * Block used to compute arc tangent of 2 values
  124926. */
  124927. export class ArcTan2Block extends NodeMaterialBlock {
  124928. /**
  124929. * Creates a new ArcTan2Block
  124930. * @param name defines the block name
  124931. */
  124932. constructor(name: string);
  124933. /**
  124934. * Gets the current class name
  124935. * @returns the class name
  124936. */
  124937. getClassName(): string;
  124938. /**
  124939. * Gets the x operand input component
  124940. */
  124941. readonly x: NodeMaterialConnectionPoint;
  124942. /**
  124943. * Gets the y operand input component
  124944. */
  124945. readonly y: NodeMaterialConnectionPoint;
  124946. /**
  124947. * Gets the output component
  124948. */
  124949. readonly output: NodeMaterialConnectionPoint;
  124950. protected _buildBlock(state: NodeMaterialBuildState): this;
  124951. }
  124952. }
  124953. declare module BABYLON {
  124954. /**
  124955. * Block used to smooth step a value
  124956. */
  124957. export class SmoothStepBlock extends NodeMaterialBlock {
  124958. /**
  124959. * Creates a new SmoothStepBlock
  124960. * @param name defines the block name
  124961. */
  124962. constructor(name: string);
  124963. /**
  124964. * Gets the current class name
  124965. * @returns the class name
  124966. */
  124967. getClassName(): string;
  124968. /**
  124969. * Gets the value operand input component
  124970. */
  124971. readonly value: NodeMaterialConnectionPoint;
  124972. /**
  124973. * Gets the first edge operand input component
  124974. */
  124975. readonly edge0: NodeMaterialConnectionPoint;
  124976. /**
  124977. * Gets the second edge operand input component
  124978. */
  124979. readonly edge1: NodeMaterialConnectionPoint;
  124980. /**
  124981. * Gets the output component
  124982. */
  124983. readonly output: NodeMaterialConnectionPoint;
  124984. protected _buildBlock(state: NodeMaterialBuildState): this;
  124985. }
  124986. }
  124987. declare module BABYLON {
  124988. /**
  124989. * Block used to get the reciprocal (1 / x) of a value
  124990. */
  124991. export class ReciprocalBlock extends NodeMaterialBlock {
  124992. /**
  124993. * Creates a new ReciprocalBlock
  124994. * @param name defines the block name
  124995. */
  124996. constructor(name: string);
  124997. /**
  124998. * Gets the current class name
  124999. * @returns the class name
  125000. */
  125001. getClassName(): string;
  125002. /**
  125003. * Gets the input component
  125004. */
  125005. readonly input: NodeMaterialConnectionPoint;
  125006. /**
  125007. * Gets the output component
  125008. */
  125009. readonly output: NodeMaterialConnectionPoint;
  125010. protected _buildBlock(state: NodeMaterialBuildState): this;
  125011. }
  125012. }
  125013. declare module BABYLON {
  125014. /**
  125015. * Block used to replace a color by another one
  125016. */
  125017. export class ReplaceColorBlock extends NodeMaterialBlock {
  125018. /**
  125019. * Creates a new ReplaceColorBlock
  125020. * @param name defines the block name
  125021. */
  125022. constructor(name: string);
  125023. /**
  125024. * Gets the current class name
  125025. * @returns the class name
  125026. */
  125027. getClassName(): string;
  125028. /**
  125029. * Gets the value input component
  125030. */
  125031. readonly value: NodeMaterialConnectionPoint;
  125032. /**
  125033. * Gets the reference input component
  125034. */
  125035. readonly reference: NodeMaterialConnectionPoint;
  125036. /**
  125037. * Gets the distance input component
  125038. */
  125039. readonly distance: NodeMaterialConnectionPoint;
  125040. /**
  125041. * Gets the replacement input component
  125042. */
  125043. readonly replacement: NodeMaterialConnectionPoint;
  125044. /**
  125045. * Gets the output component
  125046. */
  125047. readonly output: NodeMaterialConnectionPoint;
  125048. protected _buildBlock(state: NodeMaterialBuildState): this;
  125049. }
  125050. }
  125051. declare module BABYLON {
  125052. /**
  125053. * Block used to posterize a value
  125054. * @see https://en.wikipedia.org/wiki/Posterization
  125055. */
  125056. export class PosterizeBlock extends NodeMaterialBlock {
  125057. /**
  125058. * Creates a new PosterizeBlock
  125059. * @param name defines the block name
  125060. */
  125061. constructor(name: string);
  125062. /**
  125063. * Gets the current class name
  125064. * @returns the class name
  125065. */
  125066. getClassName(): string;
  125067. /**
  125068. * Gets the value input component
  125069. */
  125070. readonly value: NodeMaterialConnectionPoint;
  125071. /**
  125072. * Gets the steps input component
  125073. */
  125074. readonly steps: NodeMaterialConnectionPoint;
  125075. /**
  125076. * Gets the output component
  125077. */
  125078. readonly output: NodeMaterialConnectionPoint;
  125079. protected _buildBlock(state: NodeMaterialBuildState): this;
  125080. }
  125081. }
  125082. declare module BABYLON {
  125083. /**
  125084. * Operations supported by the Wave block
  125085. */
  125086. export enum WaveBlockKind {
  125087. /** SawTooth */
  125088. SawTooth = 0,
  125089. /** Square */
  125090. Square = 1,
  125091. /** Triangle */
  125092. Triangle = 2
  125093. }
  125094. /**
  125095. * Block used to apply wave operation to floats
  125096. */
  125097. export class WaveBlock extends NodeMaterialBlock {
  125098. /**
  125099. * Gets or sets the kibnd of wave to be applied by the block
  125100. */
  125101. kind: WaveBlockKind;
  125102. /**
  125103. * Creates a new WaveBlock
  125104. * @param name defines the block name
  125105. */
  125106. constructor(name: string);
  125107. /**
  125108. * Gets the current class name
  125109. * @returns the class name
  125110. */
  125111. getClassName(): string;
  125112. /**
  125113. * Gets the input component
  125114. */
  125115. readonly input: NodeMaterialConnectionPoint;
  125116. /**
  125117. * Gets the output component
  125118. */
  125119. readonly output: NodeMaterialConnectionPoint;
  125120. protected _buildBlock(state: NodeMaterialBuildState): this;
  125121. serialize(): any;
  125122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125123. }
  125124. }
  125125. declare module BABYLON {
  125126. /**
  125127. * Class used to store a color step for the GradientBlock
  125128. */
  125129. export class GradientBlockColorStep {
  125130. /**
  125131. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125132. */
  125133. step: number;
  125134. /**
  125135. * Gets or sets the color associated with this step
  125136. */
  125137. color: Color3;
  125138. /**
  125139. * Creates a new GradientBlockColorStep
  125140. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  125141. * @param color defines the color associated with this step
  125142. */
  125143. constructor(
  125144. /**
  125145. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125146. */
  125147. step: number,
  125148. /**
  125149. * Gets or sets the color associated with this step
  125150. */
  125151. color: Color3);
  125152. }
  125153. /**
  125154. * Block used to return a color from a gradient based on an input value between 0 and 1
  125155. */
  125156. export class GradientBlock extends NodeMaterialBlock {
  125157. /**
  125158. * Gets or sets the list of color steps
  125159. */
  125160. colorSteps: GradientBlockColorStep[];
  125161. /**
  125162. * Creates a new GradientBlock
  125163. * @param name defines the block name
  125164. */
  125165. constructor(name: string);
  125166. /**
  125167. * Gets the current class name
  125168. * @returns the class name
  125169. */
  125170. getClassName(): string;
  125171. /**
  125172. * Gets the gradient input component
  125173. */
  125174. readonly gradient: NodeMaterialConnectionPoint;
  125175. /**
  125176. * Gets the output component
  125177. */
  125178. readonly output: NodeMaterialConnectionPoint;
  125179. private _writeColorConstant;
  125180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125181. serialize(): any;
  125182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125183. protected _dumpPropertiesCode(): string;
  125184. }
  125185. }
  125186. declare module BABYLON {
  125187. /**
  125188. * Block used to normalize lerp between 2 values
  125189. */
  125190. export class NLerpBlock extends NodeMaterialBlock {
  125191. /**
  125192. * Creates a new NLerpBlock
  125193. * @param name defines the block name
  125194. */
  125195. constructor(name: string);
  125196. /**
  125197. * Gets the current class name
  125198. * @returns the class name
  125199. */
  125200. getClassName(): string;
  125201. /**
  125202. * Gets the left operand input component
  125203. */
  125204. readonly left: NodeMaterialConnectionPoint;
  125205. /**
  125206. * Gets the right operand input component
  125207. */
  125208. readonly right: NodeMaterialConnectionPoint;
  125209. /**
  125210. * Gets the gradient operand input component
  125211. */
  125212. readonly gradient: NodeMaterialConnectionPoint;
  125213. /**
  125214. * Gets the output component
  125215. */
  125216. readonly output: NodeMaterialConnectionPoint;
  125217. protected _buildBlock(state: NodeMaterialBuildState): this;
  125218. }
  125219. }
  125220. declare module BABYLON {
  125221. /**
  125222. * block used to Generate a Worley Noise 3D Noise Pattern
  125223. */
  125224. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  125225. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  125226. manhattanDistance: boolean;
  125227. /**
  125228. * Creates a new WorleyNoise3DBlock
  125229. * @param name defines the block name
  125230. */
  125231. constructor(name: string);
  125232. /**
  125233. * Gets the current class name
  125234. * @returns the class name
  125235. */
  125236. getClassName(): string;
  125237. /**
  125238. * Gets the seed input component
  125239. */
  125240. readonly seed: NodeMaterialConnectionPoint;
  125241. /**
  125242. * Gets the jitter input component
  125243. */
  125244. readonly jitter: NodeMaterialConnectionPoint;
  125245. /**
  125246. * Gets the output component
  125247. */
  125248. readonly output: NodeMaterialConnectionPoint;
  125249. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125250. /**
  125251. * Exposes the properties to the UI?
  125252. */
  125253. protected _dumpPropertiesCode(): string;
  125254. /**
  125255. * Exposes the properties to the Seralize?
  125256. */
  125257. serialize(): any;
  125258. /**
  125259. * Exposes the properties to the deseralize?
  125260. */
  125261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125262. }
  125263. }
  125264. declare module BABYLON {
  125265. /**
  125266. * block used to Generate a Simplex Perlin 3d Noise Pattern
  125267. */
  125268. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  125269. /**
  125270. * Creates a new SimplexPerlin3DBlock
  125271. * @param name defines the block name
  125272. */
  125273. constructor(name: string);
  125274. /**
  125275. * Gets the current class name
  125276. * @returns the class name
  125277. */
  125278. getClassName(): string;
  125279. /**
  125280. * Gets the seed operand input component
  125281. */
  125282. readonly seed: NodeMaterialConnectionPoint;
  125283. /**
  125284. * Gets the output component
  125285. */
  125286. readonly output: NodeMaterialConnectionPoint;
  125287. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125288. }
  125289. }
  125290. declare module BABYLON {
  125291. /**
  125292. * Block used to blend normals
  125293. */
  125294. export class NormalBlendBlock extends NodeMaterialBlock {
  125295. /**
  125296. * Creates a new NormalBlendBlock
  125297. * @param name defines the block name
  125298. */
  125299. constructor(name: string);
  125300. /**
  125301. * Gets the current class name
  125302. * @returns the class name
  125303. */
  125304. getClassName(): string;
  125305. /**
  125306. * Gets the first input component
  125307. */
  125308. readonly normalMap0: NodeMaterialConnectionPoint;
  125309. /**
  125310. * Gets the second input component
  125311. */
  125312. readonly normalMap1: NodeMaterialConnectionPoint;
  125313. /**
  125314. * Gets the output component
  125315. */
  125316. readonly output: NodeMaterialConnectionPoint;
  125317. protected _buildBlock(state: NodeMaterialBuildState): this;
  125318. }
  125319. }
  125320. declare module BABYLON {
  125321. /**
  125322. * Block used to rotate a 2d vector by a given angle
  125323. */
  125324. export class Rotate2dBlock extends NodeMaterialBlock {
  125325. /**
  125326. * Creates a new Rotate2dBlock
  125327. * @param name defines the block name
  125328. */
  125329. constructor(name: string);
  125330. /**
  125331. * Gets the current class name
  125332. * @returns the class name
  125333. */
  125334. getClassName(): string;
  125335. /**
  125336. * Gets the input vector
  125337. */
  125338. readonly input: NodeMaterialConnectionPoint;
  125339. /**
  125340. * Gets the input angle
  125341. */
  125342. readonly angle: NodeMaterialConnectionPoint;
  125343. /**
  125344. * Gets the output component
  125345. */
  125346. readonly output: NodeMaterialConnectionPoint;
  125347. autoConfigure(material: NodeMaterial): void;
  125348. protected _buildBlock(state: NodeMaterialBuildState): this;
  125349. }
  125350. }
  125351. declare module BABYLON {
  125352. /**
  125353. * Block used to get the reflected vector from a direction and a normal
  125354. */
  125355. export class ReflectBlock extends NodeMaterialBlock {
  125356. /**
  125357. * Creates a new ReflectBlock
  125358. * @param name defines the block name
  125359. */
  125360. constructor(name: string);
  125361. /**
  125362. * Gets the current class name
  125363. * @returns the class name
  125364. */
  125365. getClassName(): string;
  125366. /**
  125367. * Gets the incident component
  125368. */
  125369. readonly incident: NodeMaterialConnectionPoint;
  125370. /**
  125371. * Gets the normal component
  125372. */
  125373. readonly normal: NodeMaterialConnectionPoint;
  125374. /**
  125375. * Gets the output component
  125376. */
  125377. readonly output: NodeMaterialConnectionPoint;
  125378. protected _buildBlock(state: NodeMaterialBuildState): this;
  125379. }
  125380. }
  125381. declare module BABYLON {
  125382. /**
  125383. * Block used to get the refracted vector from a direction and a normal
  125384. */
  125385. export class RefractBlock extends NodeMaterialBlock {
  125386. /**
  125387. * Creates a new RefractBlock
  125388. * @param name defines the block name
  125389. */
  125390. constructor(name: string);
  125391. /**
  125392. * Gets the current class name
  125393. * @returns the class name
  125394. */
  125395. getClassName(): string;
  125396. /**
  125397. * Gets the incident component
  125398. */
  125399. readonly incident: NodeMaterialConnectionPoint;
  125400. /**
  125401. * Gets the normal component
  125402. */
  125403. readonly normal: NodeMaterialConnectionPoint;
  125404. /**
  125405. * Gets the index of refraction component
  125406. */
  125407. readonly ior: NodeMaterialConnectionPoint;
  125408. /**
  125409. * Gets the output component
  125410. */
  125411. readonly output: NodeMaterialConnectionPoint;
  125412. protected _buildBlock(state: NodeMaterialBuildState): this;
  125413. }
  125414. }
  125415. declare module BABYLON {
  125416. /**
  125417. * Block used to desaturate a color
  125418. */
  125419. export class DesaturateBlock extends NodeMaterialBlock {
  125420. /**
  125421. * Creates a new DesaturateBlock
  125422. * @param name defines the block name
  125423. */
  125424. constructor(name: string);
  125425. /**
  125426. * Gets the current class name
  125427. * @returns the class name
  125428. */
  125429. getClassName(): string;
  125430. /**
  125431. * Gets the color operand input component
  125432. */
  125433. readonly color: NodeMaterialConnectionPoint;
  125434. /**
  125435. * Gets the level operand input component
  125436. */
  125437. readonly level: NodeMaterialConnectionPoint;
  125438. /**
  125439. * Gets the output component
  125440. */
  125441. readonly output: NodeMaterialConnectionPoint;
  125442. protected _buildBlock(state: NodeMaterialBuildState): this;
  125443. }
  125444. }
  125445. declare module BABYLON {
  125446. /**
  125447. * Effect Render Options
  125448. */
  125449. export interface IEffectRendererOptions {
  125450. /**
  125451. * Defines the vertices positions.
  125452. */
  125453. positions?: number[];
  125454. /**
  125455. * Defines the indices.
  125456. */
  125457. indices?: number[];
  125458. }
  125459. /**
  125460. * Helper class to render one or more effects
  125461. */
  125462. export class EffectRenderer {
  125463. private engine;
  125464. private static _DefaultOptions;
  125465. private _vertexBuffers;
  125466. private _indexBuffer;
  125467. private _ringBufferIndex;
  125468. private _ringScreenBuffer;
  125469. private _fullscreenViewport;
  125470. private _getNextFrameBuffer;
  125471. /**
  125472. * Creates an effect renderer
  125473. * @param engine the engine to use for rendering
  125474. * @param options defines the options of the effect renderer
  125475. */
  125476. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  125477. /**
  125478. * Sets the current viewport in normalized coordinates 0-1
  125479. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  125480. */
  125481. setViewport(viewport?: Viewport): void;
  125482. /**
  125483. * Binds the embedded attributes buffer to the effect.
  125484. * @param effect Defines the effect to bind the attributes for
  125485. */
  125486. bindBuffers(effect: Effect): void;
  125487. /**
  125488. * Sets the current effect wrapper to use during draw.
  125489. * The effect needs to be ready before calling this api.
  125490. * This also sets the default full screen position attribute.
  125491. * @param effectWrapper Defines the effect to draw with
  125492. */
  125493. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  125494. /**
  125495. * Draws a full screen quad.
  125496. */
  125497. draw(): void;
  125498. /**
  125499. * renders one or more effects to a specified texture
  125500. * @param effectWrappers list of effects to renderer
  125501. * @param outputTexture texture to draw to, if null it will render to the screen
  125502. */
  125503. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  125504. /**
  125505. * Disposes of the effect renderer
  125506. */
  125507. dispose(): void;
  125508. }
  125509. /**
  125510. * Options to create an EffectWrapper
  125511. */
  125512. interface EffectWrapperCreationOptions {
  125513. /**
  125514. * Engine to use to create the effect
  125515. */
  125516. engine: ThinEngine;
  125517. /**
  125518. * Fragment shader for the effect
  125519. */
  125520. fragmentShader: string;
  125521. /**
  125522. * Vertex shader for the effect
  125523. */
  125524. vertexShader?: string;
  125525. /**
  125526. * Attributes to use in the shader
  125527. */
  125528. attributeNames?: Array<string>;
  125529. /**
  125530. * Uniforms to use in the shader
  125531. */
  125532. uniformNames?: Array<string>;
  125533. /**
  125534. * Texture sampler names to use in the shader
  125535. */
  125536. samplerNames?: Array<string>;
  125537. /**
  125538. * The friendly name of the effect displayed in Spector.
  125539. */
  125540. name?: string;
  125541. }
  125542. /**
  125543. * Wraps an effect to be used for rendering
  125544. */
  125545. export class EffectWrapper {
  125546. /**
  125547. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  125548. */
  125549. onApplyObservable: Observable<{}>;
  125550. /**
  125551. * The underlying effect
  125552. */
  125553. effect: Effect;
  125554. /**
  125555. * Creates an effect to be renderer
  125556. * @param creationOptions options to create the effect
  125557. */
  125558. constructor(creationOptions: EffectWrapperCreationOptions);
  125559. /**
  125560. * Disposes of the effect wrapper
  125561. */
  125562. dispose(): void;
  125563. }
  125564. }
  125565. declare module BABYLON {
  125566. /**
  125567. * Helper class to push actions to a pool of workers.
  125568. */
  125569. export class WorkerPool implements IDisposable {
  125570. private _workerInfos;
  125571. private _pendingActions;
  125572. /**
  125573. * Constructor
  125574. * @param workers Array of workers to use for actions
  125575. */
  125576. constructor(workers: Array<Worker>);
  125577. /**
  125578. * Terminates all workers and clears any pending actions.
  125579. */
  125580. dispose(): void;
  125581. /**
  125582. * Pushes an action to the worker pool. If all the workers are active, the action will be
  125583. * pended until a worker has completed its action.
  125584. * @param action The action to perform. Call onComplete when the action is complete.
  125585. */
  125586. push(action: (worker: Worker, onComplete: () => void) => void): void;
  125587. private _execute;
  125588. }
  125589. }
  125590. declare module BABYLON {
  125591. /**
  125592. * Configuration for Draco compression
  125593. */
  125594. export interface IDracoCompressionConfiguration {
  125595. /**
  125596. * Configuration for the decoder.
  125597. */
  125598. decoder: {
  125599. /**
  125600. * The url to the WebAssembly module.
  125601. */
  125602. wasmUrl?: string;
  125603. /**
  125604. * The url to the WebAssembly binary.
  125605. */
  125606. wasmBinaryUrl?: string;
  125607. /**
  125608. * The url to the fallback JavaScript module.
  125609. */
  125610. fallbackUrl?: string;
  125611. };
  125612. }
  125613. /**
  125614. * Draco compression (https://google.github.io/draco/)
  125615. *
  125616. * This class wraps the Draco module.
  125617. *
  125618. * **Encoder**
  125619. *
  125620. * The encoder is not currently implemented.
  125621. *
  125622. * **Decoder**
  125623. *
  125624. * 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.
  125625. *
  125626. * To update the configuration, use the following code:
  125627. * ```javascript
  125628. * DracoCompression.Configuration = {
  125629. * decoder: {
  125630. * wasmUrl: "<url to the WebAssembly library>",
  125631. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  125632. * fallbackUrl: "<url to the fallback JavaScript library>",
  125633. * }
  125634. * };
  125635. * ```
  125636. *
  125637. * 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.
  125638. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  125639. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  125640. *
  125641. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  125642. * ```javascript
  125643. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  125644. * ```
  125645. *
  125646. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  125647. */
  125648. export class DracoCompression implements IDisposable {
  125649. private _workerPoolPromise?;
  125650. private _decoderModulePromise?;
  125651. /**
  125652. * The configuration. Defaults to the following urls:
  125653. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  125654. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  125655. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  125656. */
  125657. static Configuration: IDracoCompressionConfiguration;
  125658. /**
  125659. * Returns true if the decoder configuration is available.
  125660. */
  125661. static readonly DecoderAvailable: boolean;
  125662. /**
  125663. * Default number of workers to create when creating the draco compression object.
  125664. */
  125665. static DefaultNumWorkers: number;
  125666. private static GetDefaultNumWorkers;
  125667. private static _Default;
  125668. /**
  125669. * Default instance for the draco compression object.
  125670. */
  125671. static readonly Default: DracoCompression;
  125672. /**
  125673. * Constructor
  125674. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  125675. */
  125676. constructor(numWorkers?: number);
  125677. /**
  125678. * Stop all async operations and release resources.
  125679. */
  125680. dispose(): void;
  125681. /**
  125682. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  125683. * @returns a promise that resolves when ready
  125684. */
  125685. whenReadyAsync(): Promise<void>;
  125686. /**
  125687. * Decode Draco compressed mesh data to vertex data.
  125688. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  125689. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  125690. * @returns A promise that resolves with the decoded vertex data
  125691. */
  125692. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  125693. [kind: string]: number;
  125694. }): Promise<VertexData>;
  125695. }
  125696. }
  125697. declare module BABYLON {
  125698. /**
  125699. * Class for building Constructive Solid Geometry
  125700. */
  125701. export class CSG {
  125702. private polygons;
  125703. /**
  125704. * The world matrix
  125705. */
  125706. matrix: Matrix;
  125707. /**
  125708. * Stores the position
  125709. */
  125710. position: Vector3;
  125711. /**
  125712. * Stores the rotation
  125713. */
  125714. rotation: Vector3;
  125715. /**
  125716. * Stores the rotation quaternion
  125717. */
  125718. rotationQuaternion: Nullable<Quaternion>;
  125719. /**
  125720. * Stores the scaling vector
  125721. */
  125722. scaling: Vector3;
  125723. /**
  125724. * Convert the Mesh to CSG
  125725. * @param mesh The Mesh to convert to CSG
  125726. * @returns A new CSG from the Mesh
  125727. */
  125728. static FromMesh(mesh: Mesh): CSG;
  125729. /**
  125730. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  125731. * @param polygons Polygons used to construct a CSG solid
  125732. */
  125733. private static FromPolygons;
  125734. /**
  125735. * Clones, or makes a deep copy, of the CSG
  125736. * @returns A new CSG
  125737. */
  125738. clone(): CSG;
  125739. /**
  125740. * Unions this CSG with another CSG
  125741. * @param csg The CSG to union against this CSG
  125742. * @returns The unioned CSG
  125743. */
  125744. union(csg: CSG): CSG;
  125745. /**
  125746. * Unions this CSG with another CSG in place
  125747. * @param csg The CSG to union against this CSG
  125748. */
  125749. unionInPlace(csg: CSG): void;
  125750. /**
  125751. * Subtracts this CSG with another CSG
  125752. * @param csg The CSG to subtract against this CSG
  125753. * @returns A new CSG
  125754. */
  125755. subtract(csg: CSG): CSG;
  125756. /**
  125757. * Subtracts this CSG with another CSG in place
  125758. * @param csg The CSG to subtact against this CSG
  125759. */
  125760. subtractInPlace(csg: CSG): void;
  125761. /**
  125762. * Intersect this CSG with another CSG
  125763. * @param csg The CSG to intersect against this CSG
  125764. * @returns A new CSG
  125765. */
  125766. intersect(csg: CSG): CSG;
  125767. /**
  125768. * Intersects this CSG with another CSG in place
  125769. * @param csg The CSG to intersect against this CSG
  125770. */
  125771. intersectInPlace(csg: CSG): void;
  125772. /**
  125773. * Return a new CSG solid with solid and empty space switched. This solid is
  125774. * not modified.
  125775. * @returns A new CSG solid with solid and empty space switched
  125776. */
  125777. inverse(): CSG;
  125778. /**
  125779. * Inverses the CSG in place
  125780. */
  125781. inverseInPlace(): void;
  125782. /**
  125783. * This is used to keep meshes transformations so they can be restored
  125784. * when we build back a Babylon Mesh
  125785. * NB : All CSG operations are performed in world coordinates
  125786. * @param csg The CSG to copy the transform attributes from
  125787. * @returns This CSG
  125788. */
  125789. copyTransformAttributes(csg: CSG): CSG;
  125790. /**
  125791. * Build Raw mesh from CSG
  125792. * Coordinates here are in world space
  125793. * @param name The name of the mesh geometry
  125794. * @param scene The Scene
  125795. * @param keepSubMeshes Specifies if the submeshes should be kept
  125796. * @returns A new Mesh
  125797. */
  125798. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  125799. /**
  125800. * Build Mesh from CSG taking material and transforms into account
  125801. * @param name The name of the Mesh
  125802. * @param material The material of the Mesh
  125803. * @param scene The Scene
  125804. * @param keepSubMeshes Specifies if submeshes should be kept
  125805. * @returns The new Mesh
  125806. */
  125807. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  125808. }
  125809. }
  125810. declare module BABYLON {
  125811. /**
  125812. * Class used to create a trail following a mesh
  125813. */
  125814. export class TrailMesh extends Mesh {
  125815. private _generator;
  125816. private _autoStart;
  125817. private _running;
  125818. private _diameter;
  125819. private _length;
  125820. private _sectionPolygonPointsCount;
  125821. private _sectionVectors;
  125822. private _sectionNormalVectors;
  125823. private _beforeRenderObserver;
  125824. /**
  125825. * @constructor
  125826. * @param name The value used by scene.getMeshByName() to do a lookup.
  125827. * @param generator The mesh to generate a trail.
  125828. * @param scene The scene to add this mesh to.
  125829. * @param diameter Diameter of trailing mesh. Default is 1.
  125830. * @param length Length of trailing mesh. Default is 60.
  125831. * @param autoStart Automatically start trailing mesh. Default true.
  125832. */
  125833. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  125834. /**
  125835. * "TrailMesh"
  125836. * @returns "TrailMesh"
  125837. */
  125838. getClassName(): string;
  125839. private _createMesh;
  125840. /**
  125841. * Start trailing mesh.
  125842. */
  125843. start(): void;
  125844. /**
  125845. * Stop trailing mesh.
  125846. */
  125847. stop(): void;
  125848. /**
  125849. * Update trailing mesh geometry.
  125850. */
  125851. update(): void;
  125852. /**
  125853. * Returns a new TrailMesh object.
  125854. * @param name is a string, the name given to the new mesh
  125855. * @param newGenerator use new generator object for cloned trail mesh
  125856. * @returns a new mesh
  125857. */
  125858. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  125859. /**
  125860. * Serializes this trail mesh
  125861. * @param serializationObject object to write serialization to
  125862. */
  125863. serialize(serializationObject: any): void;
  125864. /**
  125865. * Parses a serialized trail mesh
  125866. * @param parsedMesh the serialized mesh
  125867. * @param scene the scene to create the trail mesh in
  125868. * @returns the created trail mesh
  125869. */
  125870. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  125871. }
  125872. }
  125873. declare module BABYLON {
  125874. /**
  125875. * Class containing static functions to help procedurally build meshes
  125876. */
  125877. export class TiledBoxBuilder {
  125878. /**
  125879. * Creates a box mesh
  125880. * 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)
  125881. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125885. * @param name defines the name of the mesh
  125886. * @param options defines the options used to create the mesh
  125887. * @param scene defines the hosting scene
  125888. * @returns the box mesh
  125889. */
  125890. static CreateTiledBox(name: string, options: {
  125891. pattern?: number;
  125892. width?: number;
  125893. height?: number;
  125894. depth?: number;
  125895. tileSize?: number;
  125896. tileWidth?: number;
  125897. tileHeight?: number;
  125898. alignHorizontal?: number;
  125899. alignVertical?: number;
  125900. faceUV?: Vector4[];
  125901. faceColors?: Color4[];
  125902. sideOrientation?: number;
  125903. updatable?: boolean;
  125904. }, scene?: Nullable<Scene>): Mesh;
  125905. }
  125906. }
  125907. declare module BABYLON {
  125908. /**
  125909. * Class containing static functions to help procedurally build meshes
  125910. */
  125911. export class TorusKnotBuilder {
  125912. /**
  125913. * Creates a torus knot mesh
  125914. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125915. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125916. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125917. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125921. * @param name defines the name of the mesh
  125922. * @param options defines the options used to create the mesh
  125923. * @param scene defines the hosting scene
  125924. * @returns the torus knot mesh
  125925. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125926. */
  125927. static CreateTorusKnot(name: string, options: {
  125928. radius?: number;
  125929. tube?: number;
  125930. radialSegments?: number;
  125931. tubularSegments?: number;
  125932. p?: number;
  125933. q?: number;
  125934. updatable?: boolean;
  125935. sideOrientation?: number;
  125936. frontUVs?: Vector4;
  125937. backUVs?: Vector4;
  125938. }, scene: any): Mesh;
  125939. }
  125940. }
  125941. declare module BABYLON {
  125942. /**
  125943. * Polygon
  125944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  125945. */
  125946. export class Polygon {
  125947. /**
  125948. * Creates a rectangle
  125949. * @param xmin bottom X coord
  125950. * @param ymin bottom Y coord
  125951. * @param xmax top X coord
  125952. * @param ymax top Y coord
  125953. * @returns points that make the resulting rectation
  125954. */
  125955. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  125956. /**
  125957. * Creates a circle
  125958. * @param radius radius of circle
  125959. * @param cx scale in x
  125960. * @param cy scale in y
  125961. * @param numberOfSides number of sides that make up the circle
  125962. * @returns points that make the resulting circle
  125963. */
  125964. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  125965. /**
  125966. * Creates a polygon from input string
  125967. * @param input Input polygon data
  125968. * @returns the parsed points
  125969. */
  125970. static Parse(input: string): Vector2[];
  125971. /**
  125972. * Starts building a polygon from x and y coordinates
  125973. * @param x x coordinate
  125974. * @param y y coordinate
  125975. * @returns the started path2
  125976. */
  125977. static StartingAt(x: number, y: number): Path2;
  125978. }
  125979. /**
  125980. * Builds a polygon
  125981. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  125982. */
  125983. export class PolygonMeshBuilder {
  125984. private _points;
  125985. private _outlinepoints;
  125986. private _holes;
  125987. private _name;
  125988. private _scene;
  125989. private _epoints;
  125990. private _eholes;
  125991. private _addToepoint;
  125992. /**
  125993. * Babylon reference to the earcut plugin.
  125994. */
  125995. bjsEarcut: any;
  125996. /**
  125997. * Creates a PolygonMeshBuilder
  125998. * @param name name of the builder
  125999. * @param contours Path of the polygon
  126000. * @param scene scene to add to when creating the mesh
  126001. * @param earcutInjection can be used to inject your own earcut reference
  126002. */
  126003. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  126004. /**
  126005. * Adds a whole within the polygon
  126006. * @param hole Array of points defining the hole
  126007. * @returns this
  126008. */
  126009. addHole(hole: Vector2[]): PolygonMeshBuilder;
  126010. /**
  126011. * Creates the polygon
  126012. * @param updatable If the mesh should be updatable
  126013. * @param depth The depth of the mesh created
  126014. * @returns the created mesh
  126015. */
  126016. build(updatable?: boolean, depth?: number): Mesh;
  126017. /**
  126018. * Creates the polygon
  126019. * @param depth The depth of the mesh created
  126020. * @returns the created VertexData
  126021. */
  126022. buildVertexData(depth?: number): VertexData;
  126023. /**
  126024. * Adds a side to the polygon
  126025. * @param positions points that make the polygon
  126026. * @param normals normals of the polygon
  126027. * @param uvs uvs of the polygon
  126028. * @param indices indices of the polygon
  126029. * @param bounds bounds of the polygon
  126030. * @param points points of the polygon
  126031. * @param depth depth of the polygon
  126032. * @param flip flip of the polygon
  126033. */
  126034. private addSide;
  126035. }
  126036. }
  126037. declare module BABYLON {
  126038. /**
  126039. * Class containing static functions to help procedurally build meshes
  126040. */
  126041. export class PolygonBuilder {
  126042. /**
  126043. * Creates a polygon mesh
  126044. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126045. * * 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
  126046. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126049. * * Remember you can only change the shape positions, not their number when updating a polygon
  126050. * @param name defines the name of the mesh
  126051. * @param options defines the options used to create the mesh
  126052. * @param scene defines the hosting scene
  126053. * @param earcutInjection can be used to inject your own earcut reference
  126054. * @returns the polygon mesh
  126055. */
  126056. static CreatePolygon(name: string, options: {
  126057. shape: Vector3[];
  126058. holes?: Vector3[][];
  126059. depth?: number;
  126060. faceUV?: Vector4[];
  126061. faceColors?: Color4[];
  126062. updatable?: boolean;
  126063. sideOrientation?: number;
  126064. frontUVs?: Vector4;
  126065. backUVs?: Vector4;
  126066. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126067. /**
  126068. * Creates an extruded polygon mesh, with depth in the Y direction.
  126069. * * 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)
  126070. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126071. * @param name defines the name of the mesh
  126072. * @param options defines the options used to create the mesh
  126073. * @param scene defines the hosting scene
  126074. * @param earcutInjection can be used to inject your own earcut reference
  126075. * @returns the polygon mesh
  126076. */
  126077. static ExtrudePolygon(name: string, options: {
  126078. shape: Vector3[];
  126079. holes?: Vector3[][];
  126080. depth?: number;
  126081. faceUV?: Vector4[];
  126082. faceColors?: Color4[];
  126083. updatable?: boolean;
  126084. sideOrientation?: number;
  126085. frontUVs?: Vector4;
  126086. backUVs?: Vector4;
  126087. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126088. }
  126089. }
  126090. declare module BABYLON {
  126091. /**
  126092. * Class containing static functions to help procedurally build meshes
  126093. */
  126094. export class LatheBuilder {
  126095. /**
  126096. * Creates lathe mesh.
  126097. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  126098. * * 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
  126099. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  126100. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  126101. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  126102. * * 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
  126103. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  126104. * * 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
  126105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126107. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126109. * @param name defines the name of the mesh
  126110. * @param options defines the options used to create the mesh
  126111. * @param scene defines the hosting scene
  126112. * @returns the lathe mesh
  126113. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  126114. */
  126115. static CreateLathe(name: string, options: {
  126116. shape: Vector3[];
  126117. radius?: number;
  126118. tessellation?: number;
  126119. clip?: number;
  126120. arc?: number;
  126121. closed?: boolean;
  126122. updatable?: boolean;
  126123. sideOrientation?: number;
  126124. frontUVs?: Vector4;
  126125. backUVs?: Vector4;
  126126. cap?: number;
  126127. invertUV?: boolean;
  126128. }, scene?: Nullable<Scene>): Mesh;
  126129. }
  126130. }
  126131. declare module BABYLON {
  126132. /**
  126133. * Class containing static functions to help procedurally build meshes
  126134. */
  126135. export class TiledPlaneBuilder {
  126136. /**
  126137. * Creates a tiled plane mesh
  126138. * * The parameter `pattern` will, depending on value, do nothing or
  126139. * * * flip (reflect about central vertical) alternate tiles across and up
  126140. * * * flip every tile on alternate rows
  126141. * * * rotate (180 degs) alternate tiles across and up
  126142. * * * rotate every tile on alternate rows
  126143. * * * flip and rotate alternate tiles across and up
  126144. * * * flip and rotate every tile on alternate rows
  126145. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  126146. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  126147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126148. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126149. * * 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)
  126150. * * 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)
  126151. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126152. * @param name defines the name of the mesh
  126153. * @param options defines the options used to create the mesh
  126154. * @param scene defines the hosting scene
  126155. * @returns the box mesh
  126156. */
  126157. static CreateTiledPlane(name: string, options: {
  126158. pattern?: number;
  126159. tileSize?: number;
  126160. tileWidth?: number;
  126161. tileHeight?: number;
  126162. size?: number;
  126163. width?: number;
  126164. height?: number;
  126165. alignHorizontal?: number;
  126166. alignVertical?: number;
  126167. sideOrientation?: number;
  126168. frontUVs?: Vector4;
  126169. backUVs?: Vector4;
  126170. updatable?: boolean;
  126171. }, scene?: Nullable<Scene>): Mesh;
  126172. }
  126173. }
  126174. declare module BABYLON {
  126175. /**
  126176. * Class containing static functions to help procedurally build meshes
  126177. */
  126178. export class TubeBuilder {
  126179. /**
  126180. * Creates a tube mesh.
  126181. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126182. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  126183. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  126184. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  126185. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  126186. * * 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)
  126187. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  126188. * * 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
  126189. * * 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
  126190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126194. * @param name defines the name of the mesh
  126195. * @param options defines the options used to create the mesh
  126196. * @param scene defines the hosting scene
  126197. * @returns the tube mesh
  126198. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126199. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126200. */
  126201. static CreateTube(name: string, options: {
  126202. path: Vector3[];
  126203. radius?: number;
  126204. tessellation?: number;
  126205. radiusFunction?: {
  126206. (i: number, distance: number): number;
  126207. };
  126208. cap?: number;
  126209. arc?: number;
  126210. updatable?: boolean;
  126211. sideOrientation?: number;
  126212. frontUVs?: Vector4;
  126213. backUVs?: Vector4;
  126214. instance?: Mesh;
  126215. invertUV?: boolean;
  126216. }, scene?: Nullable<Scene>): Mesh;
  126217. }
  126218. }
  126219. declare module BABYLON {
  126220. /**
  126221. * Class containing static functions to help procedurally build meshes
  126222. */
  126223. export class IcoSphereBuilder {
  126224. /**
  126225. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126226. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126227. * * 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`)
  126228. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126229. * * 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
  126230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126233. * @param name defines the name of the mesh
  126234. * @param options defines the options used to create the mesh
  126235. * @param scene defines the hosting scene
  126236. * @returns the icosahedron mesh
  126237. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126238. */
  126239. static CreateIcoSphere(name: string, options: {
  126240. radius?: number;
  126241. radiusX?: number;
  126242. radiusY?: number;
  126243. radiusZ?: number;
  126244. flat?: boolean;
  126245. subdivisions?: number;
  126246. sideOrientation?: number;
  126247. frontUVs?: Vector4;
  126248. backUVs?: Vector4;
  126249. updatable?: boolean;
  126250. }, scene?: Nullable<Scene>): Mesh;
  126251. }
  126252. }
  126253. declare module BABYLON {
  126254. /**
  126255. * Class containing static functions to help procedurally build meshes
  126256. */
  126257. export class DecalBuilder {
  126258. /**
  126259. * Creates a decal mesh.
  126260. * 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
  126261. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126262. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126263. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126264. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126265. * @param name defines the name of the mesh
  126266. * @param sourceMesh defines the mesh where the decal must be applied
  126267. * @param options defines the options used to create the mesh
  126268. * @param scene defines the hosting scene
  126269. * @returns the decal mesh
  126270. * @see https://doc.babylonjs.com/how_to/decals
  126271. */
  126272. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126273. position?: Vector3;
  126274. normal?: Vector3;
  126275. size?: Vector3;
  126276. angle?: number;
  126277. }): Mesh;
  126278. }
  126279. }
  126280. declare module BABYLON {
  126281. /**
  126282. * Class containing static functions to help procedurally build meshes
  126283. */
  126284. export class MeshBuilder {
  126285. /**
  126286. * Creates a box mesh
  126287. * * The parameter `size` sets the size (float) of each box side (default 1)
  126288. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126289. * * 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)
  126290. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126294. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126295. * @param name defines the name of the mesh
  126296. * @param options defines the options used to create the mesh
  126297. * @param scene defines the hosting scene
  126298. * @returns the box mesh
  126299. */
  126300. static CreateBox(name: string, options: {
  126301. size?: number;
  126302. width?: number;
  126303. height?: number;
  126304. depth?: number;
  126305. faceUV?: Vector4[];
  126306. faceColors?: Color4[];
  126307. sideOrientation?: number;
  126308. frontUVs?: Vector4;
  126309. backUVs?: Vector4;
  126310. updatable?: boolean;
  126311. }, scene?: Nullable<Scene>): Mesh;
  126312. /**
  126313. * Creates a tiled box mesh
  126314. * * faceTiles sets the pattern, tile size and number of tiles for a face
  126315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126316. * @param name defines the name of the mesh
  126317. * @param options defines the options used to create the mesh
  126318. * @param scene defines the hosting scene
  126319. * @returns the tiled box mesh
  126320. */
  126321. static CreateTiledBox(name: string, options: {
  126322. pattern?: number;
  126323. size?: number;
  126324. width?: number;
  126325. height?: number;
  126326. depth: number;
  126327. tileSize?: number;
  126328. tileWidth?: number;
  126329. tileHeight?: number;
  126330. faceUV?: Vector4[];
  126331. faceColors?: Color4[];
  126332. alignHorizontal?: number;
  126333. alignVertical?: number;
  126334. sideOrientation?: number;
  126335. updatable?: boolean;
  126336. }, scene?: Nullable<Scene>): Mesh;
  126337. /**
  126338. * Creates a sphere mesh
  126339. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126340. * * 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`)
  126341. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126342. * * 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
  126343. * * 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)
  126344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126347. * @param name defines the name of the mesh
  126348. * @param options defines the options used to create the mesh
  126349. * @param scene defines the hosting scene
  126350. * @returns the sphere mesh
  126351. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126352. */
  126353. static CreateSphere(name: string, options: {
  126354. segments?: number;
  126355. diameter?: number;
  126356. diameterX?: number;
  126357. diameterY?: number;
  126358. diameterZ?: number;
  126359. arc?: number;
  126360. slice?: number;
  126361. sideOrientation?: number;
  126362. frontUVs?: Vector4;
  126363. backUVs?: Vector4;
  126364. updatable?: boolean;
  126365. }, scene?: Nullable<Scene>): Mesh;
  126366. /**
  126367. * Creates a plane polygonal mesh. By default, this is a disc
  126368. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  126369. * * 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
  126370. * * 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
  126371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126374. * @param name defines the name of the mesh
  126375. * @param options defines the options used to create the mesh
  126376. * @param scene defines the hosting scene
  126377. * @returns the plane polygonal mesh
  126378. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  126379. */
  126380. static CreateDisc(name: string, options: {
  126381. radius?: number;
  126382. tessellation?: number;
  126383. arc?: number;
  126384. updatable?: boolean;
  126385. sideOrientation?: number;
  126386. frontUVs?: Vector4;
  126387. backUVs?: Vector4;
  126388. }, scene?: Nullable<Scene>): Mesh;
  126389. /**
  126390. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126391. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126392. * * 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`)
  126393. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126394. * * 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
  126395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126398. * @param name defines the name of the mesh
  126399. * @param options defines the options used to create the mesh
  126400. * @param scene defines the hosting scene
  126401. * @returns the icosahedron mesh
  126402. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126403. */
  126404. static CreateIcoSphere(name: string, options: {
  126405. radius?: number;
  126406. radiusX?: number;
  126407. radiusY?: number;
  126408. radiusZ?: number;
  126409. flat?: boolean;
  126410. subdivisions?: number;
  126411. sideOrientation?: number;
  126412. frontUVs?: Vector4;
  126413. backUVs?: Vector4;
  126414. updatable?: boolean;
  126415. }, scene?: Nullable<Scene>): Mesh;
  126416. /**
  126417. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126418. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  126419. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  126420. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  126421. * * 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
  126422. * * 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
  126423. * * 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
  126424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126427. * * 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
  126428. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  126429. * * 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
  126430. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  126431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126432. * @param name defines the name of the mesh
  126433. * @param options defines the options used to create the mesh
  126434. * @param scene defines the hosting scene
  126435. * @returns the ribbon mesh
  126436. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  126437. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126438. */
  126439. static CreateRibbon(name: string, options: {
  126440. pathArray: Vector3[][];
  126441. closeArray?: boolean;
  126442. closePath?: boolean;
  126443. offset?: number;
  126444. updatable?: boolean;
  126445. sideOrientation?: number;
  126446. frontUVs?: Vector4;
  126447. backUVs?: Vector4;
  126448. instance?: Mesh;
  126449. invertUV?: boolean;
  126450. uvs?: Vector2[];
  126451. colors?: Color4[];
  126452. }, scene?: Nullable<Scene>): Mesh;
  126453. /**
  126454. * Creates a cylinder or a cone mesh
  126455. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126456. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126457. * * 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.
  126458. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126459. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126460. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126461. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126462. * * 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).
  126463. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126464. * * 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).
  126465. * * 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
  126466. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  126467. * * 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
  126468. * * 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.
  126469. * * If `enclose` is false, a ring surface is one element.
  126470. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  126471. * * 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
  126472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126475. * @param name defines the name of the mesh
  126476. * @param options defines the options used to create the mesh
  126477. * @param scene defines the hosting scene
  126478. * @returns the cylinder mesh
  126479. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  126480. */
  126481. static CreateCylinder(name: string, options: {
  126482. height?: number;
  126483. diameterTop?: number;
  126484. diameterBottom?: number;
  126485. diameter?: number;
  126486. tessellation?: number;
  126487. subdivisions?: number;
  126488. arc?: number;
  126489. faceColors?: Color4[];
  126490. faceUV?: Vector4[];
  126491. updatable?: boolean;
  126492. hasRings?: boolean;
  126493. enclose?: boolean;
  126494. cap?: number;
  126495. sideOrientation?: number;
  126496. frontUVs?: Vector4;
  126497. backUVs?: Vector4;
  126498. }, scene?: Nullable<Scene>): Mesh;
  126499. /**
  126500. * Creates a torus mesh
  126501. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  126502. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  126503. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  126504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126507. * @param name defines the name of the mesh
  126508. * @param options defines the options used to create the mesh
  126509. * @param scene defines the hosting scene
  126510. * @returns the torus mesh
  126511. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  126512. */
  126513. static CreateTorus(name: string, options: {
  126514. diameter?: number;
  126515. thickness?: number;
  126516. tessellation?: number;
  126517. updatable?: boolean;
  126518. sideOrientation?: number;
  126519. frontUVs?: Vector4;
  126520. backUVs?: Vector4;
  126521. }, scene?: Nullable<Scene>): Mesh;
  126522. /**
  126523. * Creates a torus knot mesh
  126524. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  126525. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  126526. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  126527. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  126528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126529. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126531. * @param name defines the name of the mesh
  126532. * @param options defines the options used to create the mesh
  126533. * @param scene defines the hosting scene
  126534. * @returns the torus knot mesh
  126535. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  126536. */
  126537. static CreateTorusKnot(name: string, options: {
  126538. radius?: number;
  126539. tube?: number;
  126540. radialSegments?: number;
  126541. tubularSegments?: number;
  126542. p?: number;
  126543. q?: number;
  126544. updatable?: boolean;
  126545. sideOrientation?: number;
  126546. frontUVs?: Vector4;
  126547. backUVs?: Vector4;
  126548. }, scene?: Nullable<Scene>): Mesh;
  126549. /**
  126550. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  126551. * * 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
  126552. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126553. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126554. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126555. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126556. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126557. * * 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
  126558. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126561. * @param name defines the name of the new line system
  126562. * @param options defines the options used to create the line system
  126563. * @param scene defines the hosting scene
  126564. * @returns a new line system mesh
  126565. */
  126566. static CreateLineSystem(name: string, options: {
  126567. lines: Vector3[][];
  126568. updatable?: boolean;
  126569. instance?: Nullable<LinesMesh>;
  126570. colors?: Nullable<Color4[][]>;
  126571. useVertexAlpha?: boolean;
  126572. }, scene: Nullable<Scene>): LinesMesh;
  126573. /**
  126574. * Creates a line mesh
  126575. * 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
  126576. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126577. * * The parameter `points` is an array successive Vector3
  126578. * * 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
  126579. * * The optional parameter `colors` is an array of successive Color4, one per line point
  126580. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  126581. * * When updating an instance, remember that only point positions can change, not the number of points
  126582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126583. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  126584. * @param name defines the name of the new line system
  126585. * @param options defines the options used to create the line system
  126586. * @param scene defines the hosting scene
  126587. * @returns a new line mesh
  126588. */
  126589. static CreateLines(name: string, options: {
  126590. points: Vector3[];
  126591. updatable?: boolean;
  126592. instance?: Nullable<LinesMesh>;
  126593. colors?: Color4[];
  126594. useVertexAlpha?: boolean;
  126595. }, scene?: Nullable<Scene>): LinesMesh;
  126596. /**
  126597. * Creates a dashed line mesh
  126598. * * 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
  126599. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126600. * * The parameter `points` is an array successive Vector3
  126601. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  126602. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  126603. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  126604. * * 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
  126605. * * When updating an instance, remember that only point positions can change, not the number of points
  126606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126607. * @param name defines the name of the mesh
  126608. * @param options defines the options used to create the mesh
  126609. * @param scene defines the hosting scene
  126610. * @returns the dashed line mesh
  126611. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  126612. */
  126613. static CreateDashedLines(name: string, options: {
  126614. points: Vector3[];
  126615. dashSize?: number;
  126616. gapSize?: number;
  126617. dashNb?: number;
  126618. updatable?: boolean;
  126619. instance?: LinesMesh;
  126620. }, scene?: Nullable<Scene>): LinesMesh;
  126621. /**
  126622. * 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.
  126623. * * 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.
  126624. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  126625. * * 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.
  126626. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  126627. * * 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
  126628. * * 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
  126629. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  126630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126632. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  126633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126634. * @param name defines the name of the mesh
  126635. * @param options defines the options used to create the mesh
  126636. * @param scene defines the hosting scene
  126637. * @returns the extruded shape mesh
  126638. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  126640. */
  126641. static ExtrudeShape(name: string, options: {
  126642. shape: Vector3[];
  126643. path: Vector3[];
  126644. scale?: number;
  126645. rotation?: number;
  126646. cap?: number;
  126647. updatable?: boolean;
  126648. sideOrientation?: number;
  126649. frontUVs?: Vector4;
  126650. backUVs?: Vector4;
  126651. instance?: Mesh;
  126652. invertUV?: boolean;
  126653. }, scene?: Nullable<Scene>): Mesh;
  126654. /**
  126655. * Creates an custom extruded shape mesh.
  126656. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  126657. * * 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.
  126658. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  126659. * * 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
  126660. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  126661. * * 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
  126662. * * It must returns a float value that will be the scale value applied to the shape on each path point
  126663. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  126664. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  126665. * * 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
  126666. * * 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
  126667. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  126668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126672. * @param name defines the name of the mesh
  126673. * @param options defines the options used to create the mesh
  126674. * @param scene defines the hosting scene
  126675. * @returns the custom extruded shape mesh
  126676. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  126677. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126678. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  126679. */
  126680. static ExtrudeShapeCustom(name: string, options: {
  126681. shape: Vector3[];
  126682. path: Vector3[];
  126683. scaleFunction?: any;
  126684. rotationFunction?: any;
  126685. ribbonCloseArray?: boolean;
  126686. ribbonClosePath?: boolean;
  126687. cap?: number;
  126688. updatable?: boolean;
  126689. sideOrientation?: number;
  126690. frontUVs?: Vector4;
  126691. backUVs?: Vector4;
  126692. instance?: Mesh;
  126693. invertUV?: boolean;
  126694. }, scene?: Nullable<Scene>): Mesh;
  126695. /**
  126696. * Creates lathe mesh.
  126697. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  126698. * * 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
  126699. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  126700. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  126701. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  126702. * * 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
  126703. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  126704. * * 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
  126705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126707. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126709. * @param name defines the name of the mesh
  126710. * @param options defines the options used to create the mesh
  126711. * @param scene defines the hosting scene
  126712. * @returns the lathe mesh
  126713. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  126714. */
  126715. static CreateLathe(name: string, options: {
  126716. shape: Vector3[];
  126717. radius?: number;
  126718. tessellation?: number;
  126719. clip?: number;
  126720. arc?: number;
  126721. closed?: boolean;
  126722. updatable?: boolean;
  126723. sideOrientation?: number;
  126724. frontUVs?: Vector4;
  126725. backUVs?: Vector4;
  126726. cap?: number;
  126727. invertUV?: boolean;
  126728. }, scene?: Nullable<Scene>): Mesh;
  126729. /**
  126730. * Creates a tiled plane mesh
  126731. * * You can set a limited pattern arrangement with the tiles
  126732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126735. * @param name defines the name of the mesh
  126736. * @param options defines the options used to create the mesh
  126737. * @param scene defines the hosting scene
  126738. * @returns the plane mesh
  126739. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  126740. */
  126741. static CreateTiledPlane(name: string, options: {
  126742. pattern?: number;
  126743. tileSize?: number;
  126744. tileWidth?: number;
  126745. tileHeight?: number;
  126746. size?: number;
  126747. width?: number;
  126748. height?: number;
  126749. alignHorizontal?: number;
  126750. alignVertical?: number;
  126751. sideOrientation?: number;
  126752. frontUVs?: Vector4;
  126753. backUVs?: Vector4;
  126754. updatable?: boolean;
  126755. }, scene?: Nullable<Scene>): Mesh;
  126756. /**
  126757. * Creates a plane mesh
  126758. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  126759. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  126760. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  126761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126762. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126764. * @param name defines the name of the mesh
  126765. * @param options defines the options used to create the mesh
  126766. * @param scene defines the hosting scene
  126767. * @returns the plane mesh
  126768. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  126769. */
  126770. static CreatePlane(name: string, options: {
  126771. size?: number;
  126772. width?: number;
  126773. height?: number;
  126774. sideOrientation?: number;
  126775. frontUVs?: Vector4;
  126776. backUVs?: Vector4;
  126777. updatable?: boolean;
  126778. sourcePlane?: Plane;
  126779. }, scene?: Nullable<Scene>): Mesh;
  126780. /**
  126781. * Creates a ground mesh
  126782. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126783. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126785. * @param name defines the name of the mesh
  126786. * @param options defines the options used to create the mesh
  126787. * @param scene defines the hosting scene
  126788. * @returns the ground mesh
  126789. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126790. */
  126791. static CreateGround(name: string, options: {
  126792. width?: number;
  126793. height?: number;
  126794. subdivisions?: number;
  126795. subdivisionsX?: number;
  126796. subdivisionsY?: number;
  126797. updatable?: boolean;
  126798. }, scene?: Nullable<Scene>): Mesh;
  126799. /**
  126800. * Creates a tiled ground mesh
  126801. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126802. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126803. * * 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
  126804. * * 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
  126805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126806. * @param name defines the name of the mesh
  126807. * @param options defines the options used to create the mesh
  126808. * @param scene defines the hosting scene
  126809. * @returns the tiled ground mesh
  126810. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126811. */
  126812. static CreateTiledGround(name: string, options: {
  126813. xmin: number;
  126814. zmin: number;
  126815. xmax: number;
  126816. zmax: number;
  126817. subdivisions?: {
  126818. w: number;
  126819. h: number;
  126820. };
  126821. precision?: {
  126822. w: number;
  126823. h: number;
  126824. };
  126825. updatable?: boolean;
  126826. }, scene?: Nullable<Scene>): Mesh;
  126827. /**
  126828. * Creates a ground mesh from a height map
  126829. * * The parameter `url` sets the URL of the height map image resource.
  126830. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126831. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126832. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126833. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126834. * * 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.
  126835. * * 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).
  126836. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126838. * @param name defines the name of the mesh
  126839. * @param url defines the url to the height map
  126840. * @param options defines the options used to create the mesh
  126841. * @param scene defines the hosting scene
  126842. * @returns the ground mesh
  126843. * @see https://doc.babylonjs.com/babylon101/height_map
  126844. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126845. */
  126846. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126847. width?: number;
  126848. height?: number;
  126849. subdivisions?: number;
  126850. minHeight?: number;
  126851. maxHeight?: number;
  126852. colorFilter?: Color3;
  126853. alphaFilter?: number;
  126854. updatable?: boolean;
  126855. onReady?: (mesh: GroundMesh) => void;
  126856. }, scene?: Nullable<Scene>): GroundMesh;
  126857. /**
  126858. * Creates a polygon mesh
  126859. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126860. * * 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
  126861. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126863. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126864. * * Remember you can only change the shape positions, not their number when updating a polygon
  126865. * @param name defines the name of the mesh
  126866. * @param options defines the options used to create the mesh
  126867. * @param scene defines the hosting scene
  126868. * @param earcutInjection can be used to inject your own earcut reference
  126869. * @returns the polygon mesh
  126870. */
  126871. static CreatePolygon(name: string, options: {
  126872. shape: Vector3[];
  126873. holes?: Vector3[][];
  126874. depth?: number;
  126875. faceUV?: Vector4[];
  126876. faceColors?: Color4[];
  126877. updatable?: boolean;
  126878. sideOrientation?: number;
  126879. frontUVs?: Vector4;
  126880. backUVs?: Vector4;
  126881. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126882. /**
  126883. * Creates an extruded polygon mesh, with depth in the Y direction.
  126884. * * 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)
  126885. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126886. * @param name defines the name of the mesh
  126887. * @param options defines the options used to create the mesh
  126888. * @param scene defines the hosting scene
  126889. * @param earcutInjection can be used to inject your own earcut reference
  126890. * @returns the polygon mesh
  126891. */
  126892. static ExtrudePolygon(name: string, options: {
  126893. shape: Vector3[];
  126894. holes?: Vector3[][];
  126895. depth?: number;
  126896. faceUV?: Vector4[];
  126897. faceColors?: Color4[];
  126898. updatable?: boolean;
  126899. sideOrientation?: number;
  126900. frontUVs?: Vector4;
  126901. backUVs?: Vector4;
  126902. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126903. /**
  126904. * Creates a tube mesh.
  126905. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126906. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  126907. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  126908. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  126909. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  126910. * * 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)
  126911. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  126912. * * 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
  126913. * * 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
  126914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126916. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126918. * @param name defines the name of the mesh
  126919. * @param options defines the options used to create the mesh
  126920. * @param scene defines the hosting scene
  126921. * @returns the tube mesh
  126922. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126923. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126924. */
  126925. static CreateTube(name: string, options: {
  126926. path: Vector3[];
  126927. radius?: number;
  126928. tessellation?: number;
  126929. radiusFunction?: {
  126930. (i: number, distance: number): number;
  126931. };
  126932. cap?: number;
  126933. arc?: number;
  126934. updatable?: boolean;
  126935. sideOrientation?: number;
  126936. frontUVs?: Vector4;
  126937. backUVs?: Vector4;
  126938. instance?: Mesh;
  126939. invertUV?: boolean;
  126940. }, scene?: Nullable<Scene>): Mesh;
  126941. /**
  126942. * Creates a polyhedron mesh
  126943. * * 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
  126944. * * The parameter `size` (positive float, default 1) sets the polygon size
  126945. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  126946. * * 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`
  126947. * * 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
  126948. * * 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)`)
  126949. * * 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
  126950. * * 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
  126951. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126954. * @param name defines the name of the mesh
  126955. * @param options defines the options used to create the mesh
  126956. * @param scene defines the hosting scene
  126957. * @returns the polyhedron mesh
  126958. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  126959. */
  126960. static CreatePolyhedron(name: string, options: {
  126961. type?: number;
  126962. size?: number;
  126963. sizeX?: number;
  126964. sizeY?: number;
  126965. sizeZ?: number;
  126966. custom?: any;
  126967. faceUV?: Vector4[];
  126968. faceColors?: Color4[];
  126969. flat?: boolean;
  126970. updatable?: boolean;
  126971. sideOrientation?: number;
  126972. frontUVs?: Vector4;
  126973. backUVs?: Vector4;
  126974. }, scene?: Nullable<Scene>): Mesh;
  126975. /**
  126976. * Creates a decal mesh.
  126977. * 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
  126978. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126979. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126980. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126981. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126982. * @param name defines the name of the mesh
  126983. * @param sourceMesh defines the mesh where the decal must be applied
  126984. * @param options defines the options used to create the mesh
  126985. * @param scene defines the hosting scene
  126986. * @returns the decal mesh
  126987. * @see https://doc.babylonjs.com/how_to/decals
  126988. */
  126989. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126990. position?: Vector3;
  126991. normal?: Vector3;
  126992. size?: Vector3;
  126993. angle?: number;
  126994. }): Mesh;
  126995. }
  126996. }
  126997. declare module BABYLON {
  126998. /**
  126999. * A simplifier interface for future simplification implementations
  127000. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127001. */
  127002. export interface ISimplifier {
  127003. /**
  127004. * Simplification of a given mesh according to the given settings.
  127005. * Since this requires computation, it is assumed that the function runs async.
  127006. * @param settings The settings of the simplification, including quality and distance
  127007. * @param successCallback A callback that will be called after the mesh was simplified.
  127008. * @param errorCallback in case of an error, this callback will be called. optional.
  127009. */
  127010. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  127011. }
  127012. /**
  127013. * Expected simplification settings.
  127014. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  127015. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127016. */
  127017. export interface ISimplificationSettings {
  127018. /**
  127019. * Gets or sets the expected quality
  127020. */
  127021. quality: number;
  127022. /**
  127023. * Gets or sets the distance when this optimized version should be used
  127024. */
  127025. distance: number;
  127026. /**
  127027. * Gets an already optimized mesh
  127028. */
  127029. optimizeMesh?: boolean;
  127030. }
  127031. /**
  127032. * Class used to specify simplification options
  127033. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127034. */
  127035. export class SimplificationSettings implements ISimplificationSettings {
  127036. /** expected quality */
  127037. quality: number;
  127038. /** distance when this optimized version should be used */
  127039. distance: number;
  127040. /** already optimized mesh */
  127041. optimizeMesh?: boolean | undefined;
  127042. /**
  127043. * Creates a SimplificationSettings
  127044. * @param quality expected quality
  127045. * @param distance distance when this optimized version should be used
  127046. * @param optimizeMesh already optimized mesh
  127047. */
  127048. constructor(
  127049. /** expected quality */
  127050. quality: number,
  127051. /** distance when this optimized version should be used */
  127052. distance: number,
  127053. /** already optimized mesh */
  127054. optimizeMesh?: boolean | undefined);
  127055. }
  127056. /**
  127057. * Interface used to define a simplification task
  127058. */
  127059. export interface ISimplificationTask {
  127060. /**
  127061. * Array of settings
  127062. */
  127063. settings: Array<ISimplificationSettings>;
  127064. /**
  127065. * Simplification type
  127066. */
  127067. simplificationType: SimplificationType;
  127068. /**
  127069. * Mesh to simplify
  127070. */
  127071. mesh: Mesh;
  127072. /**
  127073. * Callback called on success
  127074. */
  127075. successCallback?: () => void;
  127076. /**
  127077. * Defines if parallel processing can be used
  127078. */
  127079. parallelProcessing: boolean;
  127080. }
  127081. /**
  127082. * Queue used to order the simplification tasks
  127083. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127084. */
  127085. export class SimplificationQueue {
  127086. private _simplificationArray;
  127087. /**
  127088. * Gets a boolean indicating that the process is still running
  127089. */
  127090. running: boolean;
  127091. /**
  127092. * Creates a new queue
  127093. */
  127094. constructor();
  127095. /**
  127096. * Adds a new simplification task
  127097. * @param task defines a task to add
  127098. */
  127099. addTask(task: ISimplificationTask): void;
  127100. /**
  127101. * Execute next task
  127102. */
  127103. executeNext(): void;
  127104. /**
  127105. * Execute a simplification task
  127106. * @param task defines the task to run
  127107. */
  127108. runSimplification(task: ISimplificationTask): void;
  127109. private getSimplifier;
  127110. }
  127111. /**
  127112. * The implemented types of simplification
  127113. * At the moment only Quadratic Error Decimation is implemented
  127114. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127115. */
  127116. export enum SimplificationType {
  127117. /** Quadratic error decimation */
  127118. QUADRATIC = 0
  127119. }
  127120. }
  127121. declare module BABYLON {
  127122. interface Scene {
  127123. /** @hidden (Backing field) */
  127124. _simplificationQueue: SimplificationQueue;
  127125. /**
  127126. * Gets or sets the simplification queue attached to the scene
  127127. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127128. */
  127129. simplificationQueue: SimplificationQueue;
  127130. }
  127131. interface Mesh {
  127132. /**
  127133. * Simplify the mesh according to the given array of settings.
  127134. * Function will return immediately and will simplify async
  127135. * @param settings a collection of simplification settings
  127136. * @param parallelProcessing should all levels calculate parallel or one after the other
  127137. * @param simplificationType the type of simplification to run
  127138. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  127139. * @returns the current mesh
  127140. */
  127141. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  127142. }
  127143. /**
  127144. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  127145. * created in a scene
  127146. */
  127147. export class SimplicationQueueSceneComponent implements ISceneComponent {
  127148. /**
  127149. * The component name helpfull to identify the component in the list of scene components.
  127150. */
  127151. readonly name: string;
  127152. /**
  127153. * The scene the component belongs to.
  127154. */
  127155. scene: Scene;
  127156. /**
  127157. * Creates a new instance of the component for the given scene
  127158. * @param scene Defines the scene to register the component in
  127159. */
  127160. constructor(scene: Scene);
  127161. /**
  127162. * Registers the component in a given scene
  127163. */
  127164. register(): void;
  127165. /**
  127166. * Rebuilds the elements related to this component in case of
  127167. * context lost for instance.
  127168. */
  127169. rebuild(): void;
  127170. /**
  127171. * Disposes the component and the associated ressources
  127172. */
  127173. dispose(): void;
  127174. private _beforeCameraUpdate;
  127175. }
  127176. }
  127177. declare module BABYLON {
  127178. /**
  127179. * Navigation plugin interface to add navigation constrained by a navigation mesh
  127180. */
  127181. export interface INavigationEnginePlugin {
  127182. /**
  127183. * plugin name
  127184. */
  127185. name: string;
  127186. /**
  127187. * Creates a navigation mesh
  127188. * @param meshes array of all the geometry used to compute the navigatio mesh
  127189. * @param parameters bunch of parameters used to filter geometry
  127190. */
  127191. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  127192. /**
  127193. * Create a navigation mesh debug mesh
  127194. * @param scene is where the mesh will be added
  127195. * @returns debug display mesh
  127196. */
  127197. createDebugNavMesh(scene: Scene): Mesh;
  127198. /**
  127199. * Get a navigation mesh constrained position, closest to the parameter position
  127200. * @param position world position
  127201. * @returns the closest point to position constrained by the navigation mesh
  127202. */
  127203. getClosestPoint(position: Vector3): Vector3;
  127204. /**
  127205. * Get a navigation mesh constrained position, within a particular radius
  127206. * @param position world position
  127207. * @param maxRadius the maximum distance to the constrained world position
  127208. * @returns the closest point to position constrained by the navigation mesh
  127209. */
  127210. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  127211. /**
  127212. * Compute the final position from a segment made of destination-position
  127213. * @param position world position
  127214. * @param destination world position
  127215. * @returns the resulting point along the navmesh
  127216. */
  127217. moveAlong(position: Vector3, destination: Vector3): Vector3;
  127218. /**
  127219. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  127220. * @param start world position
  127221. * @param end world position
  127222. * @returns array containing world position composing the path
  127223. */
  127224. computePath(start: Vector3, end: Vector3): Vector3[];
  127225. /**
  127226. * If this plugin is supported
  127227. * @returns true if plugin is supported
  127228. */
  127229. isSupported(): boolean;
  127230. /**
  127231. * Create a new Crowd so you can add agents
  127232. * @param maxAgents the maximum agent count in the crowd
  127233. * @param maxAgentRadius the maximum radius an agent can have
  127234. * @param scene to attach the crowd to
  127235. * @returns the crowd you can add agents to
  127236. */
  127237. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  127238. /**
  127239. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127240. * The queries will try to find a solution within those bounds
  127241. * default is (1,1,1)
  127242. * @param extent x,y,z value that define the extent around the queries point of reference
  127243. */
  127244. setDefaultQueryExtent(extent: Vector3): void;
  127245. /**
  127246. * Get the Bounding box extent specified by setDefaultQueryExtent
  127247. * @returns the box extent values
  127248. */
  127249. getDefaultQueryExtent(): Vector3;
  127250. /**
  127251. * Release all resources
  127252. */
  127253. dispose(): void;
  127254. }
  127255. /**
  127256. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  127257. */
  127258. export interface ICrowd {
  127259. /**
  127260. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  127261. * You can attach anything to that node. The node position is updated in the scene update tick.
  127262. * @param pos world position that will be constrained by the navigation mesh
  127263. * @param parameters agent parameters
  127264. * @param transform hooked to the agent that will be update by the scene
  127265. * @returns agent index
  127266. */
  127267. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  127268. /**
  127269. * Returns the agent position in world space
  127270. * @param index agent index returned by addAgent
  127271. * @returns world space position
  127272. */
  127273. getAgentPosition(index: number): Vector3;
  127274. /**
  127275. * Gets the agent velocity in world space
  127276. * @param index agent index returned by addAgent
  127277. * @returns world space velocity
  127278. */
  127279. getAgentVelocity(index: number): Vector3;
  127280. /**
  127281. * remove a particular agent previously created
  127282. * @param index agent index returned by addAgent
  127283. */
  127284. removeAgent(index: number): void;
  127285. /**
  127286. * get the list of all agents attached to this crowd
  127287. * @returns list of agent indices
  127288. */
  127289. getAgents(): number[];
  127290. /**
  127291. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  127292. * @param deltaTime in seconds
  127293. */
  127294. update(deltaTime: number): void;
  127295. /**
  127296. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  127297. * @param index agent index returned by addAgent
  127298. * @param destination targeted world position
  127299. */
  127300. agentGoto(index: number, destination: Vector3): void;
  127301. /**
  127302. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127303. * The queries will try to find a solution within those bounds
  127304. * default is (1,1,1)
  127305. * @param extent x,y,z value that define the extent around the queries point of reference
  127306. */
  127307. setDefaultQueryExtent(extent: Vector3): void;
  127308. /**
  127309. * Get the Bounding box extent specified by setDefaultQueryExtent
  127310. * @returns the box extent values
  127311. */
  127312. getDefaultQueryExtent(): Vector3;
  127313. /**
  127314. * Release all resources
  127315. */
  127316. dispose(): void;
  127317. }
  127318. /**
  127319. * Configures an agent
  127320. */
  127321. export interface IAgentParameters {
  127322. /**
  127323. * Agent radius. [Limit: >= 0]
  127324. */
  127325. radius: number;
  127326. /**
  127327. * Agent height. [Limit: > 0]
  127328. */
  127329. height: number;
  127330. /**
  127331. * Maximum allowed acceleration. [Limit: >= 0]
  127332. */
  127333. maxAcceleration: number;
  127334. /**
  127335. * Maximum allowed speed. [Limit: >= 0]
  127336. */
  127337. maxSpeed: number;
  127338. /**
  127339. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  127340. */
  127341. collisionQueryRange: number;
  127342. /**
  127343. * The path visibility optimization range. [Limit: > 0]
  127344. */
  127345. pathOptimizationRange: number;
  127346. /**
  127347. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  127348. */
  127349. separationWeight: number;
  127350. }
  127351. /**
  127352. * Configures the navigation mesh creation
  127353. */
  127354. export interface INavMeshParameters {
  127355. /**
  127356. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  127357. */
  127358. cs: number;
  127359. /**
  127360. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  127361. */
  127362. ch: number;
  127363. /**
  127364. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  127365. */
  127366. walkableSlopeAngle: number;
  127367. /**
  127368. * Minimum floor to 'ceiling' height that will still allow the floor area to
  127369. * be considered walkable. [Limit: >= 3] [Units: vx]
  127370. */
  127371. walkableHeight: number;
  127372. /**
  127373. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  127374. */
  127375. walkableClimb: number;
  127376. /**
  127377. * The distance to erode/shrink the walkable area of the heightfield away from
  127378. * obstructions. [Limit: >=0] [Units: vx]
  127379. */
  127380. walkableRadius: number;
  127381. /**
  127382. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  127383. */
  127384. maxEdgeLen: number;
  127385. /**
  127386. * The maximum distance a simplfied contour's border edges should deviate
  127387. * the original raw contour. [Limit: >=0] [Units: vx]
  127388. */
  127389. maxSimplificationError: number;
  127390. /**
  127391. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  127392. */
  127393. minRegionArea: number;
  127394. /**
  127395. * Any regions with a span count smaller than this value will, if possible,
  127396. * be merged with larger regions. [Limit: >=0] [Units: vx]
  127397. */
  127398. mergeRegionArea: number;
  127399. /**
  127400. * The maximum number of vertices allowed for polygons generated during the
  127401. * contour to polygon conversion process. [Limit: >= 3]
  127402. */
  127403. maxVertsPerPoly: number;
  127404. /**
  127405. * Sets the sampling distance to use when generating the detail mesh.
  127406. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  127407. */
  127408. detailSampleDist: number;
  127409. /**
  127410. * The maximum distance the detail mesh surface should deviate from heightfield
  127411. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  127412. */
  127413. detailSampleMaxError: number;
  127414. }
  127415. }
  127416. declare module BABYLON {
  127417. /**
  127418. * RecastJS navigation plugin
  127419. */
  127420. export class RecastJSPlugin implements INavigationEnginePlugin {
  127421. /**
  127422. * Reference to the Recast library
  127423. */
  127424. bjsRECAST: any;
  127425. /**
  127426. * plugin name
  127427. */
  127428. name: string;
  127429. /**
  127430. * the first navmesh created. We might extend this to support multiple navmeshes
  127431. */
  127432. navMesh: any;
  127433. /**
  127434. * Initializes the recastJS plugin
  127435. * @param recastInjection can be used to inject your own recast reference
  127436. */
  127437. constructor(recastInjection?: any);
  127438. /**
  127439. * Creates a navigation mesh
  127440. * @param meshes array of all the geometry used to compute the navigatio mesh
  127441. * @param parameters bunch of parameters used to filter geometry
  127442. */
  127443. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  127444. /**
  127445. * Create a navigation mesh debug mesh
  127446. * @param scene is where the mesh will be added
  127447. * @returns debug display mesh
  127448. */
  127449. createDebugNavMesh(scene: Scene): Mesh;
  127450. /**
  127451. * Get a navigation mesh constrained position, closest to the parameter position
  127452. * @param position world position
  127453. * @returns the closest point to position constrained by the navigation mesh
  127454. */
  127455. getClosestPoint(position: Vector3): Vector3;
  127456. /**
  127457. * Get a navigation mesh constrained position, within a particular radius
  127458. * @param position world position
  127459. * @param maxRadius the maximum distance to the constrained world position
  127460. * @returns the closest point to position constrained by the navigation mesh
  127461. */
  127462. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  127463. /**
  127464. * Compute the final position from a segment made of destination-position
  127465. * @param position world position
  127466. * @param destination world position
  127467. * @returns the resulting point along the navmesh
  127468. */
  127469. moveAlong(position: Vector3, destination: Vector3): Vector3;
  127470. /**
  127471. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  127472. * @param start world position
  127473. * @param end world position
  127474. * @returns array containing world position composing the path
  127475. */
  127476. computePath(start: Vector3, end: Vector3): Vector3[];
  127477. /**
  127478. * Create a new Crowd so you can add agents
  127479. * @param maxAgents the maximum agent count in the crowd
  127480. * @param maxAgentRadius the maximum radius an agent can have
  127481. * @param scene to attach the crowd to
  127482. * @returns the crowd you can add agents to
  127483. */
  127484. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  127485. /**
  127486. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127487. * The queries will try to find a solution within those bounds
  127488. * default is (1,1,1)
  127489. * @param extent x,y,z value that define the extent around the queries point of reference
  127490. */
  127491. setDefaultQueryExtent(extent: Vector3): void;
  127492. /**
  127493. * Get the Bounding box extent specified by setDefaultQueryExtent
  127494. * @returns the box extent values
  127495. */
  127496. getDefaultQueryExtent(): Vector3;
  127497. /**
  127498. * Disposes
  127499. */
  127500. dispose(): void;
  127501. /**
  127502. * If this plugin is supported
  127503. * @returns true if plugin is supported
  127504. */
  127505. isSupported(): boolean;
  127506. }
  127507. /**
  127508. * Recast detour crowd implementation
  127509. */
  127510. export class RecastJSCrowd implements ICrowd {
  127511. /**
  127512. * Recast/detour plugin
  127513. */
  127514. bjsRECASTPlugin: RecastJSPlugin;
  127515. /**
  127516. * Link to the detour crowd
  127517. */
  127518. recastCrowd: any;
  127519. /**
  127520. * One transform per agent
  127521. */
  127522. transforms: TransformNode[];
  127523. /**
  127524. * All agents created
  127525. */
  127526. agents: number[];
  127527. /**
  127528. * Link to the scene is kept to unregister the crowd from the scene
  127529. */
  127530. private _scene;
  127531. /**
  127532. * Observer for crowd updates
  127533. */
  127534. private _onBeforeAnimationsObserver;
  127535. /**
  127536. * Constructor
  127537. * @param plugin recastJS plugin
  127538. * @param maxAgents the maximum agent count in the crowd
  127539. * @param maxAgentRadius the maximum radius an agent can have
  127540. * @param scene to attach the crowd to
  127541. * @returns the crowd you can add agents to
  127542. */
  127543. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  127544. /**
  127545. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  127546. * You can attach anything to that node. The node position is updated in the scene update tick.
  127547. * @param pos world position that will be constrained by the navigation mesh
  127548. * @param parameters agent parameters
  127549. * @param transform hooked to the agent that will be update by the scene
  127550. * @returns agent index
  127551. */
  127552. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  127553. /**
  127554. * Returns the agent position in world space
  127555. * @param index agent index returned by addAgent
  127556. * @returns world space position
  127557. */
  127558. getAgentPosition(index: number): Vector3;
  127559. /**
  127560. * Returns the agent velocity in world space
  127561. * @param index agent index returned by addAgent
  127562. * @returns world space velocity
  127563. */
  127564. getAgentVelocity(index: number): Vector3;
  127565. /**
  127566. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  127567. * @param index agent index returned by addAgent
  127568. * @param destination targeted world position
  127569. */
  127570. agentGoto(index: number, destination: Vector3): void;
  127571. /**
  127572. * remove a particular agent previously created
  127573. * @param index agent index returned by addAgent
  127574. */
  127575. removeAgent(index: number): void;
  127576. /**
  127577. * get the list of all agents attached to this crowd
  127578. * @returns list of agent indices
  127579. */
  127580. getAgents(): number[];
  127581. /**
  127582. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  127583. * @param deltaTime in seconds
  127584. */
  127585. update(deltaTime: number): void;
  127586. /**
  127587. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127588. * The queries will try to find a solution within those bounds
  127589. * default is (1,1,1)
  127590. * @param extent x,y,z value that define the extent around the queries point of reference
  127591. */
  127592. setDefaultQueryExtent(extent: Vector3): void;
  127593. /**
  127594. * Get the Bounding box extent specified by setDefaultQueryExtent
  127595. * @returns the box extent values
  127596. */
  127597. getDefaultQueryExtent(): Vector3;
  127598. /**
  127599. * Release all resources
  127600. */
  127601. dispose(): void;
  127602. }
  127603. }
  127604. declare module BABYLON {
  127605. /**
  127606. * Class used to enable access to IndexedDB
  127607. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  127608. */
  127609. export class Database implements IOfflineProvider {
  127610. private _callbackManifestChecked;
  127611. private _currentSceneUrl;
  127612. private _db;
  127613. private _enableSceneOffline;
  127614. private _enableTexturesOffline;
  127615. private _manifestVersionFound;
  127616. private _mustUpdateRessources;
  127617. private _hasReachedQuota;
  127618. private _isSupported;
  127619. private _idbFactory;
  127620. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  127621. private static IsUASupportingBlobStorage;
  127622. /**
  127623. * Gets a boolean indicating if Database storate is enabled (off by default)
  127624. */
  127625. static IDBStorageEnabled: boolean;
  127626. /**
  127627. * Gets a boolean indicating if scene must be saved in the database
  127628. */
  127629. readonly enableSceneOffline: boolean;
  127630. /**
  127631. * Gets a boolean indicating if textures must be saved in the database
  127632. */
  127633. readonly enableTexturesOffline: boolean;
  127634. /**
  127635. * Creates a new Database
  127636. * @param urlToScene defines the url to load the scene
  127637. * @param callbackManifestChecked defines the callback to use when manifest is checked
  127638. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  127639. */
  127640. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  127641. private static _ParseURL;
  127642. private static _ReturnFullUrlLocation;
  127643. private _checkManifestFile;
  127644. /**
  127645. * Open the database and make it available
  127646. * @param successCallback defines the callback to call on success
  127647. * @param errorCallback defines the callback to call on error
  127648. */
  127649. open(successCallback: () => void, errorCallback: () => void): void;
  127650. /**
  127651. * Loads an image from the database
  127652. * @param url defines the url to load from
  127653. * @param image defines the target DOM image
  127654. */
  127655. loadImage(url: string, image: HTMLImageElement): void;
  127656. private _loadImageFromDBAsync;
  127657. private _saveImageIntoDBAsync;
  127658. private _checkVersionFromDB;
  127659. private _loadVersionFromDBAsync;
  127660. private _saveVersionIntoDBAsync;
  127661. /**
  127662. * Loads a file from database
  127663. * @param url defines the URL to load from
  127664. * @param sceneLoaded defines a callback to call on success
  127665. * @param progressCallBack defines a callback to call when progress changed
  127666. * @param errorCallback defines a callback to call on error
  127667. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  127668. */
  127669. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  127670. private _loadFileAsync;
  127671. private _saveFileAsync;
  127672. /**
  127673. * Validates if xhr data is correct
  127674. * @param xhr defines the request to validate
  127675. * @param dataType defines the expected data type
  127676. * @returns true if data is correct
  127677. */
  127678. private static _ValidateXHRData;
  127679. }
  127680. }
  127681. declare module BABYLON {
  127682. /** @hidden */
  127683. export var gpuUpdateParticlesPixelShader: {
  127684. name: string;
  127685. shader: string;
  127686. };
  127687. }
  127688. declare module BABYLON {
  127689. /** @hidden */
  127690. export var gpuUpdateParticlesVertexShader: {
  127691. name: string;
  127692. shader: string;
  127693. };
  127694. }
  127695. declare module BABYLON {
  127696. /** @hidden */
  127697. export var clipPlaneFragmentDeclaration2: {
  127698. name: string;
  127699. shader: string;
  127700. };
  127701. }
  127702. declare module BABYLON {
  127703. /** @hidden */
  127704. export var gpuRenderParticlesPixelShader: {
  127705. name: string;
  127706. shader: string;
  127707. };
  127708. }
  127709. declare module BABYLON {
  127710. /** @hidden */
  127711. export var clipPlaneVertexDeclaration2: {
  127712. name: string;
  127713. shader: string;
  127714. };
  127715. }
  127716. declare module BABYLON {
  127717. /** @hidden */
  127718. export var gpuRenderParticlesVertexShader: {
  127719. name: string;
  127720. shader: string;
  127721. };
  127722. }
  127723. declare module BABYLON {
  127724. /**
  127725. * This represents a GPU particle system in Babylon
  127726. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  127727. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  127728. */
  127729. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  127730. /**
  127731. * The layer mask we are rendering the particles through.
  127732. */
  127733. layerMask: number;
  127734. private _capacity;
  127735. private _activeCount;
  127736. private _currentActiveCount;
  127737. private _accumulatedCount;
  127738. private _renderEffect;
  127739. private _updateEffect;
  127740. private _buffer0;
  127741. private _buffer1;
  127742. private _spriteBuffer;
  127743. private _updateVAO;
  127744. private _renderVAO;
  127745. private _targetIndex;
  127746. private _sourceBuffer;
  127747. private _targetBuffer;
  127748. private _engine;
  127749. private _currentRenderId;
  127750. private _started;
  127751. private _stopped;
  127752. private _timeDelta;
  127753. private _randomTexture;
  127754. private _randomTexture2;
  127755. private _attributesStrideSize;
  127756. private _updateEffectOptions;
  127757. private _randomTextureSize;
  127758. private _actualFrame;
  127759. private readonly _rawTextureWidth;
  127760. /**
  127761. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  127762. */
  127763. static readonly IsSupported: boolean;
  127764. /**
  127765. * An event triggered when the system is disposed.
  127766. */
  127767. onDisposeObservable: Observable<GPUParticleSystem>;
  127768. /**
  127769. * Gets the maximum number of particles active at the same time.
  127770. * @returns The max number of active particles.
  127771. */
  127772. getCapacity(): number;
  127773. /**
  127774. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  127775. * to override the particles.
  127776. */
  127777. forceDepthWrite: boolean;
  127778. /**
  127779. * Gets or set the number of active particles
  127780. */
  127781. activeParticleCount: number;
  127782. private _preWarmDone;
  127783. /**
  127784. * Is this system ready to be used/rendered
  127785. * @return true if the system is ready
  127786. */
  127787. isReady(): boolean;
  127788. /**
  127789. * Gets if the system has been started. (Note: this will still be true after stop is called)
  127790. * @returns True if it has been started, otherwise false.
  127791. */
  127792. isStarted(): boolean;
  127793. /**
  127794. * Starts the particle system and begins to emit
  127795. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  127796. */
  127797. start(delay?: number): void;
  127798. /**
  127799. * Stops the particle system.
  127800. */
  127801. stop(): void;
  127802. /**
  127803. * Remove all active particles
  127804. */
  127805. reset(): void;
  127806. /**
  127807. * Returns the string "GPUParticleSystem"
  127808. * @returns a string containing the class name
  127809. */
  127810. getClassName(): string;
  127811. private _colorGradientsTexture;
  127812. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  127813. /**
  127814. * Adds a new color gradient
  127815. * @param gradient defines the gradient to use (between 0 and 1)
  127816. * @param color1 defines the color to affect to the specified gradient
  127817. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  127818. * @returns the current particle system
  127819. */
  127820. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  127821. /**
  127822. * Remove a specific color gradient
  127823. * @param gradient defines the gradient to remove
  127824. * @returns the current particle system
  127825. */
  127826. removeColorGradient(gradient: number): GPUParticleSystem;
  127827. private _angularSpeedGradientsTexture;
  127828. private _sizeGradientsTexture;
  127829. private _velocityGradientsTexture;
  127830. private _limitVelocityGradientsTexture;
  127831. private _dragGradientsTexture;
  127832. private _addFactorGradient;
  127833. /**
  127834. * Adds a new size gradient
  127835. * @param gradient defines the gradient to use (between 0 and 1)
  127836. * @param factor defines the size factor to affect to the specified gradient
  127837. * @returns the current particle system
  127838. */
  127839. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  127840. /**
  127841. * Remove a specific size gradient
  127842. * @param gradient defines the gradient to remove
  127843. * @returns the current particle system
  127844. */
  127845. removeSizeGradient(gradient: number): GPUParticleSystem;
  127846. /**
  127847. * Adds a new angular speed gradient
  127848. * @param gradient defines the gradient to use (between 0 and 1)
  127849. * @param factor defines the angular speed to affect to the specified gradient
  127850. * @returns the current particle system
  127851. */
  127852. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  127853. /**
  127854. * Remove a specific angular speed gradient
  127855. * @param gradient defines the gradient to remove
  127856. * @returns the current particle system
  127857. */
  127858. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  127859. /**
  127860. * Adds a new velocity gradient
  127861. * @param gradient defines the gradient to use (between 0 and 1)
  127862. * @param factor defines the velocity to affect to the specified gradient
  127863. * @returns the current particle system
  127864. */
  127865. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  127866. /**
  127867. * Remove a specific velocity gradient
  127868. * @param gradient defines the gradient to remove
  127869. * @returns the current particle system
  127870. */
  127871. removeVelocityGradient(gradient: number): GPUParticleSystem;
  127872. /**
  127873. * Adds a new limit velocity gradient
  127874. * @param gradient defines the gradient to use (between 0 and 1)
  127875. * @param factor defines the limit velocity value to affect to the specified gradient
  127876. * @returns the current particle system
  127877. */
  127878. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  127879. /**
  127880. * Remove a specific limit velocity gradient
  127881. * @param gradient defines the gradient to remove
  127882. * @returns the current particle system
  127883. */
  127884. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  127885. /**
  127886. * Adds a new drag gradient
  127887. * @param gradient defines the gradient to use (between 0 and 1)
  127888. * @param factor defines the drag value to affect to the specified gradient
  127889. * @returns the current particle system
  127890. */
  127891. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  127892. /**
  127893. * Remove a specific drag gradient
  127894. * @param gradient defines the gradient to remove
  127895. * @returns the current particle system
  127896. */
  127897. removeDragGradient(gradient: number): GPUParticleSystem;
  127898. /**
  127899. * Not supported by GPUParticleSystem
  127900. * @param gradient defines the gradient to use (between 0 and 1)
  127901. * @param factor defines the emit rate value to affect to the specified gradient
  127902. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127903. * @returns the current particle system
  127904. */
  127905. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127906. /**
  127907. * Not supported by GPUParticleSystem
  127908. * @param gradient defines the gradient to remove
  127909. * @returns the current particle system
  127910. */
  127911. removeEmitRateGradient(gradient: number): IParticleSystem;
  127912. /**
  127913. * Not supported by GPUParticleSystem
  127914. * @param gradient defines the gradient to use (between 0 and 1)
  127915. * @param factor defines the start size value to affect to the specified gradient
  127916. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127917. * @returns the current particle system
  127918. */
  127919. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127920. /**
  127921. * Not supported by GPUParticleSystem
  127922. * @param gradient defines the gradient to remove
  127923. * @returns the current particle system
  127924. */
  127925. removeStartSizeGradient(gradient: number): IParticleSystem;
  127926. /**
  127927. * Not supported by GPUParticleSystem
  127928. * @param gradient defines the gradient to use (between 0 and 1)
  127929. * @param min defines the color remap minimal range
  127930. * @param max defines the color remap maximal range
  127931. * @returns the current particle system
  127932. */
  127933. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127934. /**
  127935. * Not supported by GPUParticleSystem
  127936. * @param gradient defines the gradient to remove
  127937. * @returns the current particle system
  127938. */
  127939. removeColorRemapGradient(): IParticleSystem;
  127940. /**
  127941. * Not supported by GPUParticleSystem
  127942. * @param gradient defines the gradient to use (between 0 and 1)
  127943. * @param min defines the alpha remap minimal range
  127944. * @param max defines the alpha remap maximal range
  127945. * @returns the current particle system
  127946. */
  127947. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127948. /**
  127949. * Not supported by GPUParticleSystem
  127950. * @param gradient defines the gradient to remove
  127951. * @returns the current particle system
  127952. */
  127953. removeAlphaRemapGradient(): IParticleSystem;
  127954. /**
  127955. * Not supported by GPUParticleSystem
  127956. * @param gradient defines the gradient to use (between 0 and 1)
  127957. * @param color defines the color to affect to the specified gradient
  127958. * @returns the current particle system
  127959. */
  127960. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  127961. /**
  127962. * Not supported by GPUParticleSystem
  127963. * @param gradient defines the gradient to remove
  127964. * @returns the current particle system
  127965. */
  127966. removeRampGradient(): IParticleSystem;
  127967. /**
  127968. * Not supported by GPUParticleSystem
  127969. * @returns the list of ramp gradients
  127970. */
  127971. getRampGradients(): Nullable<Array<Color3Gradient>>;
  127972. /**
  127973. * Not supported by GPUParticleSystem
  127974. * Gets or sets a boolean indicating that ramp gradients must be used
  127975. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  127976. */
  127977. useRampGradients: boolean;
  127978. /**
  127979. * Not supported by GPUParticleSystem
  127980. * @param gradient defines the gradient to use (between 0 and 1)
  127981. * @param factor defines the life time factor to affect to the specified gradient
  127982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127983. * @returns the current particle system
  127984. */
  127985. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127986. /**
  127987. * Not supported by GPUParticleSystem
  127988. * @param gradient defines the gradient to remove
  127989. * @returns the current particle system
  127990. */
  127991. removeLifeTimeGradient(gradient: number): IParticleSystem;
  127992. /**
  127993. * Instantiates a GPU particle system.
  127994. * 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.
  127995. * @param name The name of the particle system
  127996. * @param options The options used to create the system
  127997. * @param scene The scene the particle system belongs to
  127998. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  127999. */
  128000. constructor(name: string, options: Partial<{
  128001. capacity: number;
  128002. randomTextureSize: number;
  128003. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  128004. protected _reset(): void;
  128005. private _createUpdateVAO;
  128006. private _createRenderVAO;
  128007. private _initialize;
  128008. /** @hidden */
  128009. _recreateUpdateEffect(): void;
  128010. /** @hidden */
  128011. _recreateRenderEffect(): void;
  128012. /**
  128013. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  128014. * @param preWarm defines if we are in the pre-warmimg phase
  128015. */
  128016. animate(preWarm?: boolean): void;
  128017. private _createFactorGradientTexture;
  128018. private _createSizeGradientTexture;
  128019. private _createAngularSpeedGradientTexture;
  128020. private _createVelocityGradientTexture;
  128021. private _createLimitVelocityGradientTexture;
  128022. private _createDragGradientTexture;
  128023. private _createColorGradientTexture;
  128024. /**
  128025. * Renders the particle system in its current state
  128026. * @param preWarm defines if the system should only update the particles but not render them
  128027. * @returns the current number of particles
  128028. */
  128029. render(preWarm?: boolean): number;
  128030. /**
  128031. * Rebuilds the particle system
  128032. */
  128033. rebuild(): void;
  128034. private _releaseBuffers;
  128035. private _releaseVAOs;
  128036. /**
  128037. * Disposes the particle system and free the associated resources
  128038. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  128039. */
  128040. dispose(disposeTexture?: boolean): void;
  128041. /**
  128042. * Clones the particle system.
  128043. * @param name The name of the cloned object
  128044. * @param newEmitter The new emitter to use
  128045. * @returns the cloned particle system
  128046. */
  128047. clone(name: string, newEmitter: any): GPUParticleSystem;
  128048. /**
  128049. * Serializes the particle system to a JSON object.
  128050. * @returns the JSON object
  128051. */
  128052. serialize(): any;
  128053. /**
  128054. * Parses a JSON object to create a GPU particle system.
  128055. * @param parsedParticleSystem The JSON object to parse
  128056. * @param scene The scene to create the particle system in
  128057. * @param rootUrl The root url to use to load external dependencies like texture
  128058. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  128059. * @returns the parsed GPU particle system
  128060. */
  128061. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  128062. }
  128063. }
  128064. declare module BABYLON {
  128065. /**
  128066. * Represents a set of particle systems working together to create a specific effect
  128067. */
  128068. export class ParticleSystemSet implements IDisposable {
  128069. /**
  128070. * Gets or sets base Assets URL
  128071. */
  128072. static BaseAssetsUrl: string;
  128073. private _emitterCreationOptions;
  128074. private _emitterNode;
  128075. /**
  128076. * Gets the particle system list
  128077. */
  128078. systems: IParticleSystem[];
  128079. /**
  128080. * Gets the emitter node used with this set
  128081. */
  128082. readonly emitterNode: Nullable<TransformNode>;
  128083. /**
  128084. * Creates a new emitter mesh as a sphere
  128085. * @param options defines the options used to create the sphere
  128086. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  128087. * @param scene defines the hosting scene
  128088. */
  128089. setEmitterAsSphere(options: {
  128090. diameter: number;
  128091. segments: number;
  128092. color: Color3;
  128093. }, renderingGroupId: number, scene: Scene): void;
  128094. /**
  128095. * Starts all particle systems of the set
  128096. * @param emitter defines an optional mesh to use as emitter for the particle systems
  128097. */
  128098. start(emitter?: AbstractMesh): void;
  128099. /**
  128100. * Release all associated resources
  128101. */
  128102. dispose(): void;
  128103. /**
  128104. * Serialize the set into a JSON compatible object
  128105. * @returns a JSON compatible representation of the set
  128106. */
  128107. serialize(): any;
  128108. /**
  128109. * Parse a new ParticleSystemSet from a serialized source
  128110. * @param data defines a JSON compatible representation of the set
  128111. * @param scene defines the hosting scene
  128112. * @param gpu defines if we want GPU particles or CPU particles
  128113. * @returns a new ParticleSystemSet
  128114. */
  128115. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  128116. }
  128117. }
  128118. declare module BABYLON {
  128119. /**
  128120. * This class is made for on one-liner static method to help creating particle system set.
  128121. */
  128122. export class ParticleHelper {
  128123. /**
  128124. * Gets or sets base Assets URL
  128125. */
  128126. static BaseAssetsUrl: string;
  128127. /**
  128128. * Create a default particle system that you can tweak
  128129. * @param emitter defines the emitter to use
  128130. * @param capacity defines the system capacity (default is 500 particles)
  128131. * @param scene defines the hosting scene
  128132. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  128133. * @returns the new Particle system
  128134. */
  128135. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  128136. /**
  128137. * This is the main static method (one-liner) of this helper to create different particle systems
  128138. * @param type This string represents the type to the particle system to create
  128139. * @param scene The scene where the particle system should live
  128140. * @param gpu If the system will use gpu
  128141. * @returns the ParticleSystemSet created
  128142. */
  128143. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  128144. /**
  128145. * Static function used to export a particle system to a ParticleSystemSet variable.
  128146. * Please note that the emitter shape is not exported
  128147. * @param systems defines the particle systems to export
  128148. * @returns the created particle system set
  128149. */
  128150. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  128151. }
  128152. }
  128153. declare module BABYLON {
  128154. interface Engine {
  128155. /**
  128156. * Create an effect to use with particle systems.
  128157. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  128158. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  128159. * @param uniformsNames defines a list of attribute names
  128160. * @param samplers defines an array of string used to represent textures
  128161. * @param defines defines the string containing the defines to use to compile the shaders
  128162. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  128163. * @param onCompiled defines a function to call when the effect creation is successful
  128164. * @param onError defines a function to call when the effect creation has failed
  128165. * @returns the new Effect
  128166. */
  128167. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  128168. }
  128169. interface Mesh {
  128170. /**
  128171. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  128172. * @returns an array of IParticleSystem
  128173. */
  128174. getEmittedParticleSystems(): IParticleSystem[];
  128175. /**
  128176. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  128177. * @returns an array of IParticleSystem
  128178. */
  128179. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  128180. }
  128181. /**
  128182. * @hidden
  128183. */
  128184. export var _IDoNeedToBeInTheBuild: number;
  128185. }
  128186. declare module BABYLON {
  128187. /** Defines the 4 color options */
  128188. export enum PointColor {
  128189. /** color value */
  128190. Color = 2,
  128191. /** uv value */
  128192. UV = 1,
  128193. /** random value */
  128194. Random = 0,
  128195. /** stated value */
  128196. Stated = 3
  128197. }
  128198. /**
  128199. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  128200. * 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.
  128201. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  128202. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  128203. *
  128204. * Full documentation here : TO BE ENTERED
  128205. */
  128206. export class PointsCloudSystem implements IDisposable {
  128207. /**
  128208. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  128209. * Example : var p = SPS.particles[i];
  128210. */
  128211. particles: CloudPoint[];
  128212. /**
  128213. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  128214. */
  128215. nbParticles: number;
  128216. /**
  128217. * This a counter for your own usage. It's not set by any SPS functions.
  128218. */
  128219. counter: number;
  128220. /**
  128221. * The PCS name. This name is also given to the underlying mesh.
  128222. */
  128223. name: string;
  128224. /**
  128225. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  128226. */
  128227. mesh: Mesh;
  128228. /**
  128229. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  128230. * Please read :
  128231. */
  128232. vars: any;
  128233. /**
  128234. * @hidden
  128235. */
  128236. _size: number;
  128237. private _scene;
  128238. private _promises;
  128239. private _positions;
  128240. private _indices;
  128241. private _normals;
  128242. private _colors;
  128243. private _uvs;
  128244. private _indices32;
  128245. private _positions32;
  128246. private _colors32;
  128247. private _uvs32;
  128248. private _updatable;
  128249. private _isVisibilityBoxLocked;
  128250. private _alwaysVisible;
  128251. private _groups;
  128252. private _groupCounter;
  128253. private _computeParticleColor;
  128254. private _computeParticleTexture;
  128255. private _computeParticleRotation;
  128256. private _computeBoundingBox;
  128257. private _isReady;
  128258. /**
  128259. * Creates a PCS (Points Cloud System) object
  128260. * @param name (String) is the PCS name, this will be the underlying mesh name
  128261. * @param pointSize (number) is the size for each point
  128262. * @param scene (Scene) is the scene in which the PCS is added
  128263. * @param options defines the options of the PCS e.g.
  128264. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  128265. */
  128266. constructor(name: string, pointSize: number, scene: Scene, options?: {
  128267. updatable?: boolean;
  128268. });
  128269. /**
  128270. * Builds the PCS underlying mesh. Returns a standard Mesh.
  128271. * If no points were added to the PCS, the returned mesh is just a single point.
  128272. * @returns a promise for the created mesh
  128273. */
  128274. buildMeshAsync(): Promise<Mesh>;
  128275. /**
  128276. * @hidden
  128277. */
  128278. private _buildMesh;
  128279. private _addParticle;
  128280. private _randomUnitVector;
  128281. private _getColorIndicesForCoord;
  128282. private _setPointsColorOrUV;
  128283. private _colorFromTexture;
  128284. private _calculateDensity;
  128285. /**
  128286. * Adds points to the PCS in random positions within a unit sphere
  128287. * @param nb (positive integer) the number of particles to be created from this model
  128288. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  128289. * @returns the number of groups in the system
  128290. */
  128291. addPoints(nb: number, pointFunction?: any): number;
  128292. /**
  128293. * Adds points to the PCS from the surface of the model shape
  128294. * @param mesh is any Mesh object that will be used as a surface model for the points
  128295. * @param nb (positive integer) the number of particles to be created from this model
  128296. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128297. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128298. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128299. * @returns the number of groups in the system
  128300. */
  128301. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128302. /**
  128303. * Adds points to the PCS inside the model shape
  128304. * @param mesh is any Mesh object that will be used as a surface model for the points
  128305. * @param nb (positive integer) the number of particles to be created from this model
  128306. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128307. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128308. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128309. * @returns the number of groups in the system
  128310. */
  128311. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128312. /**
  128313. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  128314. * This method calls `updateParticle()` for each particle of the SPS.
  128315. * For an animated SPS, it is usually called within the render loop.
  128316. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  128317. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  128318. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  128319. * @returns the PCS.
  128320. */
  128321. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  128322. /**
  128323. * Disposes the PCS.
  128324. */
  128325. dispose(): void;
  128326. /**
  128327. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  128328. * doc :
  128329. * @returns the PCS.
  128330. */
  128331. refreshVisibleSize(): PointsCloudSystem;
  128332. /**
  128333. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  128334. * @param size the size (float) of the visibility box
  128335. * note : this doesn't lock the PCS mesh bounding box.
  128336. * doc :
  128337. */
  128338. setVisibilityBox(size: number): void;
  128339. /**
  128340. * Gets whether the PCS is always visible or not
  128341. * doc :
  128342. */
  128343. /**
  128344. * Sets the PCS as always visible or not
  128345. * doc :
  128346. */
  128347. isAlwaysVisible: boolean;
  128348. /**
  128349. * Tells to `setParticles()` to compute the particle rotations or not
  128350. * Default value : false. The PCS is faster when it's set to false
  128351. * Note : particle rotations are only applied to parent particles
  128352. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  128353. */
  128354. computeParticleRotation: boolean;
  128355. /**
  128356. * Tells to `setParticles()` to compute the particle colors or not.
  128357. * Default value : true. The PCS is faster when it's set to false.
  128358. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128359. */
  128360. /**
  128361. * Gets if `setParticles()` computes the particle colors or not.
  128362. * Default value : false. The PCS is faster when it's set to false.
  128363. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128364. */
  128365. computeParticleColor: boolean;
  128366. /**
  128367. * Gets if `setParticles()` computes the particle textures or not.
  128368. * Default value : false. The PCS is faster when it's set to false.
  128369. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  128370. */
  128371. computeParticleTexture: boolean;
  128372. /**
  128373. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  128374. */
  128375. /**
  128376. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  128377. */
  128378. computeBoundingBox: boolean;
  128379. /**
  128380. * This function does nothing. It may be overwritten to set all the particle first values.
  128381. * The PCS doesn't call this function, you may have to call it by your own.
  128382. * doc :
  128383. */
  128384. initParticles(): void;
  128385. /**
  128386. * This function does nothing. It may be overwritten to recycle a particle
  128387. * The PCS doesn't call this function, you can to call it
  128388. * doc :
  128389. * @param particle The particle to recycle
  128390. * @returns the recycled particle
  128391. */
  128392. recycleParticle(particle: CloudPoint): CloudPoint;
  128393. /**
  128394. * Updates a particle : this function should be overwritten by the user.
  128395. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  128396. * doc :
  128397. * @example : just set a particle position or velocity and recycle conditions
  128398. * @param particle The particle to update
  128399. * @returns the updated particle
  128400. */
  128401. updateParticle(particle: CloudPoint): CloudPoint;
  128402. /**
  128403. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  128404. * This does nothing and may be overwritten by the user.
  128405. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  128406. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  128407. * @param update the boolean update value actually passed to setParticles()
  128408. */
  128409. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  128410. /**
  128411. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  128412. * This will be passed three parameters.
  128413. * This does nothing and may be overwritten by the user.
  128414. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  128415. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  128416. * @param update the boolean update value actually passed to setParticles()
  128417. */
  128418. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  128419. }
  128420. }
  128421. declare module BABYLON {
  128422. /**
  128423. * Represents one particle of a points cloud system.
  128424. */
  128425. export class CloudPoint {
  128426. /**
  128427. * particle global index
  128428. */
  128429. idx: number;
  128430. /**
  128431. * The color of the particle
  128432. */
  128433. color: Nullable<Color4>;
  128434. /**
  128435. * The world space position of the particle.
  128436. */
  128437. position: Vector3;
  128438. /**
  128439. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  128440. */
  128441. rotation: Vector3;
  128442. /**
  128443. * The world space rotation quaternion of the particle.
  128444. */
  128445. rotationQuaternion: Nullable<Quaternion>;
  128446. /**
  128447. * The uv of the particle.
  128448. */
  128449. uv: Nullable<Vector2>;
  128450. /**
  128451. * The current speed of the particle.
  128452. */
  128453. velocity: Vector3;
  128454. /**
  128455. * The pivot point in the particle local space.
  128456. */
  128457. pivot: Vector3;
  128458. /**
  128459. * Must the particle be translated from its pivot point in its local space ?
  128460. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  128461. * Default : false
  128462. */
  128463. translateFromPivot: boolean;
  128464. /**
  128465. * Index of this particle in the global "positions" array (Internal use)
  128466. * @hidden
  128467. */
  128468. _pos: number;
  128469. /**
  128470. * @hidden Index of this particle in the global "indices" array (Internal use)
  128471. */
  128472. _ind: number;
  128473. /**
  128474. * Group this particle belongs to
  128475. */
  128476. _group: PointsGroup;
  128477. /**
  128478. * Group id of this particle
  128479. */
  128480. groupId: number;
  128481. /**
  128482. * Index of the particle in its group id (Internal use)
  128483. */
  128484. idxInGroup: number;
  128485. /**
  128486. * @hidden Particle BoundingInfo object (Internal use)
  128487. */
  128488. _boundingInfo: BoundingInfo;
  128489. /**
  128490. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  128491. */
  128492. _pcs: PointsCloudSystem;
  128493. /**
  128494. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  128495. */
  128496. _stillInvisible: boolean;
  128497. /**
  128498. * @hidden Last computed particle rotation matrix
  128499. */
  128500. _rotationMatrix: number[];
  128501. /**
  128502. * Parent particle Id, if any.
  128503. * Default null.
  128504. */
  128505. parentId: Nullable<number>;
  128506. /**
  128507. * @hidden Internal global position in the PCS.
  128508. */
  128509. _globalPosition: Vector3;
  128510. /**
  128511. * Creates a Point Cloud object.
  128512. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  128513. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  128514. * @param group (PointsGroup) is the group the particle belongs to
  128515. * @param groupId (integer) is the group identifier in the PCS.
  128516. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  128517. * @param pcs defines the PCS it is associated to
  128518. */
  128519. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  128520. /**
  128521. * get point size
  128522. */
  128523. /**
  128524. * Set point size
  128525. */
  128526. size: Vector3;
  128527. /**
  128528. * Legacy support, changed quaternion to rotationQuaternion
  128529. */
  128530. /**
  128531. * Legacy support, changed quaternion to rotationQuaternion
  128532. */
  128533. quaternion: Nullable<Quaternion>;
  128534. /**
  128535. * Returns a boolean. True if the particle intersects a mesh, else false
  128536. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  128537. * @param target is the object (point or mesh) what the intersection is computed against
  128538. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  128539. * @returns true if it intersects
  128540. */
  128541. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  128542. /**
  128543. * get the rotation matrix of the particle
  128544. * @hidden
  128545. */
  128546. getRotationMatrix(m: Matrix): void;
  128547. }
  128548. /**
  128549. * Represents a group of points in a points cloud system
  128550. * * PCS internal tool, don't use it manually.
  128551. */
  128552. export class PointsGroup {
  128553. /**
  128554. * The group id
  128555. * @hidden
  128556. */
  128557. groupID: number;
  128558. /**
  128559. * image data for group (internal use)
  128560. * @hidden
  128561. */
  128562. _groupImageData: Nullable<ArrayBufferView>;
  128563. /**
  128564. * Image Width (internal use)
  128565. * @hidden
  128566. */
  128567. _groupImgWidth: number;
  128568. /**
  128569. * Image Height (internal use)
  128570. * @hidden
  128571. */
  128572. _groupImgHeight: number;
  128573. /**
  128574. * Custom position function (internal use)
  128575. * @hidden
  128576. */
  128577. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  128578. /**
  128579. * density per facet for surface points
  128580. * @hidden
  128581. */
  128582. _groupDensity: number[];
  128583. /**
  128584. * Only when points are colored by texture carries pointer to texture list array
  128585. * @hidden
  128586. */
  128587. _textureNb: number;
  128588. /**
  128589. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  128590. * PCS internal tool, don't use it manually.
  128591. * @hidden
  128592. */
  128593. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  128594. }
  128595. }
  128596. declare module BABYLON {
  128597. interface Scene {
  128598. /** @hidden (Backing field) */
  128599. _physicsEngine: Nullable<IPhysicsEngine>;
  128600. /**
  128601. * Gets the current physics engine
  128602. * @returns a IPhysicsEngine or null if none attached
  128603. */
  128604. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  128605. /**
  128606. * Enables physics to the current scene
  128607. * @param gravity defines the scene's gravity for the physics engine
  128608. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  128609. * @return a boolean indicating if the physics engine was initialized
  128610. */
  128611. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  128612. /**
  128613. * Disables and disposes the physics engine associated with the scene
  128614. */
  128615. disablePhysicsEngine(): void;
  128616. /**
  128617. * Gets a boolean indicating if there is an active physics engine
  128618. * @returns a boolean indicating if there is an active physics engine
  128619. */
  128620. isPhysicsEnabled(): boolean;
  128621. /**
  128622. * Deletes a physics compound impostor
  128623. * @param compound defines the compound to delete
  128624. */
  128625. deleteCompoundImpostor(compound: any): void;
  128626. /**
  128627. * An event triggered when physic simulation is about to be run
  128628. */
  128629. onBeforePhysicsObservable: Observable<Scene>;
  128630. /**
  128631. * An event triggered when physic simulation has been done
  128632. */
  128633. onAfterPhysicsObservable: Observable<Scene>;
  128634. }
  128635. interface AbstractMesh {
  128636. /** @hidden */
  128637. _physicsImpostor: Nullable<PhysicsImpostor>;
  128638. /**
  128639. * Gets or sets impostor used for physic simulation
  128640. * @see http://doc.babylonjs.com/features/physics_engine
  128641. */
  128642. physicsImpostor: Nullable<PhysicsImpostor>;
  128643. /**
  128644. * Gets the current physics impostor
  128645. * @see http://doc.babylonjs.com/features/physics_engine
  128646. * @returns a physics impostor or null
  128647. */
  128648. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  128649. /** Apply a physic impulse to the mesh
  128650. * @param force defines the force to apply
  128651. * @param contactPoint defines where to apply the force
  128652. * @returns the current mesh
  128653. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128654. */
  128655. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  128656. /**
  128657. * Creates a physic joint between two meshes
  128658. * @param otherMesh defines the other mesh to use
  128659. * @param pivot1 defines the pivot to use on this mesh
  128660. * @param pivot2 defines the pivot to use on the other mesh
  128661. * @param options defines additional options (can be plugin dependent)
  128662. * @returns the current mesh
  128663. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  128664. */
  128665. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  128666. /** @hidden */
  128667. _disposePhysicsObserver: Nullable<Observer<Node>>;
  128668. }
  128669. /**
  128670. * Defines the physics engine scene component responsible to manage a physics engine
  128671. */
  128672. export class PhysicsEngineSceneComponent implements ISceneComponent {
  128673. /**
  128674. * The component name helpful to identify the component in the list of scene components.
  128675. */
  128676. readonly name: string;
  128677. /**
  128678. * The scene the component belongs to.
  128679. */
  128680. scene: Scene;
  128681. /**
  128682. * Creates a new instance of the component for the given scene
  128683. * @param scene Defines the scene to register the component in
  128684. */
  128685. constructor(scene: Scene);
  128686. /**
  128687. * Registers the component in a given scene
  128688. */
  128689. register(): void;
  128690. /**
  128691. * Rebuilds the elements related to this component in case of
  128692. * context lost for instance.
  128693. */
  128694. rebuild(): void;
  128695. /**
  128696. * Disposes the component and the associated ressources
  128697. */
  128698. dispose(): void;
  128699. }
  128700. }
  128701. declare module BABYLON {
  128702. /**
  128703. * A helper for physics simulations
  128704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128705. */
  128706. export class PhysicsHelper {
  128707. private _scene;
  128708. private _physicsEngine;
  128709. /**
  128710. * Initializes the Physics helper
  128711. * @param scene Babylon.js scene
  128712. */
  128713. constructor(scene: Scene);
  128714. /**
  128715. * Applies a radial explosion impulse
  128716. * @param origin the origin of the explosion
  128717. * @param radiusOrEventOptions the radius or the options of radial explosion
  128718. * @param strength the explosion strength
  128719. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128720. * @returns A physics radial explosion event, or null
  128721. */
  128722. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  128723. /**
  128724. * Applies a radial explosion force
  128725. * @param origin the origin of the explosion
  128726. * @param radiusOrEventOptions the radius or the options of radial explosion
  128727. * @param strength the explosion strength
  128728. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128729. * @returns A physics radial explosion event, or null
  128730. */
  128731. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  128732. /**
  128733. * Creates a gravitational field
  128734. * @param origin the origin of the explosion
  128735. * @param radiusOrEventOptions the radius or the options of radial explosion
  128736. * @param strength the explosion strength
  128737. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128738. * @returns A physics gravitational field event, or null
  128739. */
  128740. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  128741. /**
  128742. * Creates a physics updraft event
  128743. * @param origin the origin of the updraft
  128744. * @param radiusOrEventOptions the radius or the options of the updraft
  128745. * @param strength the strength of the updraft
  128746. * @param height the height of the updraft
  128747. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  128748. * @returns A physics updraft event, or null
  128749. */
  128750. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  128751. /**
  128752. * Creates a physics vortex event
  128753. * @param origin the of the vortex
  128754. * @param radiusOrEventOptions the radius or the options of the vortex
  128755. * @param strength the strength of the vortex
  128756. * @param height the height of the vortex
  128757. * @returns a Physics vortex event, or null
  128758. * A physics vortex event or null
  128759. */
  128760. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  128761. }
  128762. /**
  128763. * Represents a physics radial explosion event
  128764. */
  128765. class PhysicsRadialExplosionEvent {
  128766. private _scene;
  128767. private _options;
  128768. private _sphere;
  128769. private _dataFetched;
  128770. /**
  128771. * Initializes a radial explosioin event
  128772. * @param _scene BabylonJS scene
  128773. * @param _options The options for the vortex event
  128774. */
  128775. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  128776. /**
  128777. * Returns the data related to the radial explosion event (sphere).
  128778. * @returns The radial explosion event data
  128779. */
  128780. getData(): PhysicsRadialExplosionEventData;
  128781. /**
  128782. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  128783. * @param impostor A physics imposter
  128784. * @param origin the origin of the explosion
  128785. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  128786. */
  128787. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  128788. /**
  128789. * Triggers affecterd impostors callbacks
  128790. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  128791. */
  128792. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  128793. /**
  128794. * Disposes the sphere.
  128795. * @param force Specifies if the sphere should be disposed by force
  128796. */
  128797. dispose(force?: boolean): void;
  128798. /*** Helpers ***/
  128799. private _prepareSphere;
  128800. private _intersectsWithSphere;
  128801. }
  128802. /**
  128803. * Represents a gravitational field event
  128804. */
  128805. class PhysicsGravitationalFieldEvent {
  128806. private _physicsHelper;
  128807. private _scene;
  128808. private _origin;
  128809. private _options;
  128810. private _tickCallback;
  128811. private _sphere;
  128812. private _dataFetched;
  128813. /**
  128814. * Initializes the physics gravitational field event
  128815. * @param _physicsHelper A physics helper
  128816. * @param _scene BabylonJS scene
  128817. * @param _origin The origin position of the gravitational field event
  128818. * @param _options The options for the vortex event
  128819. */
  128820. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  128821. /**
  128822. * Returns the data related to the gravitational field event (sphere).
  128823. * @returns A gravitational field event
  128824. */
  128825. getData(): PhysicsGravitationalFieldEventData;
  128826. /**
  128827. * Enables the gravitational field.
  128828. */
  128829. enable(): void;
  128830. /**
  128831. * Disables the gravitational field.
  128832. */
  128833. disable(): void;
  128834. /**
  128835. * Disposes the sphere.
  128836. * @param force The force to dispose from the gravitational field event
  128837. */
  128838. dispose(force?: boolean): void;
  128839. private _tick;
  128840. }
  128841. /**
  128842. * Represents a physics updraft event
  128843. */
  128844. class PhysicsUpdraftEvent {
  128845. private _scene;
  128846. private _origin;
  128847. private _options;
  128848. private _physicsEngine;
  128849. private _originTop;
  128850. private _originDirection;
  128851. private _tickCallback;
  128852. private _cylinder;
  128853. private _cylinderPosition;
  128854. private _dataFetched;
  128855. /**
  128856. * Initializes the physics updraft event
  128857. * @param _scene BabylonJS scene
  128858. * @param _origin The origin position of the updraft
  128859. * @param _options The options for the updraft event
  128860. */
  128861. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  128862. /**
  128863. * Returns the data related to the updraft event (cylinder).
  128864. * @returns A physics updraft event
  128865. */
  128866. getData(): PhysicsUpdraftEventData;
  128867. /**
  128868. * Enables the updraft.
  128869. */
  128870. enable(): void;
  128871. /**
  128872. * Disables the updraft.
  128873. */
  128874. disable(): void;
  128875. /**
  128876. * Disposes the cylinder.
  128877. * @param force Specifies if the updraft should be disposed by force
  128878. */
  128879. dispose(force?: boolean): void;
  128880. private getImpostorHitData;
  128881. private _tick;
  128882. /*** Helpers ***/
  128883. private _prepareCylinder;
  128884. private _intersectsWithCylinder;
  128885. }
  128886. /**
  128887. * Represents a physics vortex event
  128888. */
  128889. class PhysicsVortexEvent {
  128890. private _scene;
  128891. private _origin;
  128892. private _options;
  128893. private _physicsEngine;
  128894. private _originTop;
  128895. private _tickCallback;
  128896. private _cylinder;
  128897. private _cylinderPosition;
  128898. private _dataFetched;
  128899. /**
  128900. * Initializes the physics vortex event
  128901. * @param _scene The BabylonJS scene
  128902. * @param _origin The origin position of the vortex
  128903. * @param _options The options for the vortex event
  128904. */
  128905. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  128906. /**
  128907. * Returns the data related to the vortex event (cylinder).
  128908. * @returns The physics vortex event data
  128909. */
  128910. getData(): PhysicsVortexEventData;
  128911. /**
  128912. * Enables the vortex.
  128913. */
  128914. enable(): void;
  128915. /**
  128916. * Disables the cortex.
  128917. */
  128918. disable(): void;
  128919. /**
  128920. * Disposes the sphere.
  128921. * @param force
  128922. */
  128923. dispose(force?: boolean): void;
  128924. private getImpostorHitData;
  128925. private _tick;
  128926. /*** Helpers ***/
  128927. private _prepareCylinder;
  128928. private _intersectsWithCylinder;
  128929. }
  128930. /**
  128931. * Options fot the radial explosion event
  128932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128933. */
  128934. export class PhysicsRadialExplosionEventOptions {
  128935. /**
  128936. * The radius of the sphere for the radial explosion.
  128937. */
  128938. radius: number;
  128939. /**
  128940. * The strenth of the explosion.
  128941. */
  128942. strength: number;
  128943. /**
  128944. * The strenght of the force in correspondence to the distance of the affected object
  128945. */
  128946. falloff: PhysicsRadialImpulseFalloff;
  128947. /**
  128948. * Sphere options for the radial explosion.
  128949. */
  128950. sphere: {
  128951. segments: number;
  128952. diameter: number;
  128953. };
  128954. /**
  128955. * Sphere options for the radial explosion.
  128956. */
  128957. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  128958. }
  128959. /**
  128960. * Options fot the updraft event
  128961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128962. */
  128963. export class PhysicsUpdraftEventOptions {
  128964. /**
  128965. * The radius of the cylinder for the vortex
  128966. */
  128967. radius: number;
  128968. /**
  128969. * The strenth of the updraft.
  128970. */
  128971. strength: number;
  128972. /**
  128973. * The height of the cylinder for the updraft.
  128974. */
  128975. height: number;
  128976. /**
  128977. * The mode for the the updraft.
  128978. */
  128979. updraftMode: PhysicsUpdraftMode;
  128980. }
  128981. /**
  128982. * Options fot the vortex event
  128983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128984. */
  128985. export class PhysicsVortexEventOptions {
  128986. /**
  128987. * The radius of the cylinder for the vortex
  128988. */
  128989. radius: number;
  128990. /**
  128991. * The strenth of the vortex.
  128992. */
  128993. strength: number;
  128994. /**
  128995. * The height of the cylinder for the vortex.
  128996. */
  128997. height: number;
  128998. /**
  128999. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  129000. */
  129001. centripetalForceThreshold: number;
  129002. /**
  129003. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  129004. */
  129005. centripetalForceMultiplier: number;
  129006. /**
  129007. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  129008. */
  129009. centrifugalForceMultiplier: number;
  129010. /**
  129011. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  129012. */
  129013. updraftForceMultiplier: number;
  129014. }
  129015. /**
  129016. * The strenght of the force in correspondence to the distance of the affected object
  129017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129018. */
  129019. export enum PhysicsRadialImpulseFalloff {
  129020. /** Defines that impulse is constant in strength across it's whole radius */
  129021. Constant = 0,
  129022. /** Defines that impulse gets weaker if it's further from the origin */
  129023. Linear = 1
  129024. }
  129025. /**
  129026. * The strength of the force in correspondence to the distance of the affected object
  129027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129028. */
  129029. export enum PhysicsUpdraftMode {
  129030. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  129031. Center = 0,
  129032. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  129033. Perpendicular = 1
  129034. }
  129035. /**
  129036. * Interface for a physics hit data
  129037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129038. */
  129039. export interface PhysicsHitData {
  129040. /**
  129041. * The force applied at the contact point
  129042. */
  129043. force: Vector3;
  129044. /**
  129045. * The contact point
  129046. */
  129047. contactPoint: Vector3;
  129048. /**
  129049. * The distance from the origin to the contact point
  129050. */
  129051. distanceFromOrigin: number;
  129052. }
  129053. /**
  129054. * Interface for radial explosion event data
  129055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129056. */
  129057. export interface PhysicsRadialExplosionEventData {
  129058. /**
  129059. * A sphere used for the radial explosion event
  129060. */
  129061. sphere: Mesh;
  129062. }
  129063. /**
  129064. * Interface for gravitational field event data
  129065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129066. */
  129067. export interface PhysicsGravitationalFieldEventData {
  129068. /**
  129069. * A sphere mesh used for the gravitational field event
  129070. */
  129071. sphere: Mesh;
  129072. }
  129073. /**
  129074. * Interface for updraft event data
  129075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129076. */
  129077. export interface PhysicsUpdraftEventData {
  129078. /**
  129079. * A cylinder used for the updraft event
  129080. */
  129081. cylinder: Mesh;
  129082. }
  129083. /**
  129084. * Interface for vortex event data
  129085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129086. */
  129087. export interface PhysicsVortexEventData {
  129088. /**
  129089. * A cylinder used for the vortex event
  129090. */
  129091. cylinder: Mesh;
  129092. }
  129093. /**
  129094. * Interface for an affected physics impostor
  129095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129096. */
  129097. export interface PhysicsAffectedImpostorWithData {
  129098. /**
  129099. * The impostor affected by the effect
  129100. */
  129101. impostor: PhysicsImpostor;
  129102. /**
  129103. * The data about the hit/horce from the explosion
  129104. */
  129105. hitData: PhysicsHitData;
  129106. }
  129107. }
  129108. declare module BABYLON {
  129109. /** @hidden */
  129110. export var blackAndWhitePixelShader: {
  129111. name: string;
  129112. shader: string;
  129113. };
  129114. }
  129115. declare module BABYLON {
  129116. /**
  129117. * Post process used to render in black and white
  129118. */
  129119. export class BlackAndWhitePostProcess extends PostProcess {
  129120. /**
  129121. * Linear about to convert he result to black and white (default: 1)
  129122. */
  129123. degree: number;
  129124. /**
  129125. * Creates a black and white post process
  129126. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  129127. * @param name The name of the effect.
  129128. * @param options The required width/height ratio to downsize to before computing the render pass.
  129129. * @param camera The camera to apply the render pass to.
  129130. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129131. * @param engine The engine which the post process will be applied. (default: current engine)
  129132. * @param reusable If the post process can be reused on the same frame. (default: false)
  129133. */
  129134. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129135. }
  129136. }
  129137. declare module BABYLON {
  129138. /**
  129139. * This represents a set of one or more post processes in Babylon.
  129140. * A post process can be used to apply a shader to a texture after it is rendered.
  129141. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129142. */
  129143. export class PostProcessRenderEffect {
  129144. private _postProcesses;
  129145. private _getPostProcesses;
  129146. private _singleInstance;
  129147. private _cameras;
  129148. private _indicesForCamera;
  129149. /**
  129150. * Name of the effect
  129151. * @hidden
  129152. */
  129153. _name: string;
  129154. /**
  129155. * Instantiates a post process render effect.
  129156. * A post process can be used to apply a shader to a texture after it is rendered.
  129157. * @param engine The engine the effect is tied to
  129158. * @param name The name of the effect
  129159. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  129160. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  129161. */
  129162. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  129163. /**
  129164. * Checks if all the post processes in the effect are supported.
  129165. */
  129166. readonly isSupported: boolean;
  129167. /**
  129168. * Updates the current state of the effect
  129169. * @hidden
  129170. */
  129171. _update(): void;
  129172. /**
  129173. * Attaches the effect on cameras
  129174. * @param cameras The camera to attach to.
  129175. * @hidden
  129176. */
  129177. _attachCameras(cameras: Camera): void;
  129178. /**
  129179. * Attaches the effect on cameras
  129180. * @param cameras The camera to attach to.
  129181. * @hidden
  129182. */
  129183. _attachCameras(cameras: Camera[]): void;
  129184. /**
  129185. * Detaches the effect on cameras
  129186. * @param cameras The camera to detatch from.
  129187. * @hidden
  129188. */
  129189. _detachCameras(cameras: Camera): void;
  129190. /**
  129191. * Detatches the effect on cameras
  129192. * @param cameras The camera to detatch from.
  129193. * @hidden
  129194. */
  129195. _detachCameras(cameras: Camera[]): void;
  129196. /**
  129197. * Enables the effect on given cameras
  129198. * @param cameras The camera to enable.
  129199. * @hidden
  129200. */
  129201. _enable(cameras: Camera): void;
  129202. /**
  129203. * Enables the effect on given cameras
  129204. * @param cameras The camera to enable.
  129205. * @hidden
  129206. */
  129207. _enable(cameras: Nullable<Camera[]>): void;
  129208. /**
  129209. * Disables the effect on the given cameras
  129210. * @param cameras The camera to disable.
  129211. * @hidden
  129212. */
  129213. _disable(cameras: Camera): void;
  129214. /**
  129215. * Disables the effect on the given cameras
  129216. * @param cameras The camera to disable.
  129217. * @hidden
  129218. */
  129219. _disable(cameras: Nullable<Camera[]>): void;
  129220. /**
  129221. * Gets a list of the post processes contained in the effect.
  129222. * @param camera The camera to get the post processes on.
  129223. * @returns The list of the post processes in the effect.
  129224. */
  129225. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  129226. }
  129227. }
  129228. declare module BABYLON {
  129229. /** @hidden */
  129230. export var extractHighlightsPixelShader: {
  129231. name: string;
  129232. shader: string;
  129233. };
  129234. }
  129235. declare module BABYLON {
  129236. /**
  129237. * 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.
  129238. */
  129239. export class ExtractHighlightsPostProcess extends PostProcess {
  129240. /**
  129241. * The luminance threshold, pixels below this value will be set to black.
  129242. */
  129243. threshold: number;
  129244. /** @hidden */
  129245. _exposure: number;
  129246. /**
  129247. * Post process which has the input texture to be used when performing highlight extraction
  129248. * @hidden
  129249. */
  129250. _inputPostProcess: Nullable<PostProcess>;
  129251. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129252. }
  129253. }
  129254. declare module BABYLON {
  129255. /** @hidden */
  129256. export var bloomMergePixelShader: {
  129257. name: string;
  129258. shader: string;
  129259. };
  129260. }
  129261. declare module BABYLON {
  129262. /**
  129263. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  129264. */
  129265. export class BloomMergePostProcess extends PostProcess {
  129266. /** Weight of the bloom to be added to the original input. */
  129267. weight: number;
  129268. /**
  129269. * Creates a new instance of @see BloomMergePostProcess
  129270. * @param name The name of the effect.
  129271. * @param originalFromInput Post process which's input will be used for the merge.
  129272. * @param blurred Blurred highlights post process which's output will be used.
  129273. * @param weight Weight of the bloom to be added to the original input.
  129274. * @param options The required width/height ratio to downsize to before computing the render pass.
  129275. * @param camera The camera to apply the render pass to.
  129276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129277. * @param engine The engine which the post process will be applied. (default: current engine)
  129278. * @param reusable If the post process can be reused on the same frame. (default: false)
  129279. * @param textureType Type of textures used when performing the post process. (default: 0)
  129280. * @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)
  129281. */
  129282. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  129283. /** Weight of the bloom to be added to the original input. */
  129284. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129285. }
  129286. }
  129287. declare module BABYLON {
  129288. /**
  129289. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  129290. */
  129291. export class BloomEffect extends PostProcessRenderEffect {
  129292. private bloomScale;
  129293. /**
  129294. * @hidden Internal
  129295. */
  129296. _effects: Array<PostProcess>;
  129297. /**
  129298. * @hidden Internal
  129299. */
  129300. _downscale: ExtractHighlightsPostProcess;
  129301. private _blurX;
  129302. private _blurY;
  129303. private _merge;
  129304. /**
  129305. * The luminance threshold to find bright areas of the image to bloom.
  129306. */
  129307. threshold: number;
  129308. /**
  129309. * The strength of the bloom.
  129310. */
  129311. weight: number;
  129312. /**
  129313. * Specifies the size of the bloom blur kernel, relative to the final output size
  129314. */
  129315. kernel: number;
  129316. /**
  129317. * Creates a new instance of @see BloomEffect
  129318. * @param scene The scene the effect belongs to.
  129319. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  129320. * @param bloomKernel The size of the kernel to be used when applying the blur.
  129321. * @param bloomWeight The the strength of bloom.
  129322. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  129323. * @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)
  129324. */
  129325. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  129326. /**
  129327. * Disposes each of the internal effects for a given camera.
  129328. * @param camera The camera to dispose the effect on.
  129329. */
  129330. disposeEffects(camera: Camera): void;
  129331. /**
  129332. * @hidden Internal
  129333. */
  129334. _updateEffects(): void;
  129335. /**
  129336. * Internal
  129337. * @returns if all the contained post processes are ready.
  129338. * @hidden
  129339. */
  129340. _isReady(): boolean;
  129341. }
  129342. }
  129343. declare module BABYLON {
  129344. /** @hidden */
  129345. export var chromaticAberrationPixelShader: {
  129346. name: string;
  129347. shader: string;
  129348. };
  129349. }
  129350. declare module BABYLON {
  129351. /**
  129352. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  129353. */
  129354. export class ChromaticAberrationPostProcess extends PostProcess {
  129355. /**
  129356. * The amount of seperation of rgb channels (default: 30)
  129357. */
  129358. aberrationAmount: number;
  129359. /**
  129360. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  129361. */
  129362. radialIntensity: number;
  129363. /**
  129364. * 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))
  129365. */
  129366. direction: Vector2;
  129367. /**
  129368. * 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))
  129369. */
  129370. centerPosition: Vector2;
  129371. /**
  129372. * Creates a new instance ChromaticAberrationPostProcess
  129373. * @param name The name of the effect.
  129374. * @param screenWidth The width of the screen to apply the effect on.
  129375. * @param screenHeight The height of the screen to apply the effect on.
  129376. * @param options The required width/height ratio to downsize to before computing the render pass.
  129377. * @param camera The camera to apply the render pass to.
  129378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129379. * @param engine The engine which the post process will be applied. (default: current engine)
  129380. * @param reusable If the post process can be reused on the same frame. (default: false)
  129381. * @param textureType Type of textures used when performing the post process. (default: 0)
  129382. * @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)
  129383. */
  129384. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129385. }
  129386. }
  129387. declare module BABYLON {
  129388. /** @hidden */
  129389. export var circleOfConfusionPixelShader: {
  129390. name: string;
  129391. shader: string;
  129392. };
  129393. }
  129394. declare module BABYLON {
  129395. /**
  129396. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  129397. */
  129398. export class CircleOfConfusionPostProcess extends PostProcess {
  129399. /**
  129400. * 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.
  129401. */
  129402. lensSize: number;
  129403. /**
  129404. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  129405. */
  129406. fStop: number;
  129407. /**
  129408. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  129409. */
  129410. focusDistance: number;
  129411. /**
  129412. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  129413. */
  129414. focalLength: number;
  129415. private _depthTexture;
  129416. /**
  129417. * Creates a new instance CircleOfConfusionPostProcess
  129418. * @param name The name of the effect.
  129419. * @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.
  129420. * @param options The required width/height ratio to downsize to before computing the render pass.
  129421. * @param camera The camera to apply the render pass to.
  129422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129423. * @param engine The engine which the post process will be applied. (default: current engine)
  129424. * @param reusable If the post process can be reused on the same frame. (default: false)
  129425. * @param textureType Type of textures used when performing the post process. (default: 0)
  129426. * @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)
  129427. */
  129428. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129429. /**
  129430. * 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.
  129431. */
  129432. depthTexture: RenderTargetTexture;
  129433. }
  129434. }
  129435. declare module BABYLON {
  129436. /** @hidden */
  129437. export var colorCorrectionPixelShader: {
  129438. name: string;
  129439. shader: string;
  129440. };
  129441. }
  129442. declare module BABYLON {
  129443. /**
  129444. *
  129445. * This post-process allows the modification of rendered colors by using
  129446. * a 'look-up table' (LUT). This effect is also called Color Grading.
  129447. *
  129448. * The object needs to be provided an url to a texture containing the color
  129449. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  129450. * Use an image editing software to tweak the LUT to match your needs.
  129451. *
  129452. * For an example of a color LUT, see here:
  129453. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  129454. * For explanations on color grading, see here:
  129455. * @see http://udn.epicgames.com/Three/ColorGrading.html
  129456. *
  129457. */
  129458. export class ColorCorrectionPostProcess extends PostProcess {
  129459. private _colorTableTexture;
  129460. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129461. }
  129462. }
  129463. declare module BABYLON {
  129464. /** @hidden */
  129465. export var convolutionPixelShader: {
  129466. name: string;
  129467. shader: string;
  129468. };
  129469. }
  129470. declare module BABYLON {
  129471. /**
  129472. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  129473. * input texture to perform effects such as edge detection or sharpening
  129474. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  129475. */
  129476. export class ConvolutionPostProcess extends PostProcess {
  129477. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  129478. kernel: number[];
  129479. /**
  129480. * Creates a new instance ConvolutionPostProcess
  129481. * @param name The name of the effect.
  129482. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  129483. * @param options The required width/height ratio to downsize to before computing the render pass.
  129484. * @param camera The camera to apply the render pass to.
  129485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129486. * @param engine The engine which the post process will be applied. (default: current engine)
  129487. * @param reusable If the post process can be reused on the same frame. (default: false)
  129488. * @param textureType Type of textures used when performing the post process. (default: 0)
  129489. */
  129490. constructor(name: string,
  129491. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  129492. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129493. /**
  129494. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129495. */
  129496. static EdgeDetect0Kernel: number[];
  129497. /**
  129498. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129499. */
  129500. static EdgeDetect1Kernel: number[];
  129501. /**
  129502. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129503. */
  129504. static EdgeDetect2Kernel: number[];
  129505. /**
  129506. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129507. */
  129508. static SharpenKernel: number[];
  129509. /**
  129510. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129511. */
  129512. static EmbossKernel: number[];
  129513. /**
  129514. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129515. */
  129516. static GaussianKernel: number[];
  129517. }
  129518. }
  129519. declare module BABYLON {
  129520. /**
  129521. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  129522. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  129523. * based on samples that have a large difference in distance than the center pixel.
  129524. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  129525. */
  129526. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  129527. direction: Vector2;
  129528. /**
  129529. * Creates a new instance CircleOfConfusionPostProcess
  129530. * @param name The name of the effect.
  129531. * @param scene The scene the effect belongs to.
  129532. * @param direction The direction the blur should be applied.
  129533. * @param kernel The size of the kernel used to blur.
  129534. * @param options The required width/height ratio to downsize to before computing the render pass.
  129535. * @param camera The camera to apply the render pass to.
  129536. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  129537. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  129538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129539. * @param engine The engine which the post process will be applied. (default: current engine)
  129540. * @param reusable If the post process can be reused on the same frame. (default: false)
  129541. * @param textureType Type of textures used when performing the post process. (default: 0)
  129542. * @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)
  129543. */
  129544. 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);
  129545. }
  129546. }
  129547. declare module BABYLON {
  129548. /** @hidden */
  129549. export var depthOfFieldMergePixelShader: {
  129550. name: string;
  129551. shader: string;
  129552. };
  129553. }
  129554. declare module BABYLON {
  129555. /**
  129556. * Options to be set when merging outputs from the default pipeline.
  129557. */
  129558. export class DepthOfFieldMergePostProcessOptions {
  129559. /**
  129560. * The original image to merge on top of
  129561. */
  129562. originalFromInput: PostProcess;
  129563. /**
  129564. * Parameters to perform the merge of the depth of field effect
  129565. */
  129566. depthOfField?: {
  129567. circleOfConfusion: PostProcess;
  129568. blurSteps: Array<PostProcess>;
  129569. };
  129570. /**
  129571. * Parameters to perform the merge of bloom effect
  129572. */
  129573. bloom?: {
  129574. blurred: PostProcess;
  129575. weight: number;
  129576. };
  129577. }
  129578. /**
  129579. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  129580. */
  129581. export class DepthOfFieldMergePostProcess extends PostProcess {
  129582. private blurSteps;
  129583. /**
  129584. * Creates a new instance of DepthOfFieldMergePostProcess
  129585. * @param name The name of the effect.
  129586. * @param originalFromInput Post process which's input will be used for the merge.
  129587. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  129588. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  129589. * @param options The required width/height ratio to downsize to before computing the render pass.
  129590. * @param camera The camera to apply the render pass to.
  129591. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129592. * @param engine The engine which the post process will be applied. (default: current engine)
  129593. * @param reusable If the post process can be reused on the same frame. (default: false)
  129594. * @param textureType Type of textures used when performing the post process. (default: 0)
  129595. * @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)
  129596. */
  129597. 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);
  129598. /**
  129599. * Updates the effect with the current post process compile time values and recompiles the shader.
  129600. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  129601. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  129602. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  129603. * @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
  129604. * @param onCompiled Called when the shader has been compiled.
  129605. * @param onError Called if there is an error when compiling a shader.
  129606. */
  129607. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  129608. }
  129609. }
  129610. declare module BABYLON {
  129611. /**
  129612. * Specifies the level of max blur that should be applied when using the depth of field effect
  129613. */
  129614. export enum DepthOfFieldEffectBlurLevel {
  129615. /**
  129616. * Subtle blur
  129617. */
  129618. Low = 0,
  129619. /**
  129620. * Medium blur
  129621. */
  129622. Medium = 1,
  129623. /**
  129624. * Large blur
  129625. */
  129626. High = 2
  129627. }
  129628. /**
  129629. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  129630. */
  129631. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  129632. private _circleOfConfusion;
  129633. /**
  129634. * @hidden Internal, blurs from high to low
  129635. */
  129636. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  129637. private _depthOfFieldBlurY;
  129638. private _dofMerge;
  129639. /**
  129640. * @hidden Internal post processes in depth of field effect
  129641. */
  129642. _effects: Array<PostProcess>;
  129643. /**
  129644. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  129645. */
  129646. focalLength: number;
  129647. /**
  129648. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  129649. */
  129650. fStop: number;
  129651. /**
  129652. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  129653. */
  129654. focusDistance: number;
  129655. /**
  129656. * 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.
  129657. */
  129658. lensSize: number;
  129659. /**
  129660. * Creates a new instance DepthOfFieldEffect
  129661. * @param scene The scene the effect belongs to.
  129662. * @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.
  129663. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  129664. * @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)
  129665. */
  129666. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  129667. /**
  129668. * Get the current class name of the current effet
  129669. * @returns "DepthOfFieldEffect"
  129670. */
  129671. getClassName(): string;
  129672. /**
  129673. * 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.
  129674. */
  129675. depthTexture: RenderTargetTexture;
  129676. /**
  129677. * Disposes each of the internal effects for a given camera.
  129678. * @param camera The camera to dispose the effect on.
  129679. */
  129680. disposeEffects(camera: Camera): void;
  129681. /**
  129682. * @hidden Internal
  129683. */
  129684. _updateEffects(): void;
  129685. /**
  129686. * Internal
  129687. * @returns if all the contained post processes are ready.
  129688. * @hidden
  129689. */
  129690. _isReady(): boolean;
  129691. }
  129692. }
  129693. declare module BABYLON {
  129694. /** @hidden */
  129695. export var displayPassPixelShader: {
  129696. name: string;
  129697. shader: string;
  129698. };
  129699. }
  129700. declare module BABYLON {
  129701. /**
  129702. * DisplayPassPostProcess which produces an output the same as it's input
  129703. */
  129704. export class DisplayPassPostProcess extends PostProcess {
  129705. /**
  129706. * Creates the DisplayPassPostProcess
  129707. * @param name The name of the effect.
  129708. * @param options The required width/height ratio to downsize to before computing the render pass.
  129709. * @param camera The camera to apply the render pass to.
  129710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129711. * @param engine The engine which the post process will be applied. (default: current engine)
  129712. * @param reusable If the post process can be reused on the same frame. (default: false)
  129713. */
  129714. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129715. }
  129716. }
  129717. declare module BABYLON {
  129718. /** @hidden */
  129719. export var filterPixelShader: {
  129720. name: string;
  129721. shader: string;
  129722. };
  129723. }
  129724. declare module BABYLON {
  129725. /**
  129726. * Applies a kernel filter to the image
  129727. */
  129728. export class FilterPostProcess extends PostProcess {
  129729. /** The matrix to be applied to the image */
  129730. kernelMatrix: Matrix;
  129731. /**
  129732. *
  129733. * @param name The name of the effect.
  129734. * @param kernelMatrix The matrix to be applied to the image
  129735. * @param options The required width/height ratio to downsize to before computing the render pass.
  129736. * @param camera The camera to apply the render pass to.
  129737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129738. * @param engine The engine which the post process will be applied. (default: current engine)
  129739. * @param reusable If the post process can be reused on the same frame. (default: false)
  129740. */
  129741. constructor(name: string,
  129742. /** The matrix to be applied to the image */
  129743. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129744. }
  129745. }
  129746. declare module BABYLON {
  129747. /** @hidden */
  129748. export var fxaaPixelShader: {
  129749. name: string;
  129750. shader: string;
  129751. };
  129752. }
  129753. declare module BABYLON {
  129754. /** @hidden */
  129755. export var fxaaVertexShader: {
  129756. name: string;
  129757. shader: string;
  129758. };
  129759. }
  129760. declare module BABYLON {
  129761. /**
  129762. * Fxaa post process
  129763. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  129764. */
  129765. export class FxaaPostProcess extends PostProcess {
  129766. /** @hidden */
  129767. texelWidth: number;
  129768. /** @hidden */
  129769. texelHeight: number;
  129770. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129771. private _getDefines;
  129772. }
  129773. }
  129774. declare module BABYLON {
  129775. /** @hidden */
  129776. export var grainPixelShader: {
  129777. name: string;
  129778. shader: string;
  129779. };
  129780. }
  129781. declare module BABYLON {
  129782. /**
  129783. * The GrainPostProcess adds noise to the image at mid luminance levels
  129784. */
  129785. export class GrainPostProcess extends PostProcess {
  129786. /**
  129787. * The intensity of the grain added (default: 30)
  129788. */
  129789. intensity: number;
  129790. /**
  129791. * If the grain should be randomized on every frame
  129792. */
  129793. animated: boolean;
  129794. /**
  129795. * Creates a new instance of @see GrainPostProcess
  129796. * @param name The name of the effect.
  129797. * @param options The required width/height ratio to downsize to before computing the render pass.
  129798. * @param camera The camera to apply the render pass to.
  129799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129800. * @param engine The engine which the post process will be applied. (default: current engine)
  129801. * @param reusable If the post process can be reused on the same frame. (default: false)
  129802. * @param textureType Type of textures used when performing the post process. (default: 0)
  129803. * @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)
  129804. */
  129805. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129806. }
  129807. }
  129808. declare module BABYLON {
  129809. /** @hidden */
  129810. export var highlightsPixelShader: {
  129811. name: string;
  129812. shader: string;
  129813. };
  129814. }
  129815. declare module BABYLON {
  129816. /**
  129817. * Extracts highlights from the image
  129818. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  129819. */
  129820. export class HighlightsPostProcess extends PostProcess {
  129821. /**
  129822. * Extracts highlights from the image
  129823. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  129824. * @param name The name of the effect.
  129825. * @param options The required width/height ratio to downsize to before computing the render pass.
  129826. * @param camera The camera to apply the render pass to.
  129827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129828. * @param engine The engine which the post process will be applied. (default: current engine)
  129829. * @param reusable If the post process can be reused on the same frame. (default: false)
  129830. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  129831. */
  129832. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129833. }
  129834. }
  129835. declare module BABYLON {
  129836. /** @hidden */
  129837. export var mrtFragmentDeclaration: {
  129838. name: string;
  129839. shader: string;
  129840. };
  129841. }
  129842. declare module BABYLON {
  129843. /** @hidden */
  129844. export var geometryPixelShader: {
  129845. name: string;
  129846. shader: string;
  129847. };
  129848. }
  129849. declare module BABYLON {
  129850. /** @hidden */
  129851. export var geometryVertexShader: {
  129852. name: string;
  129853. shader: string;
  129854. };
  129855. }
  129856. declare module BABYLON {
  129857. /** @hidden */
  129858. interface ISavedTransformationMatrix {
  129859. world: Matrix;
  129860. viewProjection: Matrix;
  129861. }
  129862. /**
  129863. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  129864. */
  129865. export class GeometryBufferRenderer {
  129866. /**
  129867. * Constant used to retrieve the position texture index in the G-Buffer textures array
  129868. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  129869. */
  129870. static readonly POSITION_TEXTURE_TYPE: number;
  129871. /**
  129872. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  129873. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  129874. */
  129875. static readonly VELOCITY_TEXTURE_TYPE: number;
  129876. /**
  129877. * Dictionary used to store the previous transformation matrices of each rendered mesh
  129878. * in order to compute objects velocities when enableVelocity is set to "true"
  129879. * @hidden
  129880. */
  129881. _previousTransformationMatrices: {
  129882. [index: number]: ISavedTransformationMatrix;
  129883. };
  129884. /**
  129885. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  129886. * in order to compute objects velocities when enableVelocity is set to "true"
  129887. * @hidden
  129888. */
  129889. _previousBonesTransformationMatrices: {
  129890. [index: number]: Float32Array;
  129891. };
  129892. /**
  129893. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  129894. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  129895. */
  129896. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  129897. private _scene;
  129898. private _multiRenderTarget;
  129899. private _ratio;
  129900. private _enablePosition;
  129901. private _enableVelocity;
  129902. private _positionIndex;
  129903. private _velocityIndex;
  129904. protected _effect: Effect;
  129905. protected _cachedDefines: string;
  129906. /**
  129907. * Set the render list (meshes to be rendered) used in the G buffer.
  129908. */
  129909. renderList: Mesh[];
  129910. /**
  129911. * Gets wether or not G buffer are supported by the running hardware.
  129912. * This requires draw buffer supports
  129913. */
  129914. readonly isSupported: boolean;
  129915. /**
  129916. * Returns the index of the given texture type in the G-Buffer textures array
  129917. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  129918. * @returns the index of the given texture type in the G-Buffer textures array
  129919. */
  129920. getTextureIndex(textureType: number): number;
  129921. /**
  129922. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  129923. */
  129924. /**
  129925. * Sets whether or not objects positions are enabled for the G buffer.
  129926. */
  129927. enablePosition: boolean;
  129928. /**
  129929. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  129930. */
  129931. /**
  129932. * Sets wether or not objects velocities are enabled for the G buffer.
  129933. */
  129934. enableVelocity: boolean;
  129935. /**
  129936. * Gets the scene associated with the buffer.
  129937. */
  129938. readonly scene: Scene;
  129939. /**
  129940. * Gets the ratio used by the buffer during its creation.
  129941. * How big is the buffer related to the main canvas.
  129942. */
  129943. readonly ratio: number;
  129944. /** @hidden */
  129945. static _SceneComponentInitialization: (scene: Scene) => void;
  129946. /**
  129947. * Creates a new G Buffer for the scene
  129948. * @param scene The scene the buffer belongs to
  129949. * @param ratio How big is the buffer related to the main canvas.
  129950. */
  129951. constructor(scene: Scene, ratio?: number);
  129952. /**
  129953. * Checks wether everything is ready to render a submesh to the G buffer.
  129954. * @param subMesh the submesh to check readiness for
  129955. * @param useInstances is the mesh drawn using instance or not
  129956. * @returns true if ready otherwise false
  129957. */
  129958. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129959. /**
  129960. * Gets the current underlying G Buffer.
  129961. * @returns the buffer
  129962. */
  129963. getGBuffer(): MultiRenderTarget;
  129964. /**
  129965. * Gets the number of samples used to render the buffer (anti aliasing).
  129966. */
  129967. /**
  129968. * Sets the number of samples used to render the buffer (anti aliasing).
  129969. */
  129970. samples: number;
  129971. /**
  129972. * Disposes the renderer and frees up associated resources.
  129973. */
  129974. dispose(): void;
  129975. protected _createRenderTargets(): void;
  129976. private _copyBonesTransformationMatrices;
  129977. }
  129978. }
  129979. declare module BABYLON {
  129980. interface Scene {
  129981. /** @hidden (Backing field) */
  129982. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129983. /**
  129984. * Gets or Sets the current geometry buffer associated to the scene.
  129985. */
  129986. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129987. /**
  129988. * Enables a GeometryBufferRender and associates it with the scene
  129989. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  129990. * @returns the GeometryBufferRenderer
  129991. */
  129992. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  129993. /**
  129994. * Disables the GeometryBufferRender associated with the scene
  129995. */
  129996. disableGeometryBufferRenderer(): void;
  129997. }
  129998. /**
  129999. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  130000. * in several rendering techniques.
  130001. */
  130002. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  130003. /**
  130004. * The component name helpful to identify the component in the list of scene components.
  130005. */
  130006. readonly name: string;
  130007. /**
  130008. * The scene the component belongs to.
  130009. */
  130010. scene: Scene;
  130011. /**
  130012. * Creates a new instance of the component for the given scene
  130013. * @param scene Defines the scene to register the component in
  130014. */
  130015. constructor(scene: Scene);
  130016. /**
  130017. * Registers the component in a given scene
  130018. */
  130019. register(): void;
  130020. /**
  130021. * Rebuilds the elements related to this component in case of
  130022. * context lost for instance.
  130023. */
  130024. rebuild(): void;
  130025. /**
  130026. * Disposes the component and the associated ressources
  130027. */
  130028. dispose(): void;
  130029. private _gatherRenderTargets;
  130030. }
  130031. }
  130032. declare module BABYLON {
  130033. /** @hidden */
  130034. export var motionBlurPixelShader: {
  130035. name: string;
  130036. shader: string;
  130037. };
  130038. }
  130039. declare module BABYLON {
  130040. /**
  130041. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  130042. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  130043. * As an example, all you have to do is to create the post-process:
  130044. * var mb = new BABYLON.MotionBlurPostProcess(
  130045. * 'mb', // The name of the effect.
  130046. * scene, // The scene containing the objects to blur according to their velocity.
  130047. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  130048. * camera // The camera to apply the render pass to.
  130049. * );
  130050. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  130051. */
  130052. export class MotionBlurPostProcess extends PostProcess {
  130053. /**
  130054. * Defines how much the image is blurred by the movement. Default value is equal to 1
  130055. */
  130056. motionStrength: number;
  130057. /**
  130058. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  130059. */
  130060. /**
  130061. * Sets the number of iterations to be used for motion blur quality
  130062. */
  130063. motionBlurSamples: number;
  130064. private _motionBlurSamples;
  130065. private _geometryBufferRenderer;
  130066. /**
  130067. * Creates a new instance MotionBlurPostProcess
  130068. * @param name The name of the effect.
  130069. * @param scene The scene containing the objects to blur according to their velocity.
  130070. * @param options The required width/height ratio to downsize to before computing the render pass.
  130071. * @param camera The camera to apply the render pass to.
  130072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130073. * @param engine The engine which the post process will be applied. (default: current engine)
  130074. * @param reusable If the post process can be reused on the same frame. (default: false)
  130075. * @param textureType Type of textures used when performing the post process. (default: 0)
  130076. * @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)
  130077. */
  130078. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130079. /**
  130080. * Excludes the given skinned mesh from computing bones velocities.
  130081. * 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.
  130082. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  130083. */
  130084. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130085. /**
  130086. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  130087. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  130088. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  130089. */
  130090. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130091. /**
  130092. * Disposes the post process.
  130093. * @param camera The camera to dispose the post process on.
  130094. */
  130095. dispose(camera?: Camera): void;
  130096. }
  130097. }
  130098. declare module BABYLON {
  130099. /** @hidden */
  130100. export var refractionPixelShader: {
  130101. name: string;
  130102. shader: string;
  130103. };
  130104. }
  130105. declare module BABYLON {
  130106. /**
  130107. * Post process which applies a refractin texture
  130108. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130109. */
  130110. export class RefractionPostProcess extends PostProcess {
  130111. /** the base color of the refraction (used to taint the rendering) */
  130112. color: Color3;
  130113. /** simulated refraction depth */
  130114. depth: number;
  130115. /** the coefficient of the base color (0 to remove base color tainting) */
  130116. colorLevel: number;
  130117. private _refTexture;
  130118. private _ownRefractionTexture;
  130119. /**
  130120. * Gets or sets the refraction texture
  130121. * Please note that you are responsible for disposing the texture if you set it manually
  130122. */
  130123. refractionTexture: Texture;
  130124. /**
  130125. * Initializes the RefractionPostProcess
  130126. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130127. * @param name The name of the effect.
  130128. * @param refractionTextureUrl Url of the refraction texture to use
  130129. * @param color the base color of the refraction (used to taint the rendering)
  130130. * @param depth simulated refraction depth
  130131. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  130132. * @param camera The camera to apply the render pass to.
  130133. * @param options The required width/height ratio to downsize to before computing the render pass.
  130134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130135. * @param engine The engine which the post process will be applied. (default: current engine)
  130136. * @param reusable If the post process can be reused on the same frame. (default: false)
  130137. */
  130138. constructor(name: string, refractionTextureUrl: string,
  130139. /** the base color of the refraction (used to taint the rendering) */
  130140. color: Color3,
  130141. /** simulated refraction depth */
  130142. depth: number,
  130143. /** the coefficient of the base color (0 to remove base color tainting) */
  130144. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130145. /**
  130146. * Disposes of the post process
  130147. * @param camera Camera to dispose post process on
  130148. */
  130149. dispose(camera: Camera): void;
  130150. }
  130151. }
  130152. declare module BABYLON {
  130153. /** @hidden */
  130154. export var sharpenPixelShader: {
  130155. name: string;
  130156. shader: string;
  130157. };
  130158. }
  130159. declare module BABYLON {
  130160. /**
  130161. * The SharpenPostProcess applies a sharpen kernel to every pixel
  130162. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130163. */
  130164. export class SharpenPostProcess extends PostProcess {
  130165. /**
  130166. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  130167. */
  130168. colorAmount: number;
  130169. /**
  130170. * How much sharpness should be applied (default: 0.3)
  130171. */
  130172. edgeAmount: number;
  130173. /**
  130174. * Creates a new instance ConvolutionPostProcess
  130175. * @param name The name of the effect.
  130176. * @param options The required width/height ratio to downsize to before computing the render pass.
  130177. * @param camera The camera to apply the render pass to.
  130178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130179. * @param engine The engine which the post process will be applied. (default: current engine)
  130180. * @param reusable If the post process can be reused on the same frame. (default: false)
  130181. * @param textureType Type of textures used when performing the post process. (default: 0)
  130182. * @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)
  130183. */
  130184. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130185. }
  130186. }
  130187. declare module BABYLON {
  130188. /**
  130189. * PostProcessRenderPipeline
  130190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130191. */
  130192. export class PostProcessRenderPipeline {
  130193. private engine;
  130194. private _renderEffects;
  130195. private _renderEffectsForIsolatedPass;
  130196. /**
  130197. * List of inspectable custom properties (used by the Inspector)
  130198. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  130199. */
  130200. inspectableCustomProperties: IInspectable[];
  130201. /**
  130202. * @hidden
  130203. */
  130204. protected _cameras: Camera[];
  130205. /** @hidden */
  130206. _name: string;
  130207. /**
  130208. * Gets pipeline name
  130209. */
  130210. readonly name: string;
  130211. /** Gets the list of attached cameras */
  130212. readonly cameras: Camera[];
  130213. /**
  130214. * Initializes a PostProcessRenderPipeline
  130215. * @param engine engine to add the pipeline to
  130216. * @param name name of the pipeline
  130217. */
  130218. constructor(engine: Engine, name: string);
  130219. /**
  130220. * Gets the class name
  130221. * @returns "PostProcessRenderPipeline"
  130222. */
  130223. getClassName(): string;
  130224. /**
  130225. * If all the render effects in the pipeline are supported
  130226. */
  130227. readonly isSupported: boolean;
  130228. /**
  130229. * Adds an effect to the pipeline
  130230. * @param renderEffect the effect to add
  130231. */
  130232. addEffect(renderEffect: PostProcessRenderEffect): void;
  130233. /** @hidden */
  130234. _rebuild(): void;
  130235. /** @hidden */
  130236. _enableEffect(renderEffectName: string, cameras: Camera): void;
  130237. /** @hidden */
  130238. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  130239. /** @hidden */
  130240. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130241. /** @hidden */
  130242. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130243. /** @hidden */
  130244. _attachCameras(cameras: Camera, unique: boolean): void;
  130245. /** @hidden */
  130246. _attachCameras(cameras: Camera[], unique: boolean): void;
  130247. /** @hidden */
  130248. _detachCameras(cameras: Camera): void;
  130249. /** @hidden */
  130250. _detachCameras(cameras: Nullable<Camera[]>): void;
  130251. /** @hidden */
  130252. _update(): void;
  130253. /** @hidden */
  130254. _reset(): void;
  130255. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  130256. /**
  130257. * Disposes of the pipeline
  130258. */
  130259. dispose(): void;
  130260. }
  130261. }
  130262. declare module BABYLON {
  130263. /**
  130264. * PostProcessRenderPipelineManager class
  130265. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130266. */
  130267. export class PostProcessRenderPipelineManager {
  130268. private _renderPipelines;
  130269. /**
  130270. * Initializes a PostProcessRenderPipelineManager
  130271. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130272. */
  130273. constructor();
  130274. /**
  130275. * Gets the list of supported render pipelines
  130276. */
  130277. readonly supportedPipelines: PostProcessRenderPipeline[];
  130278. /**
  130279. * Adds a pipeline to the manager
  130280. * @param renderPipeline The pipeline to add
  130281. */
  130282. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  130283. /**
  130284. * Attaches a camera to the pipeline
  130285. * @param renderPipelineName The name of the pipeline to attach to
  130286. * @param cameras the camera to attach
  130287. * @param unique if the camera can be attached multiple times to the pipeline
  130288. */
  130289. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  130290. /**
  130291. * Detaches a camera from the pipeline
  130292. * @param renderPipelineName The name of the pipeline to detach from
  130293. * @param cameras the camera to detach
  130294. */
  130295. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  130296. /**
  130297. * Enables an effect by name on a pipeline
  130298. * @param renderPipelineName the name of the pipeline to enable the effect in
  130299. * @param renderEffectName the name of the effect to enable
  130300. * @param cameras the cameras that the effect should be enabled on
  130301. */
  130302. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130303. /**
  130304. * Disables an effect by name on a pipeline
  130305. * @param renderPipelineName the name of the pipeline to disable the effect in
  130306. * @param renderEffectName the name of the effect to disable
  130307. * @param cameras the cameras that the effect should be disabled on
  130308. */
  130309. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130310. /**
  130311. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  130312. */
  130313. update(): void;
  130314. /** @hidden */
  130315. _rebuild(): void;
  130316. /**
  130317. * Disposes of the manager and pipelines
  130318. */
  130319. dispose(): void;
  130320. }
  130321. }
  130322. declare module BABYLON {
  130323. interface Scene {
  130324. /** @hidden (Backing field) */
  130325. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130326. /**
  130327. * Gets the postprocess render pipeline manager
  130328. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130329. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130330. */
  130331. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130332. }
  130333. /**
  130334. * Defines the Render Pipeline scene component responsible to rendering pipelines
  130335. */
  130336. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  130337. /**
  130338. * The component name helpfull to identify the component in the list of scene components.
  130339. */
  130340. readonly name: string;
  130341. /**
  130342. * The scene the component belongs to.
  130343. */
  130344. scene: Scene;
  130345. /**
  130346. * Creates a new instance of the component for the given scene
  130347. * @param scene Defines the scene to register the component in
  130348. */
  130349. constructor(scene: Scene);
  130350. /**
  130351. * Registers the component in a given scene
  130352. */
  130353. register(): void;
  130354. /**
  130355. * Rebuilds the elements related to this component in case of
  130356. * context lost for instance.
  130357. */
  130358. rebuild(): void;
  130359. /**
  130360. * Disposes the component and the associated ressources
  130361. */
  130362. dispose(): void;
  130363. private _gatherRenderTargets;
  130364. }
  130365. }
  130366. declare module BABYLON {
  130367. /**
  130368. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  130369. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130370. */
  130371. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130372. private _scene;
  130373. private _camerasToBeAttached;
  130374. /**
  130375. * ID of the sharpen post process,
  130376. */
  130377. private readonly SharpenPostProcessId;
  130378. /**
  130379. * @ignore
  130380. * ID of the image processing post process;
  130381. */
  130382. readonly ImageProcessingPostProcessId: string;
  130383. /**
  130384. * @ignore
  130385. * ID of the Fast Approximate Anti-Aliasing post process;
  130386. */
  130387. readonly FxaaPostProcessId: string;
  130388. /**
  130389. * ID of the chromatic aberration post process,
  130390. */
  130391. private readonly ChromaticAberrationPostProcessId;
  130392. /**
  130393. * ID of the grain post process
  130394. */
  130395. private readonly GrainPostProcessId;
  130396. /**
  130397. * Sharpen post process which will apply a sharpen convolution to enhance edges
  130398. */
  130399. sharpen: SharpenPostProcess;
  130400. private _sharpenEffect;
  130401. private bloom;
  130402. /**
  130403. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  130404. */
  130405. depthOfField: DepthOfFieldEffect;
  130406. /**
  130407. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130408. */
  130409. fxaa: FxaaPostProcess;
  130410. /**
  130411. * Image post processing pass used to perform operations such as tone mapping or color grading.
  130412. */
  130413. imageProcessing: ImageProcessingPostProcess;
  130414. /**
  130415. * Chromatic aberration post process which will shift rgb colors in the image
  130416. */
  130417. chromaticAberration: ChromaticAberrationPostProcess;
  130418. private _chromaticAberrationEffect;
  130419. /**
  130420. * Grain post process which add noise to the image
  130421. */
  130422. grain: GrainPostProcess;
  130423. private _grainEffect;
  130424. /**
  130425. * Glow post process which adds a glow to emissive areas of the image
  130426. */
  130427. private _glowLayer;
  130428. /**
  130429. * Animations which can be used to tweak settings over a period of time
  130430. */
  130431. animations: Animation[];
  130432. private _imageProcessingConfigurationObserver;
  130433. private _sharpenEnabled;
  130434. private _bloomEnabled;
  130435. private _depthOfFieldEnabled;
  130436. private _depthOfFieldBlurLevel;
  130437. private _fxaaEnabled;
  130438. private _imageProcessingEnabled;
  130439. private _defaultPipelineTextureType;
  130440. private _bloomScale;
  130441. private _chromaticAberrationEnabled;
  130442. private _grainEnabled;
  130443. private _buildAllowed;
  130444. /**
  130445. * Gets active scene
  130446. */
  130447. readonly scene: Scene;
  130448. /**
  130449. * Enable or disable the sharpen process from the pipeline
  130450. */
  130451. sharpenEnabled: boolean;
  130452. private _resizeObserver;
  130453. private _hardwareScaleLevel;
  130454. private _bloomKernel;
  130455. /**
  130456. * Specifies the size of the bloom blur kernel, relative to the final output size
  130457. */
  130458. bloomKernel: number;
  130459. /**
  130460. * Specifies the weight of the bloom in the final rendering
  130461. */
  130462. private _bloomWeight;
  130463. /**
  130464. * Specifies the luma threshold for the area that will be blurred by the bloom
  130465. */
  130466. private _bloomThreshold;
  130467. private _hdr;
  130468. /**
  130469. * The strength of the bloom.
  130470. */
  130471. bloomWeight: number;
  130472. /**
  130473. * The strength of the bloom.
  130474. */
  130475. bloomThreshold: number;
  130476. /**
  130477. * The scale of the bloom, lower value will provide better performance.
  130478. */
  130479. bloomScale: number;
  130480. /**
  130481. * Enable or disable the bloom from the pipeline
  130482. */
  130483. bloomEnabled: boolean;
  130484. private _rebuildBloom;
  130485. /**
  130486. * If the depth of field is enabled.
  130487. */
  130488. depthOfFieldEnabled: boolean;
  130489. /**
  130490. * Blur level of the depth of field effect. (Higher blur will effect performance)
  130491. */
  130492. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  130493. /**
  130494. * If the anti aliasing is enabled.
  130495. */
  130496. fxaaEnabled: boolean;
  130497. private _samples;
  130498. /**
  130499. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130500. */
  130501. samples: number;
  130502. /**
  130503. * If image processing is enabled.
  130504. */
  130505. imageProcessingEnabled: boolean;
  130506. /**
  130507. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  130508. */
  130509. glowLayerEnabled: boolean;
  130510. /**
  130511. * Gets the glow layer (or null if not defined)
  130512. */
  130513. readonly glowLayer: Nullable<GlowLayer>;
  130514. /**
  130515. * Enable or disable the chromaticAberration process from the pipeline
  130516. */
  130517. chromaticAberrationEnabled: boolean;
  130518. /**
  130519. * Enable or disable the grain process from the pipeline
  130520. */
  130521. grainEnabled: boolean;
  130522. /**
  130523. * @constructor
  130524. * @param name - The rendering pipeline name (default: "")
  130525. * @param hdr - If high dynamic range textures should be used (default: true)
  130526. * @param scene - The scene linked to this pipeline (default: the last created scene)
  130527. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  130528. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  130529. */
  130530. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  130531. /**
  130532. * Get the class name
  130533. * @returns "DefaultRenderingPipeline"
  130534. */
  130535. getClassName(): string;
  130536. /**
  130537. * Force the compilation of the entire pipeline.
  130538. */
  130539. prepare(): void;
  130540. private _hasCleared;
  130541. private _prevPostProcess;
  130542. private _prevPrevPostProcess;
  130543. private _setAutoClearAndTextureSharing;
  130544. private _depthOfFieldSceneObserver;
  130545. private _buildPipeline;
  130546. private _disposePostProcesses;
  130547. /**
  130548. * Adds a camera to the pipeline
  130549. * @param camera the camera to be added
  130550. */
  130551. addCamera(camera: Camera): void;
  130552. /**
  130553. * Removes a camera from the pipeline
  130554. * @param camera the camera to remove
  130555. */
  130556. removeCamera(camera: Camera): void;
  130557. /**
  130558. * Dispose of the pipeline and stop all post processes
  130559. */
  130560. dispose(): void;
  130561. /**
  130562. * Serialize the rendering pipeline (Used when exporting)
  130563. * @returns the serialized object
  130564. */
  130565. serialize(): any;
  130566. /**
  130567. * Parse the serialized pipeline
  130568. * @param source Source pipeline.
  130569. * @param scene The scene to load the pipeline to.
  130570. * @param rootUrl The URL of the serialized pipeline.
  130571. * @returns An instantiated pipeline from the serialized object.
  130572. */
  130573. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  130574. }
  130575. }
  130576. declare module BABYLON {
  130577. /** @hidden */
  130578. export var lensHighlightsPixelShader: {
  130579. name: string;
  130580. shader: string;
  130581. };
  130582. }
  130583. declare module BABYLON {
  130584. /** @hidden */
  130585. export var depthOfFieldPixelShader: {
  130586. name: string;
  130587. shader: string;
  130588. };
  130589. }
  130590. declare module BABYLON {
  130591. /**
  130592. * BABYLON.JS Chromatic Aberration GLSL Shader
  130593. * Author: Olivier Guyot
  130594. * Separates very slightly R, G and B colors on the edges of the screen
  130595. * Inspired by Francois Tarlier & Martins Upitis
  130596. */
  130597. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  130598. /**
  130599. * @ignore
  130600. * The chromatic aberration PostProcess id in the pipeline
  130601. */
  130602. LensChromaticAberrationEffect: string;
  130603. /**
  130604. * @ignore
  130605. * The highlights enhancing PostProcess id in the pipeline
  130606. */
  130607. HighlightsEnhancingEffect: string;
  130608. /**
  130609. * @ignore
  130610. * The depth-of-field PostProcess id in the pipeline
  130611. */
  130612. LensDepthOfFieldEffect: string;
  130613. private _scene;
  130614. private _depthTexture;
  130615. private _grainTexture;
  130616. private _chromaticAberrationPostProcess;
  130617. private _highlightsPostProcess;
  130618. private _depthOfFieldPostProcess;
  130619. private _edgeBlur;
  130620. private _grainAmount;
  130621. private _chromaticAberration;
  130622. private _distortion;
  130623. private _highlightsGain;
  130624. private _highlightsThreshold;
  130625. private _dofDistance;
  130626. private _dofAperture;
  130627. private _dofDarken;
  130628. private _dofPentagon;
  130629. private _blurNoise;
  130630. /**
  130631. * @constructor
  130632. *
  130633. * Effect parameters are as follow:
  130634. * {
  130635. * chromatic_aberration: number; // from 0 to x (1 for realism)
  130636. * edge_blur: number; // from 0 to x (1 for realism)
  130637. * distortion: number; // from 0 to x (1 for realism)
  130638. * grain_amount: number; // from 0 to 1
  130639. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  130640. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  130641. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  130642. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  130643. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  130644. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  130645. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  130646. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  130647. * }
  130648. * Note: if an effect parameter is unset, effect is disabled
  130649. *
  130650. * @param name The rendering pipeline name
  130651. * @param parameters - An object containing all parameters (see above)
  130652. * @param scene The scene linked to this pipeline
  130653. * @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)
  130654. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130655. */
  130656. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  130657. /**
  130658. * Get the class name
  130659. * @returns "LensRenderingPipeline"
  130660. */
  130661. getClassName(): string;
  130662. /**
  130663. * Gets associated scene
  130664. */
  130665. readonly scene: Scene;
  130666. /**
  130667. * Gets or sets the edge blur
  130668. */
  130669. edgeBlur: number;
  130670. /**
  130671. * Gets or sets the grain amount
  130672. */
  130673. grainAmount: number;
  130674. /**
  130675. * Gets or sets the chromatic aberration amount
  130676. */
  130677. chromaticAberration: number;
  130678. /**
  130679. * Gets or sets the depth of field aperture
  130680. */
  130681. dofAperture: number;
  130682. /**
  130683. * Gets or sets the edge distortion
  130684. */
  130685. edgeDistortion: number;
  130686. /**
  130687. * Gets or sets the depth of field distortion
  130688. */
  130689. dofDistortion: number;
  130690. /**
  130691. * Gets or sets the darken out of focus amount
  130692. */
  130693. darkenOutOfFocus: number;
  130694. /**
  130695. * Gets or sets a boolean indicating if blur noise is enabled
  130696. */
  130697. blurNoise: boolean;
  130698. /**
  130699. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  130700. */
  130701. pentagonBokeh: boolean;
  130702. /**
  130703. * Gets or sets the highlight grain amount
  130704. */
  130705. highlightsGain: number;
  130706. /**
  130707. * Gets or sets the highlight threshold
  130708. */
  130709. highlightsThreshold: number;
  130710. /**
  130711. * Sets the amount of blur at the edges
  130712. * @param amount blur amount
  130713. */
  130714. setEdgeBlur(amount: number): void;
  130715. /**
  130716. * Sets edge blur to 0
  130717. */
  130718. disableEdgeBlur(): void;
  130719. /**
  130720. * Sets the amout of grain
  130721. * @param amount Amount of grain
  130722. */
  130723. setGrainAmount(amount: number): void;
  130724. /**
  130725. * Set grain amount to 0
  130726. */
  130727. disableGrain(): void;
  130728. /**
  130729. * Sets the chromatic aberration amount
  130730. * @param amount amount of chromatic aberration
  130731. */
  130732. setChromaticAberration(amount: number): void;
  130733. /**
  130734. * Sets chromatic aberration amount to 0
  130735. */
  130736. disableChromaticAberration(): void;
  130737. /**
  130738. * Sets the EdgeDistortion amount
  130739. * @param amount amount of EdgeDistortion
  130740. */
  130741. setEdgeDistortion(amount: number): void;
  130742. /**
  130743. * Sets edge distortion to 0
  130744. */
  130745. disableEdgeDistortion(): void;
  130746. /**
  130747. * Sets the FocusDistance amount
  130748. * @param amount amount of FocusDistance
  130749. */
  130750. setFocusDistance(amount: number): void;
  130751. /**
  130752. * Disables depth of field
  130753. */
  130754. disableDepthOfField(): void;
  130755. /**
  130756. * Sets the Aperture amount
  130757. * @param amount amount of Aperture
  130758. */
  130759. setAperture(amount: number): void;
  130760. /**
  130761. * Sets the DarkenOutOfFocus amount
  130762. * @param amount amount of DarkenOutOfFocus
  130763. */
  130764. setDarkenOutOfFocus(amount: number): void;
  130765. private _pentagonBokehIsEnabled;
  130766. /**
  130767. * Creates a pentagon bokeh effect
  130768. */
  130769. enablePentagonBokeh(): void;
  130770. /**
  130771. * Disables the pentagon bokeh effect
  130772. */
  130773. disablePentagonBokeh(): void;
  130774. /**
  130775. * Enables noise blur
  130776. */
  130777. enableNoiseBlur(): void;
  130778. /**
  130779. * Disables noise blur
  130780. */
  130781. disableNoiseBlur(): void;
  130782. /**
  130783. * Sets the HighlightsGain amount
  130784. * @param amount amount of HighlightsGain
  130785. */
  130786. setHighlightsGain(amount: number): void;
  130787. /**
  130788. * Sets the HighlightsThreshold amount
  130789. * @param amount amount of HighlightsThreshold
  130790. */
  130791. setHighlightsThreshold(amount: number): void;
  130792. /**
  130793. * Disables highlights
  130794. */
  130795. disableHighlights(): void;
  130796. /**
  130797. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  130798. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  130799. */
  130800. dispose(disableDepthRender?: boolean): void;
  130801. private _createChromaticAberrationPostProcess;
  130802. private _createHighlightsPostProcess;
  130803. private _createDepthOfFieldPostProcess;
  130804. private _createGrainTexture;
  130805. }
  130806. }
  130807. declare module BABYLON {
  130808. /** @hidden */
  130809. export var ssao2PixelShader: {
  130810. name: string;
  130811. shader: string;
  130812. };
  130813. }
  130814. declare module BABYLON {
  130815. /** @hidden */
  130816. export var ssaoCombinePixelShader: {
  130817. name: string;
  130818. shader: string;
  130819. };
  130820. }
  130821. declare module BABYLON {
  130822. /**
  130823. * Render pipeline to produce ssao effect
  130824. */
  130825. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  130826. /**
  130827. * @ignore
  130828. * The PassPostProcess id in the pipeline that contains the original scene color
  130829. */
  130830. SSAOOriginalSceneColorEffect: string;
  130831. /**
  130832. * @ignore
  130833. * The SSAO PostProcess id in the pipeline
  130834. */
  130835. SSAORenderEffect: string;
  130836. /**
  130837. * @ignore
  130838. * The horizontal blur PostProcess id in the pipeline
  130839. */
  130840. SSAOBlurHRenderEffect: string;
  130841. /**
  130842. * @ignore
  130843. * The vertical blur PostProcess id in the pipeline
  130844. */
  130845. SSAOBlurVRenderEffect: string;
  130846. /**
  130847. * @ignore
  130848. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130849. */
  130850. SSAOCombineRenderEffect: string;
  130851. /**
  130852. * The output strength of the SSAO post-process. Default value is 1.0.
  130853. */
  130854. totalStrength: number;
  130855. /**
  130856. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  130857. */
  130858. maxZ: number;
  130859. /**
  130860. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  130861. */
  130862. minZAspect: number;
  130863. private _samples;
  130864. /**
  130865. * Number of samples used for the SSAO calculations. Default value is 8
  130866. */
  130867. samples: number;
  130868. private _textureSamples;
  130869. /**
  130870. * Number of samples to use for antialiasing
  130871. */
  130872. textureSamples: number;
  130873. /**
  130874. * Ratio object used for SSAO ratio and blur ratio
  130875. */
  130876. private _ratio;
  130877. /**
  130878. * Dynamically generated sphere sampler.
  130879. */
  130880. private _sampleSphere;
  130881. /**
  130882. * Blur filter offsets
  130883. */
  130884. private _samplerOffsets;
  130885. private _expensiveBlur;
  130886. /**
  130887. * If bilateral blur should be used
  130888. */
  130889. expensiveBlur: boolean;
  130890. /**
  130891. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  130892. */
  130893. radius: number;
  130894. /**
  130895. * The base color of the SSAO post-process
  130896. * The final result is "base + ssao" between [0, 1]
  130897. */
  130898. base: number;
  130899. /**
  130900. * Support test.
  130901. */
  130902. static readonly IsSupported: boolean;
  130903. private _scene;
  130904. private _depthTexture;
  130905. private _normalTexture;
  130906. private _randomTexture;
  130907. private _originalColorPostProcess;
  130908. private _ssaoPostProcess;
  130909. private _blurHPostProcess;
  130910. private _blurVPostProcess;
  130911. private _ssaoCombinePostProcess;
  130912. /**
  130913. * Gets active scene
  130914. */
  130915. readonly scene: Scene;
  130916. /**
  130917. * @constructor
  130918. * @param name The rendering pipeline name
  130919. * @param scene The scene linked to this pipeline
  130920. * @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 }
  130921. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130922. */
  130923. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130924. /**
  130925. * Get the class name
  130926. * @returns "SSAO2RenderingPipeline"
  130927. */
  130928. getClassName(): string;
  130929. /**
  130930. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130931. */
  130932. dispose(disableGeometryBufferRenderer?: boolean): void;
  130933. private _createBlurPostProcess;
  130934. /** @hidden */
  130935. _rebuild(): void;
  130936. private _bits;
  130937. private _radicalInverse_VdC;
  130938. private _hammersley;
  130939. private _hemisphereSample_uniform;
  130940. private _generateHemisphere;
  130941. private _createSSAOPostProcess;
  130942. private _createSSAOCombinePostProcess;
  130943. private _createRandomTexture;
  130944. /**
  130945. * Serialize the rendering pipeline (Used when exporting)
  130946. * @returns the serialized object
  130947. */
  130948. serialize(): any;
  130949. /**
  130950. * Parse the serialized pipeline
  130951. * @param source Source pipeline.
  130952. * @param scene The scene to load the pipeline to.
  130953. * @param rootUrl The URL of the serialized pipeline.
  130954. * @returns An instantiated pipeline from the serialized object.
  130955. */
  130956. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  130957. }
  130958. }
  130959. declare module BABYLON {
  130960. /** @hidden */
  130961. export var ssaoPixelShader: {
  130962. name: string;
  130963. shader: string;
  130964. };
  130965. }
  130966. declare module BABYLON {
  130967. /**
  130968. * Render pipeline to produce ssao effect
  130969. */
  130970. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  130971. /**
  130972. * @ignore
  130973. * The PassPostProcess id in the pipeline that contains the original scene color
  130974. */
  130975. SSAOOriginalSceneColorEffect: string;
  130976. /**
  130977. * @ignore
  130978. * The SSAO PostProcess id in the pipeline
  130979. */
  130980. SSAORenderEffect: string;
  130981. /**
  130982. * @ignore
  130983. * The horizontal blur PostProcess id in the pipeline
  130984. */
  130985. SSAOBlurHRenderEffect: string;
  130986. /**
  130987. * @ignore
  130988. * The vertical blur PostProcess id in the pipeline
  130989. */
  130990. SSAOBlurVRenderEffect: string;
  130991. /**
  130992. * @ignore
  130993. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130994. */
  130995. SSAOCombineRenderEffect: string;
  130996. /**
  130997. * The output strength of the SSAO post-process. Default value is 1.0.
  130998. */
  130999. totalStrength: number;
  131000. /**
  131001. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  131002. */
  131003. radius: number;
  131004. /**
  131005. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  131006. * Must not be equal to fallOff and superior to fallOff.
  131007. * Default value is 0.0075
  131008. */
  131009. area: number;
  131010. /**
  131011. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  131012. * Must not be equal to area and inferior to area.
  131013. * Default value is 0.000001
  131014. */
  131015. fallOff: number;
  131016. /**
  131017. * The base color of the SSAO post-process
  131018. * The final result is "base + ssao" between [0, 1]
  131019. */
  131020. base: number;
  131021. private _scene;
  131022. private _depthTexture;
  131023. private _randomTexture;
  131024. private _originalColorPostProcess;
  131025. private _ssaoPostProcess;
  131026. private _blurHPostProcess;
  131027. private _blurVPostProcess;
  131028. private _ssaoCombinePostProcess;
  131029. private _firstUpdate;
  131030. /**
  131031. * Gets active scene
  131032. */
  131033. readonly scene: Scene;
  131034. /**
  131035. * @constructor
  131036. * @param name - The rendering pipeline name
  131037. * @param scene - The scene linked to this pipeline
  131038. * @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 }
  131039. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  131040. */
  131041. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131042. /**
  131043. * Get the class name
  131044. * @returns "SSAORenderingPipeline"
  131045. */
  131046. getClassName(): string;
  131047. /**
  131048. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131049. */
  131050. dispose(disableDepthRender?: boolean): void;
  131051. private _createBlurPostProcess;
  131052. /** @hidden */
  131053. _rebuild(): void;
  131054. private _createSSAOPostProcess;
  131055. private _createSSAOCombinePostProcess;
  131056. private _createRandomTexture;
  131057. }
  131058. }
  131059. declare module BABYLON {
  131060. /** @hidden */
  131061. export var standardPixelShader: {
  131062. name: string;
  131063. shader: string;
  131064. };
  131065. }
  131066. declare module BABYLON {
  131067. /**
  131068. * Standard rendering pipeline
  131069. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131070. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  131071. */
  131072. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  131073. /**
  131074. * Public members
  131075. */
  131076. /**
  131077. * Post-process which contains the original scene color before the pipeline applies all the effects
  131078. */
  131079. originalPostProcess: Nullable<PostProcess>;
  131080. /**
  131081. * Post-process used to down scale an image x4
  131082. */
  131083. downSampleX4PostProcess: Nullable<PostProcess>;
  131084. /**
  131085. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  131086. */
  131087. brightPassPostProcess: Nullable<PostProcess>;
  131088. /**
  131089. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  131090. */
  131091. blurHPostProcesses: PostProcess[];
  131092. /**
  131093. * Post-process array storing all the vertical blur post-processes used by the pipeline
  131094. */
  131095. blurVPostProcesses: PostProcess[];
  131096. /**
  131097. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  131098. */
  131099. textureAdderPostProcess: Nullable<PostProcess>;
  131100. /**
  131101. * Post-process used to create volumetric lighting effect
  131102. */
  131103. volumetricLightPostProcess: Nullable<PostProcess>;
  131104. /**
  131105. * Post-process used to smooth the previous volumetric light post-process on the X axis
  131106. */
  131107. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  131108. /**
  131109. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  131110. */
  131111. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  131112. /**
  131113. * Post-process used to merge the volumetric light effect and the real scene color
  131114. */
  131115. volumetricLightMergePostProces: Nullable<PostProcess>;
  131116. /**
  131117. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  131118. */
  131119. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  131120. /**
  131121. * Base post-process used to calculate the average luminance of the final image for HDR
  131122. */
  131123. luminancePostProcess: Nullable<PostProcess>;
  131124. /**
  131125. * Post-processes used to create down sample post-processes in order to get
  131126. * the average luminance of the final image for HDR
  131127. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  131128. */
  131129. luminanceDownSamplePostProcesses: PostProcess[];
  131130. /**
  131131. * Post-process used to create a HDR effect (light adaptation)
  131132. */
  131133. hdrPostProcess: Nullable<PostProcess>;
  131134. /**
  131135. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  131136. */
  131137. textureAdderFinalPostProcess: Nullable<PostProcess>;
  131138. /**
  131139. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  131140. */
  131141. lensFlareFinalPostProcess: Nullable<PostProcess>;
  131142. /**
  131143. * Post-process used to merge the final HDR post-process and the real scene color
  131144. */
  131145. hdrFinalPostProcess: Nullable<PostProcess>;
  131146. /**
  131147. * Post-process used to create a lens flare effect
  131148. */
  131149. lensFlarePostProcess: Nullable<PostProcess>;
  131150. /**
  131151. * Post-process that merges the result of the lens flare post-process and the real scene color
  131152. */
  131153. lensFlareComposePostProcess: Nullable<PostProcess>;
  131154. /**
  131155. * Post-process used to create a motion blur effect
  131156. */
  131157. motionBlurPostProcess: Nullable<PostProcess>;
  131158. /**
  131159. * Post-process used to create a depth of field effect
  131160. */
  131161. depthOfFieldPostProcess: Nullable<PostProcess>;
  131162. /**
  131163. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  131164. */
  131165. fxaaPostProcess: Nullable<FxaaPostProcess>;
  131166. /**
  131167. * Represents the brightness threshold in order to configure the illuminated surfaces
  131168. */
  131169. brightThreshold: number;
  131170. /**
  131171. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  131172. */
  131173. blurWidth: number;
  131174. /**
  131175. * Sets if the blur for highlighted surfaces must be only horizontal
  131176. */
  131177. horizontalBlur: boolean;
  131178. /**
  131179. * Gets the overall exposure used by the pipeline
  131180. */
  131181. /**
  131182. * Sets the overall exposure used by the pipeline
  131183. */
  131184. exposure: number;
  131185. /**
  131186. * Texture used typically to simulate "dirty" on camera lens
  131187. */
  131188. lensTexture: Nullable<Texture>;
  131189. /**
  131190. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  131191. */
  131192. volumetricLightCoefficient: number;
  131193. /**
  131194. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  131195. */
  131196. volumetricLightPower: number;
  131197. /**
  131198. * Used the set the blur intensity to smooth the volumetric lights
  131199. */
  131200. volumetricLightBlurScale: number;
  131201. /**
  131202. * Light (spot or directional) used to generate the volumetric lights rays
  131203. * The source light must have a shadow generate so the pipeline can get its
  131204. * depth map
  131205. */
  131206. sourceLight: Nullable<SpotLight | DirectionalLight>;
  131207. /**
  131208. * For eye adaptation, represents the minimum luminance the eye can see
  131209. */
  131210. hdrMinimumLuminance: number;
  131211. /**
  131212. * For eye adaptation, represents the decrease luminance speed
  131213. */
  131214. hdrDecreaseRate: number;
  131215. /**
  131216. * For eye adaptation, represents the increase luminance speed
  131217. */
  131218. hdrIncreaseRate: number;
  131219. /**
  131220. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131221. */
  131222. /**
  131223. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131224. */
  131225. hdrAutoExposure: boolean;
  131226. /**
  131227. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  131228. */
  131229. lensColorTexture: Nullable<Texture>;
  131230. /**
  131231. * The overall strengh for the lens flare effect
  131232. */
  131233. lensFlareStrength: number;
  131234. /**
  131235. * Dispersion coefficient for lens flare ghosts
  131236. */
  131237. lensFlareGhostDispersal: number;
  131238. /**
  131239. * Main lens flare halo width
  131240. */
  131241. lensFlareHaloWidth: number;
  131242. /**
  131243. * Based on the lens distortion effect, defines how much the lens flare result
  131244. * is distorted
  131245. */
  131246. lensFlareDistortionStrength: number;
  131247. /**
  131248. * Configures the blur intensity used for for lens flare (halo)
  131249. */
  131250. lensFlareBlurWidth: number;
  131251. /**
  131252. * Lens star texture must be used to simulate rays on the flares and is available
  131253. * in the documentation
  131254. */
  131255. lensStarTexture: Nullable<Texture>;
  131256. /**
  131257. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  131258. * flare effect by taking account of the dirt texture
  131259. */
  131260. lensFlareDirtTexture: Nullable<Texture>;
  131261. /**
  131262. * Represents the focal length for the depth of field effect
  131263. */
  131264. depthOfFieldDistance: number;
  131265. /**
  131266. * Represents the blur intensity for the blurred part of the depth of field effect
  131267. */
  131268. depthOfFieldBlurWidth: number;
  131269. /**
  131270. * Gets how much the image is blurred by the movement while using the motion blur post-process
  131271. */
  131272. /**
  131273. * Sets how much the image is blurred by the movement while using the motion blur post-process
  131274. */
  131275. motionStrength: number;
  131276. /**
  131277. * Gets wether or not the motion blur post-process is object based or screen based.
  131278. */
  131279. /**
  131280. * Sets wether or not the motion blur post-process should be object based or screen based
  131281. */
  131282. objectBasedMotionBlur: boolean;
  131283. /**
  131284. * List of animations for the pipeline (IAnimatable implementation)
  131285. */
  131286. animations: Animation[];
  131287. /**
  131288. * Private members
  131289. */
  131290. private _scene;
  131291. private _currentDepthOfFieldSource;
  131292. private _basePostProcess;
  131293. private _fixedExposure;
  131294. private _currentExposure;
  131295. private _hdrAutoExposure;
  131296. private _hdrCurrentLuminance;
  131297. private _motionStrength;
  131298. private _isObjectBasedMotionBlur;
  131299. private _floatTextureType;
  131300. private _camerasToBeAttached;
  131301. private _ratio;
  131302. private _bloomEnabled;
  131303. private _depthOfFieldEnabled;
  131304. private _vlsEnabled;
  131305. private _lensFlareEnabled;
  131306. private _hdrEnabled;
  131307. private _motionBlurEnabled;
  131308. private _fxaaEnabled;
  131309. private _motionBlurSamples;
  131310. private _volumetricLightStepsCount;
  131311. private _samples;
  131312. /**
  131313. * @ignore
  131314. * Specifies if the bloom pipeline is enabled
  131315. */
  131316. BloomEnabled: boolean;
  131317. /**
  131318. * @ignore
  131319. * Specifies if the depth of field pipeline is enabed
  131320. */
  131321. DepthOfFieldEnabled: boolean;
  131322. /**
  131323. * @ignore
  131324. * Specifies if the lens flare pipeline is enabed
  131325. */
  131326. LensFlareEnabled: boolean;
  131327. /**
  131328. * @ignore
  131329. * Specifies if the HDR pipeline is enabled
  131330. */
  131331. HDREnabled: boolean;
  131332. /**
  131333. * @ignore
  131334. * Specifies if the volumetric lights scattering effect is enabled
  131335. */
  131336. VLSEnabled: boolean;
  131337. /**
  131338. * @ignore
  131339. * Specifies if the motion blur effect is enabled
  131340. */
  131341. MotionBlurEnabled: boolean;
  131342. /**
  131343. * Specifies if anti-aliasing is enabled
  131344. */
  131345. fxaaEnabled: boolean;
  131346. /**
  131347. * Specifies the number of steps used to calculate the volumetric lights
  131348. * Typically in interval [50, 200]
  131349. */
  131350. volumetricLightStepsCount: number;
  131351. /**
  131352. * Specifies the number of samples used for the motion blur effect
  131353. * Typically in interval [16, 64]
  131354. */
  131355. motionBlurSamples: number;
  131356. /**
  131357. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131358. */
  131359. samples: number;
  131360. /**
  131361. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131362. * @constructor
  131363. * @param name The rendering pipeline name
  131364. * @param scene The scene linked to this pipeline
  131365. * @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)
  131366. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  131367. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131368. */
  131369. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  131370. private _buildPipeline;
  131371. private _createDownSampleX4PostProcess;
  131372. private _createBrightPassPostProcess;
  131373. private _createBlurPostProcesses;
  131374. private _createTextureAdderPostProcess;
  131375. private _createVolumetricLightPostProcess;
  131376. private _createLuminancePostProcesses;
  131377. private _createHdrPostProcess;
  131378. private _createLensFlarePostProcess;
  131379. private _createDepthOfFieldPostProcess;
  131380. private _createMotionBlurPostProcess;
  131381. private _getDepthTexture;
  131382. private _disposePostProcesses;
  131383. /**
  131384. * Dispose of the pipeline and stop all post processes
  131385. */
  131386. dispose(): void;
  131387. /**
  131388. * Serialize the rendering pipeline (Used when exporting)
  131389. * @returns the serialized object
  131390. */
  131391. serialize(): any;
  131392. /**
  131393. * Parse the serialized pipeline
  131394. * @param source Source pipeline.
  131395. * @param scene The scene to load the pipeline to.
  131396. * @param rootUrl The URL of the serialized pipeline.
  131397. * @returns An instantiated pipeline from the serialized object.
  131398. */
  131399. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  131400. /**
  131401. * Luminance steps
  131402. */
  131403. static LuminanceSteps: number;
  131404. }
  131405. }
  131406. declare module BABYLON {
  131407. /** @hidden */
  131408. export var tonemapPixelShader: {
  131409. name: string;
  131410. shader: string;
  131411. };
  131412. }
  131413. declare module BABYLON {
  131414. /** Defines operator used for tonemapping */
  131415. export enum TonemappingOperator {
  131416. /** Hable */
  131417. Hable = 0,
  131418. /** Reinhard */
  131419. Reinhard = 1,
  131420. /** HejiDawson */
  131421. HejiDawson = 2,
  131422. /** Photographic */
  131423. Photographic = 3
  131424. }
  131425. /**
  131426. * Defines a post process to apply tone mapping
  131427. */
  131428. export class TonemapPostProcess extends PostProcess {
  131429. private _operator;
  131430. /** Defines the required exposure adjustement */
  131431. exposureAdjustment: number;
  131432. /**
  131433. * Creates a new TonemapPostProcess
  131434. * @param name defines the name of the postprocess
  131435. * @param _operator defines the operator to use
  131436. * @param exposureAdjustment defines the required exposure adjustement
  131437. * @param camera defines the camera to use (can be null)
  131438. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  131439. * @param engine defines the hosting engine (can be ignore if camera is set)
  131440. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131441. */
  131442. constructor(name: string, _operator: TonemappingOperator,
  131443. /** Defines the required exposure adjustement */
  131444. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  131445. }
  131446. }
  131447. declare module BABYLON {
  131448. /** @hidden */
  131449. export var depthVertexShader: {
  131450. name: string;
  131451. shader: string;
  131452. };
  131453. }
  131454. declare module BABYLON {
  131455. /** @hidden */
  131456. export var volumetricLightScatteringPixelShader: {
  131457. name: string;
  131458. shader: string;
  131459. };
  131460. }
  131461. declare module BABYLON {
  131462. /** @hidden */
  131463. export var volumetricLightScatteringPassVertexShader: {
  131464. name: string;
  131465. shader: string;
  131466. };
  131467. }
  131468. declare module BABYLON {
  131469. /** @hidden */
  131470. export var volumetricLightScatteringPassPixelShader: {
  131471. name: string;
  131472. shader: string;
  131473. };
  131474. }
  131475. declare module BABYLON {
  131476. /**
  131477. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  131478. */
  131479. export class VolumetricLightScatteringPostProcess extends PostProcess {
  131480. private _volumetricLightScatteringPass;
  131481. private _volumetricLightScatteringRTT;
  131482. private _viewPort;
  131483. private _screenCoordinates;
  131484. private _cachedDefines;
  131485. /**
  131486. * If not undefined, the mesh position is computed from the attached node position
  131487. */
  131488. attachedNode: {
  131489. position: Vector3;
  131490. };
  131491. /**
  131492. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  131493. */
  131494. customMeshPosition: Vector3;
  131495. /**
  131496. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  131497. */
  131498. useCustomMeshPosition: boolean;
  131499. /**
  131500. * If the post-process should inverse the light scattering direction
  131501. */
  131502. invert: boolean;
  131503. /**
  131504. * The internal mesh used by the post-process
  131505. */
  131506. mesh: Mesh;
  131507. /**
  131508. * @hidden
  131509. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  131510. */
  131511. useDiffuseColor: boolean;
  131512. /**
  131513. * Array containing the excluded meshes not rendered in the internal pass
  131514. */
  131515. excludedMeshes: AbstractMesh[];
  131516. /**
  131517. * Controls the overall intensity of the post-process
  131518. */
  131519. exposure: number;
  131520. /**
  131521. * Dissipates each sample's contribution in range [0, 1]
  131522. */
  131523. decay: number;
  131524. /**
  131525. * Controls the overall intensity of each sample
  131526. */
  131527. weight: number;
  131528. /**
  131529. * Controls the density of each sample
  131530. */
  131531. density: number;
  131532. /**
  131533. * @constructor
  131534. * @param name The post-process name
  131535. * @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)
  131536. * @param camera The camera that the post-process will be attached to
  131537. * @param mesh The mesh used to create the light scattering
  131538. * @param samples The post-process quality, default 100
  131539. * @param samplingModeThe post-process filtering mode
  131540. * @param engine The babylon engine
  131541. * @param reusable If the post-process is reusable
  131542. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  131543. */
  131544. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  131545. /**
  131546. * Returns the string "VolumetricLightScatteringPostProcess"
  131547. * @returns "VolumetricLightScatteringPostProcess"
  131548. */
  131549. getClassName(): string;
  131550. private _isReady;
  131551. /**
  131552. * Sets the new light position for light scattering effect
  131553. * @param position The new custom light position
  131554. */
  131555. setCustomMeshPosition(position: Vector3): void;
  131556. /**
  131557. * Returns the light position for light scattering effect
  131558. * @return Vector3 The custom light position
  131559. */
  131560. getCustomMeshPosition(): Vector3;
  131561. /**
  131562. * Disposes the internal assets and detaches the post-process from the camera
  131563. */
  131564. dispose(camera: Camera): void;
  131565. /**
  131566. * Returns the render target texture used by the post-process
  131567. * @return the render target texture used by the post-process
  131568. */
  131569. getPass(): RenderTargetTexture;
  131570. private _meshExcluded;
  131571. private _createPass;
  131572. private _updateMeshScreenCoordinates;
  131573. /**
  131574. * Creates a default mesh for the Volumeric Light Scattering post-process
  131575. * @param name The mesh name
  131576. * @param scene The scene where to create the mesh
  131577. * @return the default mesh
  131578. */
  131579. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  131580. }
  131581. }
  131582. declare module BABYLON {
  131583. interface Scene {
  131584. /** @hidden (Backing field) */
  131585. _boundingBoxRenderer: BoundingBoxRenderer;
  131586. /** @hidden (Backing field) */
  131587. _forceShowBoundingBoxes: boolean;
  131588. /**
  131589. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  131590. */
  131591. forceShowBoundingBoxes: boolean;
  131592. /**
  131593. * Gets the bounding box renderer associated with the scene
  131594. * @returns a BoundingBoxRenderer
  131595. */
  131596. getBoundingBoxRenderer(): BoundingBoxRenderer;
  131597. }
  131598. interface AbstractMesh {
  131599. /** @hidden (Backing field) */
  131600. _showBoundingBox: boolean;
  131601. /**
  131602. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  131603. */
  131604. showBoundingBox: boolean;
  131605. }
  131606. /**
  131607. * Component responsible of rendering the bounding box of the meshes in a scene.
  131608. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  131609. */
  131610. export class BoundingBoxRenderer implements ISceneComponent {
  131611. /**
  131612. * The component name helpfull to identify the component in the list of scene components.
  131613. */
  131614. readonly name: string;
  131615. /**
  131616. * The scene the component belongs to.
  131617. */
  131618. scene: Scene;
  131619. /**
  131620. * Color of the bounding box lines placed in front of an object
  131621. */
  131622. frontColor: Color3;
  131623. /**
  131624. * Color of the bounding box lines placed behind an object
  131625. */
  131626. backColor: Color3;
  131627. /**
  131628. * Defines if the renderer should show the back lines or not
  131629. */
  131630. showBackLines: boolean;
  131631. /**
  131632. * @hidden
  131633. */
  131634. renderList: SmartArray<BoundingBox>;
  131635. private _colorShader;
  131636. private _vertexBuffers;
  131637. private _indexBuffer;
  131638. private _fillIndexBuffer;
  131639. private _fillIndexData;
  131640. /**
  131641. * Instantiates a new bounding box renderer in a scene.
  131642. * @param scene the scene the renderer renders in
  131643. */
  131644. constructor(scene: Scene);
  131645. /**
  131646. * Registers the component in a given scene
  131647. */
  131648. register(): void;
  131649. private _evaluateSubMesh;
  131650. private _activeMesh;
  131651. private _prepareRessources;
  131652. private _createIndexBuffer;
  131653. /**
  131654. * Rebuilds the elements related to this component in case of
  131655. * context lost for instance.
  131656. */
  131657. rebuild(): void;
  131658. /**
  131659. * @hidden
  131660. */
  131661. reset(): void;
  131662. /**
  131663. * Render the bounding boxes of a specific rendering group
  131664. * @param renderingGroupId defines the rendering group to render
  131665. */
  131666. render(renderingGroupId: number): void;
  131667. /**
  131668. * In case of occlusion queries, we can render the occlusion bounding box through this method
  131669. * @param mesh Define the mesh to render the occlusion bounding box for
  131670. */
  131671. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  131672. /**
  131673. * Dispose and release the resources attached to this renderer.
  131674. */
  131675. dispose(): void;
  131676. }
  131677. }
  131678. declare module BABYLON {
  131679. /** @hidden */
  131680. export var depthPixelShader: {
  131681. name: string;
  131682. shader: string;
  131683. };
  131684. }
  131685. declare module BABYLON {
  131686. /**
  131687. * This represents a depth renderer in Babylon.
  131688. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  131689. */
  131690. export class DepthRenderer {
  131691. private _scene;
  131692. private _depthMap;
  131693. private _effect;
  131694. private readonly _storeNonLinearDepth;
  131695. private readonly _clearColor;
  131696. /** Get if the depth renderer is using packed depth or not */
  131697. readonly isPacked: boolean;
  131698. private _cachedDefines;
  131699. private _camera;
  131700. /**
  131701. * Specifiess that the depth renderer will only be used within
  131702. * the camera it is created for.
  131703. * This can help forcing its rendering during the camera processing.
  131704. */
  131705. useOnlyInActiveCamera: boolean;
  131706. /** @hidden */
  131707. static _SceneComponentInitialization: (scene: Scene) => void;
  131708. /**
  131709. * Instantiates a depth renderer
  131710. * @param scene The scene the renderer belongs to
  131711. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  131712. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  131713. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  131714. */
  131715. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  131716. /**
  131717. * Creates the depth rendering effect and checks if the effect is ready.
  131718. * @param subMesh The submesh to be used to render the depth map of
  131719. * @param useInstances If multiple world instances should be used
  131720. * @returns if the depth renderer is ready to render the depth map
  131721. */
  131722. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131723. /**
  131724. * Gets the texture which the depth map will be written to.
  131725. * @returns The depth map texture
  131726. */
  131727. getDepthMap(): RenderTargetTexture;
  131728. /**
  131729. * Disposes of the depth renderer.
  131730. */
  131731. dispose(): void;
  131732. }
  131733. }
  131734. declare module BABYLON {
  131735. interface Scene {
  131736. /** @hidden (Backing field) */
  131737. _depthRenderer: {
  131738. [id: string]: DepthRenderer;
  131739. };
  131740. /**
  131741. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  131742. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  131743. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  131744. * @returns the created depth renderer
  131745. */
  131746. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  131747. /**
  131748. * Disables a depth renderer for a given camera
  131749. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  131750. */
  131751. disableDepthRenderer(camera?: Nullable<Camera>): void;
  131752. }
  131753. /**
  131754. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  131755. * in several rendering techniques.
  131756. */
  131757. export class DepthRendererSceneComponent implements ISceneComponent {
  131758. /**
  131759. * The component name helpfull to identify the component in the list of scene components.
  131760. */
  131761. readonly name: string;
  131762. /**
  131763. * The scene the component belongs to.
  131764. */
  131765. scene: Scene;
  131766. /**
  131767. * Creates a new instance of the component for the given scene
  131768. * @param scene Defines the scene to register the component in
  131769. */
  131770. constructor(scene: Scene);
  131771. /**
  131772. * Registers the component in a given scene
  131773. */
  131774. register(): void;
  131775. /**
  131776. * Rebuilds the elements related to this component in case of
  131777. * context lost for instance.
  131778. */
  131779. rebuild(): void;
  131780. /**
  131781. * Disposes the component and the associated ressources
  131782. */
  131783. dispose(): void;
  131784. private _gatherRenderTargets;
  131785. private _gatherActiveCameraRenderTargets;
  131786. }
  131787. }
  131788. declare module BABYLON {
  131789. /** @hidden */
  131790. export var outlinePixelShader: {
  131791. name: string;
  131792. shader: string;
  131793. };
  131794. }
  131795. declare module BABYLON {
  131796. /** @hidden */
  131797. export var outlineVertexShader: {
  131798. name: string;
  131799. shader: string;
  131800. };
  131801. }
  131802. declare module BABYLON {
  131803. interface Scene {
  131804. /** @hidden */
  131805. _outlineRenderer: OutlineRenderer;
  131806. /**
  131807. * Gets the outline renderer associated with the scene
  131808. * @returns a OutlineRenderer
  131809. */
  131810. getOutlineRenderer(): OutlineRenderer;
  131811. }
  131812. interface AbstractMesh {
  131813. /** @hidden (Backing field) */
  131814. _renderOutline: boolean;
  131815. /**
  131816. * Gets or sets a boolean indicating if the outline must be rendered as well
  131817. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  131818. */
  131819. renderOutline: boolean;
  131820. /** @hidden (Backing field) */
  131821. _renderOverlay: boolean;
  131822. /**
  131823. * Gets or sets a boolean indicating if the overlay must be rendered as well
  131824. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  131825. */
  131826. renderOverlay: boolean;
  131827. }
  131828. /**
  131829. * This class is responsible to draw bothe outline/overlay of meshes.
  131830. * It should not be used directly but through the available method on mesh.
  131831. */
  131832. export class OutlineRenderer implements ISceneComponent {
  131833. /**
  131834. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  131835. */
  131836. private static _StencilReference;
  131837. /**
  131838. * The name of the component. Each component must have a unique name.
  131839. */
  131840. name: string;
  131841. /**
  131842. * The scene the component belongs to.
  131843. */
  131844. scene: Scene;
  131845. /**
  131846. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  131847. */
  131848. zOffset: number;
  131849. private _engine;
  131850. private _effect;
  131851. private _cachedDefines;
  131852. private _savedDepthWrite;
  131853. /**
  131854. * Instantiates a new outline renderer. (There could be only one per scene).
  131855. * @param scene Defines the scene it belongs to
  131856. */
  131857. constructor(scene: Scene);
  131858. /**
  131859. * Register the component to one instance of a scene.
  131860. */
  131861. register(): void;
  131862. /**
  131863. * Rebuilds the elements related to this component in case of
  131864. * context lost for instance.
  131865. */
  131866. rebuild(): void;
  131867. /**
  131868. * Disposes the component and the associated ressources.
  131869. */
  131870. dispose(): void;
  131871. /**
  131872. * Renders the outline in the canvas.
  131873. * @param subMesh Defines the sumesh to render
  131874. * @param batch Defines the batch of meshes in case of instances
  131875. * @param useOverlay Defines if the rendering is for the overlay or the outline
  131876. */
  131877. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  131878. /**
  131879. * Returns whether or not the outline renderer is ready for a given submesh.
  131880. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  131881. * @param subMesh Defines the submesh to check readyness for
  131882. * @param useInstances Defines wheter wee are trying to render instances or not
  131883. * @returns true if ready otherwise false
  131884. */
  131885. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131886. private _beforeRenderingMesh;
  131887. private _afterRenderingMesh;
  131888. }
  131889. }
  131890. declare module BABYLON {
  131891. /**
  131892. * Class used to manage multiple sprites of different sizes on the same spritesheet
  131893. * @see http://doc.babylonjs.com/babylon101/sprites
  131894. */
  131895. export class SpritePackedManager extends SpriteManager {
  131896. /** defines the packed manager's name */
  131897. name: string;
  131898. /**
  131899. * Creates a new sprite manager from a packed sprite sheet
  131900. * @param name defines the manager's name
  131901. * @param imgUrl defines the sprite sheet url
  131902. * @param capacity defines the maximum allowed number of sprites
  131903. * @param scene defines the hosting scene
  131904. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  131905. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  131906. * @param samplingMode defines the smapling mode to use with spritesheet
  131907. * @param fromPacked set to true; do not alter
  131908. */
  131909. constructor(
  131910. /** defines the packed manager's name */
  131911. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  131912. }
  131913. }
  131914. declare module BABYLON {
  131915. /**
  131916. * Defines the list of states available for a task inside a AssetsManager
  131917. */
  131918. export enum AssetTaskState {
  131919. /**
  131920. * Initialization
  131921. */
  131922. INIT = 0,
  131923. /**
  131924. * Running
  131925. */
  131926. RUNNING = 1,
  131927. /**
  131928. * Done
  131929. */
  131930. DONE = 2,
  131931. /**
  131932. * Error
  131933. */
  131934. ERROR = 3
  131935. }
  131936. /**
  131937. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  131938. */
  131939. export abstract class AbstractAssetTask {
  131940. /**
  131941. * Task name
  131942. */ name: string;
  131943. /**
  131944. * Callback called when the task is successful
  131945. */
  131946. onSuccess: (task: any) => void;
  131947. /**
  131948. * Callback called when the task is not successful
  131949. */
  131950. onError: (task: any, message?: string, exception?: any) => void;
  131951. /**
  131952. * Creates a new AssetsManager
  131953. * @param name defines the name of the task
  131954. */
  131955. constructor(
  131956. /**
  131957. * Task name
  131958. */ name: string);
  131959. private _isCompleted;
  131960. private _taskState;
  131961. private _errorObject;
  131962. /**
  131963. * Get if the task is completed
  131964. */
  131965. readonly isCompleted: boolean;
  131966. /**
  131967. * Gets the current state of the task
  131968. */
  131969. readonly taskState: AssetTaskState;
  131970. /**
  131971. * Gets the current error object (if task is in error)
  131972. */
  131973. readonly errorObject: {
  131974. message?: string;
  131975. exception?: any;
  131976. };
  131977. /**
  131978. * Internal only
  131979. * @hidden
  131980. */
  131981. _setErrorObject(message?: string, exception?: any): void;
  131982. /**
  131983. * Execute the current task
  131984. * @param scene defines the scene where you want your assets to be loaded
  131985. * @param onSuccess is a callback called when the task is successfully executed
  131986. * @param onError is a callback called if an error occurs
  131987. */
  131988. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131989. /**
  131990. * Execute the current task
  131991. * @param scene defines the scene where you want your assets to be loaded
  131992. * @param onSuccess is a callback called when the task is successfully executed
  131993. * @param onError is a callback called if an error occurs
  131994. */
  131995. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131996. /**
  131997. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  131998. * This can be used with failed tasks that have the reason for failure fixed.
  131999. */
  132000. reset(): void;
  132001. private onErrorCallback;
  132002. private onDoneCallback;
  132003. }
  132004. /**
  132005. * Define the interface used by progress events raised during assets loading
  132006. */
  132007. export interface IAssetsProgressEvent {
  132008. /**
  132009. * Defines the number of remaining tasks to process
  132010. */
  132011. remainingCount: number;
  132012. /**
  132013. * Defines the total number of tasks
  132014. */
  132015. totalCount: number;
  132016. /**
  132017. * Defines the task that was just processed
  132018. */
  132019. task: AbstractAssetTask;
  132020. }
  132021. /**
  132022. * Class used to share progress information about assets loading
  132023. */
  132024. export class AssetsProgressEvent implements IAssetsProgressEvent {
  132025. /**
  132026. * Defines the number of remaining tasks to process
  132027. */
  132028. remainingCount: number;
  132029. /**
  132030. * Defines the total number of tasks
  132031. */
  132032. totalCount: number;
  132033. /**
  132034. * Defines the task that was just processed
  132035. */
  132036. task: AbstractAssetTask;
  132037. /**
  132038. * Creates a AssetsProgressEvent
  132039. * @param remainingCount defines the number of remaining tasks to process
  132040. * @param totalCount defines the total number of tasks
  132041. * @param task defines the task that was just processed
  132042. */
  132043. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  132044. }
  132045. /**
  132046. * Define a task used by AssetsManager to load meshes
  132047. */
  132048. export class MeshAssetTask extends AbstractAssetTask {
  132049. /**
  132050. * Defines the name of the task
  132051. */
  132052. name: string;
  132053. /**
  132054. * Defines the list of mesh's names you want to load
  132055. */
  132056. meshesNames: any;
  132057. /**
  132058. * Defines the root url to use as a base to load your meshes and associated resources
  132059. */
  132060. rootUrl: string;
  132061. /**
  132062. * Defines the filename of the scene to load from
  132063. */
  132064. sceneFilename: string;
  132065. /**
  132066. * Gets the list of loaded meshes
  132067. */
  132068. loadedMeshes: Array<AbstractMesh>;
  132069. /**
  132070. * Gets the list of loaded particle systems
  132071. */
  132072. loadedParticleSystems: Array<IParticleSystem>;
  132073. /**
  132074. * Gets the list of loaded skeletons
  132075. */
  132076. loadedSkeletons: Array<Skeleton>;
  132077. /**
  132078. * Gets the list of loaded animation groups
  132079. */
  132080. loadedAnimationGroups: Array<AnimationGroup>;
  132081. /**
  132082. * Callback called when the task is successful
  132083. */
  132084. onSuccess: (task: MeshAssetTask) => void;
  132085. /**
  132086. * Callback called when the task is successful
  132087. */
  132088. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  132089. /**
  132090. * Creates a new MeshAssetTask
  132091. * @param name defines the name of the task
  132092. * @param meshesNames defines the list of mesh's names you want to load
  132093. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  132094. * @param sceneFilename defines the filename of the scene to load from
  132095. */
  132096. constructor(
  132097. /**
  132098. * Defines the name of the task
  132099. */
  132100. name: string,
  132101. /**
  132102. * Defines the list of mesh's names you want to load
  132103. */
  132104. meshesNames: any,
  132105. /**
  132106. * Defines the root url to use as a base to load your meshes and associated resources
  132107. */
  132108. rootUrl: string,
  132109. /**
  132110. * Defines the filename of the scene to load from
  132111. */
  132112. sceneFilename: string);
  132113. /**
  132114. * Execute the current task
  132115. * @param scene defines the scene where you want your assets to be loaded
  132116. * @param onSuccess is a callback called when the task is successfully executed
  132117. * @param onError is a callback called if an error occurs
  132118. */
  132119. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132120. }
  132121. /**
  132122. * Define a task used by AssetsManager to load text content
  132123. */
  132124. export class TextFileAssetTask extends AbstractAssetTask {
  132125. /**
  132126. * Defines the name of the task
  132127. */
  132128. name: string;
  132129. /**
  132130. * Defines the location of the file to load
  132131. */
  132132. url: string;
  132133. /**
  132134. * Gets the loaded text string
  132135. */
  132136. text: string;
  132137. /**
  132138. * Callback called when the task is successful
  132139. */
  132140. onSuccess: (task: TextFileAssetTask) => void;
  132141. /**
  132142. * Callback called when the task is successful
  132143. */
  132144. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  132145. /**
  132146. * Creates a new TextFileAssetTask object
  132147. * @param name defines the name of the task
  132148. * @param url defines the location of the file to load
  132149. */
  132150. constructor(
  132151. /**
  132152. * Defines the name of the task
  132153. */
  132154. name: string,
  132155. /**
  132156. * Defines the location of the file to load
  132157. */
  132158. url: string);
  132159. /**
  132160. * Execute the current task
  132161. * @param scene defines the scene where you want your assets to be loaded
  132162. * @param onSuccess is a callback called when the task is successfully executed
  132163. * @param onError is a callback called if an error occurs
  132164. */
  132165. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132166. }
  132167. /**
  132168. * Define a task used by AssetsManager to load binary data
  132169. */
  132170. export class BinaryFileAssetTask extends AbstractAssetTask {
  132171. /**
  132172. * Defines the name of the task
  132173. */
  132174. name: string;
  132175. /**
  132176. * Defines the location of the file to load
  132177. */
  132178. url: string;
  132179. /**
  132180. * Gets the lodaded data (as an array buffer)
  132181. */
  132182. data: ArrayBuffer;
  132183. /**
  132184. * Callback called when the task is successful
  132185. */
  132186. onSuccess: (task: BinaryFileAssetTask) => void;
  132187. /**
  132188. * Callback called when the task is successful
  132189. */
  132190. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  132191. /**
  132192. * Creates a new BinaryFileAssetTask object
  132193. * @param name defines the name of the new task
  132194. * @param url defines the location of the file to load
  132195. */
  132196. constructor(
  132197. /**
  132198. * Defines the name of the task
  132199. */
  132200. name: string,
  132201. /**
  132202. * Defines the location of the file to load
  132203. */
  132204. url: string);
  132205. /**
  132206. * Execute the current task
  132207. * @param scene defines the scene where you want your assets to be loaded
  132208. * @param onSuccess is a callback called when the task is successfully executed
  132209. * @param onError is a callback called if an error occurs
  132210. */
  132211. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132212. }
  132213. /**
  132214. * Define a task used by AssetsManager to load images
  132215. */
  132216. export class ImageAssetTask extends AbstractAssetTask {
  132217. /**
  132218. * Defines the name of the task
  132219. */
  132220. name: string;
  132221. /**
  132222. * Defines the location of the image to load
  132223. */
  132224. url: string;
  132225. /**
  132226. * Gets the loaded images
  132227. */
  132228. image: HTMLImageElement;
  132229. /**
  132230. * Callback called when the task is successful
  132231. */
  132232. onSuccess: (task: ImageAssetTask) => void;
  132233. /**
  132234. * Callback called when the task is successful
  132235. */
  132236. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  132237. /**
  132238. * Creates a new ImageAssetTask
  132239. * @param name defines the name of the task
  132240. * @param url defines the location of the image to load
  132241. */
  132242. constructor(
  132243. /**
  132244. * Defines the name of the task
  132245. */
  132246. name: string,
  132247. /**
  132248. * Defines the location of the image to load
  132249. */
  132250. url: string);
  132251. /**
  132252. * Execute the current task
  132253. * @param scene defines the scene where you want your assets to be loaded
  132254. * @param onSuccess is a callback called when the task is successfully executed
  132255. * @param onError is a callback called if an error occurs
  132256. */
  132257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132258. }
  132259. /**
  132260. * Defines the interface used by texture loading tasks
  132261. */
  132262. export interface ITextureAssetTask<TEX extends BaseTexture> {
  132263. /**
  132264. * Gets the loaded texture
  132265. */
  132266. texture: TEX;
  132267. }
  132268. /**
  132269. * Define a task used by AssetsManager to load 2D textures
  132270. */
  132271. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  132272. /**
  132273. * Defines the name of the task
  132274. */
  132275. name: string;
  132276. /**
  132277. * Defines the location of the file to load
  132278. */
  132279. url: string;
  132280. /**
  132281. * Defines if mipmap should not be generated (default is false)
  132282. */
  132283. noMipmap?: boolean | undefined;
  132284. /**
  132285. * Defines if texture must be inverted on Y axis (default is false)
  132286. */
  132287. invertY?: boolean | undefined;
  132288. /**
  132289. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132290. */
  132291. samplingMode: number;
  132292. /**
  132293. * Gets the loaded texture
  132294. */
  132295. texture: Texture;
  132296. /**
  132297. * Callback called when the task is successful
  132298. */
  132299. onSuccess: (task: TextureAssetTask) => void;
  132300. /**
  132301. * Callback called when the task is successful
  132302. */
  132303. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  132304. /**
  132305. * Creates a new TextureAssetTask object
  132306. * @param name defines the name of the task
  132307. * @param url defines the location of the file to load
  132308. * @param noMipmap defines if mipmap should not be generated (default is false)
  132309. * @param invertY defines if texture must be inverted on Y axis (default is false)
  132310. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132311. */
  132312. constructor(
  132313. /**
  132314. * Defines the name of the task
  132315. */
  132316. name: string,
  132317. /**
  132318. * Defines the location of the file to load
  132319. */
  132320. url: string,
  132321. /**
  132322. * Defines if mipmap should not be generated (default is false)
  132323. */
  132324. noMipmap?: boolean | undefined,
  132325. /**
  132326. * Defines if texture must be inverted on Y axis (default is false)
  132327. */
  132328. invertY?: boolean | undefined,
  132329. /**
  132330. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132331. */
  132332. samplingMode?: number);
  132333. /**
  132334. * Execute the current task
  132335. * @param scene defines the scene where you want your assets to be loaded
  132336. * @param onSuccess is a callback called when the task is successfully executed
  132337. * @param onError is a callback called if an error occurs
  132338. */
  132339. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132340. }
  132341. /**
  132342. * Define a task used by AssetsManager to load cube textures
  132343. */
  132344. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  132345. /**
  132346. * Defines the name of the task
  132347. */
  132348. name: string;
  132349. /**
  132350. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132351. */
  132352. url: string;
  132353. /**
  132354. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132355. */
  132356. extensions?: string[] | undefined;
  132357. /**
  132358. * Defines if mipmaps should not be generated (default is false)
  132359. */
  132360. noMipmap?: boolean | undefined;
  132361. /**
  132362. * Defines the explicit list of files (undefined by default)
  132363. */
  132364. files?: string[] | undefined;
  132365. /**
  132366. * Gets the loaded texture
  132367. */
  132368. texture: CubeTexture;
  132369. /**
  132370. * Callback called when the task is successful
  132371. */
  132372. onSuccess: (task: CubeTextureAssetTask) => void;
  132373. /**
  132374. * Callback called when the task is successful
  132375. */
  132376. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  132377. /**
  132378. * Creates a new CubeTextureAssetTask
  132379. * @param name defines the name of the task
  132380. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132381. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132382. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132383. * @param files defines the explicit list of files (undefined by default)
  132384. */
  132385. constructor(
  132386. /**
  132387. * Defines the name of the task
  132388. */
  132389. name: string,
  132390. /**
  132391. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132392. */
  132393. url: string,
  132394. /**
  132395. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132396. */
  132397. extensions?: string[] | undefined,
  132398. /**
  132399. * Defines if mipmaps should not be generated (default is false)
  132400. */
  132401. noMipmap?: boolean | undefined,
  132402. /**
  132403. * Defines the explicit list of files (undefined by default)
  132404. */
  132405. files?: string[] | undefined);
  132406. /**
  132407. * Execute the current task
  132408. * @param scene defines the scene where you want your assets to be loaded
  132409. * @param onSuccess is a callback called when the task is successfully executed
  132410. * @param onError is a callback called if an error occurs
  132411. */
  132412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132413. }
  132414. /**
  132415. * Define a task used by AssetsManager to load HDR cube textures
  132416. */
  132417. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  132418. /**
  132419. * Defines the name of the task
  132420. */
  132421. name: string;
  132422. /**
  132423. * Defines the location of the file to load
  132424. */
  132425. url: string;
  132426. /**
  132427. * Defines the desired size (the more it increases the longer the generation will be)
  132428. */
  132429. size: number;
  132430. /**
  132431. * Defines if mipmaps should not be generated (default is false)
  132432. */
  132433. noMipmap: boolean;
  132434. /**
  132435. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132436. */
  132437. generateHarmonics: boolean;
  132438. /**
  132439. * 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)
  132440. */
  132441. gammaSpace: boolean;
  132442. /**
  132443. * Internal Use Only
  132444. */
  132445. reserved: boolean;
  132446. /**
  132447. * Gets the loaded texture
  132448. */
  132449. texture: HDRCubeTexture;
  132450. /**
  132451. * Callback called when the task is successful
  132452. */
  132453. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  132454. /**
  132455. * Callback called when the task is successful
  132456. */
  132457. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  132458. /**
  132459. * Creates a new HDRCubeTextureAssetTask object
  132460. * @param name defines the name of the task
  132461. * @param url defines the location of the file to load
  132462. * @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.
  132463. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132464. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132465. * @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)
  132466. * @param reserved Internal use only
  132467. */
  132468. constructor(
  132469. /**
  132470. * Defines the name of the task
  132471. */
  132472. name: string,
  132473. /**
  132474. * Defines the location of the file to load
  132475. */
  132476. url: string,
  132477. /**
  132478. * Defines the desired size (the more it increases the longer the generation will be)
  132479. */
  132480. size: number,
  132481. /**
  132482. * Defines if mipmaps should not be generated (default is false)
  132483. */
  132484. noMipmap?: boolean,
  132485. /**
  132486. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132487. */
  132488. generateHarmonics?: boolean,
  132489. /**
  132490. * 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)
  132491. */
  132492. gammaSpace?: boolean,
  132493. /**
  132494. * Internal Use Only
  132495. */
  132496. reserved?: boolean);
  132497. /**
  132498. * Execute the current task
  132499. * @param scene defines the scene where you want your assets to be loaded
  132500. * @param onSuccess is a callback called when the task is successfully executed
  132501. * @param onError is a callback called if an error occurs
  132502. */
  132503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132504. }
  132505. /**
  132506. * Define a task used by AssetsManager to load Equirectangular cube textures
  132507. */
  132508. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  132509. /**
  132510. * Defines the name of the task
  132511. */
  132512. name: string;
  132513. /**
  132514. * Defines the location of the file to load
  132515. */
  132516. url: string;
  132517. /**
  132518. * Defines the desired size (the more it increases the longer the generation will be)
  132519. */
  132520. size: number;
  132521. /**
  132522. * Defines if mipmaps should not be generated (default is false)
  132523. */
  132524. noMipmap: boolean;
  132525. /**
  132526. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  132527. * but the standard material would require them in Gamma space) (default is true)
  132528. */
  132529. gammaSpace: boolean;
  132530. /**
  132531. * Gets the loaded texture
  132532. */
  132533. texture: EquiRectangularCubeTexture;
  132534. /**
  132535. * Callback called when the task is successful
  132536. */
  132537. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  132538. /**
  132539. * Callback called when the task is successful
  132540. */
  132541. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  132542. /**
  132543. * Creates a new EquiRectangularCubeTextureAssetTask object
  132544. * @param name defines the name of the task
  132545. * @param url defines the location of the file to load
  132546. * @param size defines the desired size (the more it increases the longer the generation will be)
  132547. * If the size is omitted this implies you are using a preprocessed cubemap.
  132548. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132549. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  132550. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  132551. * (default is true)
  132552. */
  132553. constructor(
  132554. /**
  132555. * Defines the name of the task
  132556. */
  132557. name: string,
  132558. /**
  132559. * Defines the location of the file to load
  132560. */
  132561. url: string,
  132562. /**
  132563. * Defines the desired size (the more it increases the longer the generation will be)
  132564. */
  132565. size: number,
  132566. /**
  132567. * Defines if mipmaps should not be generated (default is false)
  132568. */
  132569. noMipmap?: boolean,
  132570. /**
  132571. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  132572. * but the standard material would require them in Gamma space) (default is true)
  132573. */
  132574. gammaSpace?: boolean);
  132575. /**
  132576. * Execute the current task
  132577. * @param scene defines the scene where you want your assets to be loaded
  132578. * @param onSuccess is a callback called when the task is successfully executed
  132579. * @param onError is a callback called if an error occurs
  132580. */
  132581. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132582. }
  132583. /**
  132584. * This class can be used to easily import assets into a scene
  132585. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  132586. */
  132587. export class AssetsManager {
  132588. private _scene;
  132589. private _isLoading;
  132590. protected _tasks: AbstractAssetTask[];
  132591. protected _waitingTasksCount: number;
  132592. protected _totalTasksCount: number;
  132593. /**
  132594. * Callback called when all tasks are processed
  132595. */
  132596. onFinish: (tasks: AbstractAssetTask[]) => void;
  132597. /**
  132598. * Callback called when a task is successful
  132599. */
  132600. onTaskSuccess: (task: AbstractAssetTask) => void;
  132601. /**
  132602. * Callback called when a task had an error
  132603. */
  132604. onTaskError: (task: AbstractAssetTask) => void;
  132605. /**
  132606. * Callback called when a task is done (whatever the result is)
  132607. */
  132608. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  132609. /**
  132610. * Observable called when all tasks are processed
  132611. */
  132612. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  132613. /**
  132614. * Observable called when a task had an error
  132615. */
  132616. onTaskErrorObservable: Observable<AbstractAssetTask>;
  132617. /**
  132618. * Observable called when all tasks were executed
  132619. */
  132620. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  132621. /**
  132622. * Observable called when a task is done (whatever the result is)
  132623. */
  132624. onProgressObservable: Observable<IAssetsProgressEvent>;
  132625. /**
  132626. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  132627. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  132628. */
  132629. useDefaultLoadingScreen: boolean;
  132630. /**
  132631. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  132632. * when all assets have been downloaded.
  132633. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  132634. */
  132635. autoHideLoadingUI: boolean;
  132636. /**
  132637. * Creates a new AssetsManager
  132638. * @param scene defines the scene to work on
  132639. */
  132640. constructor(scene: Scene);
  132641. /**
  132642. * Add a MeshAssetTask to the list of active tasks
  132643. * @param taskName defines the name of the new task
  132644. * @param meshesNames defines the name of meshes to load
  132645. * @param rootUrl defines the root url to use to locate files
  132646. * @param sceneFilename defines the filename of the scene file
  132647. * @returns a new MeshAssetTask object
  132648. */
  132649. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  132650. /**
  132651. * Add a TextFileAssetTask to the list of active tasks
  132652. * @param taskName defines the name of the new task
  132653. * @param url defines the url of the file to load
  132654. * @returns a new TextFileAssetTask object
  132655. */
  132656. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  132657. /**
  132658. * Add a BinaryFileAssetTask to the list of active tasks
  132659. * @param taskName defines the name of the new task
  132660. * @param url defines the url of the file to load
  132661. * @returns a new BinaryFileAssetTask object
  132662. */
  132663. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  132664. /**
  132665. * Add a ImageAssetTask to the list of active tasks
  132666. * @param taskName defines the name of the new task
  132667. * @param url defines the url of the file to load
  132668. * @returns a new ImageAssetTask object
  132669. */
  132670. addImageTask(taskName: string, url: string): ImageAssetTask;
  132671. /**
  132672. * Add a TextureAssetTask to the list of active tasks
  132673. * @param taskName defines the name of the new task
  132674. * @param url defines the url of the file to load
  132675. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132676. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  132677. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  132678. * @returns a new TextureAssetTask object
  132679. */
  132680. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  132681. /**
  132682. * Add a CubeTextureAssetTask to the list of active tasks
  132683. * @param taskName defines the name of the new task
  132684. * @param url defines the url of the file to load
  132685. * @param extensions defines the extension to use to load the cube map (can be null)
  132686. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132687. * @param files defines the list of files to load (can be null)
  132688. * @returns a new CubeTextureAssetTask object
  132689. */
  132690. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  132691. /**
  132692. *
  132693. * Add a HDRCubeTextureAssetTask to the list of active tasks
  132694. * @param taskName defines the name of the new task
  132695. * @param url defines the url of the file to load
  132696. * @param size defines the size you want for the cubemap (can be null)
  132697. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132698. * @param generateHarmonics defines if you want to automatically generate (true by default)
  132699. * @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)
  132700. * @param reserved Internal use only
  132701. * @returns a new HDRCubeTextureAssetTask object
  132702. */
  132703. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  132704. /**
  132705. *
  132706. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  132707. * @param taskName defines the name of the new task
  132708. * @param url defines the url of the file to load
  132709. * @param size defines the size you want for the cubemap (can be null)
  132710. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132711. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  132712. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  132713. * @returns a new EquiRectangularCubeTextureAssetTask object
  132714. */
  132715. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  132716. /**
  132717. * Remove a task from the assets manager.
  132718. * @param task the task to remove
  132719. */
  132720. removeTask(task: AbstractAssetTask): void;
  132721. private _decreaseWaitingTasksCount;
  132722. private _runTask;
  132723. /**
  132724. * Reset the AssetsManager and remove all tasks
  132725. * @return the current instance of the AssetsManager
  132726. */
  132727. reset(): AssetsManager;
  132728. /**
  132729. * Start the loading process
  132730. * @return the current instance of the AssetsManager
  132731. */
  132732. load(): AssetsManager;
  132733. /**
  132734. * Start the loading process as an async operation
  132735. * @return a promise returning the list of failed tasks
  132736. */
  132737. loadAsync(): Promise<void>;
  132738. }
  132739. }
  132740. declare module BABYLON {
  132741. /**
  132742. * Wrapper class for promise with external resolve and reject.
  132743. */
  132744. export class Deferred<T> {
  132745. /**
  132746. * The promise associated with this deferred object.
  132747. */
  132748. readonly promise: Promise<T>;
  132749. private _resolve;
  132750. private _reject;
  132751. /**
  132752. * The resolve method of the promise associated with this deferred object.
  132753. */
  132754. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  132755. /**
  132756. * The reject method of the promise associated with this deferred object.
  132757. */
  132758. readonly reject: (reason?: any) => void;
  132759. /**
  132760. * Constructor for this deferred object.
  132761. */
  132762. constructor();
  132763. }
  132764. }
  132765. declare module BABYLON {
  132766. /**
  132767. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  132768. */
  132769. export class MeshExploder {
  132770. private _centerMesh;
  132771. private _meshes;
  132772. private _meshesOrigins;
  132773. private _toCenterVectors;
  132774. private _scaledDirection;
  132775. private _newPosition;
  132776. private _centerPosition;
  132777. /**
  132778. * Explodes meshes from a center mesh.
  132779. * @param meshes The meshes to explode.
  132780. * @param centerMesh The mesh to be center of explosion.
  132781. */
  132782. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  132783. private _setCenterMesh;
  132784. /**
  132785. * Get class name
  132786. * @returns "MeshExploder"
  132787. */
  132788. getClassName(): string;
  132789. /**
  132790. * "Exploded meshes"
  132791. * @returns Array of meshes with the centerMesh at index 0.
  132792. */
  132793. getMeshes(): Array<Mesh>;
  132794. /**
  132795. * Explodes meshes giving a specific direction
  132796. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  132797. */
  132798. explode(direction?: number): void;
  132799. }
  132800. }
  132801. declare module BABYLON {
  132802. /**
  132803. * Class used to help managing file picking and drag'n'drop
  132804. */
  132805. export class FilesInput {
  132806. /**
  132807. * List of files ready to be loaded
  132808. */
  132809. static readonly FilesToLoad: {
  132810. [key: string]: File;
  132811. };
  132812. /**
  132813. * Callback called when a file is processed
  132814. */
  132815. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  132816. private _engine;
  132817. private _currentScene;
  132818. private _sceneLoadedCallback;
  132819. private _progressCallback;
  132820. private _additionalRenderLoopLogicCallback;
  132821. private _textureLoadingCallback;
  132822. private _startingProcessingFilesCallback;
  132823. private _onReloadCallback;
  132824. private _errorCallback;
  132825. private _elementToMonitor;
  132826. private _sceneFileToLoad;
  132827. private _filesToLoad;
  132828. /**
  132829. * Creates a new FilesInput
  132830. * @param engine defines the rendering engine
  132831. * @param scene defines the hosting scene
  132832. * @param sceneLoadedCallback callback called when scene is loaded
  132833. * @param progressCallback callback called to track progress
  132834. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  132835. * @param textureLoadingCallback callback called when a texture is loading
  132836. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  132837. * @param onReloadCallback callback called when a reload is requested
  132838. * @param errorCallback callback call if an error occurs
  132839. */
  132840. 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);
  132841. private _dragEnterHandler;
  132842. private _dragOverHandler;
  132843. private _dropHandler;
  132844. /**
  132845. * Calls this function to listen to drag'n'drop events on a specific DOM element
  132846. * @param elementToMonitor defines the DOM element to track
  132847. */
  132848. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  132849. /**
  132850. * Release all associated resources
  132851. */
  132852. dispose(): void;
  132853. private renderFunction;
  132854. private drag;
  132855. private drop;
  132856. private _traverseFolder;
  132857. private _processFiles;
  132858. /**
  132859. * Load files from a drop event
  132860. * @param event defines the drop event to use as source
  132861. */
  132862. loadFiles(event: any): void;
  132863. private _processReload;
  132864. /**
  132865. * Reload the current scene from the loaded files
  132866. */
  132867. reload(): void;
  132868. }
  132869. }
  132870. declare module BABYLON {
  132871. /**
  132872. * Defines the root class used to create scene optimization to use with SceneOptimizer
  132873. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132874. */
  132875. export class SceneOptimization {
  132876. /**
  132877. * Defines the priority of this optimization (0 by default which means first in the list)
  132878. */
  132879. priority: number;
  132880. /**
  132881. * Gets a string describing the action executed by the current optimization
  132882. * @returns description string
  132883. */
  132884. getDescription(): string;
  132885. /**
  132886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132887. * @param scene defines the current scene where to apply this optimization
  132888. * @param optimizer defines the current optimizer
  132889. * @returns true if everything that can be done was applied
  132890. */
  132891. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132892. /**
  132893. * Creates the SceneOptimization object
  132894. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132895. * @param desc defines the description associated with the optimization
  132896. */
  132897. constructor(
  132898. /**
  132899. * Defines the priority of this optimization (0 by default which means first in the list)
  132900. */
  132901. priority?: number);
  132902. }
  132903. /**
  132904. * Defines an optimization used to reduce the size of render target textures
  132905. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132906. */
  132907. export class TextureOptimization extends SceneOptimization {
  132908. /**
  132909. * Defines the priority of this optimization (0 by default which means first in the list)
  132910. */
  132911. priority: number;
  132912. /**
  132913. * 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
  132914. */
  132915. maximumSize: number;
  132916. /**
  132917. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132918. */
  132919. step: number;
  132920. /**
  132921. * Gets a string describing the action executed by the current optimization
  132922. * @returns description string
  132923. */
  132924. getDescription(): string;
  132925. /**
  132926. * Creates the TextureOptimization object
  132927. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132928. * @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
  132929. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132930. */
  132931. constructor(
  132932. /**
  132933. * Defines the priority of this optimization (0 by default which means first in the list)
  132934. */
  132935. priority?: number,
  132936. /**
  132937. * 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
  132938. */
  132939. maximumSize?: number,
  132940. /**
  132941. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132942. */
  132943. step?: number);
  132944. /**
  132945. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132946. * @param scene defines the current scene where to apply this optimization
  132947. * @param optimizer defines the current optimizer
  132948. * @returns true if everything that can be done was applied
  132949. */
  132950. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132951. }
  132952. /**
  132953. * Defines an optimization used to increase or decrease the rendering resolution
  132954. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132955. */
  132956. export class HardwareScalingOptimization extends SceneOptimization {
  132957. /**
  132958. * Defines the priority of this optimization (0 by default which means first in the list)
  132959. */
  132960. priority: number;
  132961. /**
  132962. * Defines the maximum scale to use (2 by default)
  132963. */
  132964. maximumScale: number;
  132965. /**
  132966. * Defines the step to use between two passes (0.5 by default)
  132967. */
  132968. step: number;
  132969. private _currentScale;
  132970. private _directionOffset;
  132971. /**
  132972. * Gets a string describing the action executed by the current optimization
  132973. * @return description string
  132974. */
  132975. getDescription(): string;
  132976. /**
  132977. * Creates the HardwareScalingOptimization object
  132978. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132979. * @param maximumScale defines the maximum scale to use (2 by default)
  132980. * @param step defines the step to use between two passes (0.5 by default)
  132981. */
  132982. constructor(
  132983. /**
  132984. * Defines the priority of this optimization (0 by default which means first in the list)
  132985. */
  132986. priority?: number,
  132987. /**
  132988. * Defines the maximum scale to use (2 by default)
  132989. */
  132990. maximumScale?: number,
  132991. /**
  132992. * Defines the step to use between two passes (0.5 by default)
  132993. */
  132994. step?: number);
  132995. /**
  132996. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132997. * @param scene defines the current scene where to apply this optimization
  132998. * @param optimizer defines the current optimizer
  132999. * @returns true if everything that can be done was applied
  133000. */
  133001. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133002. }
  133003. /**
  133004. * Defines an optimization used to remove shadows
  133005. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133006. */
  133007. export class ShadowsOptimization extends SceneOptimization {
  133008. /**
  133009. * Gets a string describing the action executed by the current optimization
  133010. * @return description string
  133011. */
  133012. getDescription(): string;
  133013. /**
  133014. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133015. * @param scene defines the current scene where to apply this optimization
  133016. * @param optimizer defines the current optimizer
  133017. * @returns true if everything that can be done was applied
  133018. */
  133019. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133020. }
  133021. /**
  133022. * Defines an optimization used to turn post-processes off
  133023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133024. */
  133025. export class PostProcessesOptimization extends SceneOptimization {
  133026. /**
  133027. * Gets a string describing the action executed by the current optimization
  133028. * @return description string
  133029. */
  133030. getDescription(): string;
  133031. /**
  133032. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133033. * @param scene defines the current scene where to apply this optimization
  133034. * @param optimizer defines the current optimizer
  133035. * @returns true if everything that can be done was applied
  133036. */
  133037. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133038. }
  133039. /**
  133040. * Defines an optimization used to turn lens flares off
  133041. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133042. */
  133043. export class LensFlaresOptimization extends SceneOptimization {
  133044. /**
  133045. * Gets a string describing the action executed by the current optimization
  133046. * @return description string
  133047. */
  133048. getDescription(): string;
  133049. /**
  133050. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133051. * @param scene defines the current scene where to apply this optimization
  133052. * @param optimizer defines the current optimizer
  133053. * @returns true if everything that can be done was applied
  133054. */
  133055. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133056. }
  133057. /**
  133058. * Defines an optimization based on user defined callback.
  133059. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133060. */
  133061. export class CustomOptimization extends SceneOptimization {
  133062. /**
  133063. * Callback called to apply the custom optimization.
  133064. */
  133065. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  133066. /**
  133067. * Callback called to get custom description
  133068. */
  133069. onGetDescription: () => string;
  133070. /**
  133071. * Gets a string describing the action executed by the current optimization
  133072. * @returns description string
  133073. */
  133074. getDescription(): string;
  133075. /**
  133076. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133077. * @param scene defines the current scene where to apply this optimization
  133078. * @param optimizer defines the current optimizer
  133079. * @returns true if everything that can be done was applied
  133080. */
  133081. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133082. }
  133083. /**
  133084. * Defines an optimization used to turn particles off
  133085. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133086. */
  133087. export class ParticlesOptimization extends SceneOptimization {
  133088. /**
  133089. * Gets a string describing the action executed by the current optimization
  133090. * @return description string
  133091. */
  133092. getDescription(): string;
  133093. /**
  133094. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133095. * @param scene defines the current scene where to apply this optimization
  133096. * @param optimizer defines the current optimizer
  133097. * @returns true if everything that can be done was applied
  133098. */
  133099. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133100. }
  133101. /**
  133102. * Defines an optimization used to turn render targets off
  133103. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133104. */
  133105. export class RenderTargetsOptimization extends SceneOptimization {
  133106. /**
  133107. * Gets a string describing the action executed by the current optimization
  133108. * @return description string
  133109. */
  133110. getDescription(): string;
  133111. /**
  133112. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133113. * @param scene defines the current scene where to apply this optimization
  133114. * @param optimizer defines the current optimizer
  133115. * @returns true if everything that can be done was applied
  133116. */
  133117. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133118. }
  133119. /**
  133120. * Defines an optimization used to merge meshes with compatible materials
  133121. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133122. */
  133123. export class MergeMeshesOptimization extends SceneOptimization {
  133124. private static _UpdateSelectionTree;
  133125. /**
  133126. * Gets or sets a boolean which defines if optimization octree has to be updated
  133127. */
  133128. /**
  133129. * Gets or sets a boolean which defines if optimization octree has to be updated
  133130. */
  133131. static UpdateSelectionTree: boolean;
  133132. /**
  133133. * Gets a string describing the action executed by the current optimization
  133134. * @return description string
  133135. */
  133136. getDescription(): string;
  133137. private _canBeMerged;
  133138. /**
  133139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133140. * @param scene defines the current scene where to apply this optimization
  133141. * @param optimizer defines the current optimizer
  133142. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  133143. * @returns true if everything that can be done was applied
  133144. */
  133145. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  133146. }
  133147. /**
  133148. * Defines a list of options used by SceneOptimizer
  133149. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133150. */
  133151. export class SceneOptimizerOptions {
  133152. /**
  133153. * Defines the target frame rate to reach (60 by default)
  133154. */
  133155. targetFrameRate: number;
  133156. /**
  133157. * Defines the interval between two checkes (2000ms by default)
  133158. */
  133159. trackerDuration: number;
  133160. /**
  133161. * Gets the list of optimizations to apply
  133162. */
  133163. optimizations: SceneOptimization[];
  133164. /**
  133165. * Creates a new list of options used by SceneOptimizer
  133166. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  133167. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  133168. */
  133169. constructor(
  133170. /**
  133171. * Defines the target frame rate to reach (60 by default)
  133172. */
  133173. targetFrameRate?: number,
  133174. /**
  133175. * Defines the interval between two checkes (2000ms by default)
  133176. */
  133177. trackerDuration?: number);
  133178. /**
  133179. * Add a new optimization
  133180. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  133181. * @returns the current SceneOptimizerOptions
  133182. */
  133183. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  133184. /**
  133185. * Add a new custom optimization
  133186. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  133187. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  133188. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133189. * @returns the current SceneOptimizerOptions
  133190. */
  133191. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  133192. /**
  133193. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  133194. * @param targetFrameRate defines the target frame rate (60 by default)
  133195. * @returns a SceneOptimizerOptions object
  133196. */
  133197. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133198. /**
  133199. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  133200. * @param targetFrameRate defines the target frame rate (60 by default)
  133201. * @returns a SceneOptimizerOptions object
  133202. */
  133203. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133204. /**
  133205. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  133206. * @param targetFrameRate defines the target frame rate (60 by default)
  133207. * @returns a SceneOptimizerOptions object
  133208. */
  133209. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133210. }
  133211. /**
  133212. * Class used to run optimizations in order to reach a target frame rate
  133213. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133214. */
  133215. export class SceneOptimizer implements IDisposable {
  133216. private _isRunning;
  133217. private _options;
  133218. private _scene;
  133219. private _currentPriorityLevel;
  133220. private _targetFrameRate;
  133221. private _trackerDuration;
  133222. private _currentFrameRate;
  133223. private _sceneDisposeObserver;
  133224. private _improvementMode;
  133225. /**
  133226. * Defines an observable called when the optimizer reaches the target frame rate
  133227. */
  133228. onSuccessObservable: Observable<SceneOptimizer>;
  133229. /**
  133230. * Defines an observable called when the optimizer enables an optimization
  133231. */
  133232. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  133233. /**
  133234. * Defines an observable called when the optimizer is not able to reach the target frame rate
  133235. */
  133236. onFailureObservable: Observable<SceneOptimizer>;
  133237. /**
  133238. * Gets a boolean indicating if the optimizer is in improvement mode
  133239. */
  133240. readonly isInImprovementMode: boolean;
  133241. /**
  133242. * Gets the current priority level (0 at start)
  133243. */
  133244. readonly currentPriorityLevel: number;
  133245. /**
  133246. * Gets the current frame rate checked by the SceneOptimizer
  133247. */
  133248. readonly currentFrameRate: number;
  133249. /**
  133250. * Gets or sets the current target frame rate (60 by default)
  133251. */
  133252. /**
  133253. * Gets or sets the current target frame rate (60 by default)
  133254. */
  133255. targetFrameRate: number;
  133256. /**
  133257. * Gets or sets the current interval between two checks (every 2000ms by default)
  133258. */
  133259. /**
  133260. * Gets or sets the current interval between two checks (every 2000ms by default)
  133261. */
  133262. trackerDuration: number;
  133263. /**
  133264. * Gets the list of active optimizations
  133265. */
  133266. readonly optimizations: SceneOptimization[];
  133267. /**
  133268. * Creates a new SceneOptimizer
  133269. * @param scene defines the scene to work on
  133270. * @param options defines the options to use with the SceneOptimizer
  133271. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  133272. * @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)
  133273. */
  133274. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  133275. /**
  133276. * Stops the current optimizer
  133277. */
  133278. stop(): void;
  133279. /**
  133280. * Reset the optimizer to initial step (current priority level = 0)
  133281. */
  133282. reset(): void;
  133283. /**
  133284. * Start the optimizer. By default it will try to reach a specific framerate
  133285. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  133286. */
  133287. start(): void;
  133288. private _checkCurrentState;
  133289. /**
  133290. * Release all resources
  133291. */
  133292. dispose(): void;
  133293. /**
  133294. * Helper function to create a SceneOptimizer with one single line of code
  133295. * @param scene defines the scene to work on
  133296. * @param options defines the options to use with the SceneOptimizer
  133297. * @param onSuccess defines a callback to call on success
  133298. * @param onFailure defines a callback to call on failure
  133299. * @returns the new SceneOptimizer object
  133300. */
  133301. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  133302. }
  133303. }
  133304. declare module BABYLON {
  133305. /**
  133306. * Class used to serialize a scene into a string
  133307. */
  133308. export class SceneSerializer {
  133309. /**
  133310. * Clear cache used by a previous serialization
  133311. */
  133312. static ClearCache(): void;
  133313. /**
  133314. * Serialize a scene into a JSON compatible object
  133315. * @param scene defines the scene to serialize
  133316. * @returns a JSON compatible object
  133317. */
  133318. static Serialize(scene: Scene): any;
  133319. /**
  133320. * Serialize a mesh into a JSON compatible object
  133321. * @param toSerialize defines the mesh to serialize
  133322. * @param withParents defines if parents must be serialized as well
  133323. * @param withChildren defines if children must be serialized as well
  133324. * @returns a JSON compatible object
  133325. */
  133326. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  133327. }
  133328. }
  133329. declare module BABYLON {
  133330. /**
  133331. * Class used to host texture specific utilities
  133332. */
  133333. export class TextureTools {
  133334. /**
  133335. * Uses the GPU to create a copy texture rescaled at a given size
  133336. * @param texture Texture to copy from
  133337. * @param width defines the desired width
  133338. * @param height defines the desired height
  133339. * @param useBilinearMode defines if bilinear mode has to be used
  133340. * @return the generated texture
  133341. */
  133342. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  133343. }
  133344. }
  133345. declare module BABYLON {
  133346. /**
  133347. * This represents the different options available for the video capture.
  133348. */
  133349. export interface VideoRecorderOptions {
  133350. /** Defines the mime type of the video. */
  133351. mimeType: string;
  133352. /** Defines the FPS the video should be recorded at. */
  133353. fps: number;
  133354. /** Defines the chunk size for the recording data. */
  133355. recordChunckSize: number;
  133356. /** The audio tracks to attach to the recording. */
  133357. audioTracks?: MediaStreamTrack[];
  133358. }
  133359. /**
  133360. * This can help with recording videos from BabylonJS.
  133361. * This is based on the available WebRTC functionalities of the browser.
  133362. *
  133363. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  133364. */
  133365. export class VideoRecorder {
  133366. private static readonly _defaultOptions;
  133367. /**
  133368. * Returns whether or not the VideoRecorder is available in your browser.
  133369. * @param engine Defines the Babylon Engine.
  133370. * @returns true if supported otherwise false.
  133371. */
  133372. static IsSupported(engine: Engine): boolean;
  133373. private readonly _options;
  133374. private _canvas;
  133375. private _mediaRecorder;
  133376. private _recordedChunks;
  133377. private _fileName;
  133378. private _resolve;
  133379. private _reject;
  133380. /**
  133381. * True when a recording is already in progress.
  133382. */
  133383. readonly isRecording: boolean;
  133384. /**
  133385. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  133386. * @param engine Defines the BabylonJS Engine you wish to record.
  133387. * @param options Defines options that can be used to customize the capture.
  133388. */
  133389. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  133390. /**
  133391. * Stops the current recording before the default capture timeout passed in the startRecording function.
  133392. */
  133393. stopRecording(): void;
  133394. /**
  133395. * Starts recording the canvas for a max duration specified in parameters.
  133396. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  133397. * If null no automatic download will start and you can rely on the promise to get the data back.
  133398. * @param maxDuration Defines the maximum recording time in seconds.
  133399. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  133400. * @return A promise callback at the end of the recording with the video data in Blob.
  133401. */
  133402. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  133403. /**
  133404. * Releases internal resources used during the recording.
  133405. */
  133406. dispose(): void;
  133407. private _handleDataAvailable;
  133408. private _handleError;
  133409. private _handleStop;
  133410. }
  133411. }
  133412. declare module BABYLON {
  133413. /**
  133414. * Class containing a set of static utilities functions for screenshots
  133415. */
  133416. export class ScreenshotTools {
  133417. /**
  133418. * Captures a screenshot of the current rendering
  133419. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133420. * @param engine defines the rendering engine
  133421. * @param camera defines the source camera
  133422. * @param size This parameter can be set to a single number or to an object with the
  133423. * following (optional) properties: precision, width, height. If a single number is passed,
  133424. * it will be used for both width and height. If an object is passed, the screenshot size
  133425. * will be derived from the parameters. The precision property is a multiplier allowing
  133426. * rendering at a higher or lower resolution
  133427. * @param successCallback defines the callback receives a single parameter which contains the
  133428. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  133429. * src parameter of an <img> to display it
  133430. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  133431. * Check your browser for supported MIME types
  133432. */
  133433. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  133434. /**
  133435. * Captures a screenshot of the current rendering
  133436. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133437. * @param engine defines the rendering engine
  133438. * @param camera defines the source camera
  133439. * @param size This parameter can be set to a single number or to an object with the
  133440. * following (optional) properties: precision, width, height. If a single number is passed,
  133441. * it will be used for both width and height. If an object is passed, the screenshot size
  133442. * will be derived from the parameters. The precision property is a multiplier allowing
  133443. * rendering at a higher or lower resolution
  133444. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  133445. * Check your browser for supported MIME types
  133446. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  133447. * to the src parameter of an <img> to display it
  133448. */
  133449. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  133450. /**
  133451. * Generates an image screenshot from the specified camera.
  133452. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133453. * @param engine The engine to use for rendering
  133454. * @param camera The camera to use for rendering
  133455. * @param size This parameter can be set to a single number or to an object with the
  133456. * following (optional) properties: precision, width, height. If a single number is passed,
  133457. * it will be used for both width and height. If an object is passed, the screenshot size
  133458. * will be derived from the parameters. The precision property is a multiplier allowing
  133459. * rendering at a higher or lower resolution
  133460. * @param successCallback The callback receives a single parameter which contains the
  133461. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  133462. * src parameter of an <img> to display it
  133463. * @param mimeType The MIME type of the screenshot image (default: image/png).
  133464. * Check your browser for supported MIME types
  133465. * @param samples Texture samples (default: 1)
  133466. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  133467. * @param fileName A name for for the downloaded file.
  133468. */
  133469. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  133470. /**
  133471. * Generates an image screenshot from the specified camera.
  133472. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133473. * @param engine The engine to use for rendering
  133474. * @param camera The camera to use for rendering
  133475. * @param size This parameter can be set to a single number or to an object with the
  133476. * following (optional) properties: precision, width, height. If a single number is passed,
  133477. * it will be used for both width and height. If an object is passed, the screenshot size
  133478. * will be derived from the parameters. The precision property is a multiplier allowing
  133479. * rendering at a higher or lower resolution
  133480. * @param mimeType The MIME type of the screenshot image (default: image/png).
  133481. * Check your browser for supported MIME types
  133482. * @param samples Texture samples (default: 1)
  133483. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  133484. * @param fileName A name for for the downloaded file.
  133485. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  133486. * to the src parameter of an <img> to display it
  133487. */
  133488. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  133489. /**
  133490. * Gets height and width for screenshot size
  133491. * @private
  133492. */
  133493. private static _getScreenshotSize;
  133494. }
  133495. }
  133496. declare module BABYLON {
  133497. /**
  133498. * Interface for a data buffer
  133499. */
  133500. export interface IDataBuffer {
  133501. /**
  133502. * Reads bytes from the data buffer.
  133503. * @param byteOffset The byte offset to read
  133504. * @param byteLength The byte length to read
  133505. * @returns A promise that resolves when the bytes are read
  133506. */
  133507. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  133508. /**
  133509. * The byte length of the buffer.
  133510. */
  133511. readonly byteLength: number;
  133512. }
  133513. /**
  133514. * Utility class for reading from a data buffer
  133515. */
  133516. export class DataReader {
  133517. /**
  133518. * The data buffer associated with this data reader.
  133519. */
  133520. readonly buffer: IDataBuffer;
  133521. /**
  133522. * The current byte offset from the beginning of the data buffer.
  133523. */
  133524. byteOffset: number;
  133525. private _dataView;
  133526. private _dataByteOffset;
  133527. /**
  133528. * Constructor
  133529. * @param buffer The buffer to read
  133530. */
  133531. constructor(buffer: IDataBuffer);
  133532. /**
  133533. * Loads the given byte length.
  133534. * @param byteLength The byte length to load
  133535. * @returns A promise that resolves when the load is complete
  133536. */
  133537. loadAsync(byteLength: number): Promise<void>;
  133538. /**
  133539. * Read a unsigned 32-bit integer from the currently loaded data range.
  133540. * @returns The 32-bit integer read
  133541. */
  133542. readUint32(): number;
  133543. /**
  133544. * Read a byte array from the currently loaded data range.
  133545. * @param byteLength The byte length to read
  133546. * @returns The byte array read
  133547. */
  133548. readUint8Array(byteLength: number): Uint8Array;
  133549. /**
  133550. * Read a string from the currently loaded data range.
  133551. * @param byteLength The byte length to read
  133552. * @returns The string read
  133553. */
  133554. readString(byteLength: number): string;
  133555. /**
  133556. * Skips the given byte length the currently loaded data range.
  133557. * @param byteLength The byte length to skip
  133558. */
  133559. skipBytes(byteLength: number): void;
  133560. }
  133561. }
  133562. declare module BABYLON {
  133563. /**
  133564. * A cursor which tracks a point on a path
  133565. */
  133566. export class PathCursor {
  133567. private path;
  133568. /**
  133569. * Stores path cursor callbacks for when an onchange event is triggered
  133570. */
  133571. private _onchange;
  133572. /**
  133573. * The value of the path cursor
  133574. */
  133575. value: number;
  133576. /**
  133577. * The animation array of the path cursor
  133578. */
  133579. animations: Animation[];
  133580. /**
  133581. * Initializes the path cursor
  133582. * @param path The path to track
  133583. */
  133584. constructor(path: Path2);
  133585. /**
  133586. * Gets the cursor point on the path
  133587. * @returns A point on the path cursor at the cursor location
  133588. */
  133589. getPoint(): Vector3;
  133590. /**
  133591. * Moves the cursor ahead by the step amount
  133592. * @param step The amount to move the cursor forward
  133593. * @returns This path cursor
  133594. */
  133595. moveAhead(step?: number): PathCursor;
  133596. /**
  133597. * Moves the cursor behind by the step amount
  133598. * @param step The amount to move the cursor back
  133599. * @returns This path cursor
  133600. */
  133601. moveBack(step?: number): PathCursor;
  133602. /**
  133603. * Moves the cursor by the step amount
  133604. * If the step amount is greater than one, an exception is thrown
  133605. * @param step The amount to move the cursor
  133606. * @returns This path cursor
  133607. */
  133608. move(step: number): PathCursor;
  133609. /**
  133610. * Ensures that the value is limited between zero and one
  133611. * @returns This path cursor
  133612. */
  133613. private ensureLimits;
  133614. /**
  133615. * Runs onchange callbacks on change (used by the animation engine)
  133616. * @returns This path cursor
  133617. */
  133618. private raiseOnChange;
  133619. /**
  133620. * Executes a function on change
  133621. * @param f A path cursor onchange callback
  133622. * @returns This path cursor
  133623. */
  133624. onchange(f: (cursor: PathCursor) => void): PathCursor;
  133625. }
  133626. }
  133627. declare module BABYLON {
  133628. /** @hidden */
  133629. export var blurPixelShader: {
  133630. name: string;
  133631. shader: string;
  133632. };
  133633. }
  133634. declare module BABYLON {
  133635. /** @hidden */
  133636. export var pointCloudVertexDeclaration: {
  133637. name: string;
  133638. shader: string;
  133639. };
  133640. }
  133641. // Mixins
  133642. interface Window {
  133643. mozIndexedDB: IDBFactory;
  133644. webkitIndexedDB: IDBFactory;
  133645. msIndexedDB: IDBFactory;
  133646. webkitURL: typeof URL;
  133647. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  133648. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  133649. WebGLRenderingContext: WebGLRenderingContext;
  133650. MSGesture: MSGesture;
  133651. CANNON: any;
  133652. AudioContext: AudioContext;
  133653. webkitAudioContext: AudioContext;
  133654. PointerEvent: any;
  133655. Math: Math;
  133656. Uint8Array: Uint8ArrayConstructor;
  133657. Float32Array: Float32ArrayConstructor;
  133658. mozURL: typeof URL;
  133659. msURL: typeof URL;
  133660. VRFrameData: any; // WebVR, from specs 1.1
  133661. DracoDecoderModule: any;
  133662. setImmediate(handler: (...args: any[]) => void): number;
  133663. }
  133664. interface HTMLCanvasElement {
  133665. requestPointerLock(): void;
  133666. msRequestPointerLock?(): void;
  133667. mozRequestPointerLock?(): void;
  133668. webkitRequestPointerLock?(): void;
  133669. /** Track wether a record is in progress */
  133670. isRecording: boolean;
  133671. /** Capture Stream method defined by some browsers */
  133672. captureStream(fps?: number): MediaStream;
  133673. }
  133674. interface CanvasRenderingContext2D {
  133675. msImageSmoothingEnabled: boolean;
  133676. }
  133677. interface MouseEvent {
  133678. mozMovementX: number;
  133679. mozMovementY: number;
  133680. webkitMovementX: number;
  133681. webkitMovementY: number;
  133682. msMovementX: number;
  133683. msMovementY: number;
  133684. }
  133685. interface Navigator {
  133686. mozGetVRDevices: (any: any) => any;
  133687. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133688. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133689. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133690. webkitGetGamepads(): Gamepad[];
  133691. msGetGamepads(): Gamepad[];
  133692. webkitGamepads(): Gamepad[];
  133693. }
  133694. interface HTMLVideoElement {
  133695. mozSrcObject: any;
  133696. }
  133697. interface Math {
  133698. fround(x: number): number;
  133699. imul(a: number, b: number): number;
  133700. }
  133701. interface WebGLRenderingContext {
  133702. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  133703. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  133704. vertexAttribDivisor(index: number, divisor: number): void;
  133705. createVertexArray(): any;
  133706. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  133707. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  133708. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  133709. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  133710. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  133711. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  133712. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  133713. // Queries
  133714. createQuery(): WebGLQuery;
  133715. deleteQuery(query: WebGLQuery): void;
  133716. beginQuery(target: number, query: WebGLQuery): void;
  133717. endQuery(target: number): void;
  133718. getQueryParameter(query: WebGLQuery, pname: number): any;
  133719. getQuery(target: number, pname: number): any;
  133720. MAX_SAMPLES: number;
  133721. RGBA8: number;
  133722. READ_FRAMEBUFFER: number;
  133723. DRAW_FRAMEBUFFER: number;
  133724. UNIFORM_BUFFER: number;
  133725. HALF_FLOAT_OES: number;
  133726. RGBA16F: number;
  133727. RGBA32F: number;
  133728. R32F: number;
  133729. RG32F: number;
  133730. RGB32F: number;
  133731. R16F: number;
  133732. RG16F: number;
  133733. RGB16F: number;
  133734. RED: number;
  133735. RG: number;
  133736. R8: number;
  133737. RG8: number;
  133738. UNSIGNED_INT_24_8: number;
  133739. DEPTH24_STENCIL8: number;
  133740. MIN: number;
  133741. MAX: number;
  133742. /* Multiple Render Targets */
  133743. drawBuffers(buffers: number[]): void;
  133744. readBuffer(src: number): void;
  133745. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  133746. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  133747. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  133748. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  133749. // Occlusion Query
  133750. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  133751. ANY_SAMPLES_PASSED: number;
  133752. QUERY_RESULT_AVAILABLE: number;
  133753. QUERY_RESULT: number;
  133754. }
  133755. interface WebGLProgram {
  133756. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  133757. }
  133758. interface EXT_disjoint_timer_query {
  133759. QUERY_COUNTER_BITS_EXT: number;
  133760. TIME_ELAPSED_EXT: number;
  133761. TIMESTAMP_EXT: number;
  133762. GPU_DISJOINT_EXT: number;
  133763. QUERY_RESULT_EXT: number;
  133764. QUERY_RESULT_AVAILABLE_EXT: number;
  133765. queryCounterEXT(query: WebGLQuery, target: number): void;
  133766. createQueryEXT(): WebGLQuery;
  133767. beginQueryEXT(target: number, query: WebGLQuery): void;
  133768. endQueryEXT(target: number): void;
  133769. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  133770. deleteQueryEXT(query: WebGLQuery): void;
  133771. }
  133772. interface WebGLUniformLocation {
  133773. _currentState: any;
  133774. }
  133775. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  133776. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  133777. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  133778. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  133779. interface WebGLRenderingContext {
  133780. readonly RASTERIZER_DISCARD: number;
  133781. readonly DEPTH_COMPONENT24: number;
  133782. readonly TEXTURE_3D: number;
  133783. readonly TEXTURE_2D_ARRAY: number;
  133784. readonly TEXTURE_COMPARE_FUNC: number;
  133785. readonly TEXTURE_COMPARE_MODE: number;
  133786. readonly COMPARE_REF_TO_TEXTURE: number;
  133787. readonly TEXTURE_WRAP_R: number;
  133788. readonly HALF_FLOAT: number;
  133789. readonly RGB8: number;
  133790. readonly RED_INTEGER: number;
  133791. readonly RG_INTEGER: number;
  133792. readonly RGB_INTEGER: number;
  133793. readonly RGBA_INTEGER: number;
  133794. readonly R8_SNORM: number;
  133795. readonly RG8_SNORM: number;
  133796. readonly RGB8_SNORM: number;
  133797. readonly RGBA8_SNORM: number;
  133798. readonly R8I: number;
  133799. readonly RG8I: number;
  133800. readonly RGB8I: number;
  133801. readonly RGBA8I: number;
  133802. readonly R8UI: number;
  133803. readonly RG8UI: number;
  133804. readonly RGB8UI: number;
  133805. readonly RGBA8UI: number;
  133806. readonly R16I: number;
  133807. readonly RG16I: number;
  133808. readonly RGB16I: number;
  133809. readonly RGBA16I: number;
  133810. readonly R16UI: number;
  133811. readonly RG16UI: number;
  133812. readonly RGB16UI: number;
  133813. readonly RGBA16UI: number;
  133814. readonly R32I: number;
  133815. readonly RG32I: number;
  133816. readonly RGB32I: number;
  133817. readonly RGBA32I: number;
  133818. readonly R32UI: number;
  133819. readonly RG32UI: number;
  133820. readonly RGB32UI: number;
  133821. readonly RGBA32UI: number;
  133822. readonly RGB10_A2UI: number;
  133823. readonly R11F_G11F_B10F: number;
  133824. readonly RGB9_E5: number;
  133825. readonly RGB10_A2: number;
  133826. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  133827. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  133828. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  133829. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  133830. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  133831. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  133832. 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;
  133833. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  133834. readonly TRANSFORM_FEEDBACK: number;
  133835. readonly INTERLEAVED_ATTRIBS: number;
  133836. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  133837. createTransformFeedback(): WebGLTransformFeedback;
  133838. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  133839. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  133840. beginTransformFeedback(primitiveMode: number): void;
  133841. endTransformFeedback(): void;
  133842. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  133843. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133844. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133845. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133846. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  133847. }
  133848. interface ImageBitmap {
  133849. readonly width: number;
  133850. readonly height: number;
  133851. close(): void;
  133852. }
  133853. interface WebGLQuery extends WebGLObject {
  133854. }
  133855. declare var WebGLQuery: {
  133856. prototype: WebGLQuery;
  133857. new(): WebGLQuery;
  133858. };
  133859. interface WebGLSampler extends WebGLObject {
  133860. }
  133861. declare var WebGLSampler: {
  133862. prototype: WebGLSampler;
  133863. new(): WebGLSampler;
  133864. };
  133865. interface WebGLSync extends WebGLObject {
  133866. }
  133867. declare var WebGLSync: {
  133868. prototype: WebGLSync;
  133869. new(): WebGLSync;
  133870. };
  133871. interface WebGLTransformFeedback extends WebGLObject {
  133872. }
  133873. declare var WebGLTransformFeedback: {
  133874. prototype: WebGLTransformFeedback;
  133875. new(): WebGLTransformFeedback;
  133876. };
  133877. interface WebGLVertexArrayObject extends WebGLObject {
  133878. }
  133879. declare var WebGLVertexArrayObject: {
  133880. prototype: WebGLVertexArrayObject;
  133881. new(): WebGLVertexArrayObject;
  133882. };
  133883. // Type definitions for WebVR API
  133884. // Project: https://w3c.github.io/webvr/
  133885. // Definitions by: six a <https://github.com/lostfictions>
  133886. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  133887. interface VRDisplay extends EventTarget {
  133888. /**
  133889. * Dictionary of capabilities describing the VRDisplay.
  133890. */
  133891. readonly capabilities: VRDisplayCapabilities;
  133892. /**
  133893. * z-depth defining the far plane of the eye view frustum
  133894. * enables mapping of values in the render target depth
  133895. * attachment to scene coordinates. Initially set to 10000.0.
  133896. */
  133897. depthFar: number;
  133898. /**
  133899. * z-depth defining the near plane of the eye view frustum
  133900. * enables mapping of values in the render target depth
  133901. * attachment to scene coordinates. Initially set to 0.01.
  133902. */
  133903. depthNear: number;
  133904. /**
  133905. * An identifier for this distinct VRDisplay. Used as an
  133906. * association point in the Gamepad API.
  133907. */
  133908. readonly displayId: number;
  133909. /**
  133910. * A display name, a user-readable name identifying it.
  133911. */
  133912. readonly displayName: string;
  133913. readonly isConnected: boolean;
  133914. readonly isPresenting: boolean;
  133915. /**
  133916. * If this VRDisplay supports room-scale experiences, the optional
  133917. * stage attribute contains details on the room-scale parameters.
  133918. */
  133919. readonly stageParameters: VRStageParameters | null;
  133920. /**
  133921. * Passing the value returned by `requestAnimationFrame` to
  133922. * `cancelAnimationFrame` will unregister the callback.
  133923. * @param handle Define the hanle of the request to cancel
  133924. */
  133925. cancelAnimationFrame(handle: number): void;
  133926. /**
  133927. * Stops presenting to the VRDisplay.
  133928. * @returns a promise to know when it stopped
  133929. */
  133930. exitPresent(): Promise<void>;
  133931. /**
  133932. * Return the current VREyeParameters for the given eye.
  133933. * @param whichEye Define the eye we want the parameter for
  133934. * @returns the eye parameters
  133935. */
  133936. getEyeParameters(whichEye: string): VREyeParameters;
  133937. /**
  133938. * Populates the passed VRFrameData with the information required to render
  133939. * the current frame.
  133940. * @param frameData Define the data structure to populate
  133941. * @returns true if ok otherwise false
  133942. */
  133943. getFrameData(frameData: VRFrameData): boolean;
  133944. /**
  133945. * Get the layers currently being presented.
  133946. * @returns the list of VR layers
  133947. */
  133948. getLayers(): VRLayer[];
  133949. /**
  133950. * Return a VRPose containing the future predicted pose of the VRDisplay
  133951. * when the current frame will be presented. The value returned will not
  133952. * change until JavaScript has returned control to the browser.
  133953. *
  133954. * The VRPose will contain the position, orientation, velocity,
  133955. * and acceleration of each of these properties.
  133956. * @returns the pose object
  133957. */
  133958. getPose(): VRPose;
  133959. /**
  133960. * Return the current instantaneous pose of the VRDisplay, with no
  133961. * prediction applied.
  133962. * @returns the current instantaneous pose
  133963. */
  133964. getImmediatePose(): VRPose;
  133965. /**
  133966. * The callback passed to `requestAnimationFrame` will be called
  133967. * any time a new frame should be rendered. When the VRDisplay is
  133968. * presenting the callback will be called at the native refresh
  133969. * rate of the HMD. When not presenting this function acts
  133970. * identically to how window.requestAnimationFrame acts. Content should
  133971. * make no assumptions of frame rate or vsync behavior as the HMD runs
  133972. * asynchronously from other displays and at differing refresh rates.
  133973. * @param callback Define the eaction to run next frame
  133974. * @returns the request handle it
  133975. */
  133976. requestAnimationFrame(callback: FrameRequestCallback): number;
  133977. /**
  133978. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  133979. * Repeat calls while already presenting will update the VRLayers being displayed.
  133980. * @param layers Define the list of layer to present
  133981. * @returns a promise to know when the request has been fulfilled
  133982. */
  133983. requestPresent(layers: VRLayer[]): Promise<void>;
  133984. /**
  133985. * Reset the pose for this display, treating its current position and
  133986. * orientation as the "origin/zero" values. VRPose.position,
  133987. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  133988. * updated when calling resetPose(). This should be called in only
  133989. * sitting-space experiences.
  133990. */
  133991. resetPose(): void;
  133992. /**
  133993. * The VRLayer provided to the VRDisplay will be captured and presented
  133994. * in the HMD. Calling this function has the same effect on the source
  133995. * canvas as any other operation that uses its source image, and canvases
  133996. * created without preserveDrawingBuffer set to true will be cleared.
  133997. * @param pose Define the pose to submit
  133998. */
  133999. submitFrame(pose?: VRPose): void;
  134000. }
  134001. declare var VRDisplay: {
  134002. prototype: VRDisplay;
  134003. new(): VRDisplay;
  134004. };
  134005. interface VRLayer {
  134006. leftBounds?: number[] | Float32Array | null;
  134007. rightBounds?: number[] | Float32Array | null;
  134008. source?: HTMLCanvasElement | null;
  134009. }
  134010. interface VRDisplayCapabilities {
  134011. readonly canPresent: boolean;
  134012. readonly hasExternalDisplay: boolean;
  134013. readonly hasOrientation: boolean;
  134014. readonly hasPosition: boolean;
  134015. readonly maxLayers: number;
  134016. }
  134017. interface VREyeParameters {
  134018. /** @deprecated */
  134019. readonly fieldOfView: VRFieldOfView;
  134020. readonly offset: Float32Array;
  134021. readonly renderHeight: number;
  134022. readonly renderWidth: number;
  134023. }
  134024. interface VRFieldOfView {
  134025. readonly downDegrees: number;
  134026. readonly leftDegrees: number;
  134027. readonly rightDegrees: number;
  134028. readonly upDegrees: number;
  134029. }
  134030. interface VRFrameData {
  134031. readonly leftProjectionMatrix: Float32Array;
  134032. readonly leftViewMatrix: Float32Array;
  134033. readonly pose: VRPose;
  134034. readonly rightProjectionMatrix: Float32Array;
  134035. readonly rightViewMatrix: Float32Array;
  134036. readonly timestamp: number;
  134037. }
  134038. interface VRPose {
  134039. readonly angularAcceleration: Float32Array | null;
  134040. readonly angularVelocity: Float32Array | null;
  134041. readonly linearAcceleration: Float32Array | null;
  134042. readonly linearVelocity: Float32Array | null;
  134043. readonly orientation: Float32Array | null;
  134044. readonly position: Float32Array | null;
  134045. readonly timestamp: number;
  134046. }
  134047. interface VRStageParameters {
  134048. sittingToStandingTransform?: Float32Array;
  134049. sizeX?: number;
  134050. sizeY?: number;
  134051. }
  134052. interface Navigator {
  134053. getVRDisplays(): Promise<VRDisplay[]>;
  134054. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  134055. }
  134056. interface Window {
  134057. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  134058. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  134059. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  134060. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134061. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134062. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  134063. }
  134064. interface Gamepad {
  134065. readonly displayId: number;
  134066. }
  134067. type XRSessionMode =
  134068. | "inline"
  134069. | "immersive-vr"
  134070. | "immersive-ar";
  134071. type XRReferenceSpaceType =
  134072. | "viewer"
  134073. | "local"
  134074. | "local-floor"
  134075. | "bounded-floor"
  134076. | "unbounded";
  134077. type XREnvironmentBlendMode =
  134078. | "opaque"
  134079. | "additive"
  134080. | "alpha-blend";
  134081. type XRVisibilityState =
  134082. | "visible"
  134083. | "visible-blurred"
  134084. | "hidden";
  134085. type XRHandedness =
  134086. | "none"
  134087. | "left"
  134088. | "right";
  134089. type XRTargetRayMode =
  134090. | "gaze"
  134091. | "tracked-pointer"
  134092. | "screen";
  134093. type XREye =
  134094. | "none"
  134095. | "left"
  134096. | "right";
  134097. interface XRSpace extends EventTarget {
  134098. }
  134099. interface XRRenderState {
  134100. depthNear?: number;
  134101. depthFar?: number;
  134102. inlineVerticalFieldOfView?: number;
  134103. baseLayer?: XRWebGLLayer;
  134104. }
  134105. interface XRInputSource {
  134106. handedness: XRHandedness;
  134107. targetRayMode: XRTargetRayMode;
  134108. targetRaySpace: XRSpace;
  134109. gripSpace: XRSpace | undefined;
  134110. gamepad: Gamepad | undefined;
  134111. profiles: Array<string>;
  134112. }
  134113. interface XRSession {
  134114. addEventListener: Function;
  134115. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  134116. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  134117. requestAnimationFrame: Function;
  134118. end(): Promise<void>;
  134119. renderState: XRRenderState;
  134120. inputSources: Array<XRInputSource>;
  134121. }
  134122. interface XRReferenceSpace extends XRSpace {
  134123. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  134124. onreset: any;
  134125. }
  134126. interface XRFrame {
  134127. session: XRSession;
  134128. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  134129. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  134130. }
  134131. interface XRViewerPose extends XRPose {
  134132. views: Array<XRView>;
  134133. }
  134134. interface XRPose {
  134135. transform: XRRigidTransform;
  134136. emulatedPosition: boolean;
  134137. }
  134138. interface XRWebGLLayerOptions {
  134139. antialias ?: boolean;
  134140. depth ?: boolean;
  134141. stencil ?: boolean;
  134142. alpha ?: boolean;
  134143. multiview ?: boolean;
  134144. framebufferScaleFactor ?: number;
  134145. }
  134146. declare var XRWebGLLayer: {
  134147. prototype: XRWebGLLayer;
  134148. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  134149. };
  134150. interface XRWebGLLayer {
  134151. framebuffer: WebGLFramebuffer;
  134152. framebufferWidth: number;
  134153. framebufferHeight: number;
  134154. getViewport: Function;
  134155. }
  134156. interface XRRigidTransform {
  134157. position: DOMPointReadOnly;
  134158. orientation: DOMPointReadOnly;
  134159. matrix: Float32Array;
  134160. inverse: XRRigidTransform;
  134161. }
  134162. interface XRView {
  134163. eye: XREye;
  134164. projectionMatrix: Float32Array;
  134165. transform: XRRigidTransform;
  134166. }
  134167. interface XRInputSourceChangeEvent {
  134168. session: XRSession;
  134169. removed: Array<XRInputSource>;
  134170. added: Array<XRInputSource>;
  134171. }